compilation of pattern-matching?
Neil Mitchell
ndmitchell at gmail.com
Wed Mar 25 16:04:45 EDT 2009
Hi
> Your idea of simply ordering patterns is certainly appealing from the programming point of view. I don't yet see how to propagate that information through the pattern compilation algorithm, retain the resulting information in the optimizer, and exploit it in a code generator. But it might well be possible. Maybe you can write a Haskell workshop paper about it?
I don't find ordering of patterns appealing, I find it scary! I order
my patterns according to the semantics I desire, and then additionally
by what looks pretty. I'd like it if whatever cleverness GHC can work
is used rather than requiring me to think. If the order of patterns is
to become important, it has to be with an explicit "look, I know
something you don't" pragma rather than by default.
As an example, I suspect that the "hot-path" on most list pattern
matches is in the (:) case. I don't want to ever teach a user that (:)
comes before [] because ... long spiel about branch prediction ...
Controlling branch prediction will only ever be a niche activity, so
the defaults should reflect that.
Thanks
Neil
More information about the Glasgow-haskell-users
mailing list