What are AST Macros?

Nick Sabalausky a at a.a
Mon Jul 12 18:41:00 PDT 2010


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:i1ge6c$c9s$1 at digitalmars.com...
> On 07/12/2010 06:21 PM, Nick Sabalausky wrote:
>> "Steven Schveighoffer"<schveiguy at yahoo.com>  wrote in message
>>>
>>> Brainfuck is basically a toy example of a language.  Nobody uses it for
>>> serious work.  Mixins are much better than a hack, the syntax of using
>>> them is just not polished.  They are easy to use/understand because a)
>>> people understand the language and b) people understand string
>>> manipulation.
>>>
>>
>> But when you're talking about the string being actual code, you're not
>> always talking about typical string manipulation, sometimes you're 
>> talking
>> about parsing which is only "string manipulation" superficially.
>>
>>>
>>> I'll give you another example -- javascript and HTML editing.  Most 
>>> people
>>> would prefer to just use the innerHTML component of an element than have
>>> to use the DOM methods to create individual elements and add them as
>>> children, etc.
>>>
>>
>> For writing, yes, but there's also reading: How many people do you know 
>> who
>> would rather find the elements they want by parsing innerHTML instead of
>> just dealing with the readily-available tree? None, I would hope, but the
>> latter is essentially what we have to do for many of the more advanced
>> things that string mixins *technically* replace AST macros for.
>
> But bitfields and other similar code generating samples don't parse - they 
> generate.
>

I already agreed to that part ("For writing, yes..."). But there are other 
uses that *do* parse, and others that do both. The point is NOT that string 
mixins are *always* unsatisfactory as a replacement for AST macros. The 
point is that *there are perfectly legitimate use-cases* where string mixins 
are unsatisfactory as a replacement for AST macros. I think you've already 
agreed to this in other posts.




More information about the Digitalmars-d mailing list