On 1/22/14 4:53 AM, Don wrote:
On Wednesday, 22 January 2014 at 04:29:05 UTC, Walter Bright wrote:
http://www.reddit.com/r/programming/comments/1vtm2l/so_you_want_to_write_your_own_language_dr_dobbs/


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.

There's a lot of value in defining a larger complex language in terms of a much simpler core. This technique has been applied successfully by a variety of languages (Java and Haskell come to mind).

For us, I opine that the scope statement would've had a million subtle issues if it weren't defined in terms of try/catch/finally.

My understanding is that your concern is related to the stage at which lowering is performed, which I'd agree with.


Andrei

Reply via email to