Skip Menu |
 

This queue is for tickets about the Data-Alias CPAN distribution.

Report information
The Basics
Id: 75703
Status: resolved
Priority: 0/
Queue: Data-Alias

People
Owner: Nobody in particular
Requestors: rsimoes [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Using &deref prevents &alias from working
Download (untitled) / with headers
text/plain 456b
The documentation for Data::Alias states that &deref "Applies the applicable dereferencing operator to each." However, when &alias is used together with &deref, it yields an unexpected result: use Data::Alias qw(alias deref); my $arref = [qw(a..z)]; print $arref, "\n"; # ARRAY(0x13a5de8) alias my @arr1 = @$arref; print \@arr1, "\n"; # ARRAY(0x13a5de8) alias my @arr2 = deref $arref; print \@arr2, "\n"; # ARRAY(0x13ba458)
Subject: Re: [rt.cpan.org #75703] Using &deref prevents &alias from working
Date: Sun, 4 Aug 2013 18:23:44 +0100
To: Richard Sim??es via RT <bug-Data-Alias [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 868b
Richard Sim??es via RT wrote: Show quoted text
>The documentation for Data::Alias states that &deref "Applies the >applicable dereferencing operator to each." However, when &alias is used >together with &deref, it yields an unexpected result:
You were expecting to alias the underlying array. However, that it does not is not a bug in the code. "deref $arref" is *not* precisely equivalent to "@$arref". deref is not a magical operator. Rather, it's a *function*, and when given an arry reference it dereferences that and returns the elements of the array. What you get back is necessarily a list of the array elements, and there is no remaining reference to the original array. The alias operator then cannot alias to the original array; it falls back to the general list-assignment behaviour of aliasing the elements of the list. The documentation could be clearer. -zefram
Doc expanded in Data-Alias-1.17, now on CPAN.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.