John Hughes wrote on the Std Haskell board:
 
> `Punning' can be used in three places in Haskell. Suppose a record
> type is defined by
> 
>         data R = R{x :: Int}
> 
> Then
> * R{x} constructs a record, and is equivalent to R{x=x}
> * r{x} updates the x field of record r, and is equivalent to r{x=x}
> * R{x} can be used as a pattern; its meaning is not defined by the
>   report, but is presumably supposed to be the same as R{x=x}
> 
> I've used this. It's convenient, but I had a bad taste in my mouth
> afterwards. I support removing all forms of punning from the
> language. But this would, of course, break existing programs. I want
> to do it anyway. Note that the puns become syntactically incorrect
> in every case, so broken programs can be mended just by correcting
> the syntax errors.

I'm surprised and disappointed with the Standard Haskell effort on
punning.  A grand total of two messages but absolutely no discussion
and *pop* there it went down the pipe.

Yes it convenient, and sometimes even very convenient.  I can't see
the value of arguments like "bad taste in the mouth".  Why was it
introduced in the first place?  Are there any *known* examples where
this feature has caused problems?  As John notices, the punning form
do not overlap syntactically with anything, so you can't used them by
accident.

Instead of junking it, I would rather have seen the pattern matching
punning syntax (R{x}) become official, as this is the most useful of
the three punning.

/Tommy


Reply via email to