[Haskell-cafe] what does @ mean?.....

Serge LE HUITOUZE slehuitouze at telisma.com
Fri Dec 28 11:21:06 EST 2007

Jedaï wrote:
> [...]
> Yes, but in the second version, it has to reconstruct (S a) before
> comparing it to "one" where in the first it could do the comparison
> directly. In this cas there may be some optimisation involved that
> negate this difference but in many case it can do a real performance
> difference.
> The "as-pattern" (@ means as) is both practical and performant in most cases.

Chris wrote:
> The first example takes apart the (Just n) and later reconstructs (Just n).
> Unless the compiler is fairly clever, this will cause the new (Just n) to be a
> new allocation instead of reusing the input value.  The second form uses an

I tend to believe that the '@' notation is mere syntactic sugar.
Indeed, it seems to me that Haskell compilers need not to be very clever to
share the identical sub-expressions, for one very simple reason implied by
Haskell semantics: referential transparency.

Am I right, or am I missing something?

And, of course, I'm not saying that syntactic sugar is bad.
As Alfonso noted, it saves some typing and avoids screwing up while trying
to modify multiple occurrences of the same sub-expression.
And, an even more important I think, a software engineering benefit: It
emphasizes for the reader that we really are talking about the very same
thing at two (or more) different places.


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.17.9/1198 - Release Date: 26/12/2007 17:26

More information about the Haskell-Cafe mailing list