Stephen Howard wrote:
> I'm not familiar with the XS stash, but was under the impression that
> the pure perl Stash tried to run object methods prior to virtual
> methods. I would expect that to be the desired priority if not.
Yes, that's right. However the problem is happening in the parser at
compile time and so never even gets to hit the stash at runtime.
The TT2 parser first splits a directive into tokens, and it is here that
it recognises 'div' as a reserved word for the math operator. It doesn't
matter that it doesn't make any sense for a math operator to appear
after a '.' because we're just lexing here and not doing a full blown
parse. In short, the code just hasn't got the smarts to do any better.
It's program to recognise 'div' as a math operator and that's all it does.
When the parser method gets a look-in, it blows an error because it knows
that a 'div' math operator shouldn't be there, but it's too late to do
anything about it.
In TT3 we're using a recursive descent parser for these parts of
the language, and it allows us to be much smarter. We effectively
do the lexing and parsing in one action. What that means in practice
is that 'div' will only be a reserved word in those places where it
could be a math operator. Anywhere else it will be treated as whatever
it is.
Hence:
foo.div # OK - 'div' is a variable item
foo div bar # OK - 'div' is a math operator
TT3 - coming Real Soon Now.... :-)
A
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates