| Store | Cart

Re: Concerning the branch smoke-me/arc/deprecate-delete-array

From: Father Chrysostomos <spr...@cpan.org>
21 Aug 2014 03:32:31 -0000
Jan Dubois wrote:
> On Tue, Aug 19, 2014 at 10:01 AM, Father Chrysostomos wrote:> > If the adjustment of $#foo by delete $foo[...] is the main reason> > for deprecating it, then why not just stop delete from changing> > the length?> > Maybe I'm missing something, but isn't this the only difference> between 'delete $a[$i]' and 'undef $a[$i]'.  So 'delete' and 'exists'> would just become aliases for 'undef' and 'defined' when applied to> array elements?

Existent elements can hold the undefined value.

> I don't think this feature should have been added, but since it> already exists, I don't see any reason to change or remove it unless> it stands in the way of some desirable improvement. So I would rather> mark it as 'discouraged', if we have to do anything, and leave as is> instead of keeping it marked as 'deprecated' (cf. perlpolicy).> > Do you have a pointer to the discussion *why* it was deprecated.> Maybe that was at a time where we didn't yet differentiate between> 'deprecate' and 'discourage' in the policy?

It started with ticket #72064 (or maybe some messages before that).
The subject has come up a few times over the years in various threads.

When Nicholas Clark added array support to keys/each/values, he did
not make it consistent with the 'sparse array' feature of delete and
exists, not know about the latter feature.

The consensus in #72064 (in which I declined to participate, still
having scars from losing the 'split'-in-void-context, and not wanting
to have another argument) seems to be that the 'sparse array' feature
is surprising and weird.

My position is that it was a documented feature for a whole decade
before anyone even noticed anything 'wrong' with it.*  Even Larry
Wall endorsed it when it was added.  Removing it doesn't help anyone
and breaks existing code.  (And I find keys, et al., next to useless
on arrays as currently implemented, since I can write the same things
in other ways that are hardly more complex.)

* I'm exaggerating a little, to try and get my point across.

Recent Messages in this Thread
Father Chrysostomos Aug 21, 2014 03:32 am
Ricardo Signes Aug 21, 2014 01:50 pm
Jan Dubois Aug 21, 2014 06:05 pm
Brian Fraser Aug 21, 2014 06:09 pm
Karl Williamson Aug 21, 2014 06:24 pm
Dave Mitchell Aug 25, 2014 07:42 pm
Ricardo Signes Aug 21, 2014 06:55 pm
Jan Dubois Aug 19, 2014 05:43 pm
Aaron Crane Aug 21, 2014 11:03 am
Messages in this thread