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

Re: Transparent / Opaque references

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?=22TSa_=28Thomas_Sandla=DF=29=22?=
Date:
June 2, 2005 11:36
Subject:
Re: Transparent / Opaque references
Message ID:
429F51BA.4000404@orthogon.com
Luke Palmer wrote:
> When we heard that Larry didn't acutally want $$foo to infinitely
> dereference, some of us were overjoyed, and others severely
> disappointed.  Both transparent dereferencing (infinite $$foo) and
> opaque dereferencing (one-level $$foo) have their uses, but they are
> definitely distinct.

I guess a syntax like the reduce meta operator

[$]$ref = whatever();

doesn't work for the $ sigil because it firstly is
no operator and secondly unary. So I join the single
$-single-steps-party.

Might it be applicable to use .() as the dereferencer
of scalar variables that derefs to the next none(Ref)
type and if that is a Code it dispatches to it as expected?
This nicely gives:

$x = 3
$y = \$x;

$y() = 7;

say $x;  #  prints 7

$y = 23; # detaches from $x

say $x;  # still prints 7

One detail is that lvalue subs without params
must be taken care of. But they'll have a proxy
anyway to handle assignment.

Another general thing is of course that explicitly constant Refs
shall not be applicable as a lhs of assignment. This applies to
chains of prefixed $ as well.
-- 
TSa (Thomas SandlaƟ)


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