At 10:00 AM -0600 8/3/03, Luke Palmer wrote:
Is this supposed to happen?

    % parrot -
    .sub _main
        $S0 = "Hello\n"
        $S1 = $S0
        substr $S1, 2, 2, ""
        print $S0
        print $S1
        end
    .end
    (EOF)
    Heo
    Heo

Aren't strings supposed to follow value semantics?

Don't think so, no. = in IMCC, unless things have changed, is equivalent to the set operation in parrot assembly, and that just copies the contents of the register. Since string registers are just pointers, you'll get this sort of aliasing behaviour. For true copies you need either the assign op (to reuse the destination) or the clone op (to make a clone of the original)
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to