reia::apply only works with modules, not class objects
Reported by Philipp Pirozhkov | 2008-12-29 15:23:15 UTC
module A
def x
'x'
class B
def y
'y'
>> reia::apply(~A, ~x, [])
=> "x"
>> b=reia::apply(~B, ~start, [])
=> #<Object>
>> reia::apply(b, ~y, [])
exception error: undefined function object:y/1
in function reia_erl:erl_funcall/3
in call from erl_eval:do_apply/5
in call from eval_shim:exprs/3
in call from reia_erl:erl_funcall/3
in call from 'Eval':exprs/2
Comments and changes to this ticket
-

Philipp Pirozhkov 2008-12-29 15:34:31 UTC
adding
apply({object, {Pid, _Module}}, Method, Arguments) -> reia_class:call(Pid, {Method, Arguments});to reia.erl helps to resolve this
-

Philipp Pirozhkov 2008-12-29 17:14:40 UTC
There's a more complex case:
>> class A .. def a(x) .. Local.puts(x.inspect()) .. => ~ok >> a=A.start() => #<Object> >> reia::apply(a, ~a, ["aa"]) "aa" => nil >> reia::apply(a, ~a, [("aa")]) "aa" => nil >> reia::apply(a, ~a, [[("aa")]]) ["aa"] => nil>> class B .. def b(x,y) .. Local.puts(x.inspect()) .. Local.puts(y.inspect()) .. => ~ok >> b=B.start() => #<Object> >> reia::apply(b, ~b, ["bb","cc"]) "bb" "cc" => nil >> reia::apply(b, ~b, [[("bb")],"cc"]) ["bb"] "cc" => nil >> reia::apply(b, ~b, [("bb","qq"),"cc"]) exception throw: {error,unknown_receiver, {{string,<<"bb">>},{string,<<"qq">>}}} in function reia_class:call/2 in call from reia_erl:erl_funcall/3 in call from erl_eval:do_apply/5 in call from eval_shim:exprs/3 in call from reia_erl:erl_funcall/3 in call from 'Eval':exprs/2 >> reia::apply(b, ~b, [[("bb","qq")],"cc"]) exception throw: {error,unknown_receiver, {{string,<<"bb">>},{string,<<"qq">>}}} in function reia_class:call/2 in call from reia_erl:erl_funcall/3 in call from erl_eval:do_apply/5 in call from eval_shim:exprs/3 in call from reia_erl:erl_funcall/3 in call from 'Eval':exprs/2 -

Philipp Pirozhkov 2008-12-29 17:26:27 UTC
the second issue isn't major, i've found a workaround to pass arguments as a hash instead of tuple array
-

Philipp Pirozhkov 2008-12-29 18:23:23 UTC
- no changes were found...
-

Tony Arcieri 2009-02-16 22:18:51 UTC
- State changed from new to resolved
This is resolved by the new reia:spawn/spawn_link and reia:invoke functions.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Reia a dynamic scripting language for the Erlang virtual machine (BEAM)