Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion S06: Pairs as lvalues
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Luke Palmer  
View profile  
 More options Feb 26 2005, 6:03 pm
Newsgroups: perl.perl6.language
From: l...@luqui.org (Luke Palmer)
Date: Sat, 26 Feb 2005 16:03:21 -0700
Local: Sat, Feb 26 2005 6:03 pm
Subject: Re: S06: Pairs as lvalues

Ingo Blechschmidt writes:
> that's really convenient, but what will the following code do?
>   my $x = (a => 42); # $x is a Pair.
>   $x = 13;           # Is $x now the Pair (a => 13) or
>                      #           the Int 13?

It's the Int 13.  Your example looks a lot like this one:

    my $x = [ 1, 2, 3 ];
    $x = 13;

And you could say that is an error because:

    [ 1, 2, 3 ] = 13;

Is an error, but you'd be wrong.  You see, in your example, the pair is
not "functioning as an lvalue".  The variable is the thing that is the
lvalue, not the pair.

I belive you could get the pair as an lvalue if you did:

    my (Pair $x) := (a => 42);
    $x = 13;

Because the variable x is now *fundamentally* a pair; it has no
container, so to speak.  But it would die, because you're trying to
change a constant value.

Luke


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google