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 17, 2005 02:24
Subject:
Re: return of copies vs references
Message ID:
p06210202be5f09c5aebe@[192.168.1.102]
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

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