
Dear All, Henning Thielmann wrote:
I object strongly to the proposal http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse because it solves problems with syntactic sugar with even more sugar, where no sugar is needed at all.
In order to solve the trouble I propose enhancements to teachers, compilers and standard libraries: 1. 'if' syntax should be teached as if a then b else c This indentation makes pretty clear, what is condition, and what is the result in both cases.
People obviously have different opinions here, and I'd say there are perfectly reasonable arguments for a number of different styles of indentation. As the discussion following Henning's mail has demonstrated. The background to the proposal was that Haskell 98 prevents an arguably reasonable style of indentation, and that this has turned out to be a problem in practice: i.e. it tends to trip up a lot of unsuspecting people, in particular beginners. Yes, one can argue that they should learn "the right way", but this is really a very minor detail that many think would be best if people didn't have to worry about in the first place. The proposal is actually very lightweight (just allow an optional ";" in the appropriate place), and thus it is not even a question about new "syntactic sugar". At least not according to my understanding of the term. Also, it does not complicate the (already complicated) layout rules further, which is quite important. If I recall correctly, the proposal was implemented in GHC (and JHC?) shortly after it had been put forward, with very little effort indeed, and has not caused any ill side effects that I'm aware of.
3. If a compiler suspects that a parsing problem is related to 'do' and 'if' it should suggest indentation if a then b else c or even better, the usage of if- or (?)-function.
As a matter of principle, I don't think a language standard should say much if anything about how a conforming compiler or interpreter should report errors. We can argue the pros and cons of the existing "if" syntax, but I don't think anyone is seriously proposing that it be dropped from Haskell' (that would break an awful lot of code for very little gain). Having additional functions that accomplish the same thing as "if" does not seem all that appealing to me at least.
So, please add this to the 'Cons' list.
Henning, I'm afraid I don't quite understand what the conses are? Could you clarify the concrete ill effects of the proposal, please? Best, /Henrik -- Henrik Nilsson School of Computer Science and Information Technology The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.