Re: + and -: syntax wars!
|... ("Pathetic, ruddy planet---I've no sympathy at all.") | |--Joe That was "apathetic bloody planet..." George
Re: + and -: syntax wars!
I'm sure this is a minority opinion, but... It is hard to find a paper on any interesting topic that does not introduce a new syntax. The business of thinking about specific issues seems intimately connected to finding a good representation for the issue in print. It seems clear from this that hacking syntax is a *good* thing, and everyone does it because it is useful in problem solving. This is the long way around of saying that I don't agree that rigid syntax is a good thing. I don't believe that one set syntax for a language is a good thing. It is *very* true that freeing up syntax opens the door to all kinds of abuses, but we're all adults. Rigid syntax does not prevent abuses, it just prevents me from developing a syntax that fits my problem domain. On the low level, then, I am all for rebinding +, - and anything else. The standard operator symbols are valuable for rebinding because they have so many different meanings in different contexts. I would be more willing to prevent the rebinding of obscure operator symbols because they have so few meanings! On another level, what about a language that could handle multiple symbol tokens (if-then-else, [-], while-do) as well as all the different fixities? It is available now in OBJ3, but the parsing algorithm is backtracking -- expensive and difficult to predict for certain constructs. My wish? A language that allowed syntax modifications and warned me about bad ones. Then constructs like n+k wouldn't be the headache of implementers, just the people who use them. Hopefully the basic language would be simpler and maybe syntax would disappear from discussions like this because everybody could have the one they liked. Ken
Re: + and -: syntax wars!
Oops, PreludeCore cannot be hidden. I guess I've made a fool of myself (but that happens often :-). > Can't we find anything more interesting to discuss that the syntax?? You are welcome to! :-) But sweeping syntax matters under the carpet does not improve anything. > | ... But what I find a bit strange is that even when + and - > | are overridden locally n+k and prefix - still have their old meanings. > | Well, it's just one more exception to the rule to remember about Haskell. > Yes, but we need to emphasize that rebinding such operators is a Bad Idea. > (Maybe Phil is right, that we should simply forbid it.) I agree that it should be forbidden, not for the love of prohibitions, but in order to detect more errors in programs statically, and to avoid some quite unnecessary ways to muddle a Haskell program. But there are several degrees to which rebinding could be forbidden. Here are some of the alternatives (sorry if you find this confusing/confused :-): 1. Forbidding rebinding + and -. 2. Forbidding rebinding operators/function names exported from classes in PreludeCore. (Except in instance declarations, of course.) 3. Forbidding rebinding operators/function names declared by classes in scope. (Except...) 4. Forbidding rebinding any name exported by PreludeCore. 5. Forbidding rebinding any name in scope. I don't like singling out +, -, and PreludeCore more than necessary, so alternative 3 (plus remark below) or 5 are good candidates in my opinion. I still think that Lennarts quiz declaration should be illegal at least on the grounds Paul gave (i.e., even if the name (+) is replaced by some other name): Names bound by the "lhs"es (in each let/where declaration part) should not be allowed to be rebound by some argument pattern within one of the "funlhs"es in the declaration. Syntactically confused /kent k
Re: + and -: syntax wars!
>This whole issue regarding redefinition of + and - is getting confused >unnecessarily. Both of these are in PreludeCore and cannot be renamed >or hidden. Because of this their fixities cannot be changed. It is >possible to locally shadow + and - but this cannot change their >fixities and has no effect on + in n+k patterns. > >Can't we find anything more interesting to discuss that the syntax?? > Yes, it's not all that interesting, is it? The trouble is that it's IMPORTANT. I think that what Lennart and Kent have been saying is that the report is not clear in these matters. Since it's a reference point, it is vital that all who read it understand what is required when writing programs and when making implementations. That's the trouble with standardisation! And isn't that what the idea of Haskell is all about? Of course we have tried to have our cake and eat it by allowing subsets, supersets, supersets of subsets ... Tony Davie Department of Mathematical and Computational Sciences Tel: +44 334 63257 St.Andrews University Fax: +44 334 63278 North Haugh [EMAIL PROTECTED] St.Andrews Scotland KY16 9SS Q: What do you get if you cross a mountain climber with a mosquito? A: You can't. The mosquito is a vector, but the mountain climber is a scaler.
Re: + and -: syntax wars!
> This whole issue regarding redefinition of + and - is getting confused > unnecessarily. Both of these are in PreludeCore and cannot be renamed > or hidden. Because of this their fixities cannot be changed. It is > possible to locally shadow + and - but this cannot change their > fixities and has no effect on + in n+k patterns. Exactly! But what I find a bit strange is that even when + and - are overridden locally n+k and prefix - still have their old meanings. Well, it's just one more exception to the rule to remember about Haskell. > Can't we find anything more interesting to discuss that the syntax?? Maybe. -- Lennart
+ and -: syntax wars!
This whole issue regarding redefinition of + and - is getting confused unnecessarily. Both of these are in PreludeCore and cannot be renamed or hidden. Because of this their fixities cannot be changed. It is possible to locally shadow + and - but this cannot change their fixities and has no effect on + in n+k patterns. Can't we find anything more interesting to discuss that the syntax?? John Peterson Yale Haskell Project
Re: + and -: syntax wars!
John Peterson Lennart Augustsson Joe Fasel | > This whole issue regarding redefinition of + and - is getting confused | > unnecessarily. Both of these are in PreludeCore and cannot be renamed | > or hidden. Because of this their fixities cannot be changed. It is | > possible to locally shadow + and - but this cannot change their | > fixities and has no effect on + in n+k patterns. | Exactly! But what I find a bit strange is that even when + and - | are overridden locally n+k and prefix - still have their old meanings. | Well, it's just one more exception to the rule to remember about Haskell. Yes, but we need to emphasize that rebinding such operators is a Bad Idea. (Maybe Phil is right, that we should simply forbid it.) What you want to do instead is provide a Num (in this case) instance. If you complain that your funny + and - don't have the right types to be part of a Num instance, I have no sympathy. ("Pathetic, ruddy planet---I've no sympathy at all.") --Joe