Fwd: [Caja] An experiment and some questions

"Mark Miller" <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
Much of the thinking that we (especially Kevin and Dean) have done
about module systems for E may bear on Ihab's question.


---------- Forwarded message ----------
From:  <[email protected]>
Date: Feb 6, 2008 4:55 PM
Subject: [Caja] An experiment and some questions
To: Google Caja Discuss <google-caja-discuss-/[email protected]>


Hi folks,

I have been experimenting with writing the rewriter rules in
JavaScript. I will put that on hold for the moment while I take care
of the other issues but this raises a question. Is there a standard
mechanism whereby a Caja module can import another Caja module in a
capability safe manner?

In what I did, I have tried to follow E's "maker" pattern. Here is a
JavaScript module --

http://code.google.com/p/google-caja/source/browse/changes/ihab/js-rules/trunk/src/java/com/google/caja/parser/quasiliteral/defaultCajaRewriter.js

and notice that it is passed an 'importer', which is a capability to
import modules. It uses that to import another module, the source of
which is here --

http://code.google.com/p/google-caja/source/browse/changes/ihab/js-rules/trunk/src/java/com/google/caja/parser/quasiliteral/cajaRuleSupport.js

and note that this creates an *instance* of the imported module, which
has only the capabilities supplied to it by the importing module. I
used the idiom of one top-level function expression as the "return
value" of a module to achieve this. The JsImporter class, which is in
Java --

http://code.google.com/p/google-caja/source/browse/changes/ihab/js-rules/trunk/src/java/com/google/caja/parser/quasiliteral/JsImporter.java

caches the ASTs of a given module file, so it doesn't have to
re-parse, and simply re-evaluates the function every time a module is
imported.

     *    *    *    *    *

* What, if any, is or should be the equivalent functionality in Caja?
Should an importing module import another into the same ___OUTERS___,
or should the ___OUTERS___ for the imported one be "cleanroom"
isolated?

* How does that relate to other JS module systems? Should we be
working more closely with http://modulesjs.com/?

Ihab

-- 
Ihab A.B. Awad, Palo Alto, CA
 --~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to
http://groups.google.com/group/google-caja-discuss
 To unsubscribe, email google-caja-discuss-unsubscribe-/[email protected]
 -~----------~----~----~----~------~----~------~--~---
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.