[e-lang] Dot-based Property Access

Mark S. Miller e-lang@mail.eros-os.org
Sat, 15 Jun 2002 23:35:05 -0700


--=====================_747435285==_.ALT
Content-Type: text/plain; charset="us-ascii"

Another draft note of a resolution for the next release:

                            Dot-based Property Access

Conventionally, an expression followed by a dot, followed by a name, and not 
followed by an open paren would indicate direct access of an object's 
instance variables. However, such direct access to an object's instance 
variables would violate E's philosophy -- in E, all instance variables are 
private, and, more importantly, all inter-object access is mediated only by 
messages. Instead, E adopts the convention introduced by Java beans, Corba, 
and other systems of speaking of a "getFoo()" message as accessing a virtual 
"foo" object-property, and speaking of a "setFoo(newValue)" message as 
virtually assigning a new value to this object-property. Note that the 
concept of object-property has no deeper reality than as a way of speaking 
of these two messages. 

(By convention, a getFoo() message should be free of semantically 
significant side effects, and a getFoo() following a setFoo(newValue) should 
return newValue or something that can be thought of as a coercion of 
newValue. When an object has a getFoo() method but no corresponding 
setFoo(newValue) method, we say that it's a read-only object-property.)

As of this release, E revives a syntactic shorthand of using the conventional 
member-access syntax instead for object-property access. For example:

    interp.expand          expands to interp.getExpand()

    interp.expand := true  expands to
                             interp.setExpand(def ares_1 := true)
                             ares_1

                           When evaluated for effect, this 
                           is equivalent to
                             interp.setExpand(true)


----------------------------------------
Text by me above is hereby placed in the public domain

        Cheers,
        --MarkM

--=====================_747435285==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
Another draft note of a resolution for the next release:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Dot-based Property Access<br><br>
Conventionally, an expression followed by a dot, followed by a name, and
not <br>
followed by an open paren would indicate direct access of an object's
<br>
instance variables. However, such direct access to an object's instance
<br>
variables would violate E's philosophy -- in E, all instance variables
are <br>
private, and, more importantly, all inter-object access is mediated only
by <br>
messages. Instead, E adopts the convention introduced by Java beans,
Corba, <br>
and other systems of speaking of a &quot;getFoo()&quot; message as
accessing a virtual <br>
&quot;foo&quot; object-property, and speaking of a
&quot;setFoo(newValue)&quot; message as <br>
virtually assigning a new value to this object-property. Note that the
<br>
concept of object-property has no deeper reality than as a way of
speaking <br>
of these two messages. <br><br>
(By convention, a getFoo() message should be free of semantically <br>
significant side effects, and a getFoo() following a setFoo(newValue)
should <br>
return newValue or something that can be thought of as a coercion of
<br>
newValue. When an object has a getFoo() method but no corresponding 
<br>
setFoo(newValue) method, we say that it's a read-only
object-property.)<br><br>
As of this release, E revives a syntactic shorthand of using the
conventional <br>
member-access syntax instead for object-property access. For
example:<br><br>
<tt>&nbsp;&nbsp;&nbsp;
interp.expand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
expands to interp.getExpand()<br><br>
&nbsp;&nbsp;&nbsp; interp.expand := true&nbsp; expands to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
interp.setExpand(def ares_1 := true)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ares_1<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
When evaluated for effect, this <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
is equivalent to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
interp.setExpand(true)<br><br>
</tt><x-sigsep><p></x-sigsep>
----------------------------------------<br>
Text by me above is hereby placed in the public domain<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cheers,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --MarkM<br>
</html>

--=====================_747435285==_.ALT--