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

Richard O'Keefe ok@REDACTED
Sat Jun 6 07:46:28 CEST 2009

On 5 Jun 2009, at 7:27 pm, Vlad Dumitrescu wrote:
> Returning to the proposed syntax, I have a suggestion that is (to me,
> at least) just as good and requires no syntax change:
> It was suggested to use
>    string:substring(string:S, start:X, length:J)
> or
>    string:substring(S) start(X) length(J)
> that will be converted by the parser to something like
>    string:substring_length_start(S, J, X).
> The original problem is that one wants to know what the arguments are
> at the call site, but IMHO the tags don't need to sit right next to
> the argument.

But putting the tags next to the arguments is precisely what's
> Why not just directly use
>    string:substring_string_start_length(S, X, J)
> ?
> I find it easy to map tags with arguments, it's almost as verbose as
> the other suggestions, it works today.

That's pretty much the naming style that I developed for Prolog and
pushed in my book.  It's the best you can do without any syntax
change at all.  However, it has, as I found to my sorrow, one flaw:
it relies on the ability of human beings to count.  They can't.
It also relies on the ability of human beings to remember to change
the name when they add or reorder the arguments.  We're not very
good at that either.

For some strange reason, people who are perfectly happy with
keyword parameters sometimes seem to be quite unwilling to use
long procedure names.

I'm reminded of the way that Ada 95 had a perfectly good way of
invoking methods of objects, in many ways superior to dot notation
(because the controlling argument need not be the first, and need
not even be _one_ argument).  But Ada 2005 has succumbed to peer
pressure and adopted Java-style dot notation.  I am aware of the
technical arguments for it, but I bet the peer pressure was the
real issue.

> Another observation is that with string:substring(S) start(X)
> length(J), the first argument is special (has no tag).

Yes it has: substring(_).

Actually, the full proposal allows

	substring of(String) offset(Start) length(lLength)

so your (really valid) point is addressed.  Time to write this
up as a proper EEP.

More information about the erlang-questions mailing list