← Back to Pull requests

Update `push()` documentation to include examples and be more novice friendly #20737

Merged
scottchiefbaker merged 1 files (20 lines) on Feb 07, 2023 15:42 UTC
View on GitHub
scottchiefbaker scottchiefbaker commented on Jan 24, 2023 00:01 UTC
Author

The push() documentation is very developer heavy. I added some examples and simplified the wording so it's more novice friendly.

Diff: 20 lines (+12 / -8) across 1 files Reviewer: demerphq Review duration: 21100m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.21) × (1 − Review Confidence (0.75)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.21 · 20 lines diff across 1 files
0.21
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.51 · 5 substantive comment(s)
0.51
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
74%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.182
Real PR Conversation Timeline
18 items
haarg haarg commented on Jan 24, 2023 00:32 UTC
Contributor

I like the new additions, but I don't like the existing example using a loop. I feel like the entire "A more technical explanation:" to "but is more efficient." section could be eliminated. It seems unneeded and inaccurate.

demerphq demerphq commented on code on Jan 24, 2023 05:55 UTC
Code Review
pod/perlfunc.pod:1
@@ -6164,8 +6182,7 @@ effect as
         $ARRAY[++$#ARRAY] = $value;

Shouldn't this be $ARRAY[@ARRAY] = $value;?

demerphq demerphq requested changes on Jan 24, 2023 06:00 UTC
Changes Requested Reviewer

Mostly looks ok to me. One minor nit, I don't think we should use $#ARRAY++ in docs for push @ARRAY is more natural, and doesn't require understanding that you can change the size if the array by assigning to $#ARRAY. (Frankly that operation is rare enough that I had forgotten it was legal, presizing strings and hashes is rarely done but is still more common IME than presizing arrays.).

Grinnz Grinnz commented on code on Jan 24, 2023 06:06 UTC
Code Review
pod/perlfunc.pod:1
@@ -6164,8 +6182,7 @@ effect as
         $ARRAY[++$#ARRAY] = $value;

I think the intent is to show (to someone intimately familiar with how $#prefix works) that the operation increases the size of the array and then assigns the element there. But I agree with @haarg that this entire example doesn't give any useful information.

demerphq demerphq commented on code on Jan 24, 2023 09:49 UTC
Code Review
pod/perlfunc.pod:1
@@ -6164,8 +6182,7 @@ effect as
         $ARRAY[++$#ARRAY] = $value;

I'm good with removing, but if we don't we should restate as I diid. The original is cryptic, and unnecessary (as you know there is no need to presize the array to store into an index) and we shouldn't explain one concept by invoking a separate and even more complex concept. Assigning a value to the next available index is often done the way I wrote it (ive done it myself many times [although usually in two statements] and ive seen others do it as well), but I can't recall ever having seen it done the way it's shown in that example.

JRaspass JRaspass commented on code on Jan 24, 2023 10:53 UTC
Code Review
pod/perlfunc.pod:1
@@ -6156,6 +6156,24 @@ X<push> X<stack>
 
 =for Pod::Functions append one or more elements to an array
 
+Adds one or more items to the B<end> of an array.
+
+	my @animals = ("cat");
+	push(@animals, "mouse"); # ("cat", "mouse")
+
+	my @colors = ("red");
+	push(@colors, ("blue", "green"); # ("red", "blue", "green")

Two open parens, one closing.

JRaspass JRaspass commented on code on Jan 24, 2023 10:55 UTC
Code Review
pod/perlfunc.pod:1
@@ -6156,6 +6156,24 @@ X<push> X<stack>
 
 =for Pod::Functions append one or more elements to an array
 
+Adds one or more items to the B<end> of an array.
+
+	my @animals = ("cat");
+	push(@animals, "mouse"); # ("cat", "mouse")
+
+	my @colors = ("red");
+	push(@colors, ("blue", "green"); # ("red", "blue", "green")

There's a few of these, and in the unshift examples. Not sure I'd bother with the inner parens, the subs are variadic and the parens might confuse people? YMMV

scottchiefbaker scottchiefbaker commented on code on Jan 24, 2023 18:01 UTC
Code Review
pod/perlfunc.pod:1
@@ -6156,6 +6156,24 @@ X<push> X<stack>
 
 =for Pod::Functions append one or more elements to an array
 
+Adds one or more items to the B<end> of an array.
+
+	my @animals = ("cat");
+	push(@animals, "mouse"); # ("cat", "mouse")
+
+	my @colors = ("red");
+	push(@colors, ("blue", "green"); # ("red", "blue", "green")

Good catch... I updated the PR

scottchiefbaker scottchiefbaker commented on Jan 24, 2023 18:18 UTC
Author

It was pretty unanimous that the original technical definition didn't add a lot to the documentation so I removed it. The diff looks gnarly now because of all the text moving around, but the wording is MUCH cleaner now.

scottchiefbaker scottchiefbaker commented on Jan 25, 2023 16:14 UTC
Author

What's next on this PR?

I'd like to work on shift() and pop() doc fixes next, but I want to focus on this until it lands.

haarg haarg commented on Jan 25, 2023 16:37 UTC
Contributor

lgtm

scottchiefbaker scottchiefbaker commented on Jan 29, 2023 05:39 UTC
Author

Ping

iabyn iabyn commented on Jan 30, 2023 15:59 UTC
Contributor

I don't like the return value example. You effectively say the same thing 3 times ("returns the number of elements") without adding any more information or clarity. Showing the return value being printed out doesn't add anything. Perheps get rid of the 'say' and change the comment line just above the 'push' to

sets $color_count to 5

demerphq demerphq commented on Feb 07, 2023 13:08 UTC
Contributor

This ticket was stalled. I have removed the comment that it was stalled by.

demerphq demerphq commented on Feb 07, 2023 13:08 UTC
Contributor

And I will merge once CI passes successfully.

demerphq demerphq approved these changes on Feb 07, 2023 13:09 UTC
Approved Reviewer

Approved these changes.

demerphq demerphq commented on Feb 07, 2023 15:42 UTC
Contributor

Thanks. Applied.

Reviewers
Assignees
scottchiefbaker scottchiefbaker
Labels
risk: low confidence: 74.6% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 21.2% (LOW) · Higher = larger blast radius
21.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 74.6% · Lower = rushed or shallow review
74.6%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.4% · Safe to merge
5.4%
Repository