Peter Scott wrote:
> Have often wanted a way to tell whether a scalar was a number

> way to get at the SvIOK and SvNOK results would be great.

SvIOK, SvNOK and "is a number" are not the same thing at all.
Often numbers are strings that just look like numbers. Perl doesn't
eagerly convert stuff into numbers -- it waits until it needs to.

For example:

if (/(\d+)/) {
  ...
}

$1 is not SvIOK, but it is definitely a number. I seriously
doubt if Perl 6 is going to change this behavior (if it ain't
broken don't fix it...)

IMHO, the language shouldn't know about SvIOK etc. Perhaps
ref() can be supplemented with a typeof() function taking one
or two args. typeof($s) would just return the type of $s.
typeof($s, 'integer') could check to see if $s is coercible
to integer.

- Ken

Reply via email to