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

Re: [Sc-devel] environment-safe functions



Or, slightly tighter (avoids redundant assignment if envir is not nil):

+ Function {
inEnvir { |envir|
envir ?? { envir = currentEnvironment };
^{ |... args| envir.use({ this.valueArray(args) }) }
}
}

hjh


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



: 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