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

[REBOL] Re: Rebol/Gotcha Handling previously defined words

From: nitsch-lists:netcologne at: 10-Dec-2003 21:22

Hi Tim, Am Mittwoch 10 Dezember 2003 20:30 schrieb Tim Johnson:
> Well, I did it again, and punished myself severely for the > transgression, but I can't bring back the time I lost.... > > I created a subroutine in a context and called it 'reduce. And I forgot > to either redefine or provide an absolute path for system/words/reduce. > > Bad Tim, bad, bad Tim! > > This poses the need for a wonderful one-liner that would throw an > error or warning in case a word is defined and used in a context that > already exists in system/words. > > I'm just starting to dig into lisp as a part of learning emacs and I > believe that language does have such safeguards, but I haven't been able > to get to that understanding yet. > > Any ideas? comments?
You need a very long line for this, but my.context: func [[catch]block /local ctx] [ ctx: context block foreach word first ctx [ if all [value? w: in system/words word any-function? get w] [ throw make error! join "You don't want to redefine this: " word ] ] ] ctx: my.context[a: b: none] ctx2: my.context[a: reduce: none] ** User Error: You don't want to redefine this: reduce ** Near: my.context [a: reduce: none]