News for hackers. Stuff that matters.
Re:My First Fifteen Compilers by mhh__ on Friday July 12, 2019 @08:04PM (#20425619)
There's no reason for the approach to be slow anyway because as long as there is a reasonable way for information to be retained inter-pass then they should be doing approximately the same amount of work as a less discrete alternative. AST lowering can be very fruitful for languages with lots of metaprogramming etc., i.e. DRY principle. Error propagation could be a bit lacklustre if not handled with care, however.

On a more local basis, if you program in a language that encourages it, composing work at compile time can save a huge amount of cruft that one might imagine comes with using a many-pass compiler.

https://d.godbolt.org/z/w9At24 (Already posted on this thread), I wrote this little example to show how you can compose series of discrete manipulations in D into what is indistinguishable from a normal function as if it were monolithically written by hand.

That example (in D, in particular) could be made as pure-functional and discrete as is desired but I used pointers to keep it small.

Compilers are extremely good at optimizing interprocedural code, or at least better than a human, so a certain level of lazyness can be bestowed upon the programmer at the expense of trusting a compiler.

There are no comments on this comment yet.