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

Re: Transparent / Opaque references

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 28, 2005 00:29
Subject:
Re: Transparent / Opaque references
Message ID:
42981DD1.40304@conway.org
Brent 'Dax' Royal-Gordon wrote:

> Juerd <juerd@convolution.nl> wrote:
> 
>>There is no way to get an anonymous rw scalar, is there?
> 
> 
> There's always the Perl 5 hack:
> 
>     \do { my $x }
> 
> Although that's not truly anonymous, I suppose.

There's a less-well-known hack that *is* truly anonymous:

     $anon_scalar_ref = \eval{undef};

Or, of you prefer your anonymous scalar initialized:

     $anon_scalar_ref = \eval{ $init_val };


However, in A6 
(http://dev.perl.org/perl6/doc/design/apo/A06.html#Digression_on_types),
Larry muses:

     Though for the closure case, it's possible we could define some kind
     of non-my article to introduce a type unambiguously:

         $closure = a Camel sub ($name) {...}
         $closure = an Aardvark sub () {...}

     Presumably "a" or "an" is short for "anonymous". Which is more or
     less what the indefinite article means in English.


So presumably, one could also envisage:

     $anon_scalar_ref = a Scalar;

Damian



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