HaloO,

John M. Dlugosz wrote:
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:
It's called overload resolution. Perl 6 can't do
that at compile time unless *all* targets are
available as rw and readonly variants.

I don't follow that statement.  Can you give an example?

multi sub foo (Int $i)       {...}
multi sub foo (Int $i is rw) {...}
multi sub foo (Num $n)       {...}
multi sub foo (Num $n is rw) {...}

# OK so far

multi sub foo (Str $s is rw) {...} # not OK

sub bar ($x)
{
    $x = 3;   # error, $x is readonly
    foo($x);  # error, could hit rw Str
}

I must admit though, that my statement was a bit lax.
All targets readonly is fine. But the first rw
requires the insertion of rw targets for all
other variants. Perhaps you can get away with
less than all if you can prove that they'll never
be in the candidate set together with an rw. Note
that such a prove might be falsified subsequently
by introducing an Any sub like bar above.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to