[stringtemplate-interest] v4 ST

Graham Wideman gwlist at grahamwideman.com
Tue Oct 6 17:55:23 PDT 2009


At 10/6/2009 04:58 PM, Terence Parr wrote:
>Actually
>
>st.add("name, "parrt");
>
>might not be as clear as
>
>st.put("name, "parrt");
>
>but will people think it means "replace" instead of add?  I kind of  
>like put
>
>what about
>
>st.attr("name, "parrt");

Well to me, "put" doesn't describe anything pertinent to ST.  How would you, in english, describe what that method does, using the word "put"?  It "puts" the arguments into the list. We already have more precise and customary words for that: add and append.  

And to conspicuously *not* use those words suggests that add/append is specifically *not* what the method does. Instead, it suggests putting the ST itself, whatever that might mean (eg: onto a stream or something).

Is the resistance to "add" that it's not sufficiently clear in:

myST.add(args)

... what the args are being added to? Perhaps because an ST is not primarily a list or collection?  If so then augment "add" with further description of what aspect of ST the add is adding to... something having the sense of "add this argument to the ST's list of attributes", or for short:

  addAttribute

or addAttrib <--- (but personally the savings in typing is wiped out by the burden of having to remember degree of abbreviation: Attr, Attrib, Att etc)

Using st.attr() I think has the same problem as st.setAttribute... it's not clear that you are adding to the attributes rather then replacing. Also, in java and some other languages, the fact that attr() is deliberately not named either setSomething or add or addSomething suggests that it does not set or add something.

If you're thinking that "add" is too concretely about ST's implementation, then something more along the lines of "associate", "enscope" or "makeAvailable" is more the sense desired?

But... I'm still favoring plain-and-simple add or addAttribute.

-- Graham



More information about the stringtemplate-interest mailing list