Re: [q-lang-users] Q 7.2 RC1 Issue 2: Notation
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-19 20:07:47
|
John Cowan wrote: > I'm not happy with "over" as the notation for rational numbers. > In particular, "1 over 5+2 over 3" looks totally wrong for 1/5 + 2/3; > the visual grouping is hopelessly broken. I realize that we can't use > "/" for this purpose, but can't we use another symbol operator? Actually I've been tossing around the idea to make the "/" builtin undefined on Int Int so that it could be defined in the library. But that would probably break just about any Q script out there, so it's not really an option. > > I would propose "|", which is visually close to "/" and is used in the > "units" program for the same purpose. A non-ASCII alternative would be ÷ > (division sign). These would be very minor changes to the lexer. "|" is not possible as it is already used as a delimiter in list/stream/tuple notation, so we'd get very evil ambiguities in the expression grammar. And I don't like the idea of using something which is not 7 bit ASCII. Of course a programmer can easily define his own aliases using extended characters, but the language and the library should be 7 bit only IMHO. So I'm afraid that the only 7 bit ASCII punctuation symbol that's left is "%" (incidentally, this is also what Haskell uses for the same purpose). It's been a while since this has been used as a comment character, so I'd say it's safe to reuse it now. Then you could type your example as "1%5 + 2%3". Acceptable? ATM user-defined operator symbols can only be made from punctuation symbols outside the 7 bit range, but I guess that I could change that, even if it's only to be used in this single case. Rob, what's your take on this? Do you prefer "over" or "%"? After all it's your module. ;-) -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |