[stringtemplate-interest] Multimethods

karadimas harry harry.karadimas at hmn.aphp.fr
Sat Nov 15 07:23:43 PST 2008


Well, actually, YES ! 
I thought about that on the way home after I posted this reply.
However it only works with having the "response" object in a Thread-Local
parameter, used by the renderer that handles the "url" format.
More generally what I proposed was either :
  - An hardcoded mechanism to just encode URLs the way the spec wants it
  - A more general mechanism to set parameters in the template before calling it; then the format/renderers can use them (for example, setting the desired locale explicitly can help enforce the user's desired locale in the generated text). This parameter could be passed to the renderer (just like the "format" String), without any other information related to the template. Of course I understand this could be misused, so there
should be a balance here between how strict we want things to be and what facilities we want to offer to the programmers. Anyway it is quite hard for the view author to misuse st; for the "model" programmer it is not
that hard. I like the st language/syntax very much, and except for the multiplication of files I find it quite handy; however, I find myself programming a lot just for the view, having to forsee a lot of possible cases, constructing intermediate objects just for st, and I think we should think a bit about that. I think
if programmers misuse the model and make non-decidable calls during template execution, it's their fault,
they didn't catch the whole idea of the thing. Or maybe they take some risk into account, having been warned,
and they can't complain about that. 

> Message: 4
> Date: Fri, 14 Nov 2008 19:29:40 +0200
> From: Roman Odaisky <roma at qwertty.com>
> Subject: Re: [stringtemplate-interest] Multimethods
> To: stringtemplate-interest at antlr.org
> Message-ID: <200811141929.45559.roma at qwertty.com>
> Content-Type: text/plain; charset="utf-8"
> 
> On Friday, 14.11.2008 16:59:11 Harry Karadimas wrote:
> > If I could write $url("http://myserver/foo/bar?next="+i)$
> > it would feel more natural than
> > ${http://myserver/foo/bar?next=$i$};format="url"$
> 
> Doesn?t $it; format="url"$ in a url.st work?
> 
> -- 
> HTH
> Roman.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/pkcs7-signature
> Size: 2286 bytes
> Desc: not available
> Url : http://www.antlr.org:8080/pipermail/stringtemplate-
> interest/attachments/20081114/47751e55/attachment-0001.bin 
> 

Harry


More information about the stringtemplate-interest mailing list