[E-Lang] Syntax Reductions: Consensus so far

Tyler Close tclose@oilspace.com
Tue, 6 Mar 2001 09:54:14 -0000


MarkM wrote:
> At 03:54 AM Monday 3/5/01, Tyler Close wrote:
> >Just to throw another log on the fire, what do you think
> of changing:
> >
> >        def add(a, b) :any {
> >                a + b
> >        }
> >
> >to:
> >
> >        to add(a, b) :any {
> >                a + b
> >        }
>
> This fatally conflicts with other design goals.  When
> defining a function, the
> name is simply a variable name, as is familiar from Scheme.
>  When defining a
> method, the name is a message name to be looked up in a
> whole 'nother name
> space -- the vTable of the receiving object.  The current
> syntax already has
> some danger of suggesting that these two are more similar
> than they are.
> The above suggestion makes this possible confusion a certainty.

I understand that there is a difference between the variable
definition and the method name, but I am not sure that everyone needs
to understand this. What sort of bad things could happen if people did
not realize the distinction.

Keep in mind that def foo() {} is now a final variable declaration, so
we're not creating an assignable variable. The variable name and the
method name are permanently bound.

> I chose the name "to" to suggest that one should usually
> chose verbs for
> message names.  Similarly, one should usually chose nouns
> for variable
> names.  Variable names are used to designate objects
> (including functions).
> Message names are used to ask these objects to do
> something.  The function
> syntax can be seen as a way to ask an object to "do your
> thing", whatever
> that may be, which therefore doesn't need to be named.

Functions will be given verb names. They will be called as if they
were methods. How many times have we done the add() example?

As Zooko points out, a function's 'reason for being' is to act like a
stateless method. It should be declared like a method that is not in
an object definition and therefore has no state.

Tyler