compilation of pattern-matching?
Simon Marlow
marlowsd at gmail.com
Fri Mar 27 05:14:42 EDT 2009
Claus Reinke wrote:
> You are right that this doesn't help my performance argument,
> as performance issues are outside the language definition (not
> observable in the language definition sense). It was merely an answer to
> the vehement claims that pattern order is irrelevant.
The order of branches in a case expression *in Core* is irrelevant (except
that GHC assumes DEFAULT comes first). The order of pattern matches in a
Haskell expression is, of course, semantically significant.
Nobody is claiming you can change the order of pattern matches in Haskell
in general without it changing the meaning.
> |It's not that GHC deliberately re-orders case alternatives, |it's that
> it doesn't deliberately not do it.
>
> no longer is a safe default strategy (actually, it never was, as
> the bug shows;-). Neither is sorting patterns by constructor tag,
> as seems to happen on the way to Core.
I was talking about Core. I thought you were too - sorry. Since what you
wanted was the order of tests to somehow remain fixed from Haskell through
to assembly code, that would imply not reordering them through Core, which
GHC does not guarantee not to do. The order of branches in a case
expression has no semantic significance in Core.
Cheers,
Simon
PS. nice bug.
More information about the Glasgow-haskell-users
mailing list