Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction to the description of C<delete> #13744

Closed
p5pRT opened this issue Apr 17, 2014 · 7 comments
Closed

Correction to the description of C<delete> #13744

p5pRT opened this issue Apr 17, 2014 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 17, 2014

Migrated from rt.perl.org#121681 (status was 'resolved')

Searchable as RT121681$

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2014

From anno5@me.com

The description of C<delete> in perlfunc.pod says​:

  ...
  However, if all deleted elements fall at the end of an array,
  the array's size shrinks to the position of the highest element
  that still tests true for exists(), or to 0 if none do.
  ...

This isn't quite correct. It isn't required for all deletions to be at the end of the string, shrinking happens if any of them are. I'd also add a sentence that gives the rationale for this seemingly unsystematic behavior. I suggest to change the passage to read (patch attached)

  However, if any deleted elements fall at the end of an array,
  the array's size shrinks to the position of the highest element
  that still tests true for exists(), or to 0 if none do. In other words, an
  array won't have trailing nonexistent elements after a delete.

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2014

From anno5@me.com

patch

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2014

From @tonycoz

On Thu Apr 17 11​:50​:30 2014, anno5@​me.com wrote​:

However, if any deleted elements fall at the end of an array,
the array's size shrinks to the position of the highest element
that still tests true for exists(), or to 0 if none do. In other
words, an
array won't have trailing nonexistent elements after a delete.

That looks good to me.

I'll apply it post 5.20.

Attached is a git format-patch as I plan to apply it, using your email from the AUTHORS file instead of from this ticket. If you want that changed, please let me know.

Tony

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2014

From @tonycoz

0001-perl-121681-fix-documentation-of-delete-at-the-end-o.patch
From d69d48cf2a4a44e0544d0b8dc04948c6474802f9 Mon Sep 17 00:00:00 2001
From: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Date: Mon, 21 Apr 2014 10:16:07 +1000
Subject: [perl #121681] fix documentation of delete at the end of an array

---
 pod/perlfunc.pod |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 9a5ee74..0cc1e9a 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -1368,9 +1368,10 @@ in their corresponding positions.
 delete() may also be used on arrays and array slices, but its behavior is less
 straightforward.  Although exists() will return false for deleted entries,
 deleting array elements never changes indices of existing values; use shift()
-or splice() for that.  However, if all deleted elements fall at the end of an
+or splice() for that.  However, if any deleted elements fall at the end of an
 array, the array's size shrinks to the position of the highest element that
-still tests true for exists(), or to 0 if none do.
+still tests true for exists(), or to 0 if none do. In other words, an
+array won't have trailing nonexistent elements after a delete.
 
 B<WARNING:> Calling delete on array values is deprecated and likely to
 be removed in a future version of Perl.
-- 
1.7.10.4

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2014

From @tonycoz

On Sun Apr 20 17​:24​:06 2014, tonyc wrote​:

On Thu Apr 17 11​:50​:30 2014, anno5@​me.com wrote​:

However, if any deleted elements fall at the end of an array,
the array's size shrinks to the position of the highest element
that still tests true for exists(), or to 0 if none do. In other
words, an
array won't have trailing nonexistent elements after a delete.

That looks good to me.

I'll apply it post 5.20.

Attached is a git format-patch as I plan to apply it, ...

Ricardo approved this for pre-5.20 on IRC last night[1], applied as deaf6ad.

[1] from the perspective of GMT+1000

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant