Opened 7 years ago

Closed 14 months ago

#1390 closed defect (wontfix)

The behavior between `values` and `call/cc` is inconsistent.

Reported by: Kooda Owned by:
Priority: minor Milestone: someday
Component: compiler Version: 4.12.0
Keywords: Cc:
Estimated difficulty: hard

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

Change History (5)

comment:1 Changed 7 years ago by sjamaan

Estimated difficulty: easy
Milestone: someday5.0

Makes more sense to fix for 5.x

comment:2 Changed 7 years ago by sjamaan

Resolution: fixed
Status: newclosed

Fixed with 2dc0c5929a

comment:3 Changed 6 years ago by sjamaan

Resolution: fixed
Status: closedreopened

comment:4 Changed 6 years ago by sjamaan

Estimated difficulty: easyhard
Milestone: 5.0someday

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.

comment:5 Changed 14 months ago by felix winkelmann

Resolution: wontfix
Status: reopenedclosed
Note: See TracTickets for help on using tickets.