Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
arrayref/hashref in spectest suite
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
Patrick R. Michaud  
View profile  
 More options Aug 18 2008, 2:38 pm
Newsgroups: perl.perl6.language
From: pmich...@pobox.com (Patrick R. Michaud)
Date: Mon, 18 Aug 2008 13:38:05 -0500
Local: Mon, Aug 18 2008 2:38 pm
Subject: arrayref/hashref in spectest suite
There are quite a few tests in the spectest suite that
make mention of "arrayref" and "hashref", and that expect
things to work like references do in Perl 5.  I'd like to
get some confirmation/clarification on them.

Here's one example:

    my $foo = [ 42 ];
    my $bar = { a => 23 };
    $foo[1] = $bar;
    $bar<b> = 24;

    say $foo[1]<b>;     #  "24" or undef ???

The test suite expects "24" to be output here, treating
treating C< $foo[1] > as a reference to the hash in
C<$bar>, such that any changes to C<$bar> are also reflected
in C<$foo[1]>.  Is this correct Perl 6?  I would somewhat expect
a reference to be instead handled using a statement like

    $foo[1] := $bar;

Comments and clarifications appreciated.

Pm


 
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.
Moritz Lenz  
View profile  
 More options Aug 19 2008, 1:42 pm
Newsgroups: perl.perl6.language
From: mor...@casella.verplant.org (Moritz Lenz)
Date: Tue, 19 Aug 2008 19:42:10 +0200
Local: Tues, Aug 19 2008 1:42 pm
Subject: Re: arrayref/hashref in spectest suite

IMHO yes. Remember that $foo is really just an Array object, just like
any other object. Why should Array objects be cloned on assignment? If
you do a
@a = @b
you get cloning behaviour because the @ sigil implies a container type,
whereas a with a $ sigil you just hand references to objects.

> I would somewhat expect
> a reference to be instead handled using a statement like

>     $foo[1] := $bar;

> Comments and clarifications appreciated.

> Pm

--
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/

 
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.
tho...@sandlass.de  
View profile  
 More options Aug 20 2008, 6:29 am
Newsgroups: perl.perl6.language
From: tho...@sandlass.de
Date: Wed, 20 Aug 2008 12:29:35 +0200
Local: Wed, Aug 20 2008 6:29 am
Subject: Re: arrayref/hashref in spectest suite
On Monday, 18. August 2008 20:38:05 Patrick R. Michaud wrote:

> I would somewhat expect
> a reference to be instead handled using a statement like

>     $foo[1] := $bar;

> Comments and clarifications appreciated.

I would also opt for copy semantics whenever = is used
for assignment. But it seems to be the case that this
is not deep, just like captures are only one level deep
readonly. So, I would also expect $foo[1] = \$bar to
result in 24.

Regards, TSa.
--
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


 
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.
Larry Wall  
View profile  
 More options Aug 20 2008, 2:56 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 20 Aug 2008 11:56:03 -0700
Local: Wed, Aug 20 2008 2:56 pm
Subject: Re: arrayref/hashref in spectest suite
On Mon, Aug 18, 2008 at 01:38:05PM -0500, Patrick R. Michaud wrote:

: There are quite a few tests in the spectest suite that
: make mention of "arrayref" and "hashref", and that expect
: things to work like references do in Perl 5.  I'd like to
: get some confirmation/clarification on them.
:
: Here's one example:
:
:     my $foo = [ 42 ];
:     my $bar = { a => 23 };
:     $foo[1] = $bar;
:     $bar<b> = 24;
:
:     say $foo[1]<b>;     #  "24" or undef ???
:
: The test suite expects "24" to be output here, treating
: treating C< $foo[1] > as a reference to the hash in
: C<$bar>, such that any changes to C<$bar> are also reflected
: in C<$foo[1]>.  Is this correct Perl 6?  I would somewhat expect
: a reference to be instead handled using a statement like
:
:     $foo[1] := $bar;
:
: Comments and clarifications appreciated.

Well, sure, you can use := for clarity, but we left = in the language
to provide (to the extent possible) the same semantics that it
does in Perl 5.  And when it comes to non-value types, there really
are still references, even if we try not to talk about them much.
So I think assignment is basically about copying around identities,
where value types treat identity differently than object types (or
at least, objects types that aren't pretending to be value types).
In any case, an array or a hash is not pretending to be a value type,
so it just clones its identity (a reference, if you will) by default.

It's quite possible this is insane, but I can't tell in my current
state of jet lag.

Larry


 
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.
Thom Boyer  
View profile  
 More options Aug 20 2008, 11:39 am
Newsgroups: perl.perl6.language
From: t...@boyers.org (Thom Boyer)
Date: Wed, 20 Aug 2008 09:39:31 -0600
Local: Wed, Aug 20 2008 11:39 am
Subject: Re: arrayref/hashref in spectest suite

Patrick R. Michaud wrote:
>     my $foo = [ 42 ];
>     my $bar = { a => 23 };
>     $foo[1] = $bar;
TSa (Thomas Sandlaß) wrote:
> I would also opt for copy semantics whenever = is used for assignment.

But C<$foo[1] = $bar> *does* use copy semantics. The thing on the right
is a reference to a hash, and that reference is copied (by value) into
C<$foo[1]>.

It seems what you're really requesting is for the assignment operator to
auto-dereference references. But if you can't copy references, they
become pretty useless.
=thom


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »