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

Re: Apoc2 - Context and variables

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 4, 2001 19:58
Subject:
Re: Apoc2 - Context and variables
Message ID:
200105050258.MAA45324@indy05.csse.monash.edu.au

   > I'm interested in what happens with interactions:
   > 
   >    $a = @b;
   > 
   > Does this:
   > 
   >    1. Get the length (doesn't seem to make sense now)

No. length(@b) or @b.length() for that.

   >    2. Pull a reference to @b (like Perl5's "$a = \@b")

Yep. Scalar context eval of arrays, hashes, and subs produces a reference.

   >    3. Get the first element of @b

No. That's still:

	($a) = @b;

...which may well grab *only* the first element, because the lvalue's
structure determines the rvalue's eval context (just like a sub's
parameter list determines its argument's contexts)


   > Similarly, how about:
   > 
   >    %c = @d;
   > 
   > Does this:
   > 
   >    1. Create a hash w/ alternating keys/vals like Perl5
   >    2. Do the equivalent of "%c = \@d" in Perl5
   >    3. Or the mystery meat behind Door #3

This one's still less-than-certain. Definitely either 1 or 3 though.
If option 3, it would be the equivalent of the Perl 5:

        %c = map {($_=>undef)} @d;

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