[Haskell-cafe] Strange subtract operator behavior
lennart at augustsson.net
Tue Oct 16 22:13:23 EDT 2007
If naturals have a perfectly reasonable subtraction then they also have a
perfectly reasonable negate; the default is 0-x.
(Oh, subtraction wasn't THAT reasonable, you say. :) )
On 10/17/07, John Meacham <john at repetae.net> wrote:
> On Tue, Oct 16, 2007 at 06:27:19PM -0300, Isaac Dupree wrote:
> > Peter Verswyvelen wrote:
> > >Personally I could also live with allowing no space between the minus
> > >sign and the number... If you leave a space, - becomes the subtract
> > >operator.
> > I once thought that... there was the opposition that (x-1) subtraction
> > of a constant appears too often. And I found that I myself wrote that
> > several times. And saying "whitespace on the left but not the right"
> > seems too complicated for Haskell lexer semantics. So the current
> > situation is just unhappy, that's all. (and maybe compiler warnings
> > could still be implemented)
> not just unhappy, but inefficient.
> -10 tranlates to (negate (fromInteger 10)) requiring 2 indirect class
> calls rather than what one might expect (fromInteger -10)
> also, negate in Num is sort of ugly IMHO. It would be nice if it wern't
> there. Things like naturals have a perfectly reasonable subtract, but no
> I think losing x-1 would be worth it. but I know there were some other
> ideas out there that might be preferable but could still be handled at
> the lexing stage rather than the parsing one...
> John Meacham - ⑆repetae.net⑆john⑈
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe