[racket-dev] else clauses: possible change to match?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Fri May 3 16:39:44 EDT 2013

On 05/03/2013 09:12 AM, Eli Barzilay wrote:
> A few minutes ago, Robby Findler wrote:
>> Given that we don't yet even have a prototype of racket2, I'm going
>> to guess that "near" isn't all that near. IMO, there are other big
>> things that we should be focused on going first (notably the package
>> system).
> +1, since the "damage" would be that people will need to convert uses
> `match', but that'll be minor compared to `cond'.

+1, same reasons.

When I don't use match for a while, the first time I use it, I almost 
always write [else ...] as the last clause. Then I catch myself and 
replace `else' with `_'.

I started being careful about catch-all cases in `match' when I wrote an 
expression similar to this:

   (match a
     [(list x)  #t]
     [else  (case (first a)
              [(6)  #f]
              [else  #t])])

got this error:

   case: bad syntax (not a datum sequence) in: else

and was completely baffled for a long time.

> A few minutes ago, J. Ian Johnson wrote:
>> I've used else as a catch-all binding in match. Yes, it's not the
>> best practice, but I think since I've done it, other people must
>> have done it too. This could annoy them.
> Do you have an actual use that would *break*?  That is, something like
>      (match x ... [else else])

I'll bet almost every use of just `else' as a pattern in the wild 
doesn't have `else' in the body because it's intended to be a catch-all 
case. If it does have `else' in the body, it's almost certainly in a 
`cond' or a `case', which is either an error or hideous style.

Neil ⊥

Posted on the dev mailing list.