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 ?
>
Core erlang has "letrec", so you shouldn't have to nest those let statements.
>> 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.
>
Afaik, [ foo | bar ] is as desugared as it gets -- weird, I know.
> Thank you
>> ludovic
> _______________________________________________
> erlang-questions mailing list
>>http://erlang.org/mailman/listinfo/erlang-questions
Tom