-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add check-equal?/values and check-match/values #73
base: master
Are you sure you want to change the base?
Conversation
I don't understand why it would have to evaluate anything differently. |
It has to evaluate them in the context of |
What expression do you expect people to evaluate that distinguishes these two contexts? Yes, I agree there are theoretically some (things that call |
The What about adding a (define-check (check-equal? (values-list actual) (values-list expected))
... compare actual and expected, which are each lists of values ...)
;; captures the values returned by both expressions and passes them as lists
(check-equal? (values 1 2) (values 1 3)) That way, the equal checks don't need to use |
But they still have to be almost "full-fledged" macros, in that they can't be function-like anymore. It won't be equivalent to say |
I think it's a reasonable tradeoff. It's purely additive; no existing uses of |
And what if someone is testing functions that look at continuation-mark stuff? (Edit: I can't find a way to detect it other than looking at the error message, so far.) |
Would that work now? |
I don't think that supporting people writing And the earlier distinguishing context I gave was meant to reenforce how there aren't any interesting contexts that can distinguish them. |
Here's something that distinguishes them: #lang racket/base
(require rackunit)
(define fn-context (#%plain-app make-continuation-prompt-tag 'fn-context))
(define-syntax-rule (#%app f a ...)
(#%plain-app (with-continuation-mark fn-context 'function-position f)
(with-continuation-mark fn-context 'argument-position a)
...))
(define (stuff)
(let/cc k
(continuation-mark-set->list (continuation-marks k) fn-context)))
;; this passes:
(#%app check-equal? (stuff) '(argument-position))
;; this fails:
(check-equal?/values (stuff) '(argument-position)) (Edited to leave out unnecessary call-with-values) |
Well, of course that does. If you write
|
Put another way, in case what I wrote was not clear: your example is not really about continuation marks. Here's another example to illustrate this point.
I don't think this is relevant to |
Do |
Okay. I just realized |
(Re: @jackfirth's comment) |
I don't see why it can't act as a function when used higher order, it would just lose its magical value-capturing abilities (and any "value-list" argument would be a list of one value) |
@AlexKnauth I see what you mean now: if But even if it did, I'd say that changing it is still a good idea. I don't think that examples like you posted are ones that we need to worry about. |
faca5d9
to
bba2d08
Compare
bba2d08
to
6eec4fc
Compare
Related to #71. I put
check-equal?/values
in a separate form becausecheck-equal?
is meant to be a function-like check, and adding multiple values to the existingcheck-equal?
would require it to evaluate it's arguments differently from how a function would.