On Mon, Aug 07, 2000 at 02:27:34PM -0000, Perl6 RFC Librarian wrote:
> This RFC proposes that numeric comparison operators default to stringwise
> comparison when both arguments are non-numeric strings.
>
> =head1 DESCRIPTION
>
> Currently the expression:
>
> "cat" == "dog"
>
> returns true.
[snip]
> It is further proposed that the current warning:
>
> Argument "%s" isn't numeric
>
> be changed to:
>
> Arguments of "%s" aren't numeric - using string comparison instead
So, as far as I understand this, you are suggesting that the comparison give
meaningful results, while still also spitting out a warning. Doesn't this
serve to advocate turning off warnings? Why behave correctly in spite of a
warning, and the fact, that the user is using the operator incorrectly?
> sub insert
> {
> my ($self, $key, $value) = @_;
> if (!defined($self->{key}))
> {
> $self->{key} = $key;
> return $self->{value} = $value;
> }
> my $compare = $key <=> $self->{key};
> return $self->{value} = $value unless $compare;
>
> $self->{$compare} = $self->new() unless $self->{$compare};
> return $self->{$compare}->insert($key,$value);
> }
I would argue that you should be manipulating your data, or checking values,
so that numbers and strings are sorted how you wish. The proposed isnum(),
or way-to-determine-if-a-scalar-is-a-number would help. This should be an
explicit check, though, because you have a very definite idea about how you
want things sorted.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--