W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2006

[whatwg] Side effects free scripts

From: Alexey Feldgendler <alexey@feldgendler.ru>
Date: Sun, 28 May 2006 17:23:07 +0700
Message-ID: <op.s99a4tnq1h6og4@pancake.feldgendler.ru>
On Sun, 28 May 2006 17:05:45 +0700, Sjoerd Visscher <sjoerd at w3future.com>  
wrote:

>> When a script thread is in side effect free mode:
>>  1. It stays in this mode until the thread completes.
>>  2. It can call any non-native function, but the same restrictions  
>> apply.
>>  3. It cannot assign any variables except locals.
>>  4. It cannot call any native function except those specifically marked  
>> by the spec as side effects free. For example, sin() is side effects  
>> free, and window.open() is not.
>>  5. It can read any property that can be normally read.
>>  6. It cannot assign any property for which a native setter function is  
>> used.

> Ok, here you make it clear that with side effects you only mean visible  
> side effects?

No, all side effects in the mathematical sense. The script is not allowed  
to alter the state of the world in any way.

> It seems you are fine with setting properties of non-native javascript  
> objects.

No, that's included in "It cannot assign any variables except locals".  
Maybe I should make it explicit that it also applies to properties of  
non-native objects.

>> 7. It cannot create new object instances except those specifically  
>> marked by the spec as side effects free. For example, RegExp is side  
>> effects free, and Image is not.

> Creating an Image should be allowed. It might be needed for  
> measurements. Appending it to the document shouldn't.

Creating an Image may initiate a download. That's a side effect, and, in  
fact, creating Image objects is widely used to steal cookies.


-- 
Alexey Feldgendler <alexey at feldgendler.ru>
[ICQ: 115226275] http://feldgendler.livejournal.com
Received on Sunday, 28 May 2006 03:23:07 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:46 UTC