On Tue, 2009-12-01 at 14:22 +0000, Ian Lynagh wrote: > 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
I would put 2 last. We require things to be more indented to indicate that they "belong". If we allowed things to "belong" at the same indentation we'd write thing like: foo x = ... where y = ... As for 1 vs 3, if H'98 had always made it an error then I would not argue especially strongly that it should be allowed rather than continue to be declared a layout error. That said, if the proposal was to make it meaningful then I would not object since it would not break existing programs, would not be visually ambiguous in most cases and would allow a more compact layout (using less horizontal space). Duncan _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
