patch applied (ghc): Fix a bug in alternative layout rule
Ian Lynagh
igloo at earth.li
Tue Dec 1 09:22:45 EST 2009
On Tue, Dec 01, 2009 at 12:40:33PM +0000, Duncan Coutts wrote:
> On Mon, 2009-11-30 at 23:30 +0000, Ian Lynagh wrote:
> > On Mon, Nov 30, 2009 at 11:05:21PM +0000, Duncan Coutts wrote:
> > > On Mon, 2009-11-30 at 17:26 +0000, Ian Lynagh wrote:
> > >
> > > > f2 x = x + case () of
> > > > () -> x
> > > > where x = 5
> > >
> > > 10, same reason.
> >
> > So if you look at f2 from the perspective of someone new to the
> > language, given they understand the scoping of f1 and f3, would they
> > expect that where binding to scope over the entire RHS rather than just
> > the case expression? Maybe it's just me, but I don't think that would
> > match my intuition.
>
> They would know that it has to be one or the other. The new person would
> reason that the language designers either picked > or >= for column
> offset. Which one they picked is something a new person would have to
> look up, or just try, or avoid.
>
> >From a casual perspective there's nothing subtle about this case, it
> does just look like a question of an arbitrary choice between >= vs >.
> Programmers don't (and do not have to) realise that in reality parsing
> this relies on the error rule.
Let me try asking it another way: If in H98 the above was an error, and
we were discussing what to change it to, how would you rank the options?
My answer would be:
1: Keep it as an error; no real need/benefit to make it a special case
2: The bindings should scope over the case expression only, as the where
clause looks like it "belongs" with the case expression
3: Scope over the whole function
Thanks
Ian
More information about the Cvs-ghc
mailing list