[Sc-devel] environment-safe functions

James Harkins jamshark70 at gmail.com
Sat Nov 24 18:29:15 PST 2007


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 at dewdrop-world.net
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.create.ucsb.edu/pipermail/sc-devel/attachments/20071124/84688c0c/attachment-0001.htm


More information about the Sc-devel mailing list