- From: liorean <liorean@gmail.com>
- Date: Thu, 1 Jun 2006 06:21:02 +0200
On 01/06/06, Andrew Fedoniouk <news at terrainformatica.com> wrote: >> 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. Well, it does mean that it typically doesn't have any side effects within the ECMAScript language. It may have implementation side effects built in to chosen algorithm, but those side effects are not apparent in the language. > 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. Sure, data might be less than perfectly random. But the algorithm is not specified, so any patterns will be implementation specific. Even hardware specific in many cases. > Formally: as there is no formal detection algorithm > as term "side effect free script" is a nonsence, mathematicaly speaking. Can't that definition, in the specific context of ECMAScript, be established? Let's say something like this: - All functions (including constructors, methods and host object methods) are sent an internal boolean argument representing a requirement for them to throw a permission error if any action they perform lead to possible data persistence after the local scope has been destroyed. - All variable assignments must be to local variables. - Objects stored in non-local variables may not be assigned to local variables. - Member assignment may only take place on objects stored in local variables. Or something like that... The problem is that verifying whether function may result in side effects is a pain that must be delayed until runtime. You cannot know that methods, functions or constructors are side effect free unless they are host objects and readonly. You can't even assume that hello+' world'; is side effect free since the hello variable might contain an object with a toString method that has side effects. So, determining if a function is side effect free needs to be done while that function is run. -- David "liorean" Andersson <uri:http://liorean.web-graphics.com/>
Received on Wednesday, 31 May 2006 21:21:02 UTC