Dave Mitchell wrote:
> * Is there ever any need to for a PMC type which holds both an int and a
> num? In the Perl 5 case we were constrained by code that expected to always
> find an int (or a num) in a fixed slot in the SV; with PMCs, all access
> to these slots is via methods, so an int-num or num-int conversion can
> be done on the fly.
There is. You can't necessarily convert on the fly - perl5 allows
dual-typed SVs where the string and number aren't necessarily
interchangable versions of each other. I use this ability, for example, to
map C #define constants to perl SVs that behave like the symbolic value in
a string context and the numeric value in a numeric constant. e.g. given
this in a header file:
#define FOO 2
#define BAR 4
and mapping those to similarly named perl variables
my $fb = $foo | $bar;
assigns 6 to $fb, but
print("$foo | $bar\n");
prints out "FOO | BAR"
This is a really useful feature because it means that you don't need huge
lookup tables to convert from the numeric to the string version of a
constant - it is both at the same time.
--
Alan Burlison
--
$ head -1 /dev/bollocks
immutably engage omnipresent server-centric drivers