[stringtemplate-interest] Fail on undefined property
Terence Parr
parrt at cs.usfca.edu
Fri Jul 31 12:52:31 PDT 2009
On Jul 31, 2009, at 12:48 PM, Sam Harwell wrote:
> The problem is the same code path is used for evaluating conditional
> expressions, where a missing attribute is "false". I believe when the
> write method encounters an undefined property, it *should* throw an
> exception. For example:
>
> Should not throw if x is undefined:
>
> <if(x)><x><endif>
>
> Should throw if x is undefined:
>
> <x>
Well, it's very useful to evaluate to an empty string sometimes.
Hi, <firstname> <lastname>
if you only know the first name, we shouldn't have to gate every
reference to other attributes to prevent an exception.
> Note that we already do throw an exception in the following case if
> x is
> defined but has no member f. The behavior should be made consistent,
> but
> we have to be careful about informing people of the change since it's
> absolutely a breaking change.
>
> <x.f>
When I build the new version, I will make a consistent policy. Most
likely there will be a choice that the user can set about strictness,
turning on various bits in a set about what should throw an exception.
T
More information about the stringtemplate-interest
mailing list