On 11/17/07, Mark Clements gmane@kennel17.co.uk wrote:
There are magic words that are directives to the parser, e.g. __NOTOC__ and there are magic words that are variables to be expanded, e.g. {{PAGENAME}}. I don't necessarily consider it a problem to have the two forms, so long as the syntax is unambiguous (i.e. wrap in __ for parser directives, {{ }} for variables). I am not sure if this is currently the case or not.
The ambiguity arises from using a single word to describe both kinds of item. It is confusing to use a single word to refer to two distinct concepts, and this is not helped by describing them as 'magic words', a name which only serves to make them seem even more mysterious. It would be better if they were referred to as 'parser directives' and 'built-in variables' respectively, and not grouped together under the single term. If it were up to me, I'd lose the term 'magic word' altogether.
I think the code generally refers to the second type as "magic variables". In your next email you suggest that __TOC__ is effectively a magic variable, but it's really not: it's not immediately substituted by something else. For example, in this code:
foo __TOC__ blah __TOC__ wah
The second __TOC__ is not substituted by anything at all.
Anyway, if all magic words look like __x__ and all magic variables look like {{x}} then I'm very happy. If all magic words/variables look like __x__ or {{x}} without any particular distinction, that I'm still happy. Other alternatives are...scarier.
Steve (Progress report: I'm playing a lot with ANTLR atm. It's awesome. It doesn't (yet) generate PHP but there ought to be a way around that. Trying to understand syntactic predicates...)