[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] environment-safe functions and pseudovariables



Hi Ron -

Good point. It would be nice to have a help doc to point out these
pseudovariables. For example, thisProcess is used in passing in two
help files (Platform, SkipJack) but not actually documented.
thisFunction isn't mentioned anywhere in help.

The "Environment" help doc describes currentEnvironment and
topEnvironment very nicely.

currentEnvironment is used in lots of help docs, although
Streams-Patterns-Events4 mistakenly calls it a class variable of
Object.

Dan


2007/11/25, ronald kuivila <rkuivila@xxxxxxxxxxxx>:
>
> Hi James,
>
> You are quite right.  No that I am thinking about it, currentEnvironment is
> a pseudovariable, so it suffices to write
>
>  envir = envir ? currentEnvironment;
>
> Hmm, is anyone writing about pseudovariables?
> As far as I know, there is no help page.
>
> RJK
>
>
>
> On Nov 24, 2007, at 6:29 PM, James Harkins wrote:
>
> Works for me, thanks. I will probably keep the e short form in my library,
> especially since there is already the precedent of single letter methods for
> Function -- if we can have p and r, why not e? :)  But I won't ask for that
> to go into the main library.
>
> Oops... I just read this more carefully. It won't work. You have to save the
> environment outside the returned function. The whole problem is that
> currentEnvironment is not the expected environment inside the function!
>
> + Function {
>  inEnvir { |envir|
>  envir = envir ?? {currentEnvironment};
>  ^{ |... args| envir.use({ this.valueArray(args) }) }
>  }
> }
>
>
> hjh
>
>
>
> On Nov 24, 2007, at 4:35 PM, Dan Stowell wrote:
>
> How about something along the lines of
>
> + Function {
>  inEnvir { |envir|
>  ^{ |... args| (envir ?? {currentEnvironment}).use({ this.valueArray(args)
> }) }
>  }
> }
>
>
> : H. James Harkins
> : jamshark70@xxxxxxxxxxxxxxxxx
> : http://www.dewdrop-world.net
> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>
> "Come said the Muse,
> Sing me a song no poet has yet chanted,
> Sing me the universal."  -- Whitman
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>
>


-- 
http://www.mcld.co.uk