[erlang-questions] Core Erlang apply target expression behaviour
Karl Nilsson
kjnilsson@REDACTED
Fri Apr 21 19:12:27 CEST 2017
Whilst trying to compile some code to core erlang I came across a problem
when the target expression (e0 in spec) to apply was another apply
expression. According to the spec I thought that would be ok however when
compiling the .core file with erlc I got an "no_file: Warning: invalid
function call" error.
What I then tried, not thinking it would work, was to wrap the inner apply
expression in a let expression. This to my surprise worked just fine. I've
included the code below. 'addSix` is the working function and `addSix2` is
the dodgy one. Am I doing something wrong in `addSix2` to in terms of how I
print my AST or is it simply that `addSix2` cannot be made to work? I also
tried putting some parens around it but that also didn't work.
'add'/2 =
fun (_a0,_b0) ->
call 'erlang':'+'(_a0,_b0)
'addFive'/0 =
fun () ->
let <_a0> = 5
in fun (_b0) ->
apply 'add'/2 (_a0,_b0)
'addSix'/1 =
fun (_x0) ->
call 'erlang':'+'(let <_fez0> = apply 'addFive'/0 ()
in apply _fez0 (_x0),1)
'addSix2'/1 =
fun (_x0) ->
call 'erlang':'+'(apply apply 'addFive'/0 () (_x0),1)
Cheers
Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170421/1c8266ee/attachment.htm>
More information about the erlang-questions
mailing list