Pinoccio / library-pinoccio

Arduino library for Pinoccio
Other
28 stars 24 forks source link

command.scout.ack assumes the first arg is a plain command name #195

Open alexglow opened 10 years ago

alexglow commented 10 years ago

Entered in Arduino IDE: command.scout.ack("led.green(500)", 11, "led.green", 500);

It works as expected (both Scouts' LEDs flash green, 500ms). However, it returns an error: missing )

According to Jeremie: It is trying to run led.green(500)(1,rssi) Just assumes the first arg is a plain command name, it can detect a ( and skip that

(Which is why, if you store led.green(500) as a command and substitute that into command.scout.ack, you don't get an error.)

Cheers!

matthijskooijman commented 10 years ago

According to Jeremie: It is trying to run led.green(500)(1,rssi) This is also what the docs say:

| a local callback ScoutScript command, callback is evaluated if it is | defined. The callback command will be passed two arguments, err and | rssi.

Perhaps this could be clarified by saying "a local callback ScoutScript function" instead, though.

Just assumes the first arg is a plain command name, it can detect a ( and skip that If Jeremie is saying to ignore the part after the () - then I'd be opposed - things will break in hard-to-debug ways if the argument list is silently discarded and replaced.

Better would be to return an error message if ( appears in the command. Or, even better, check if the function is defined when command.scout.ack is execurted and return a proper error, instead of just executing it when the ack is received, resulting in an unclear error message.

(Which is why, if you store "led.green(500)" as a command and substitute that in, you don't get an error.) That's how it's supposed to work.

Cheers!


Reply to this email directly or view it on GitHub: https://github.com/Pinoccio/library-pinoccio/issues/195