#421 closed defect (fixed)
#!optional arguments are not "evaluated in an environment in which all previous parameters have been bound."
Reported by: | Alan Post | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 4.9.0 |
Component: | expander | Version: | 4.6.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
Chicken Scheme uses DSSSL style lambda lists, as an extension to standard scheme:
http://wiki.call-cc.org/man/4/Extensions%20to%20the%20standard
Optional parameters are permitted to have an initializer, and the documentation states:
"The corresponding <initializer> is evaluated in an environment in which all previous parameters have been bound."
I would expect the following to work (note that a1 is being bound to the value of a0):
(define (foo #!optional a0 (a1 a0))
(list a0 a1))
(foo) => (#f #f)
(foo 0) => (0 0)
However, I instead get the following error:
Note: the following toplevel variables are referenced but unbound:
a0 (in def-a123)
I've attached a test case for #!optional parameters testing additional cases.
I'm running chicken scheme from git, commit cd19d7e077f0a6b53c3c804c972ec3738683e9ab.
My platform is OpenBSD 4.8-snapshot.
Attachments (1)
Change History (5)
Changed 14 years ago by
Attachment: | test-optional.scm added |
---|
comment:1 Changed 14 years ago by
Likely fixed by changing let-optionals to let-optionals* in expand.scm:374
comment:2 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Using let-optionals*
is not only correct, it also generates faster and smaller code. Thanks a lot, Alan! I added the testcase (and fixed a few problems with it).
test case designed to be placed in chicken-core/tests/