[whatwg] Side effects free scripts

Andrew Fedoniouk news at terrainformatica.com
Wed May 31 09:40:32 PDT 2006


----- Original Message ----- 
From: "liorean" <liorean at gmail.com>


> On 29/05/06, Andrew Fedoniouk <news at terrainformatica.com> wrote:
>> Axiom:
>>
>>   Code which is not altering the state of the world cannot produce 
>> anything
>>   useful (work) for that world.
>>
>> (C:) Mine.
>
>
> How about something like this?
>
>    <img src="javascript:generateImage(1e6*Math.random()>>0);" alt=""/>
>
>    function generateImage(seed){
>        /* use the seed to write generate an XBM image here */
>        return image;
>    }
>
> That code could be made entirely side effect free, but still useful.

>From mathematic standpoint:
By its definition Math.random() function is not side effect free
in ECMAScript. It uses static variable for generation of pseudo-number 
sequences.

Andrew Fedoniouk.
http://terrainformatica.com






More information about the whatwg mailing list