On Thu, Oct 6, 2011 at 6:10 PM, Jay McCarthy <[email protected]> wrote: > In Eli's example, only the second pattern could match > > But if we wrote it this way: > > (define (list?? x) (printf "list-checking ~s\n" x) (list? x)) > (define (one?? x) (printf "one-checking ~s\n" x) (eq? 1 x)) > (match '(1 (2) 3) > [(list (? one??) (list 2) 3) 1] > [(list _ (? list??) _) 2] > [(list (? one??) (list 20) 30) 3]) > > Are you saying that match is allowed to return 1 or 2 depending on > these reorderings and this is in some sense an "illegal" match > expression?
No, definitely not! `match' might test components in whatever order it wants, but the semantics of when a match is found is just top-to-bottom, and `match' always takes the first successful match. -- sam th [email protected] _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev

