Re: Preliminary Haskell 1.3 report now available
Thomas Hallgren [EMAIL PROTECTED] writes: In the syntax for labeled fields (records) the symbol - is chosen as the operator used to associate a label with a value in constructions and patterns: [...] According to a committee member, there were no convincing reasons why - was chosen. Other symbols, like = and := were also considered. I support Thomas Hallgen's suggestion that `=' be used instead. Another reason, in addition to the two he mentioned, is that the `-' symbol is very unintuitive when used for pattern matching, because the arrow is in the *opposite* direction to the data-flow. I find this very confusing. -- Fergus Henderson | Designing grand concepts is fun; [EMAIL PROTECTED] | finding nitty little bugs is just work. http://www.cs.mu.oz.au/~fjh | -- Brooks, in "The Mythical Man-Month". PGP key fingerprint: 00 D7 A2 27 65 09 B6 AC 8B 3E 0F 01 E7 5D C4 3F
Re: Preliminary Haskell 1.3 report now available
I always favoured `=' over `-', but I don't care much. -- Lennart
Re: Preliminary Haskell 1.3 report now available
First, I am happy to see that Haskell 1.3, with its many valuable improvements over Haskell 1.2, is finally getting ready, but I also have a comment: In the syntax for labeled fields (records) the symbol - is chosen as the operator used to associate a label with a value in constructions and patterns: data Date = Date {day, month, year :: Int} today = Date{day - 11, month - 10, year - 1995} According to a committee member, there were no convincing reasons why - was chosen. Other symbols, like = and := were also considered. Here are some (in my opinion) good reasons for using = instead of - : 1. In ordinary declarations, :: is used to specify the type of a name and = is used to specify its value: day, month, year :: Int day = 11; month = 10; year = 1995 so for consistency I think the same notations should be used inside record values: data Date = Date {day, month, year :: Int} date :: Date date = Date {day = 11, month = 10, year = 1995} 2. The - symbol is used also in list comprehensions and the new monad syntax ('do'): [ 2*x | x - [1..10] ] do c - getChar; putChar c In these uses of - the name on the lhs does not have the same type as the expression on the rhs (above, x::Int, but [1..10]::[Int] and c::Char but getChar::IO Char). The value that the lhs name (or, indeed, pattern) is bound to is "extracted" from the value of the rhs expression. This is very different from what happens with field labels, so a difference in syntax is motivated. Sadly, I suspect it would be difficult to convince the committee to change their minds about this at this late stage, but I am sure it would be even more difficult to change it for a later version of Haskell... Regards, Thomas Hallgren
Re: Preliminary Haskell 1.3 report now available
I always favoured `=' over `-', but I don't care much. -- Lennart
Re: Preliminary Haskell 1.3 report now available
Thomas Hallgren [EMAIL PROTECTED] writes: In the syntax for labeled fields (records) the symbol - is chosen as the operator used to associate a label with a value in constructions and patterns: [...] According to a committee member, there were no convincing reasons why - was chosen. Other symbols, like = and := were also considered. I support Thomas Hallgen's suggestion that `=' be used instead. Another reason, in addition to the two he mentioned, is that the `-' symbol is very unintuitive when used for pattern matching, because the arrow is in the *opposite* direction to the data-flow. I find this very confusing. Indeed, a couple of reasons I find convincing myself: 1 - SML uses '=' too, therefore it is one less problem for people moving to/from SML/Haskell. 2 - The '-' notation always reminds me of list comprehensions, e.g. at first sight if I see an expression like R{v - [1..10]} I could think v is an integer (taken from [1..10]) when it is actually a list. the following expression is also confusing: [R{v - [1..x]} | x - [1..10]] (defines a list of records) An expression using records on the rhs of the '|' should be even more interesting (and useful for obfuscated Haskell competitions). The same applies for records with fields defined with list comprehensions. Andre. Andre SantosDepartamento de Informatica e-mail: [EMAIL PROTECTED] Universidade Federal de Pernambuco http://www.di.ufpe.br/~alms CP 7851, CEP 50732-970, Recife PE Brazil