Hi Sebastian,
IMHO, it is a good idea compared to my suggestion and I think easier to
implement.
cheers.
Sebastian Werner wrote:
>
> What's about to introduce a special variable prefix which declares a
> variable to not get optimized e.g. "$vData" instead of "vData".
>
> Sebastian
>
>
>
> frederic schrieb:
>> Thanks Alessandro. I can often rewrite code with an "array syntax" but
>> sometimes I must keep eval instruction.
>> What do you think about an enhancement in the compiler to manage
>> exception
>> in optimization ? for example have Javascript "tags" who define a section
>> without optimization ?
>>
>>
>>
>> Alessandro Sala wrote:
>>>
>>> Hi Frederic,
>>>
>>> I have trouble when compiling with string/variable optimization the
>>> following JS code :
>>>
>>> myClass.myFunction=function(vData){
>>> var test=".getValue()";
>>> alert(vData);
>>> alert(eval("vData."+test));
>>> }
>>>
>>> vData seems the same in eval() function after compiling with opt whereas
>>> vData in alert(vData) seems converted in $XXX value.
>>>
>>> Is it a bug ? to avoid the pb I have desactived the var/string opts.
>>>
>>> this is not a bug, and it has nothing to do with string optimization:
>>> its'a limit of the variable optimizer due to the dynamic nature of the
>>> Javascript language.
>>>
>>> This is what's happening here: the variable optimizer replaces every
>>> occurrence of the variable "vData" with a shorter identifier,
>>> let's
>>> say $x; this works as long as vData can be identified as a variable at
>>> compile time, i.e. if it is used in "static" code, such as the function
>>> argument declaration and the first alert().
>>>
>>> On the other hand, vData is simply a string inside the second alert(),
>>> and as such it doesn't get substituted by $x: it only becomes a
>>> variable at runtime, when it is interpreted by eval(), but since the
>>> string passed to eval() can be constructed in arbitrary ways and can
>>> contain arbitrary code, there's no way for the variable optimizer to
>>> apply the same identifier replacements at compile time as those found
>>> in "static" code.
>>>
>>> If you want to use the variable optimizer, I would suggest you modify
>>> your code so to avoid using eval() in this way:
>>> myClass.myFunction=function(vData){
>>> var test="getValue";
>>> alert(vData);
>>> alert(vData[test]());
>>> }
>>> This way you won't have trouble with the variable optimizer and you are
>>> still able to dynamically select the method to be called.
>>>
>>> Cheers,
>>> Alessandro
>>>
>>>
>>>
>>>
>>>
>>>
>>> begin:vcard
>>> fn:Alessandro Sala
>>> n:Sala;Alessandro
>>> email;internet:alessandro {dot} sala {at} mclink {dot} net
>>> version:2.1
>>> end:vcard
>>>
>>>
>>> -------------------------------------------------------------------------
>>> Take Surveys. Earn Cash. Influence the Future of IT
>>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>>> your
>>> opinions on IT & business topics through brief surveys - and earn cash
>>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>>
>>>
>>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
--
View this message in context:
http://www.nabble.com/problem-with-Variable-String-optimizations-tf2781275.html#a7772430
Sent from the qooxdoo-devel mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel