[erlang-questions] Extensions to comprehensions eeps

Richard A. O'Keefe ok@REDACTED
Thu Jul 31 03:48:07 CEST 2008


On 30 Jul 2008, at 9:13 pm, Anthony Shipman wrote:

> A recent eep says
>
>    Currently, Erlang has
>
>        Pattern <- Expr
>
>    to enumerate over the elements of a single list and
>
>        Pattern <= Expr
>
>    to enumerate over a binary.  EEP 12 [1] adds
>
>        Pattern [<-] List
>        Pattern {<-} Tuple
>        Pattern <<<->> Binary
>
> Why the plethora of obscure arrow symbols? We should only need the  
> one arrow.

We already have two.
I do not find the distinction between <- and <= at all clear,
especially given the number of requests we've had to make <= a
spelling for less-than-or-equal, and I do not find Clean's
distinction between <- (lists) and <-: (arrays) mnemonic either.
Adding the appropriate brackets is a way of trying to make it
mnemonic.  As the EEP points out, I would have preferred
<-[], <-{}, <-<<>>, but couldn't get that through Yecc.

>
> Since it is a dynamic language the system should know what type of  
> collection
> is supplied and iterate appropriately.

The generated code needs to be different in each case,
which means that the compiler needs to know, unless the code
is to be slower or bigger or both.
>
>
> With the above symbols if I change a string from a list to a binary  
> I've got
> to go and change all of the comprehensions.

Yes.  It has been that way for quite some time,
and it's only now that you've noticed?

> The funny symbols are a kind of type annotation by stealth that is  
> quite
> irregular in the language.


When it is right out there in the open, how is it "stealth"?

Please clarify how <- vs <= (in the existing language)
is "type annotation by stealth" and 'and' vs 'band' is not.





More information about the erlang-questions mailing list