Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#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)

test-optional.scm (3.7 KB) - added by Alan Post 9 years ago.
test case designed to be placed in chicken-core/tests/

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by Alan Post

Attachment: test-optional.scm added

test case designed to be placed in chicken-core/tests/

comment:1 Changed 9 years ago by sjamaan

Likely fixed by changing let-optionals to let-optionals* in expand.scm:374

comment:2 Changed 9 years ago by felix winkelmann

Resolution: fixed
Status: newclosed

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).

comment:3 Changed 9 years ago by felix winkelmann

Milestone: 4.7.04.8.0

Milestone 4.7.0 deleted

comment:4 Changed 7 years ago by felix winkelmann

Milestone: 4.8.04.9.0

Milestone 4.8.0 deleted

Note: See TracTickets for help on using tickets.