[whatwg] Side effects free scripts

Alexey Feldgendler alexey at feldgendler.ru
Sun May 28 23:29:15 PDT 2006


On Mon, 29 May 2006 13:13:30 +0700, Andrew Fedoniouk <news at terrainformatica.com> wrote:

>> 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.

It's not the script itself which does it. The caller could use the return value to change the state of the world according to it, but the caller isn't "side effects free".

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

No, it won't. It will hit either the stack depth limit or the time execution limit, but the state of the world won't change in either case.

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

Sandboxes don't prevent scripts from hanging, either. It's the execution time limit which helps deal with such cases.


-- 
Alexey Feldgendler <alexey at feldgendler.ru>
[ICQ: 115226275] http://feldgendler.livejournal.com



More information about the whatwg mailing list