develooper Front page | perl.perl6.internals | Postings from April 2008

[perl #52778] Are resizable arrays too Perlish?

Thread Next
From:
Bob Rogers
Date:
April 12, 2008 01:03
Subject:
[perl #52778] Are resizable arrays too Perlish?
# New Ticket Created by  Bob Rogers 
# Please include the string:  [perl #52778]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52778 >


   As the transcript below shows, Parrot out-Perls even Perl by changing
the array length when accessing a non-existent element, and not just
when storing one.  It would be easy enough to give Parrot the same
behavior as Perl, but it's not clear that that's entirely the right
thing.  The real question is therefore:  What's the appropriate
autovivification behavior for the resizable array base classes, which
presumably ought to be language-agnostic?

					-- Bob Rogers
					   http://rgrjr.dyndns.org/

------------------------------------------------------------------------
rogers@rgr> cat array-autoviv.pl
#! /usr/bin/perl -w

my @array;

print $array[7] || '';

print scalar(@array), "\n";
rogers@rgr> ./array-autoviv.pl
0
rogers@rgr> cat array-autoviv.pir
.sub main :main
	.local pmc array
	array = new 'ResizablePMCArray'

	$P0 = array[7]

	$I0 = array
	print $I0
	print "\n"
.end
rogers@rgr> ./parrot array-autoviv.pir
8
rogers@rgr> 

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About