[whatwg] Side effects free scripts

Andrew Fedoniouk news at terrainformatica.com
Sun May 28 23:13:30 PDT 2006

----- Original Message ----- 
From: "Alexey Feldgendler" <alexey at feldgendler.ru>
Subject: Re: [whatwg] Side effects free scripts

> On Mon, 29 May 2006 08:31:06 +0700, Andrew Fedoniouk 
> <news at terrainformatica.com> wrote:
>>>> 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.
>>   Code which is not altering the state of the world cannot produce 
>> anything
>>   useful (work) for that world.
> The only useful result of a side effects free script is its return value. 
> That is, in fact, the very purpose for which CSS expression() exists. It's 
> MEANT to be side effects free, but is systematically abused.

Strictly speaking returned result changes state of the world.

And in practice something like:
function foo() {  return "bar" + foo();  }
will definitely change state of the system.

Because of "halting problem" the only feasible way to ensure safety of the 
function (at some extent) is a sandbox.

> By the way, there are even some optimizations for expression() handling 
> possible when the scripts are forced to have no side effects -- it's 
> possible to avoid repeated invocations of the script when it's known that 
> the state of the world has not changed.

Optimization is a different story. It is not a proof of safety of some code.

Andrew Fedoniouk.

More information about the whatwg mailing list