HaloO,

Luke Palmer wrote:
The most immediate offender here is the referential passing semantics.

IIRC, the default is to be a read-only ref. Not even local modifications
are permitted if the 'is copy' property is missing.


 Here is a code case:

    sub foo ($x, &code) {
        &code();
        say $x;
    }
    my $bar = 41;
    foo($bar, { $bar++ });

As far as I recall, the spec says that this should output "42".  My
intuition tells me that it should output "41".

My intuition also opts for 41. Evaluating &code() inside foo either
violates the constance of its own $x if the changes propagate back
into the already bound/passed argument or violates the callers
excapsulation. The latter depends on what exactly the second argument
of the call of foo closes over. Theoretically the binding of
CALLER<$bar> to foo<$x> could spill over to the closure which then
would mean foo(x => $bar, { $x++ }) and require $x beeing declared
either 'is copy' or 'is rw'. In other words it could be marked as error.
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to