[Haskell-cafe] Strange subtract operator behavior
Lennart Augustsson
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. :) )
-- Lennart
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
> negate.
>
> 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
>
>
> --
> John Meacham - ⑆repetae.net⑆john⑈
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071017/f19e68b3/attachment-0001.htm
More information about the Haskell-Cafe
mailing list