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

[REBOL] Re: Q: Functions and the visibility of words

From: al:bri:xtra at: 26-Apr-2001 21:28

Colin wrote:
> 2. I've gotten into the habit of starting all functions like this: > > myfunc: func [.... /local aa bb cc dd]
Why not get Rebol do the work for you? 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 ] ] I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/