[E-Lang] get, set, and dot

Marc Stiegler marcs@skyhunter.com
Tue, 27 Feb 2001 10:44:53 -0700

> MarcS wrote:
> > While I agree with the usage convention of using the
> > 1-method shortcut only
> > for Makers, I still think keeping the shortcut in the
> > language is a good
> > idea. The important thing it saves in Makers is a level of
> > indentation,
> So why not use the "function()" style for this. Why do you need a
> specially named "new" method? This isn't class based programming.
> Pretending that it is only deceives the reader about very important
> architectural differences in the model of computation.
> If you want to distinguish a function from a constructor, then I
> suggest using a capital for the first letter of a constructor and a
> lower-case for the first letter of a function.

An intriguing idea. A variant would be to use "new" as a prefix with the
function shortcut, as in

def newThing() :any {
    def thing {...}

I strongly desire to have the term "new" in the convention somehow, to help
make it recognizable to Java programmers. I remember when I was first
looking at E, before markm had adopted the "new" method name convention for
makers, I just was not getting the point that the makers were the E
equivalent of classes. In retrospect it is amazing just how important that
naming convention was for me to understand E's object construction, and
email does not allow me to emphasize it enough.

One minor disadvantage with this proposed style is that it reads less well
when the constructor supplies other functionality besides the basic "new"
purpose. This does not happen often, but it does happen often enough to be
worth mentioning. One recent example is the notary/inspector system, in
which a thingMaker not only supplies "new" but also "getInspector":

def newThing {
    to run :any {
        def thing {....}
    to getInspector :any {inspector}

def myThing := newThing()
# in the next line, "newThing" is not as natural as "thingMaker" would be
def trustedThing := newThing getInspector vouch(untrustedThing)

Trying to project consequences of the change, I foresee the following issue.
I cannot tell how much more often beginners would make the mistake
of leaving out the parenthesis during construction than they would make the
mistake of leaving out the "new":

def myThing := thingMaker
def myThing := newThing

Just reading this as English, it is clear that the unadorned"thingMaker" is
missing something for being the constructor of a new thing--looking at it,
you say, "I'm not getting a new thing, I'm getting an old Maker". But
"newThing" looks just fine, though it is just as wrong. This could be a
serious problem. Actually, I suspect it is a serious problem. I can see not
only beginners, but also old hands getting nailed by the missing parens. I
can hear my own curses already :-)

Truthfully, though, I may be the last guy to get enthused about this
proposal: I cannot bear to think about all the changes I would have to make
in both the book and the bodies of code I have written if we got rid of the
1-method constructor. So though I do not think the proposal is the right
choice, I really need to recuse myself from judgement :-)

Fortunately, I think markm has some other reasons for the 1-method shortcut,
in addition to the one here you have assaulted with substantial success :-)