Thank you, Luke and Larry, for your replies.  They did help.

For now, I will use the syntax $obj.:bar[] and $obj.:baz{} in the get_bar|baz() accessor methods to get copies returned; if the rules change again, I'll update later.

I noticed that the example seemed incomplete, saying only what would happen with the above in list context, and not saying what would happen in scalar context.

I would like a way of specifying that the copy always happens regardless of the caller's context. This doesn't have to be a language 'default', and I'm fine if its a little more verbose, just as long as its consistent and unambiguous.

    return $self.:foo           # in any context
    return $self.:bar[];        # in list context
    return $self.:baz{};        # in list context
    return $:foo;               # in any context
    return @:bar;               # in any context
    return %:baz;               # in any context

Eg, something that is like lines 5 and 6, but lets me explicitly use 'self'.

-- Darren Duncan

Reply via email to