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

[whatwg] Side effects free scripts

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Wed, 31 May 2006 15:43:42 -0700
Message-ID: <001801c68503$ab77a960$c302000a@internal.toppro.net>

----- Original Message ----- 
From: "liorean" <liorean@gmail.com>
To: "whatwg" <whatwg at whatwg.org>
Sent: Wednesday, May 31, 2006 9:54 AM
Subject: Re: [whatwg] Side effects free scripts


| On 31/05/06, Andrew Fedoniouk <news at terrainformatica.com> wrote:
| > ----- Original Message -----
| > From: "liorean" <liorean at gmail.com>
| > 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.
| 
| Well, the ECMAScript spec states:
| >15.8.2.14 random ( )
| >Returns a number value with positive sign, greater than or equal to 0
| but less than 1, chosen randomly or pseudo randomly with approximately
| uniform distribution over that range, using an
| implementation-dependent algorithm or strategy. This function takes no
| arguments.
| 
| 
| There is nothing in that definition that I find indicates that it has
| any side effects. It's all about generating a number, no side effects
| are specified or implied.

This does not mean that it has no side effects. 

I don't know any algorithm of random number generation which is not 
using previous value stored somewhere (seed). (I mean software based 
random generation only)

Pseudo number generators have long but limited length of generated sequence.
So in some circumstances external "no side effects script", being invoked, 
can force legacy code to produce not so random data. I think you understand
implications of this.

David, this is just one small demo of the problem. 

Formally: as there is no formal detection algorithm 
as term "side effect free script" is a nonsence, mathematicaly speaking.

Andrew Fedoniouk.
http://terrainformatica.com
Received on Wednesday, 31 May 2006 15:43:42 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:27 UTC