> 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
- Re: RFC 171 (v1) my Dog $spot should call a const... Jonathan Scott Duff
- Re: RFC 171 (v1) my Dog $spot should call a c... Hildo Biersma
- Re: RFC 171 (v1) my Dog $spot should call... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call a constructo... Hildo Biersma
- Re: RFC 171 (v1) my Dog $spot should call a const... Matt Youell
- Re: RFC 171 (v1) my Dog $spot should call a c... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should call a c... Hildo Biersma
- Re: RFC 171 (v1) my Dog $spot should call... Nathan Wiger
- Re: RFC 171 (v1) my Dog $spot should call... Matt Youell
- Re: RFC 171 (v1) my Dog $spot should call a const... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should call a const... Nathan Wiger
- Re: RFC 171 (v1) my Dog $spot should call a constructo... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call a const... Nathan Wiger
- Re: RFC 171 (v1) my Dog $spot should call a c... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should ... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot sh... Michael Fowler
- Re: RFC 171 (v1) my Dog $spo... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should ... Damian Conway
- Re: RFC 171 (v1) my Dog $spot sh... Piers Cawley
- RE: RFC 171 (v1) my Dog $spot should call a constructo... Evan Howarth
