-
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
Rebinding car leads to unexpected behavior #368
Comments
Does the call to apply actually retrieve the binding of the procedure at runtime? That would explain this... And maybe also #367 . |
Aha! It's stklos>
(define-module x
(export (rename mycar car))
(define (mycar x)
(print 'MYCAR)
(car x)))
stklos> (import x)
stklos> car
#[closure mycar]
stklos> (car '(1 2 3))
MYCAR
1 |
By the way... I am embarrassed -- I can't find where |
Weird.....
in |
Ok, I think I understand now... There's this stub:
But when
It does |
Hi @jpellegrini, I think there is no problem here, in fact 😉 : module stklos> (define-module x
(import SCHEME)
(export (rename mycar car))
(define (mycar . args)
(print 'MYCAR)
(apply car args)))
;; x
stklos> (import x)
stklos> car
#[closure mycar]
stklos> (car '(1 2 3))
MYCAR
1
stklos> You can even use |
Hi @egallesio !
Thank you. I suppose it will also work with modules created in C. I'll check that later. |
Hi @egallesio ! It didn't seem to completely fix the issue -- see my comments on PR #404 . One way to reproduce the problem is this: I also tried defining SRFI 125 as R7RS library (not module); and importing SCHEME, as you recommended, but that didn't help... |
Maybe the internal STklos code could run in a separate module? |
And... Is this related to #367 also? |
Hm, it looks like the code rewriter changed this behavior. It isn't fixed, but... Different! stklos> (define-module x
(export (rename mycar car))
(define (mycar . args)
(print 'MYCAR)
(apply car args)))
;; x
stklos> (import x)
stklos> car
#[closure mycar]
stklos> (car '(1 2 3))
1 It didn't print |
Hi @egallesio !
I was working on SRFI 101, which redefines car, cdr etc, and found this:
Why?
The text was updated successfully, but these errors were encountered: