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: maximo:meteorstudios at: 10-Dec-2003 16:27

this is a Q&D function for catching redefining words... there are many things which can be added to this (like context handling), but I thought of supplying the most basic idea and letting the imagination of others run loose ;-) safe-func: func [word args body][ if value? in system/words word [ print ["WARNING function" uppercase to-string word "has been redefined"] ] set in system/words word func args body ]
>> safe-func 'remove [arg1][probe arg1]
WARNING function REMOVE has been redefined
>> remove "HH"
HH you can also protect all words with have a value before starting your script like so: wordlist: query system/words foreach word wordlist [ if value? in system/words word [ protect word ] ]
>> remove: true
** Script Error: Word remove is protected, cannot modify ** Near: remove: true -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.