On 1/22/2014 4:53 AM, Don wrote:
On Wednesday, 22 January 2014 at 04:29:05 UTC, Walter Bright wrote:

Great article. I was surprised that you mentioned lowering positively, though.

I think from DMD we have enough experience to say that although lowering sounds
good, it's generally a bad idea. It gives you a mostly-working prototype very
quickly, but you pay a heavy price for it. It destroys valuable semantic
information. You end up with poor quality error messages, and
counter-intuitively, you can end up with _more_ special cases (eg, lowering
ref-foreach in DMD means ref local variables can spread everywhere). And it
reduces possibilities for the optimizer.

In DMD, lowering has caused *major* problems with AAs, foreach. and
builtin-functions, and some of the transformations that the inliner makes. It's
also caused problems with postincrement and exponentation. Probably there are
other examples.

It seems to me that what does make sense is to perform lowering as the final
step before passing the code to the backend. If you do it too early, you're
shooting yourself in the foot.

On the other hand, the lowering of loops to for uncovered numerous bugs, and the lowering of scope to try-finally made it actually implementable and fairly bug-free.

Reply via email to