On 4/6/12 10:09 AM, Timon Gehr wrote:
Speaking of the distinction, it would be great if we arranged things
such that attributes are a lowering to existing D (i.e. the compiler
rewrites a nice attribute syntax into clunky D code you wouldn't want to
write by hand).


What would that look like?

Essentially we want to associate with any symbol (be it a type, function, method, or whatnot) some extra information in the form of a tuple of key/value pairs. The value can be anything CTFE. How would one do that "by hand", albeit ugly and verbose? Once we get the desired functionality, we work back on a syntax for it. And we're done.

Lowerings have worked miracles for us in terms of keeping language
semantics simple and reducing implementation bugs.

What do you have in mind here?

All: foreach, scope, operator overloading - wherever we used lowerings it's been an unqualified success. I am only sorry we didn't use them more often and more systematically.

All lowerings I am aware of are trivial ones and their implementation
resulted in sloppy error handling (eg: foreach) for no clear benefit.

Defining foreach as a lowering clarifies to both the library author and the user what the expectations are.

Some of them (eg: with statement) have even made the implementation bug
situation worse.

"with" is not implemented via a lowering.


Andrei

Reply via email to