[stringtemplate-interest] [ST4 Beta4] Default args are not always evaluated in the context of their template
Udo Borkowski
ub at abego-software.de
Thu Feb 17 13:22:38 PST 2011
Hi Ter,
> Hi Udo. I'm pretty sure Sam is correct. This is a lazy evaluation issue. comment inline ####
Yes, Sam is correct, in describing how the system behaves and why. I never doubted this.
My question is: is this the *expected* behavior, i.e. is this the behavior you had in mind when saying "the default args are formally defined to have the same context as the template itself, hence, default arguments can see the other arguments."? Or is it just the way things are currently implemented?
Regarding your question:
>> t2(p1,p2) ::= <<
>> inside t2: p1=<p1>, p2=<p2> #### <p2> evaluates {<p1>} and p1 has value "B", right?
p1 has the value "A" in the context of t1. p1 has the value "B" in the context of t2. If I understood you correctly the subtemplate {<p1>} has the same context as the template t1, hence p1 in the subtemplate {<p1>} has value "A" (not "B").
Udo
On 17.02.2011, at 21:55, Terence Parr wrote:
> Hi Udo. I'm pretty sure Sam is correct. This is a lazy evaluation issue. comment inline ####
> On Feb 17, 2011, at 3:03 AM, Udo Borkowski wrote:
>> -----------
>> t1(p1,p2={<p1>}) ::= <<
>> inside t1: p1=<p1>, p2=<p2>
>> <t2(p1="B",p2=p2)>
>>>
>>
>> t2(p1,p2) ::= <<
>> inside t2: p1=<p1>, p2=<p2> #### <p2> evaluates {<p1>} and p1 has value "B", right?
>>>
>>
>> main() ::= <<
>> Use default value for p2
>> <t1(p1="A")>
>>>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list