> What, then, happens to the following code:
> 
> my Dog $spot;
> if ($age > 12) {
>     $spot = new Doberman();
> } else {
>     $spot = new Corgi();
> }

This is a tricky case that deserves a lot of attention, but not exactly
as written. Imagine this code block:

   my int ($x, $y, $z) = (4, 5, 6);
   if ( $x < $y ) {
      $x = $z;
   }

That seems like simple enough code. But what would that = line do?

   $x = $z;     # $x->STORE($z)

That doesn't make any sense, because $z is an object of class int, and
not a number.

I'd propose the following precedence rules for assignment:

   1. If it's an object being assigned, then the old object
      gets overwritten

   2. If it's a simple value being assigned, then ->STORE
      is called

So for example:

   my int ($x, $y, $z) = (4, 5, 6);
   if ( $x < $y ) {
      $x = $z;       # $x overwritten
      $y = "15";     # $y->STORE(15)
   }

That's off the top of my head. Any input? This point should probably be
addressed in the RFC in one way or another.

-Nate

Reply via email to