#27 ✓resolved
Philipp Pirozhkov

unable to call class's module_info

Reported by Philipp Pirozhkov | March 29th, 2009 @ 03:38 PM

After latest block changes, it's unable to call class's module_info function:


>> load('home.re')      
=> Home
>> Home.module_info()   
exception error: undefined function 'Home':module_info/2
  in function  erl_eval:do_apply/5
  in call from eval_shim:exprs/2
  in call from reia_erl:erl_funcall/3
  in call from 'Eval':exprs/2

exception claims that i'm trying to call /2 function, while i'm trying to call /0


>> Home.module_info(:compile)
exception error: undefined function 'Home':module_info/2
  in function  erl_eval:do_apply/5
  in call from eval_shim:exprs/2
  in call from reia_erl:erl_funcall/3
  in call from 'Eval':exprs/2

calling with argument results in the same exception

the workaround for that could be an info() function for a class/module, since Reia itself should provide that kind of info, and not to be bound tightly to the underlying erlang vm

what is exactly required is the last_loaded timestamp:


[_,_,(:time,last_loaded),_] = reia::apply(controller, :module_info, [:compile])

Comments and changes to this ticket

  • Philipp Pirozhkov

    Philipp Pirozhkov March 29th, 2009 @ 03:38 PM

    • Assigned user set to “Tony Arcieri”
  • Tony Arcieri

    Tony Arcieri March 30th, 2009 @ 12:25 AM

    • State changed from “new” to “resolved”

    I added a hack to facilitate calling module_info the way it worked before for the time being. Expect this to get merged into the reflection functions for modules and go away in the future. Reopen if it's not working the way it did before.

  • Philipp Pirozhkov

    Philipp Pirozhkov March 30th, 2009 @ 03:47 PM

    Still fails:

    
    reia::apply(controller, :module_info, [:compile])
    

    same as:

    
    Home.module_info(:compile)
    

    Yes, it's a workaround to make a laaaaaarge pattern matching, but that looks too ugly

  • Tony Arcieri

    Tony Arcieri March 30th, 2009 @ 04:01 PM

    Okay, pull again and you should be able to pass a parameter to module_info just like you can in Erlang, e.g:

    
    Object.module_info(:compile)
    

    Also note you don't need anything ugly to get that out of the returned module_info() data... this will get it for you:

    
    compile_info = [info | (:compile, info) in Object.module_info()][0]
    

    If you want to get to the time from the raw module_info structure, you can use:

    
    time = [[time | (:time, time) in info] | (:compile, info) in Object.module_info()][0][0]  
    
  • Philipp Pirozhkov

    Philipp Pirozhkov April 6th, 2009 @ 11:08 AM

    • Tag changed from block to dispatch

    thanks for nice list comprehension tip!

    but module_info call still doesn't work using meta-call:

    
    Binary.module_info()
    @@@ works fine
    

    reia::apply(:'Binary', :module_info, []) @@@ fails with:

    
    exception error: undefined function 'Binary':module_info/2
      in function  reia:apply/4
      in call from reia_erl:erl_funcall/3
      in call from erl_eval:do_apply/5
      in call from eval_shim:exprs/2
      in call from reia_erl:erl_funcall/3
      in call from 'Eval':exprs/2
    

    Looks like reia:apply/3 calls apply/4 and it calls erlang:apply(:'Binary', :module_info, [{}, nil]) that is unexpected by Binary to accept block and empty hash, too

    do not take this into account if there will be a different solution later, i have an erlang::apply instead of reia::apply workaround for that

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

Tags

Pages