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

Re: Transparent / Opaque references

Thread Previous | Thread Next
Damian Conway
May 28, 2005 00:29
Re: Transparent / Opaque references
Message ID:
Brent 'Dax' Royal-Gordon wrote:

> Juerd <> 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 
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;


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About