D parsing

Philippe Sigaud philippe.sigaud at gmail.com
Wed Nov 6 15:23:05 PST 2013


On Wed, Nov 6, 2013 at 9:34 AM, Chad Joan <chadjoan at gmail.com> wrote:

> On Wednesday, 6 November 2013 at 08:19:13 UTC, Jacob Carlborg wrote:
>
>> On 2013-11-05 17:55, Philippe Sigaud wrote:
>>
>>  Walter is far from convinced that AST manipulation is a good thing. You
>>> would have to convince him first. His fear is that it will lead to
>>> unreadable code, and everyone using her own personnal version of D.
>>> AFAICT, nothing of the sort happened in Lisp (I mean, Lispers have
>>> balkanization, but *not* due to AST manipulation).
>>>
>>
>> You know, Walter did a talk about AST macros at the first D conference.
>> The idea back then was to add AST macros, hence the "macro" keyword.
>>
>
> Also, IIRC, it is believed that string mixins with CTFE are potentially
> more powerful.  I am under the assumption that Walter is taking the long
> view and waiting for the community to furnish their own powerful AST
> manipulation tools using the existing spec.  I suspect that he is opposed
> to baking AST manipulation into the /language spec/, but is perfectly
> accepting of the notion of using AST manipulation to generate code, reduce
> boilerplate, implement exotic features and DSLs, and so on.  Just don't
> complicate the core language any more than it already is.  Sorry if I
> misrepresented you Walter; I can only make educated guesses ;)
>

Well, I remember him saying that he doesn't want everybody and their dog to
change the D syntax. If we get macros, that's exactly what we can do. For
example, telling the compiler (or another tool), to rewrite

int a := 1;

into

immutable a = 1;

But that means the original not-D code cannot be compiled by anyone with a
D compiler anymore (obviously). And soon everybody is transforming the
grammar according to what they think is cool.
That's his PoV IIRC.

I'm more interested in getting to ability to define my own lowerings: in
the same way that scope statements or foreach over ranges are rewritten
into lower-level D code by the comiler, I would like to be able to define
my own syntactic constructs.

Plus, everybody here know that AST macros can cure world hunger :) Wouldn't
that be nice?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131107/fb7f74d7/attachment.html>


More information about the Digitalmars-d mailing list