13 Nov 13:02
Re: Pattern Matching
Daniel Fischer <daniel.is.fischer <at> web.de>
2009-11-13 12:02:53 GMT
2009-11-13 12:02:53 GMT
Am Freitag 13 November 2009 11:05:15 schrieb Andrew Coppin: > Colin Paul Adams wrote: > > If I had a dollar for every time I've written something like > > > > Andrew> case msg of eVENT_QUIT -> ... eVENT_POST -> ... > > Andrew> eVENT_RESIZE -> ... > > > > Andrew> and spent an hour trying to figure out why the messages > > Andrew> aren't being processed right...> > > > So why aren't they? > > Because what I *should* have written is > > case msg of > _ | msg == eVENT_QUIT -> ... > > | msg == eVENT_POST -> ... > | msg == eVENT_RESIZE -> ... > > which is something quite different. > > (And, entertainingly, because the incorrect version is perfectly valid > source code, no compiler errors or warnings...) It yells "overlapping patterns" -- you do pass -Wall, don't you?
> >
> > So why aren't they?
>
> Because what I *should* have written is
>
> case msg of
> _ | msg == eVENT_QUIT -> ...
>
> | msg == eVENT_POST -> ...
> | msg == eVENT_RESIZE -> ...
>
> which is something quite different.
>
> (And, entertainingly, because the incorrect version is perfectly valid
> source code, no compiler errors or warnings...)
It yells "overlapping patterns" -- you do pass -Wall, don't you?
RSS Feed