On Thu, Nov 30, 2000 at 06:43:35PM +0000, David Mitchell wrote:
> * do values ever get demoted - eg an expression inolving bigints that evaluates
> to 0: should this be returned as an int or a bigint?

[I may have mailed this already]

Experimentation on perl5 says yes.
Making the sv_setuv actually set an iv (ie signed, rather than unsigned)
whenever the unsigned integer was actually small enough to be a signed
integer got a measurable speedup.
I'm guessing that this was because many more of the "IV op IV" code
got hit, which was usually simpler than the mixed "IV op UV" code.

So I'd suggest using int rather than bigint, on the assumption that
returning the simplest (accurate) thing (if it's cheap for you to determine
that something simpler is accurate) is more likely to allow the next
operator to go simple

Likewise, adding two complex numbers and finding that the imaginary part
is 0 would return a number of some real type, not some complex type.

> * for the code '$c = $a + $b' - is the current SV type of $c thrown away
> and replaced  with whatever type ($a + $b) evaluates to?

Not sure - I'd presume yes unless $c has overloaded =
this is probably a language issue, and waiting on the language spec

Nicholas Clark

Reply via email to