REBOL [
Title: "Fun"
Date: 3-Jul-2002
Name: Fun
Version: 1.0.0
File: %Fun.r
Author: "Andrew Martin"
Purpose: "Automatic local word generation for a function."
Email: Al.Bri@xtra.co.nz
Web: http://valley.150m.com
Category: [util script 4]
]
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 LocalRefinement
][
throw-on-error [
Locals: make block! 0
if found? LocalRefinement: find Spec /local [
insert tail Locals next LocalRefinement
Spec: copy/part Spec LocalRefinement
]
foreach Value Body [
if all [
set-word? :Value
not found? find Spec to refinement! :Value
][
insert tail Locals to word! :Value
]
]
Locals: exclude Locals Spec
function Spec Locals Body
]
]