Comments (8)
This is because the script is parsed before it is executed (so it doesn't see the new operator entry while parsing).
from io.
So, this is by design and I'm SOL?
from io.
How could it be designed any differently? Would you parse and eval each line separately? What if an line eval attempted to look at the message tree - it would not be able to see the rest of it and this would also lead to a SOL situation.
from io.
You can avoid the problem by simply putting the:
OperatorTable addAssignOperator("=>", "setKey")
bit in a separate script file.
from io.
To clarify, my comment of "by design" was in regard to IO having inconsistent behavior depending on the environment and/or mode of execution.
I didn't actually intend on questioning "parse before execute" -- language design and implementation isn't my realm to question. But, outside this realm, your original response was rather useless. It gave me some additional understanding of the VM, that I appreciate, but it didn't resolve the issue.
From an admittedly naive understanding, it is at least odd that a new assignment operator isn't actually known until execution when the parser is what seems to need it. So, perhaps addAssignOperator
could be rethought to be a parsable message rather than an executable message? I don't know...
Nevertheless, thank you for the suggestion. However, placing it in a separate file doesn't seem to make any difference. I've tried placing it in an addon script and importing, as well as just trying to execute it with doFile
. Am I missing a 3rd option?
from io.
If you send me your email address, I can send you a zip that shows it working.
from io.
Also, here's the code if you don't mind creating the files yourself:
FILE: map.io
map(foo => 2, bar => 3)
FILE: op.io
OperatorTable addAssignOperator("=>", "setKey")
map := method(
call message arguments foreach(arg, writeln(arg))
)
FILE: runme.io
doFile("op.io")
doFile("map.io")
from io.
Ah. Didn't think to run everything through doFile
.
Though, that did lead me to find Message fromString
, which works just as well with a little less overhead in the setup: ;)
OperatorTable addAssignOperator("=>", "setKey")
map := method(
call message arguments foreach(arg,
writeln(Message fromString(arg asString))
)
)
map(foo => 2, bar => 3)
from io.
Related Issues (20)
- iolanguage.org is no longer delegated HOT 2
- Unexpected behavior of Object doMessage HOT 18
- How to set color for the output? HOT 2
- How cancel a message in Io's REPL without leaving the REPL? HOT 6
- sudo make install fails on CenOS in the Install Eerie part HOT 3
- New Eerie version incompatible with addon system (needs agreement) HOT 13
- Embedding Io HOT 2
- does not build on armhf: unrecognized command line option ‘-msse2’ HOT 3
- Does anyone compile it on M1 successfully? HOT 8
- Additional syntax flavour variants of Io? HOT 2
- mingw64 build failing HOT 4
- Improvements to C code that can improvement robustness HOT 5
- Why my code raise exception that "Object does not respond to 'Random'" HOT 4
- No implement of function IoVMCodeInit in file IoState.c HOT 5
- No way to convert from a binary string back to a number? HOT 5
- "UnsupportedSpecializationException" when trying to Io with GraalVM HOT 11
- Does not support Apple Silicon HOT 6
- Help: Building in openSUSE HOT 5
- deprecated slice in the io tutorial
- REPL eat newline
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from io.