When I start up an R3 Alpha 99 session, and enter this as the first command, I get an error:
>> is-email-addr: get bind to-word "email?" bind? 'system
** Script error: email? is not in the specified context
** Where: bind
** Near: bind to-word "email?" bind? 'system
But if I quit, restart and instead execute a test to prove that the email? primitive lives in global context like the system object, the test itself makes my alias work:
>> equal? bind? 'system bind? 'email?
== true
>> is-email-addr: get bind to-word "email?" bind? 'system
>> is-email-addr fork@example.com
== true
What’s going on, here?
Binding doesn’t add words to the context, unless you tell it to – you have to use
bind/new.But your question shows a couple misconceptions about the R3 binding model. There is no single global context in R3, not like R2. The word
'systemin your example is bound to the task-local shared script context, aka the user context. And getting the right value for words in the user context often means importing them from the system context, or the exports of the loaded modules, a process known as interning the words.To do what you apparently want to do here, it would be best for you to use
intern, like this:The
to-blockis used becauseinternis generally used to operate on whole blocks of code. I’ll fix it in the next version so it can work on words directly as well; then you will be able to do this:I hope this helps.
Why aren’t you using the word directly? Using strings and converting to words later has so much overhead, which is usually unnecessary.