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

[REBOL] Re: localized func alternative...

From: tim:johnsons-web at: 27-Feb-2004 16:55

* Maxim Olivier-Adlhoch <[maximo--meteorstudios--com]> [040227 14:05]:
> Hi all, > > Has anyone programed an alternative to func (function, has, does) which declares every set-word as local by default? > > I find rebol's liberal use of global namespace to be the most limiting factor in scaling rebol to large tools.
No kidding. There much be a reason, but I dunno why.....
> I'd rather have to define global words than local words (especially in api tools).
; Below is code that I use. It is developed by Andrew Martin with the ; last mod by me. I believe that Ladislav has a 'fun also... make object! [ Find-Locals: function [Locals [block!] Body [block!] Deep [none! logic!]] [Value] [ parse Body [ any [ set Value set-word! ( if not found? find Locals Value: to word! :Value [ insert tail Locals Value ] ) | set Value block! ( if Deep [ Find-Locals Locals Value Deep ] ) | skip ] ] Locals ] set 'Fun function [ "Automatic local word generation for a function." Spec [block!] {Optional help info followed by arg words, optional type and string.} Body [block!] "The body block of the function." /Deep "Inspect block! values recursively for more local words." ][ Locals LocalRefinement ][ Locals: copy [] if found? LocalRefinement: find Spec /local [ insert Locals next LocalRefinement Spec: copy/part Spec LocalRefinement ] Find-Locals Locals Body Deep Locals: exclude Locals Spec function Spec Locals Body ] set 'Sub :Fun ] def: sub[Spec[block!] Body[block!]][sub/deep Spec Body] ; added by Tim
> There is MUCH less chance that incidious errors will be generated or exposed.
Enjoy! I sure have. Kudos to Andrew and Ladislav
> A notable example is the recent S: variable useage in the sql tool which would not have occured. > > TIA! > > -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." > > -- > To unsubscribe from this list, just send an email to > [rebol-request--rebol--com] with unsubscribe as the subject.
-- Tim Johnson <[tim--johnsons-web--com]>