[stringtemplate-interest] Force single-valued template

Terence Parr parrt at cs.usfca.edu
Sun Nov 20 11:46:11 PST 2005


On Nov 20, 2005, at 10:26 AM, sohail at taggedtype.net wrote:
>>>> power(lhs,rhs)::=<<std::power(<lhs>,<rhs>)>>
>>>>
>>>> for 2**3**5, this should give:
>>>>
>>>> std::power(2,std::power(3,5))
>>>>
>>>> I don't think there is a way to do it without forcing lhs and rhs
>>>> to be
>>>> single valued.
>>>
>>> How about using first(lhs) to get the first element?
>
> I don't particularly like this solution as it will cause a silent  
> failure.
> I'd really like an exception to be thrown while the template is being
> constructed.

Oh I see what you mean. Well, one could look at it that the  
controller/model should determine the logic of what is valid data-- 
the view should simply display it, not enforce anything dealing with  
validity of data.

Ter


More information about the stringtemplate-interest mailing list