Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

io Assignment Operator not evaluating?

Tags:

iolanguage

OperatorTable addAssignOperator(":", "myAssignMethod")
"foo" : "bar"

That gives an error that a Sequence does not respond to ":" (":" is still being treated as a message, not an operator).

I think it should get evaluated to myAssignMethod("foo", "bar") (since "foo" = "bar" becomes updateSlot("foo", "bar")), but it's not. However:

OperatorTable addAssignOperator(":", "myAssignMethod")
doString("\"foo\" : \"bar\"")

that does work properly, and myAssignMethod gets called. So how do I get whatever processing happens on the code during doString() to work in the main code of the file?

like image 456
MidnightLightning Avatar asked Sep 01 '26 21:09

MidnightLightning


1 Answers

: is a valid identifier, and has special meaning. It's used to indicate number of arguments in the objective-c binding. It's highly recommended you choose another operator.

Also note, that all operator table modifications must be done prior to your file you're using them in being loaded and parsed, since operator shuffling occurs at compile time (when the file is loaded) and not at evaluation time. The REPL hides this problem as it has a new compile with each time you hit enter.

Additionally, if you want to see what something will be compiled to (useful for operators) wrap it inside a message() call. i.e., message(1 + 2) will yield 1 +(2) in the REPL.

like image 63
jer Avatar answered Sep 03 '26 12:09

jer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!