[stringtemplate-interest] StringTemplate Compiler for .NET
Volkan Ceylan
volkanceylan at gmail.com
Sun Mar 22 03:02:49 PDT 2009
As i understand, you are trying to create a slot (bin) for all
referencable attributes in the template and
its all anonymous subtemplates in its expression tree. As far as i
know, one can access a calculated
property of an object by means of "attribute.(expression)" but
currently there is no way to
access a template attribute whose name is calculated by an expression
like "(expression)".
Unless an idea of "this" special variable is introduced into
StringTemplate, and it is allowed access
an attribute by an expression like this.(expression), your idea of
given a template, list of attributes that
could be accessed is constant is right. So creating a bin for every
possible attribute and accessing attributes
by their predetermined index is possible. This will eliminate the need
for hash tables, and also eliminate
recursive attribute lookups from a subtemplate to the root template.
I'm sure you are aware that same doesn't hold true for formal
arguments (or default arguments it, i0, i, x etc)
and every anonymous template instance should have its own array of
arguments, even though its also
predetermined list of bins. Also it should be noted that if an
anonymous template/subtemplate has a formal
argument it's value takes predence over a possible global attribute
with the same name.
ST is similar to a lets say a javascript program where attributes are
global variables and arguments are
function parameters. Each template instance is a function with
arguments where its a dynamic
subfunction of its enclosing instance as its enclosing instance may
change dynamically for named
template calls.
There may be some problems when PassThroughAttributes is enabled that
you should be aware of.
More information about the stringtemplate-interest
mailing list