Hacker News new | ask | show | jobs
by ppereira 3932 days ago
It looks like this software breaks compiler error messages.

One of the great features of Knuth and Levy's CWEB is that errors are reported in terms of locations in the literate source. This feature, which works by way of line pragmas, is essential for proper debugger support and, in my opinion, sanity while coding larger projects.

If it is missing, it is often better to skip the "tangle" step entirely and have the literate source map directly to the program source line for line. Trying to "pattern-match" the compiler errors against tags in the source file is a painful waste of time. The 1-1 mapping is quite practical for more functional languages if one writes code in a style more like SICP than the TeX sources.

1 comments

Thanks for the comment. Because this "Literate" software outputs nicely formatted code (including automatically included comments identifying code blocks) in the target language, it's not too big a deal, you can just see what line the compiler errors are referring to in the target source code. CWEB's approach of treating the tangled code as only intended for machine reading has the major drawback that you can't share the target source code with others and expect them to be able to read it; they need to buy into CWEB too. So there's a trade-off here.
> CWEB's approach of treating the tangled code as only intended for machine reading has the major drawback that you can't share the target source code with others and expect them to be able to read it; they need to buy into CWEB too.

There's not much of a trade off there. Either you use the tools that generated the code and edit their inputs, or the first time you update the code and rebuild your changes get clobbered.

And if people really find that literate programming makes the code that much harder to follow that they'd rather not use it, maybe it's not a great idea to use it.

It seems like this could be solved by making it an option? During development, generate line number pragmas to improve the error messages. Then when you have a working program, format the code nicely.
That's an excellent idea. I don't think it would work for all languages, but it's still a good solution, and will be added to the TODO list.