[e-lang] [Caja] Functional auditor for Cajita [minor correction]

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Dec 8 11:17:57 PST 2009


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
Url : http://www.eros-os.org/pipermail/e-lang/attachments/20091208/4ef4412f/attachment-0001.bin 


More information about the e-lang mailing list