[e-lang] JavaScript style reminiscent of E
Julien Couvreur
jcouv at microsoft.com
Thu Apr 14 12:12:25 EDT 2005
Here's another good read on the topic of private members in javascript,
from Douglas Crockford: http://www.crockford.com/javascript/private.html
Cheers,
Julien
-----Original Message-----
From: e-lang-bounces at mail.eros-os.org
[mailto:e-lang-bounces at mail.eros-os.org] On Behalf Of Norman Hardy
Sent: Wednesday, April 13, 2005 6:59 PM
To: Discussion of E and other capability languages;
david.nospam.hopwood at blueyonder.co.uk
Subject: Re: [e-lang] JavaScript style reminiscent of E
On Apr 13, 2005, at 5:27 PM, David Hopwood wrote:
> Norman Hardy wrote:
>> See <http://cap-lore.com/Languages/js/S.html> for a note for a
>> JavaScript audience advocating a style of JavaScript
>> that provides abstraction to achieve access control.
>> There is little here of interest to E users except that JavaScript
>> provides data abstraction thru lexical closure just like E.
>> This is contrary to almost all JavaScript tutorials and practice.
>
> I briefly looked through the Javascript/ECMAscript semantics looking
> for features not compatible with capability discipline. It seems to
> support dynamically scoped variables -- so don't use those. Also the
> module system depends on globally accessible namespaces; this means
> that there is no way to block access to the standard libraries, which
> were not designed to follow capability discipline.
If you use as your objects what the documentation and tutorials refer
to as "objects"
then the holder of an object reference has direct access to all its
parts--no privacy!
If you use instead a map from string to function, as my example above,
then the holder
of a reference to the map does not have such access.
The pseudo object is merely a bundle of closures.
I don't know the cost of storing and running such code, but the syntax
for defining
such an object is short and sweet, somewhat like E.
The resulting pseudo objects are called the same way as the
conventional objects.
Unlike Java or C++ if b is an object and m is a method on that object,
b.m evaluates
to a function and can be thus passed as an argument of type function.
The recipient has no access to other methods on b.
ActionScript affords this protection in their API.
I don't think that Javascript/ECMAscript provides any sort of dynamic
scoping that defeats the map style of object, but then again that
document
is big and very hard to read.
>
>
Imagination consoles us for what we are not, humour for what we are.
Winston Churchill
http://cap-lore.com
_______________________________________________
e-lang mailing list
e-lang at mail.eros-os.org
http://www.eros-os.org/mailman/listinfo/e-lang
More information about the e-lang
mailing list