[erlang-questions] List to proplist?

Zvi <>
Fri Oct 31 13:24:40 CET 2008


While Richard is right about the tradeoff, I do not agree with his
conclusions, that it's either/either. You can dance on both weddings.
You can have both highly-readable, succint, expressive code (without
memorizing uncomprehensive assembler/perl-like character sequences) and
still leave the option to optimize for performance / code size for those
wishing to do it.
For example:

when prototyping or working from shell, you will write:

C = {1,2,3}.
[X+1 || X<-C].

C = [1,2,3].
[X+1 || X<-C].

but when writing production code, you may write:

f(C) when is_tuple(C) ->
     [X+1 || X<-C].

or

f(C) when is_list(C) ->
     [X+1 || X<-C].

(another possibility is using type specs).

Without a cheatshit, nobody will remeber all the spicies of <- , <=, {<-},
(<-). etc.

Zvi


Andras Georgy Bekes wrote:
> 
> On Friday 31 October 2008, Zvi wrote:
>> Why there should be multiple variants for '<-' ? After all Erlang has
>> dynamic typing, recognizing which collection type is T at run-time
>> should cost just one compare.
> This has been aswered long ago:
> http://www.erlang.org/pipermail/erlang-questions/2008-July/037072.html
> 
> 	Georgy
> 

-- 
View this message in context: http://www.nabble.com/List-to-proplist--tp20063268p20264874.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list