[stringtemplate-interest] Force single-valued template

sohail at taggedtype.net sohail at taggedtype.net
Sun Nov 20 09:48:11 PST 2005


Sorry if you get this twice Terence, not used to my web mail interface :)

>
> On Nov 19, 2005, at 11:19 PM, Sohail Somani wrote:
>
>> Is there a way to force a single valued template?
>>
>> For example:
>>
>> foo(bar)::=<<
>> <bar>
>>>>
>>
>> I want foo to die if there is more than one bar. Is there another
>> way to
>> approach this?
>
> Hi.  Do you mean throw an exception when you try to set bar?  Or, do
> you mean just not print anything?
>
> My first design for arguments of templates included cardinality like:
>
> foo(a,b?,c*,d+) ::= "..."
>
> where plain 'a' meant exactly one.  Unfortunately there was so much
> stuff written with just plain arguments listed that I didn't feel
> like it was possible to change.  Further, it complicated the
> evaluation of predicates (slowed it down a bit) and I wasn't sure how
> many people would use it.  I believe I have the infrastructure in
> there still; just not hooked up.
>
> Can you explain the primary motivation?

Hi Terence,

The primary motivation is implementation of right and left associative
operators:

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.

Thanks

Sohail



More information about the stringtemplate-interest mailing list