#lisp - Mon 9 Apr 2007 between 00:00 and 00:31

NY Lost Funds



whaleofconfusionif you knew the lexical environment variables, you could simply dynamically bind and unbind them in an unwind-protect around the eval to simulate lexical environment awareness
rahulhah
nyefIt's simple enough to create new bindings within the eval for the same values, but propagating changes back would be tricky.
rahulwhaleofconfusion: lexical bindings don't exist in that way
nyefAnd you'd need to know -which- values.
rahulthey aren't "things" after compilation.
whaleofconfusionit's a moot point unless you could get a list of current lexical variables somehow
nyefYou can't possibly need to export all of them anyway.
pkhuongwhaleofconfusion: what happens when I do (eval '(lambda () [capture the lexical environment!!])) ?
whaleofconfusionit would work
rahulI think it's clear he doesn't understand implementation of languages with lexical scoping...
whaleofconfusion: how could it possibly work?
whaleofconfusionI'll post some pseudocode, give me a minute
rahulwhaleofconfusion: EVAL isn't in the same lexical scope as its caller
pkhuongor worse, evaluating to a function that side-effects the captured environment.
dsteuberI think this is a case where eval is very evil.
Isn't eval in the null lexical environment?
rahulyes
dsteuberSo there is no variable capture at all.
rahulthere can't be
eval is a function.
dsteuberI don't think there's ever been a case where I felt the need to use eval. I think it exists for the REPL.
rahulit would be useful if you are having people type/build code in your app, which would be something similar to a REPL, yes
dsteuberSame thing really.
rahulat the conceptual level, yeah
dsteuberUnless you leave the compiler and interpreter (where applicable) out of your image.
rahulalthough code building may not LOOK like a repl
pkhuongdsteuber: it's good to know that it's there if you must use it. It's my dynamic security blanket ;)
dsteuberIt's in the CL package, so it is available to be used if needed even if the needs are rare.
foomi wish eval-in-lexenv was standardized
dsteuberA function like macro?
rahulfoom: it would create a closure around ALL the current lexical variables?
foomno, you pass it a form and an env
(see sbcl source)
rahulwhere would you get the env?
foom&env in a macro, most likely.
rahuland how would it relate to an env that existed at compile time?
pkhuongfoom: envs have dynamic extent.
rahulwhich means nothing outside of that macro
the env is temp data used by the compiler, basically

Page: 2 9 16 23 30 37 44 51 58 

IrcArchive

NY Lost Funds