[erlang-questions] erlang improvement - objective c (or smalltalk) syntax

Richard O'Keefe <>
Fri Jun 5 06:46:00 CEST 2009


On 4 Jun 2009, at 9:10 pm, Joe Armstrong wrote:

> I've been writing some objective-C and like the method calling syntax.
> Objective-C (and smalltalk) code is very readable without lot's of  
> comments

It comes from Smalltalk, except that they forgot that you are
supposed to put spaces after the colons.
>
> Could we do something similar in Erlang?
> This was (I think)  discussed a long time ago but can't find the  
> discussion.

There was a proposal from me that
     f0(<args0>) f1(<args1>) ... fn(<argsn>)
should be handled by
     - keeping the f0 group at the beginning
     - sorting the remaining groups alphabetically
     - putting underscores between the names

>
>
> Imagine a function like string:substring/3. A call to this looks like:
>
>        string:substring(Str, I, J)

So that would be
	string:substring(Str) offset(I) length(J)
or
	string:substring(Str) length(J) offset(I)
both converting to
	string:substring_length_offset(Str, J, I)

A generalisation would allow each fi to be a sequence of
atoms, so you could write
	string:substring of(Str) offset(I) length(J)
or using prepositions as is common practice in Ada,
	string:substring of(Str) from(I) for(J)

>

> This change has many advantages:
>
>            + forces use of meaningful tag names in arguments
>            + don't have to remember argument order
>            + variable names in the body of a function become shorter
>
>
> If we were to make this change we would have to rewrite all the
> standard libraries
> but this would be a *good thing* - since this time we could get them  
> right.
>
> This is would also be a backwards compatible change (I think)




More information about the erlang-questions mailing list