IRC channel logs


back to list of logs

***haroldwu_home is now known as haroldwu
<zzach>(local-eval ... (the-environment)) seems to keep dynamic scope if put inside define-macro, but not inside define-syntax. Does it work if define-syntax is modified somehow?
<mark_weaver>you really shouldn't use 'define-macro', ever. it's just for backward compatibility.
<zzach>mark_weaver: it seems to be the only possibility to use local-eval inside a macro.
<mark_weaver>'local-eval' and 'the-environment' work properly with 'define-syntax'. however, it should be noted that if you put (the-environment) within a macro template, it will capture the lexical environment of that macro definition, not the place where it's used.
<mark_weaver>if you want to capture the environment from where the macro is used, then you must pass an argument to 'the-environment': an identifier.
<mark_weaver>then it will capture the environment from where that identifier was introduced.
<mark_weaver>the easiest thing is to pass the keyword from the macro that you're defining, e.g. (define-syntax my-the-environment (lambda (x) (syntax-case x () ((my-the-environment) #'(the-environment my-the-environment)))))
<mark_weaver>note that to do this, it's important that you use 'syntax-case', not 'syntax-rules', and that the first element of the pattern is not '_', but rather a pattern variable that you then pass to 'the-environment'.
<mark_weaver>if you're still having trouble, show me the code and I'll take a look.
<zzach>OK, will try to write a macro using syntax-case .
<mark_weaver>I guess this feature of 'the-environment' isn't documented, but it probably should be.
<mark_weaver>the thing is, we don't recommend using 'local-eval' and 'the-environment'. the existence of 'the-environment' within a procedure effectively disables almost all optimizations in that procedure, because the compiler has to make pessimal assumptions.
<mark_weaver>(because it means that any code with access to that environment can read or write the local variables at any time)
<mark_weaver>(even from another thread)
<civodul>mark_weaver: i'll review & apply tromey's patches
<civodul>oh you already did actually, perfect :-)
*civodul catches up
<davexunit>damn. just got bit by that bug where you stack overflow, ask for a backtrace, and crash guile. :(
<civodul>davexunit: it's fixed! :-)
<civodul>there's still a quirk at the REPL, but it no longer crashes
<civodul>commit 70057f3 in stable-2.0