Cast should support multiple-value expressions
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
Cast should be able to support multiple-value expressions, such as
(cast (values 1 2) (values Integer Integer))
Is there any reusable code for attaching contracts to multi-value expressions like this? I noticed that these two ways of doing that do very different things:
(define/contract (f)
(-> (values number? number?))
5)
(define (g)
(with-contract g #:results [number? number?] 5))
One raises a contract blame error specifying the function that violated the contract, the numbers of values expected and received, the contract and the context within the contract that was violated, where the contract came from, and who is to blame for violating the contract.
The other raises a result arity mismatch error specifying the numbers of values expected and received, but without any contract or blame information. I imagine this can be implemented much more easily and efficiently, without needing call-with-values, but it is a much worse error message.
For multi-value expressions like (cast (values 1 2) (values Integer Integer)), which strategy should it use? Is there any reusable code for either strategy? The code for the first strategy in racket/contract/private/arrow-val-first.rkt and racket/contract/private/arrow-higher-order.rkt seems specific to function contracts, and the with-contract form for the second strategy doesn't seem to allow specifying the negative party for the blame.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading racket/contract/private/arrow-val-first.rkt and racket/contract/private/arrow-higher-order.rkt, then compare their behavior with the with-contract form described in the issue. Decide which contract and blame behavior multi-value cast expressions should provide; done means cast supports the shown expression with a clearly defined error strategy.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100