Closed p5pRT closed 8 years ago
$ perl -wE'$_ = bless([]); push $_\, "a";' Not an unblessed ARRAY reference at -e line 1.
It appears that when the check was added to C\
- Eric
On Tue\, Jul 12\, 2011 at 1:52 PM\, Eric Brine \perlbug\-followup@​perl\.orgwrote:
# New Ticket Created by "Eric Brine" # Please include the string: [perl #94654] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=94654 >
This is a bug report for perl from ikegami@adaelis.com\, generated with the help of perlbug 1.39 running under perl 5.14.0.
----------------------------------------------------------------- [Please describe your issue here]
$ perl -wE'$_ = bless([]); push $_\, "a";' Not an unblessed ARRAY reference at -e line 1.
It appears that when the check was added to C\
\, C\ and C\ \, it was mistakenly added to C\ \, C\ \, C\ \, C\ and C\ too. - Eric
Just to be clear\, the bug is that C\
On Tue\, Jul 12\, 2011 at 2:12 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
It appears that when the check was added to C\
\, C\ and C\ \, it was mistakenly added to C\ \, C\ \, C\ \, C\ and C\ too. - Eric
Just to be clear\, the bug is that C\
works on some arrays but not others (e.g. blessed array\, blessed hash with overloaded @{}) . This limitation is neither documented nor required.
In RT #80626\, the final decision was the automatic dereferencing should only happen on unblessed arrays/hashes for all of "the customary array and hash functions" (IIRC the phrase). While this is not strictly necessary for "push $array_object"\, the intent was to have consistency between push/pop/shift/unshift/splice and keys/value/each rather than have array objects work on the first set and fail on the second set.
The documentation should be amended to reflect this limitation.
-- David
The RT System itself - Status changed from 'new' to 'open'
On Tue\, Jul 12\, 2011 at 2:28 PM\, David Golden \xdaveg@​gmail\.com wrote:
On Tue\, Jul 12\, 2011 at 2:12 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
It appears that when the check was added to C\
\, C\ and C\ \, it was mistakenly added to C\ \, C\ \, C\ \, C\ and C\ too. - Eric
Just to be clear\, the bug is that C\
works on some arrays but not others (e.g. blessed array\, blessed hash with overloaded @{}) . This limitation is neither documented nor required. In RT #80626\, the final decision was the automatic dereferencing should only happen on unblessed arrays/hashes for all of "the customary array and hash functions"
I thought we were trying to get rid of the bugs resulting from choice of storage format. Why are we introducing new ones as work is being down to fix the Unicode Bug\, smart matching\, etc?
On Tue\, Jul 12\, 2011 at 2:43 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
I thought we were trying to get rid of the bugs resulting from choice of storage format. Why are we introducing new ones as work is being down to fix the Unicode Bug\, smart matching\, etc?
One argument is that objects are opaque and perl should not go around messing with their internals without an explicit dereference (of an appropriate type) supplied by the user. The same problem doesn't exist with unblessed references.
It could be made to work with array-only functions (push/pop/etc.) but is ambiguous for array-or-hash functions (keys/values/each). I think the idea in the end was that it's easier to teach if those two work similarly (i.e. only on unblessed references).
David
David Golden \xdaveg@​gmail\.com writes:
One argument is that objects are opaque and perl should not go around messing with their internals without an explicit dereference (of an appropriate type) supplied by the user. The same problem doesn't exist with unblessed references.
Okay\, but then:
$ perl -wlE 'my $a = bless[]; push $a\, 1' Not an unblessed ARRAY reference at -e line 1.
There's no such thing as an "unblessed ARRAY reference". It's either an array reference or an object. So the message should read: "Not an ARRAY reference".
-- Johan
On Tue\, Jul 12\, 2011 at 12:19 PM\, Johan Vromans \jvromans@​squirrel\.nl wrote:
David Golden \xdaveg@​gmail\.com writes:
One argument is that objects are opaque and perl should not go around messing with their internals without an explicit dereference (of an appropriate type) supplied by the user. The same problem doesn't exist with unblessed references.
Okay\, but then:
$ perl -wlE 'my $a = bless[]; push $a\, 1' Not an unblessed ARRAY reference at -e line 1.
There's no such thing as an "unblessed ARRAY reference". It's either an array reference or an object. So the message should read: "Not an ARRAY reference".
That would be an inaccurate and misleading error message since the operand is clearly an array reference\, it is merely one we've singled out for unusual treatment.
Josh
Joshua ben Jore \twists@​gmail\.com writes:
On Tue\, Jul 12\, 2011 at 12:19 PM\, Johan Vromans \jvromans@​squirrel\.nl wrote:
David Golden \xdaveg@​gmail\.com writes:
One argument is that objects are opaque and perl should not go around messing with their internals ...
There's no such thing as an "unblessed ARRAY reference". It's either an array reference or an object. So the message should read: "Not an ARRAY reference".
That would be an inaccurate and misleading error message since the operand is clearly an array reference\,
Au contraire. If the statement is that objects are opaque\, then the array reference becomes an opaque object as soon as it is blessed. Refering to "unblessed array reference" implies there's also a "blessed array reference'. But by blessing an array reference it becomes an object.
-- Johan
On Tue\, 12 Jul 2011\, Johan Vromans wrote:
Joshua ben Jore \twists@​gmail\.com writes:
That would be an inaccurate and misleading error message since the operand is clearly an array reference\,
Au contraire. If the statement is that objects are opaque\, then the array reference becomes an opaque object as soon as it is blessed. Refering to "unblessed array reference" implies there's also a "blessed array reference'. But by blessing an array reference it becomes an object.
While it does indeed become an object\, that doesn't mean it ceases to be an array reference at the same time. Otherwise it would be pretty useless because you wouldn't have anything to hang your instance data onto. This still works\, right:
push @$self\, $whatever;
So it isn't unreasonable to expect this to work as well:
push $self\, $whatever;
Claiming that the later doesn't work because $self is not an array reference doesn't make any sense because then the former should have failed as well.
Cheers\, -Jan
On Tue\, Jul 12\, 2011 at 2:46 PM\, David Golden \xdaveg@​gmail\.com wrote:
On Tue\, Jul 12\, 2011 at 2:43 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
I thought we were trying to get rid of the bugs resulting from choice of storage format. Why are we introducing new ones as work is being down to fix the Unicode Bug\, smart matching\, etc?
One argument is that objects are opaque and perl should not go around messing with their internals without an explicit dereference (of an appropriate type) supplied by the user. The same problem doesn't exist with unblessed references.
First\, it's not Perl doing the "messing"\, it's the caller\, and it may very well be fine for it to "mess".
sub enqueue { my $queue = shift; return if !@_; lock $queue; push $queue\, @_; &cond_signal($queue); }
Second\, the point of forbidding this was for prevent confusion with objects with overloaded operators\, yet those intentionally return something that can be messed with here.
It could be made to work with array-only functions (push/pop/etc.) but
is ambiguous for array-or-hash functions (keys/values/each).
The bug report is just for the former.
I think the idea in the end was that it's easier to teach if those two work similarly (i.e. only on unblessed references).
It removes one inconsistency but adds two more:
- C\<push $a\, $_;> is not equivalent to C\<push @$a\, $_;>
- C\
- Eric
This ticket can be closed (and I am closing it)\, because the auto-deref feature to which it pertains was removed in 5.24.
--
Father Chrysostomos
@cpansprout - Status changed from 'open' to 'rejected'
Migrated from rt.perl.org#94654 (status was 'rejected')
Searchable as RT94654$