David-Sarah Hopwood wrote:
> Consider the following example (in ECMAScript syntax since I'll just get
> confused switching between ECMAScript and E):
>
> var f = /*...@functional*/ function() {
> return cajita.deepFreeze(function() { return {}; });
> };
> var obj = f(); obj.p = "surprise";
This should have been obj = f()().
(Static typing would have caught that bug :-)
> If this followed equivalent auditor definitions to E, it would pass the
> audit checks, even though 'var obj = f(); obj.p = "surprise";' causes
> an *internal* side-effect (that is, a side effect to an object that does
> not escape).
>
> Note that if we wrap this with another function g:
>
> var g = /*...@functional*/ function() {
> var f = /*...@functional*/ function() {
> return cajita.deepFreeze(function() { return {}; });
> };
> var obj = f(); obj.p = "surprise";
Same here.
> return cajita.deepFreeze(obj);
> }
>
> the object returned by g (with p:"surprise") is deep-frozen by the
> time it is returned, so f and g arguably *are* functional, even
> though the object f returns is *not* functional.
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
signature.asc
Description: OpenPGP digital signature
