To to translate emit() for 0.6.x?

7 views
Skip to first unread message

Sebastian Sardina

unread,
Jan 7, 2018, 7:35:51 AM1/7/18
to sarl
Hi

I think all the emits() I used to have in 0.5.x are giving this error in 0.6.x:

Description Resource Path Location Type
Invalid number of arguments. The method emit(UUID, Event) is not applicable for the arguments (CarArrivedPercept) Skill_SingleSimulatorInteraction.sarl /sarl-elevatorsim-ctrl/src/main/sarl/au/edu/rmit/elevatorsim/sarlctrl/skills line: 121 /sarl-elevatorsim-ctrl/src/main/sarl/au/edu/rmit/elevatorsim/sarlctrl/skills/Skill_SingleSimulatorInteraction.sarl SARL Problem


If I add null as a first argument to each emit( ) it seems to work. for example :

agentSpace.emit(null, new ModelChangePercept(time, id, newModel))

(of course used to work in 0.5.x without the null)

Is this related to this change?: https://github.com/sarl/sarl/commit/cc93392f68e740d207ceff666cc872d81ff2cee2 ? (though this seems just adding a new emit)

I am not sure if just adding "null" is the way to go, I suspect I am missing something and the solution is easy (or so I hope!)... :-)

Cheers,

Sebastian

Sebastian Sardina

unread,
Jan 8, 2018, 4:29:52 AM1/8/18
to sarl
OK so it does seem that emit/2 (emit with 2 arguments) has indeed been deprectated and removed:

@Inline(value = "emit(null, $1, null)")
 
@Deprecated
 
default void emit(Event event) {
 emit
(null, event, null);
 
}


Works if I do emit(null, ... ) or emit(this.ID, ...). 

1) Which is the one to be used? Seems like null was the default one before?

2) But then code does not work with previous versions, for  example with 0.5.8. Is there any way to write this so that code works with 0.5.8 and 0.6.1?

Thanks

Sebastian

Stéphane Galland

unread,
Jan 8, 2018, 5:36:06 AM1/8/18
to sarl
Dear Sebastian.

My recommendation is:
1) Use the ExternalContextAccess capacity: uses ExternalContextAccess
2) Call: space.emit(event)

The SARL compiler will uses the emis function from the capacity that calls the emit function (with 3 parameters) of the space for you.

The key change is the "uses" statement.

Stéphane.

Sebastian Sardina

unread,
Jan 8, 2018, 6:21:19 AM1/8/18
to sarl
Thanks Stephane! Seems to work. It is not exactly clear to me why and I am a bit not clear yet on contexts and spaces, but this is my issue I guess.

It would still be useful to have an example that uses emit in various ways showcasing spaces and contexts, I couldn't find one, maybe it is there?

Thanks anyway, now seems to work. 

Sebastian
PS: I am trying to migrate my SARL systems to 0.6.1 :-)
Reply all
Reply to author
Forward
0 new messages