Re: [q-lang-users] Q 7.2 RC1 Issue 2: Notation
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-06-20 23:13:22
|
Albert Graef scripsit: > This wouldn't just be unpopular and break backwards compatibility, it's > also a misfeature (in a programming language, as opposed to a computer > algebra system), because you could never be sure which type is returned > by (/). This in turn will make some code involving numbers as arguments > to other functions very error-prone. It's true that it doesn't really > matter what the type of the result of (/) is as long as you stay within > the realm of arithmetic expressions, but when you eventually pass the > result to another function (printf, e.g.) then it does matter a lot. A > similar (but even worse) issue has already been beaten to death over at > the Python mailing list, see, e.g., http://www.python.org/dev/peps/pep-0238/ I agree: we need different operators for exact and inexact division. > So where do we go from here? I'd be happy with both "over" and "%", but > I think that John raised a legitimate concern about "over" which, in > this form, only arises with "over" because it's used as in the visual > representation of numbers. I think it's not quite as bad as he makes it > out to be, though. You'd never see something like "1 over 5+2 over 3" in > a printed result unless it's in a quoted term or a symbolic expression. True, but you will see "1 over 5+2 over 3*i", which was the example in the first draft of my original e-mail. I removed the "*i", thinking it would just confuse the issue, and not realizing that removing it made the expression no longer in normal form. I'm beginning to wonder if this unparsing is the Right Thing after all: it makes it harder to see what is a normal form and what is not. If you type "1 over 5+2 over 3*i" into a Q 7.2 RC1 interpreter, you get back "1 over 5+2 over 3*i", as if the expression were in fact in normal form. But it's not; the underlying normal form is "complex::complex (rational::rat 1 5) (rational::rat 2 3)", which is then effectively denormalized for printing purposes. -- May the hair on your toes never fall out! John Cowan --Thorin Oakenshield (to Bilbo) co...@cc... |