Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: object funnies

From: ingo:2b1 at: 20-Oct-2001 10:55

Hi all, (I tried to sort my thoughts first, but didn't succeed, so you'll have to live with what you'll now get ;-) I think there are two reasons Rebol defaults to use words global: - it's easier to implement - it's more consistent And now some random thoughts ... AFAIK those languages defaulting to local contexts need their variables to be declared in the respective contexts, am I right here? For Rebol, where words don't have to be declared it gets a little bit complicated ... f: func [a][ v: a ] ; 'v should default to local, right? f: func [a][ print a ] ; but sure you'll want the global 'print ? Hhhhmmmm, OK, set-words default to local, get-words to global context. Now something a little more weird f: func [a][ print a p: :print print: func [b][p ["-->" b] print a ] Should the first print use the global word? Or is print local to the function, so it is undefined in the first line? (Having said that, I really like default to local, and I've once sent a proposal to feedback about a "reversed-logic" func: f: func[a /global g][ ... ] with 'g being global, all other words being local by default. But AFAIK it is not possible to add words to a context once it's created, so we just _can't_ catch every word in the local context, yet ...
>> ha
** Script Error: ha has no value ** Near: ha
>> c: context [f: func[w][do compose [(to-set-word w) 2] ]] >> c/f "ha"
== 2
>> ha
== 2 ) Well, as I said, just some random thoughts, and I'd be glad if you can prove me wrong ... kind regards, Ingo