Calling a Module from Erlang

4 views
Skip to first unread message

Dave Bryson

unread,
Oct 27, 2010, 9:21:44 AM10/27/10
to Reia
What's the correct way to call a Module - Function in Reia from
Erlang. I'm using the latest code from git and tried the following:

With the module:

module Hello
def greeting(name)
System.puts("Hello #{name}")
end
end

Then in my Erlang code I try:

Result = reia:invoke('Hello',greeting,["dave"]),

However this fails and gives me a {bad_record, reia_object} error.

Thanks,
Dave

Tony Arcieri

unread,
Oct 27, 2010, 3:55:10 PM10/27/10
to re...@googlegroups.com
On Wed, Oct 27, 2010 at 7:21 AM, Dave Bryson <debr...@gmail.com> wrote:
Result = reia:invoke('Hello',greeting,["dave"]),

However this fails and gives me a {bad_record, reia_object} error.

This is a bug, reia:invoke *should* work with the core types, but the way it's written now it expects you to create an object first with reia:inst/2 and invoke methods on it.

I also had a reia:apply/3 function before specifically for invoking functions on modules, but with reia:invoke it really shouldn't be needed. I'll see if I can get this fixed.
 
--
Tony Arcieri
Medioh! A Kudelski Brand

Tony Arcieri

unread,
Oct 27, 2010, 3:57:11 PM10/27/10
to re...@googlegroups.com
On Wed, Oct 27, 2010 at 1:55 PM, Tony Arcieri <tony.a...@medioh.com> wrote:
I also had a reia:apply/3 function before specifically for invoking functions on modules, but with reia:invoke it really shouldn't be needed. I'll see if I can get this fixed.

Actually after a bit more reflection, reia:apply is still needed. Were this to actually work, it would try to invoke the "greeting" method of the :Hello atom, not the Hello module. Still, you should be able to invoke methods on core types with reia:invoke.

I'll go ahead and add reia:apply back, which is what you need here.

Tony Arcieri

unread,
Oct 27, 2010, 4:15:29 PM10/27/10
to Dave Bryson, Reia Mailing List
Both Reia and Efene should be good resources for people looking to build languages on Erlang

On Wed, Oct 27, 2010 at 2:13 PM, Dave Bryson <debr...@gmail.com> wrote:
Tony,

Thanks for the quick response!  This is exciting work you're doing.
I've used  Erlang for a while and briefly looked at Reia in the past
but didn't have a real need for it then.  Now I'm looking at creating
a scripting environment for users on distributed nodes so Reia looks
to be a great fit for that.   Your work is also a great learning
resource for writing a parser for Erlang.  I'm aware of the power of
the Abstract format but never really exercised it.  I'd like to
experiment in the future with creating a specific DSL on top of Erlang
and I think your work will help me figure out how to do that.

Thanks again,
Dave

On Oct 27, 2:57 pm, Tony Arcieri <tony.arci...@medioh.com> wrote:

Tony Arcieri

unread,
Nov 15, 2010, 1:35:45 PM11/15/10
to re...@googlegroups.com
Created an issue for this. Will try to get it addressed soon:

Reply all
Reply to author
Forward
0 new messages