This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Seperate class for Perl scalars?
Per Bothner <per@bothner.com> wrote:
> One other suggestion: So you really need the Scalar class? Why not use
> String and Number classes directly? (You can use the classes in gnu.math,
> if you wish, or plain old Number sub-classes in java.lang.)
The problem that I have come across is that it will cause many String to
Number conversions if I do that.
For example, in Perl:
$x = 5; $x .= "foo"; print $x ;
yields:
5foo
And
$x = "5bar"; $y = 7 + $x; print "$x$y";
yields:
5bar12
So, the lowest common denominator is likely strings; however, typical Perl
programs will have many implicit conversions. A scalar inside the current
perl implementation has the ability to hold multiple representations of
different types at once, and results are cached.
I worry about excessive number to string conversions if I don't do the same
thing here.
Thoughts?
--
Bradley M. Kuhn - http://www.ebb.org/bkuhn
PGP signature