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

Dmitrii Dimandt dmitriid@REDACTED
Thu Jun 4 12:39:49 CEST 2009


On Jun 4, 2009, at 12: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
>
> Could we do something similar in Erlang?
> This was (I think)  discussed a long time ago but can't find the  
> discussion.
>
> Imagine a function like string:substring/3. A call to this looks like:
>
>        string:substring(Str, I, J)
>
> The problem with this is that it's difficult to remember the  
> argument order
> and you have to consult the documentation *to find out the order of
> the arguments*
> I *know* what the arguments are (a string, a start index and a length)
> but I have to
> consult the documentation to find the order.

As Bengt Kleberg pointed out, this will lead to developers looking  
into documentation for correct parameter names

The reason is that there's really no easy way to determine the order  
of parameters in a function other than by looking it up in the docs.

IDEs don't help either because they usually resort to m(ModuleName)  
and all they can give you is the arity of the function (I'm not saying  
that current IDEs or their authors are bad :) I woudln't want to force  
them to parse erlang docs as well).

Perhaps a solution would be for erlang to somehow include "function  
hints" in function info. Something along the lines of

 > m(string).
...
substring/3
...
 >m(string, substring/3).
substring(Start, Index, Length)





More information about the erlang-questions mailing list