develooper Front page | perl.perl6.language | Postings from March 2005

Re: return of copies vs references

Thread Previous | Thread Next
From:
Darren Duncan
Date:
March 28, 2005 23:13
Subject:
Re: return of copies vs references
Message ID:
p06210200be6eafec6fbe@[192.168.1.102]
At 7:10 AM +0100 3/29/05, Piers Cawley wrote:
>Doesn't that rather depend on the type of the attribute? Personally, if I get
>an object back from accessor method then I expect that any modifications of
>that object's state will be seen the next time I look at the results of that
>accessor method. This is a direct result of the way reference types work, and
>the world is a better place because of it. If you want a (deep) copy of the
>returned object you should say so:
>    my $res = $object.attribute.clone;

I recanted what you're replying to last week.  Essentially, I agree 
with you that references of non-scalar values should be returned by 
default, and that the method must do an explicit copy if that's what 
they want returned.  Things are much simpler that way, and its how 
Perl 5 worked. -- Darren Duncan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About