Re: Fusion Laws?
Michael Haufe <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On Wednesday, March 30, 2016 at 5:26:17 PM UTC-5, Boris Zbarsky wrote:
> On 3/30/16 6:17 PM, Michael Haufe wrote:
> > In general yes. The exceptions are of course idempotent ones like dom calls which are constant after creation (window.self perhaps?), and innocuous side-effects that are never used:
> >
> > xs.map(function(x){
> > var d = Date.now(); //side-effect
> > var r = Math.random(); //side-effect
> > return x
> > });
>
> The problem is that it's hard to prove functions are side-effect-free in
> JS, in even this weak sense. For example, your function there might do
> absolutely anything, depending on what's been done to the Date and Math
> properties on the global. :(
It's a shame there isn't an Attribute Grammar definition for the semantics of ECMAScript, it might make this a bit more tractable...
I found a related thread on es-discuss:
<https://mail.mozilla.org/pipermail/es-discuss/2012-November/thread.html#26657>
I think Brendan said it best. To paraphrase: we'd be eaten by a grue if we tried.