Summary
The behavior between `values` and `call/cc` is inconsistent.
Metadata
- Id: 552f6ea5e5d3764fcf3071e39d699af31830dcc1
- Trac id: 1390
- Type: defect
- Reporter: kooda
- Owner:
- Cc:
- Status: closed
- Component: compiler
- Estimated difficulty: hard
- Resolution: wontfix
- Priority: minor
- Milestone: someday
- Version: 4.12.0
- Changetime: 2023-11-06 23:32:33 UTC
- Created: 2017-08-02 11:35:15 UTC
- Keywords:
Description
With regard to multiple return values, `values` and `call/cc` behave differently.
I think the `call/cc` case should not error out.
Also, the error message is a bit unhelpful (sometimes the call to call/cc is not known from the user, for example `thread-join!` uses it) and in some cases no call trace is available.
(print (values 1 2 3)) ;; no problem
(define (stuff)
(call/cc
(lambda (return)
(return 1 2 3))))
(print (stuff)) ;; Error: bad argument count - received 3 but expected 1
Changes and comments
[2017-08-25 15:31:49 UTC] sjamaan set difficulty to easy
[2017-08-25 15:31:49 UTC] sjamaan changed milestone from someday to 5.0
[2017-08-25 15:31:49 UTC] sjamaan wrote:
Makes more sense to fix for 5.x
[2017-09-12 21:05:40 UTC] sjamaan changed status from new to closed
[2017-09-12 21:05:40 UTC] sjamaan set resolution to fixed
[2017-09-12 21:05:40 UTC] sjamaan wrote:
Fixed with 2dc0c5929a
[2019-04-08 12:31:26 UTC] sjamaan changed status from closed to reopened
[2019-04-08 12:31:26 UTC] sjamaan removed resolution fixed
[2019-04-08 12:40:39 UTC] sjamaan changed milestone from 5.0 to someday
[2019-04-08 12:40:39 UTC] sjamaan wrote:
Reverted in 3e0f640ecf22f6be7af1947b875132415556ca5b
This turns out not to work because when you capture a generated continuation, this assumes it receives one argument and does not check for the argument count. Adding these checks would be prohibitively slow, so we don't do it.
There might be a way to avoid doing this (the code hardcodes argcount from the lambda, which is not strictly necessary; we could call save_and_reclaim with `c` from C, instead of the Scheme `n`, but this doesn't solve everything; we generate `t0`...`tn` which index into the argvector and we also generate direct calls to trampoline functions with `c` set to the argument count we know the trampoline accepts and so on. These assumptions need to be removed before we can do this.
It is not even certain we really should want this feature in the first place.