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

[REBOL] Re: Fun functions

From: al:bri:xtra at: 5-Jan-2001 16:23

And here's a better version that handles the case if you call Fun with a Specification block all ready containing a /local refinement and local 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 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 ] ] 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] ] ; Don't do this. Rebol/Core's internet protocols can't handle it. ; Func: :Fun The examples for the above 'problem' are: read http://www.rebol.com Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/