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."
> -----Original Message-----
> From: Volker Nitsch [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 10, 2003 3:36 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Re: Rebol/Gotcha Handling previously defined words
>
>
>
> Am Mittwoch 10 Dezember 2003 20:30 schrieb Tim Johnson:
>
> Quickly fixing myself:
> (forgot return-value, added object to checklist)
>
> my.context: func [[catch] block /local ctx] [
> ctx: context block
> foreach word first ctx [
> if all [
> value? w: in system/words word
> any [
> ; add your checks here
> any-function? get w
> object? get w
> ]
> ] [
> throw make error! join "You don't want to
> redefine this: " word
> ]
> ]
> ctx ; oops, never forget return value..
> ]
>
> ctx: my.context [a: b: none]
> ? ctx
> ctx2: my.context [a: reduce: none]
>
> > TIA
>
> -Volker
>
> --
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.
>
>
--
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.