#18 ✓resolved
Philipp Pirozhkov

reia::apply only works with modules, not class objects

Reported by Philipp Pirozhkov | December 29th, 2008 @ 03:23 PM


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

    Philipp Pirozhkov December 29th, 2008 @ 03:34 PM

    adding

    
    apply({object, {Pid, _Module}}, Method, Arguments) ->
      reia_class:call(Pid, {Method, Arguments});
    

    to reia.erl helps to resolve this

  • Philipp Pirozhkov

    Philipp Pirozhkov December 29th, 2008 @ 05:14 PM

    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

    Philipp Pirozhkov December 29th, 2008 @ 05:26 PM

    the second issue isn't major, i've found a workaround to pass arguments as a hash instead of tuple array

  • Philipp Pirozhkov
  • Tony Arcieri

    Tony Arcieri February 16th, 2009 @ 10:18 PM

    • 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.

New-ticket Create new ticket

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)

People watching this ticket

Attachments

Pages