[REBOL] Re: Fun functions
From: al:bri:xtra at: 5-Jan-2001 12:04
I forgot two little points, getting rid of duplicate locals and allowing
set-word!s to refer to the argument words.
Fun: function [
"Automatic local word generation for a function." [catch]
Spec [block!] {Optional help info followed by arg words (and optional
type and string).}
Body [block!] "The body block of the function."
][
Locals
][
throw-on-error [
Locals: make block! 0
foreach Value Body [
if set-word? :Value [
insert tail Locals to word! :Value
]
]
Locals: exclude unique Locals Spec
function Spec Locals Body
]
]
Func: :Fun
Does: fun [
{A shortcut to define a function that has no arguments or locals.}
[catch]
Body [block!] "The body block of the function."
][
throw-on-error [Fun [] Body]
]
I've also included changes for 'func and 'does, in case people feel
enthusiastic. :-)
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/