[erlang-questions] Core erlang wildcards and sequences

Anthony Ramine <>
Thu Aug 1 15:57:30 CEST 2013


Hello,

Replied inline.

-- 
Anthony Ramine

Le 1 août 2013 à 15:51,  a écrit :

> 
> 
> El Jul 31, 2013, a las 15:02, "Ludovic Demblans" <> escribió:
> 
>> Hi everybody,
>> 
>> I'm building a small DSL which compiles to Erlang VM. I have two
>> questions about how to achieve this.
>> 
>> First, if i want compile this pseudo code
>> 
>>   a = something
>>   b = do_something_with(a) %% involves a
>>   ... rest of code ...
>> 
>> I end to build the following (pseudo) core erlang code:
>> 
>>   let A = something
>>       in let B = apply do_something_with(A)
>>           in ... rest of code
>> 
>> I printed dummy erlang code to core erlang representation and it
>> resulted in the same forms, namely a stack of 'let expressions'.
>> 
>> Is that ok ? Are there better ways to achieve this in certain situations ?

Erlang does it that way.

> Core erlang has "letrec", so you shouldn't have to nest those let statements.

Irrelevant, letrec is only for functional values.

>> Then, i want to implement wildcards ( _ ), so in core erlang i create
>> a regular variable (which is never used) to match any value. Again, is
>> there a better way to do this, does one more variable involves more
>> overhead (i assume the compiler will optimize it anyway) ?
>> 
>> One more question !! I figured out that operators like + are calls to
>> erlang:'+'. I would like to play with the cons opearator but neither
>> erlang:'|' nor erlang:'cons' seems to exist. Is there another name ?
>> This is not important, just for fun.

There is no cons operator.

> Afaik, [ foo | bar ] is as desugared as it gets -- weird, I know.
> 
>> Thank you
>> 
>> ludovic


More information about the erlang-questions mailing list