DIP 50 - AST macros

Zsombor Barna belzurix at sch.bme.hu
Thu Nov 14 11:42:35 PST 2013


On Thursday, 14 November 2013 at 18:23:20 UTC, Andrei 
Alexandrescu wrote:
> On 11/14/13 2:17 AM, Walter Bright wrote:
>> On 11/14/2013 2:07 AM, Chris Cain wrote:
>>> I guess I would have thought the exact opposite from you... 
>>> that this is
>>> precisely something that *should* be done with a 
>>> library-defined macro.
>>
>> Again, I reiterate what experience shows happens with macro 
>> systems in
>> the long term.
>
> FWIW Walter talked me back around 2005-2006 into abandoning my 
> own ideas about languages with configurable syntax.
>
> There are quite a few failings about comparing programming 
> languages against natural languages, but here's one that I 
> think does have value: fixed syntax is ingrained into people's 
> notion of language, and swapping syntax within an otherwise 
> identical linguistic context is extremely taxing on the brain. 
> Anyone who's read with a C or C++ codebase full of macros and 
> #if-driven code can attest how unbelievably difficult 
> juxtapositions of the normal syntax with preprocessor syntax 
> can quickly become. That's part of why "static if" has been so 
> successful in D - it drives new semantics but within the same 
> syntax.
>
> Natural languages are "humans complete" because they are the 
> one vehicle we use to describe and manipulate our understanding 
> of the entire reality. If configurable syntax was something 
> necessary to model the world, it would have inevitably occurred 
> in natural languages one way or another. Instead, all human 
> languages (with no exception I know of) have fixed syntax and 
> prefer to add modeling power in other ways. There must be 
> something about this.
>
>
> Andrei

D's syntax remains the same ( statements, expressions, function 
calling, numbers etc. ). These AST manipulation tools just define 
new words or language constructs. Human languages tend to be 
altered as times passes and the needs change. That's why new 
words appear. Even the grammar is not the same as the one my 
grandparents used.


More information about the Digitalmars-d mailing list