[E-Lang] newbie syntax: picayune points from a prejudiced programmer

zooko@zooko.com zooko@zooko.com
Fri, 02 Mar 2001 11:08:47 -0800


(This is a response to an older message of MarkM's from Wednesday.)


Here are the two biggest problems that I have seen so far for E as a
shell language:  required "def " for each variable and required ":any"
type-annotations for each function.



 MarkM wrote:

> >* In fact, would it be possible to provide Python's automatic
> >  declaration of variables with no keyword?  If we could write
> >
> >  answer := a
> >
> >  instead of
> >
> >  def answer := a
> >
> >  this would be big win in terms of interactive, scripting,
> >  fast-writing style.
> 
> We actually did this at one point (and there's still some dead code in the 
> implementation for supporting this I need to remove), but only at top level 
> scope, and only in an interactive environment.  Since then I've come to 
> believe that it's a bad idea, even in this restricted setting (see previous 
> correspondence with Hal & Bill about the semantics of re-entering code).
> 
> Outside this restricted setting, it's a terrible idea.  To obtain the code 
> inspection advantage of lexical scoping (see previous reply to Vijay), it 
> must be possible to easily match up a use-occurrence of a variable name to 
> the corresponding defining occurrence.


Hm.  When I'm doing this in Python I search, either visually or with my
editor's search function, for "answer *=".  In E, I could easily search
for "answer *:=".  Wouldn't this accomplish the same thing?



> >* Can we assume that functions with no type annotation are ":any"
> >  functions?  I hate typing the same thing over and over, and ":any" is
> >  going to be the type for > 90% of the functions, especially in
> >  scripting/first-prototype code.
> 
> Actually, much greater than 10% of the functions/methods you'll define have 
> return type ":void", and possibly even a majority of them.  But as Steve 
> points out, this isn't the real issue.  The real issue is POLA -- the 
> Principle Of Least Authority. If we made the default ":any", as we used to, 
> then the path of least resistance would be to return the last value 
> evaluated whether you needed to or not.  When you didn't need to, your own 
> cooperative code would not use the extra authority accidentally provided it, 
> and you wouldn't catch the security-hole bug in your code.  We actually had 
> many such uncaught security holes before we made this change.


That makes sense.


If you made it so that a function always returned nothing unless the
programmer used the explicit "return" keyword, then you would not need
type annotations at all, although you could still have them as optional
features form of documentation and static error-detection.


Then both people with :void functions and people with :any functions
could leave out the type annotation altogether.


In addition to making type-annotations optional, this would lose the
benefits of an expression-style language, but would gain the benefits
of familiarity.  (Of the Big Six sourceforge languages, Perl is
expression-style;  C, C++, Java and Python require the `return'
keyword;  I don't know about PHP.)


Regards,

Zooko