Dan Sugalski wrote:
>     my $foo;
>     $foo = 12;
>     print $foo;
>     $foo /= 24;
>     print $foo;
> 
> may well have the vtable pointer attached to the PMC for $foo change with 
> every line of code. Probably will, honestly.

Well, there's only two assignments there, so I assume that print is
going to upgrade the scalar to have a string rep. Are you thinking of
scalar representations something like:

  undef
  integer
  integer_with_string
  real_with_string (dirty)
  real_with_string

I like the principle of automatically changing representations, but
shouldn't the compiler be a little smarter? In this example every
expression has a static type. We're burning memory and CPU just to do
stuff at run-time that the compiler could have eliminated. For
example, Perl could use reps like:

  number (undef)
  number (int)
  number (int)
  number (float)
  number (float)

Building inlined "number" vtable ops seems like a big win if Perl
can use them.

Which brings up an interesting question. Does Perl the language
require just-in-time representation changes or is it legal for the
compiler to choose an efficient representation in advance?

- Ken

Reply via email to