Fwd: Numeric Semantics

2007-01-23 Thread Jonathan Scott Duff

I accidently sent this just to Darren ...

-Scott

-- Forwarded message --
From: Jonathan Scott Duff <[EMAIL PROTECTED]>
Date: Jan 22, 2007 6:23 PM
Subject: Re: Numeric Semantics
To: Darren Duncan <[EMAIL PROTECTED]>



On 1/22/07, Darren Duncan <[EMAIL PROTECTED]> wrote:.


I think that 1 should be an Int and 1.0 should be a Num.  That makes
things very predictable for users, as well as easy to parse ... the
visible radix point indicates that you are usually measuring to
fractions of an integer, even if you aren't in that exact case.  Also
importantly, it makes it easy for users to choose what they want.

For round-trip consistency, a generic non-formatted
num-to-char-string operation should include a .0 as appropriate if it
is converting from a Num, whereas when converting from an Int it
would not.

Furthermore, my preference is for Int and Num to be completely
disjoint types, meaning that "1 === 1.0" will return False.  However,
every Int value can be mapped to a Num value, and so "1 == 1.0" will
return True as expected, because == casts both sides as Num.



While I'm in general agreement with everything you've said it makes me a
tad  nervous to hinge so much on the difference of one character.  Can you
imagine trying to track down the bug where

   if ($alpha === $beta) { ... }

really should have been

   if ($alpha == $beta) { ... }

Anyway, it's not like this problem wasn't already there, it's just that your
email made it stand out to me.

-Scott

--
Jonathan Scott Duff
[EMAIL PROTECTED]


Re: Fwd: Numeric Semantics

2007-01-23 Thread Paul Seamons
> While I'm in general agreement with everything you've said it makes me a
> tad  nervous to hinge so much on the difference of one character.  Can you
> imagine trying to track down the bug where
>
> if ($alpha === $beta) { ... }
>
> really should have been
>
> if ($alpha == $beta) { ... }
>
> Anyway, it's not like this problem wasn't already there, it's just that
> your email made it stand out to me.

I'm not adding support to either side of the issue.  I just wanted to point 
out that with Perl 5 and other current languages I occasionally have to 
search for that bug right now.  Except it is spelled a little different with 

  if ($alpha = $beta) { ... }

When I really meant:

  if ($alpha == $beta) { ... }

It is rare though.  I think the == vs === will be rare also.

Paul


Re: Fwd: Numeric Semantics

2007-01-23 Thread Jonathan Scott Duff

On 1/23/07, Paul Seamons <[EMAIL PROTECTED]> wrote:


> While I'm in general agreement with everything you've said it makes me a
> tad  nervous to hinge so much on the difference of one character.  Can
you
> imagine trying to track down the bug where
>
> if ($alpha === $beta) { ... }
>
> really should have been
>
> if ($alpha == $beta) { ... }
>
> Anyway, it's not like this problem wasn't already there, it's just that
> your email made it stand out to me.

I'm not adding support to either side of the issue.  I just wanted to
point
out that with Perl 5 and other current languages I occasionally have to
search for that bug right now.  Except it is spelled a little different
with

  if ($alpha = $beta) { ... }

When I really meant:

  if ($alpha == $beta) { ... }

It is rare though.  I think the == vs === will be rare also.



Perhaps.

To me, finding the = vs. == bug is a bit easier due to the large conceptual
difference between the operators.  (or maybe I'm just used to looking for it
after 20+ years of coding in languages that have = and ==)  But for == vs.
===, they are both comparators and that tends to muddy the waters a bit when
it comes to your brain helping you find the bug.  (at least it does for me)

-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]