Re: [Caja] Functional auditor for Cajita [minor correction]
David-Sarah Hopwood <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
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
_______________________________________________
e-lang mailing list
[email protected]
http://www.eros-os.org/mailman/listinfo/e-lang
signature.asc
(application/pgp-signature, 292 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREIAAYFAksepm0ACgkQWUc8YzyzqAfLfQD+P49Ll1HgjjJWPfg7Km1yOr4f GRYYk6DMDfYIw6kVpLkA/32nit8WefUKDoI/uR+Ie5oNDXB2sJZoxpJine2gS6iF =56sR -----END PGP SIGNATURE-----