-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
symbol '%find-macro-clause' unbound with users SRFI-8 #705
Comments
Hello @Retropikzel Indeed. The (define-module
srfi/8
(import (scheme base))
(export receive)
(include "8.scm")) works. Of course, the library definition should work... You can also The root of the problem seems to be issue #703 : local symbols which is used by exported syntax is not really exported. This seems to be what happened here... @egallesio is this something easy to fix? |
Hi @Retropikzel, Thanks for signaling this issue. I will try to correct this rapidly (but not probably before next week).
This particular issue is probably easy to correct, but I suppose it will be more difficult to have a correct behavior with the problem you exposed in #703. More on this soon, I hope. |
This instruction is accessible through the the special compiler form (%%symbol-value 'a 'STklos) which will produce the following code 000: CONSTANT-PUSH 0 002: CONSTANT 1 004: SYMBOL-VALUE 005: Constants: 0: a 1: STklos This compiler form is used in `define-syntax` expansion which uses the unexportded `find-clause` function defined in MBE module. In STklos modules, this symbol is available through the symbol %find-macro-clause. However, in pure R7RS libraries, this symbol is not available (as well as the find-module function). The hack here consists to use %%symbol-value in the expandion of define-syntax since it is always available even if not exported by any module. NOTE: This special form can probaly be useful in other low level places where we need to have an access to unexported symbols. Note that the current version of %%symbol-value does not support the optional third parameter of symbol-value. This should correct the issue #705 signaled by @Retropikzel
Hi, Last commit corrects this issue. Happy new year. |
@Retropikzel it seems that your original code now works! :) |
@egallesio I'll review old libraries and SRFIs and see if we ca nremove some of the " |
Thank you very much! :) |
Normally, there is no more occurrence of |
I think this might also be similar. main.scm: (import (scheme base) (scheme write) (foo)) (display "The value of bar is: ") (display bar) (newline) foo.sld: (define-library (foo) (import (scheme base)) (export bar) (begin (define bar (guard (error (else "bar")) (vector-ref (vector) 100))))) stklos main.scm: **** Error while executing command ("main.scm") Where: in %execute Reason: symbol 'current-exception-handler' unbound in library (foo) stklos -V git stuff: (build.git.branch "master") (build.git.commit "834eae3") Workaround foo.scm: (define-library (foo) (import (scheme base)) (export bar) (begin (define bar (call-with-current-continuation (lambda (k) (with-exception-handler (lambda (x) (k "bar")) (lambda () (vector-ref (vector) 100)))))))) I also tested foo.scm: (define-library (foo) (import (scheme base)) (export bar) (begin (define bar (with-exception-handler (lambda (x) "bar") (lambda () (vector-ref (vector) 100)))))) And got: **** Error while executing command ("main.scm") Where: in with-exception-handler Reason: exception handler returned on non-continuable exception I have no idea what the last one should do, but I thought I'd test it to be more thorough. |
@egallesio I think this has to do with #410 . Macros are created but they do not remember the environment in which they are created -- this is why macros created in modules have such problem: (let ((x 10))
(let-syntax ((a (syntax-rules () ((_) x))))
(let ((x 20))
(a)))) STklos answers 20, but it should be 10. So when a macro is created inside a module, there is a similar problem. It doesn't remember the module definitions (which it should, without need for importing)... If there was a way to get code compiled within a module, then it would be possible to get the macro system to remember the bindings (we'd just compile the macro in the proper module). Or did I get something wrong? |
The `guard` syntax used the following symbols (not available in pure R7RS libs) - current-exception-handler - %continuable-exception? - %continuable-exception-value
I have applied a quick fix for this problem, but I'll need to modify the implementation of About the code (with-exception-handler
(lambda (x) "bar")
(lambda () (vector-ref (vector) 100))) The error about an
All the other scheme systems I have tested also detect an error in this case. |
Yes, this is a known problem (See #239 (comment)). I hope to change that in not so far future. For now, don't forget that
This is another problem. In fact, the complexity here comes from the fact that when we compile a file, which imports a library, we do not load at all the code of the library, since it can have undesirable side effects (displays, system interactions, ...) So the compiler reads the metadata of the With pure R7RS libraries, we could imagine the loading of only the definitions parts of the library (that is, everything except the Hope that I was clear in my explanation. |
main.scm:
srfi/8.sld:
srfi/8.scm:
stklos -I . main.scm
gives error:If you comment out the srfi 8 import and copy the code directly to the file it works.
The text was updated successfully, but these errors were encountered: