In the last line split&flip receives 0, but it needs a pair. The following wotks correct: #lang racket/base (define (split&flip xy) (define-values (x y) (values (car xy) (cdr xy))) (values y x)) ;; My mistake: x should be a pair
(define-values (a b) (split&flip (cons 0 1))) (cons a b) ; -> (1 . 0) In this case I don't see a fault in racket/base Jos _____ From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of Benjamin Greenman Sent: domingo, 13 de septiembre de 2015 7:58 To: Racket Users Subject: [racket-users] values considered harmful Something bad happened. I was using values and pairs, made a small mistake, and wound up with a segfault (on v6.2 and v6.2.900.16). Here's a minimal example: #lang racket/base (define (split&flip xy) (define-values (x y) (values (car xy) (cdr xy))) (values y x)) ;; My mistake: x should be a pair (define-values (a b) (split&flip (cons 0 1))) (split&flip b) What's really strange to me is that many versions of this program raise the expected "car: contract violation" error. For example, try changing the buggy line to `(values x y)` or `(values x x)` or even `(values (+ y) (+ x))`. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.