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

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



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
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

_______________________________________________
Sc-devel mailing list