Do we have performance measurements that show the importance of such reorderings?<br><br>Robby<br><br>On Thursday, October 6, 2011, Neil Toronto <<a href="mailto:neil.toronto@gmail.com">neil.toronto@gmail.com</a>> wrote:<br>
> On 10/06/2011 01:20 PM, Eli Barzilay wrote:<br>>><br>>> Just now, Neil Toronto wrote:<br>>>><br>>>> On 10/06/2011 12:28 PM, Prabhakar Ragde wrote:<br>>>>><br>>>>> On 10/6/11 2:12 PM, Eli Barzilay wrote:<br>
>>>><br>>>>>> Sam is talking about building the ASTs *while* matching, which is<br>>>>>> what Jay was trying to do with uses of `app'. I think that a<br>>>>>> teaching context is in particular one where such a thing doesn't<br>
>>>>> fit -- it obscures the distinction between the side the sexpr<br>>>>>> goes into, and the side where an AST comes out.<br>>>>><br>>>>> Okay, I see the distinction, and I apologize for not having fully<br>
>>>> understood Jay's example. I agree that this obscurity is<br>>>>> hazardous. I think, though, that I have always assumed<br>>>>> left-to-right matching, though I may never have constructed<br>
>>>> anything that would break if it didn't happen. --PR<br>>>><br>>>> I think most people expect branching constructs like 'match' to make<br>>>> in-order (left-to-right/depth-first), short-cutting decisions.<br>
>>> Additionally, the cases themselves do this. So I think the fact that<br>>>> the patterns don't is very surprising.<br>>><br>>> IIRC, the cases are also reordered to optimize tests -- and that's an<br>
>> even more important optimization:<br>>><br>>> -> (define (list?? x) (printf "list-checking ~s\n" x) (list? x))<br>>> -> (define (one?? x) (printf "one-checking ~s\n" x) (eq? 1 x))<br>
>> -> (match '(1 (2) 3)<br>>> [(list (? one??) 2 3) 1]<br>>> [(list _ (? list??) _) 2]<br>>> [(list (? one??) 20 30) 3])<br>>> list-checking (2)<br>>> 2<br>
>><br>>> and after Jay broke it, you get<br>>><br>>> one-checking 1<br>>> list-checking (2)<br>>> 2<br>>><br>>> IMO it is perfectly fine to require that stuff used in `match'<br>
>> patterns is side-effect-free, and therefore cachable and reorderable.<br>><br>> Well I'll be darned.<br>><br>> I suppose this shows just how deeply I hold assumptions about order and shortcutting.<br>
><br>> Neil T<br>><br>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://lists.racket-lang.org/listinfo/dev">http://lists.racket-lang.org/listinfo/dev</a><br>
>