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

Re: return of copies vs references

Thread Previous | Thread Next
From:
Larry Wall
Date:
March 17, 2005 01:29
Subject:
Re: return of copies vs references
Message ID:
20050317092804.GF11671@wall.org
On Thu, Mar 17, 2005 at 02:06:46AM -0700, Luke Palmer wrote:
: I'll just point out, the rest of this message, with all the autocopy
: complexity (according to /some/ people), uses this assumption.  It all
: happily goes away if $self.:bar returns a list if @:bar is declared.
: And I can't, off hand, see any other problems with it.  Maybe I'm just
: blind, though.

Yeah, that part's negotiable.  But it will seem a little strange if
we push it so far that private accessors default to protecting your
own data from you, which it would if we forced the autocopy on private
accessors in scalar context.  I think private accessors will have to be
distinguished from public accessors somehow.  With forced ref return on
private accessors we could be more general in how we specify autocopy
on all return statements, but it could be made to work the other way
too, in which case we say that only private accessors pay attention
to context.  And maybe that just falls out of the fact that private
accessors are really just subs in disguise.  So maybe the distinction
is that real methods always return lists, and only subs (and sublike
private methods) pay attention to the context in which they're called.
That's actually weirdly symmetrical with the notion that only subs can
impose compile-time context on their arguments, while methods always
have to assume list context because you have to generate the argument
list before you can know which method you're going to dispatch to.

So I could buy it either way.  Opinions?

Larry

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