cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: Global variables in flowscript
Date Tue, 08 Nov 2005 14:19:42 GMT
vjaulin wrote:
> Ugo Cei wrote:
>
>> I am feeling a little confused. What is the expected behavior of te  
>> following flowscript code:
>>
>> var x = 0;
>>
>> function fun() { print(++x); }
>>
>> when it is invoked multiple times by the same user?
>>
>> I am always getting "1" (with 2.1.8-rc1) as if the value of the  
>> global variable wasn't retained between invocations. I expected to  
>> get an incrementing sequence of values.
>>
>>     Ugo
>>
> I am not sure, but try this code
>
> x = 0; // without var
>
> function fun() { print(++x); }

It's actually exactly the same. Setting a variable without the "var" 
keyword attaches it to the top-level scope, and you're already in that 
toplevel scope :-)

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Mime
View raw message