[stringtemplate-interest] v4 ST
Zenaan Harkness
zen at freedbms.net
Tue Oct 6 19:53:45 PDT 2009
On Tue, Oct 06, 2009 at 06:09:19PM -0700, Graham Wideman wrote:
> At 10/6/2009 05:51 PM, Gerald Rosenberg wrote:
> >Have to say that I liked "inject" on first impression. Add, set and
> >put all suggest that the data is potentially still accessible, as if
> >the template is just a list or map in the model. Inject reflects the
> >conceptual separation: once injected, the template has control.
>
> OK, please correct my understanding if it's wrong:
>
> After the call to setAttribute/add/inject, in general the value that the attribute points to *is* still accessible to the caller, *can* still be changed, and is not actually "injected" into the final string until toString is called.
>
> Actually I have to admit I'm unsure when setAttribute uses reference semantics and when it uses copy, but at least sometimes it uses reference, and in any case the values are not composed into the final ST toString output until toString is called, as I understand it.
>
> If that's a correct account, then Gerald's discussion is really an argument against "inject" I think, and in favor of ...
>
> >The term "associate" might be more accurate, but it is weak and
> >long.
>
> ... which I too mentioned in earlier message, but I agree that it's long and vague.
>
> > The term "attr" is less accurate, as the parameters are
> >attribute and value. Tuple?
>
> Actually I think the args are name and value which together get composed into the attribute. Value could be a simple type or a more complex object. So attribute is an object that maps name to value.
Perhaps semantically, myST.appendAttribute(myAtt) might be most
'accurate' (for some definition of accurate).
When I describe ST to others, it goes:
1) create ST
2) add attributes
3) call toString
Because, like, you know, "you have to add your attributes to the template
engine, _before_ calling toString".
Add is the word I use in general conversation, ie "lay usage".
Add is easy to remember.
There is precedent for add in java libs (can be said of put and others
too though).
Everything else (except perhaps addAttribute) is not as simple.
If there were two entirely different classes of things being added to
ST, then perhaps I might encourage addAttribute, to distinguish from
addOtherImportantThingWhichIsDefinitelyNotAnAttribute, and
notwithstanding, I would still advocate for .add(..) to be an alias of
addAttribute (common case, short, etc).
Hopefully my vote is clear :)
cheers
zenaan
--
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.
More information about the stringtemplate-interest
mailing list