← Back to Pull requests

introduce `Base.FixNullaryCallable`, generalizing `Base.Fix` #61034

Open
nsajko opened this pull request with 122 lines diff across 3 files
View on GitHub
nsajko nsajko commented on Feb 14, 2026 11:50 UTC
Author

Allow obtaining the value of the fixed argument from a nullary callable, also known as a thunk, instead of just from a fixed value.

Diff: 122 lines (+97 / -25) across 3 files Reviewer: nsajko Review duration: 402456m
All Vouch review confidence checks passed
Residual risk 0.12 = Change Risk (0.56) × (1 − Review Confidence (0.79)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.56 · 122 lines diff across 3 files
0.56
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 5 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
79%
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.288
Self Review self_review
0.140
Real PR Conversation Timeline
9 items
nsajko nsajko commented on Feb 14, 2026 11:58 UTC
Author

Motivation:

I have a function like this:

function func(x, y)
    for e ∈ y
        x = g(x, e)
    end
    x
end

Rewriting it using foreach instead of for:

function func(x, y)
    X = Ref{Any}(x)
    function f(e)
        g(getindex(X), e)
    end
    foreach(Base.Fix1(setindex!, X) ∘ f, y)
    X[]
end

However, with Base.FixNullaryCallable, it is possible to go further along in the tacit programming style, also known as point-free style:

function func(x, y)
    X = Ref{Any}(x)
    foreach(Base.Fix1(setindex!, X) ∘ Base.FixNullaryCallable{1}(g, Base.Fix1(getindex, X)), y)
    X[]
end

nsajko nsajko commented on code on Feb 14, 2026 13:54 UTC
Code Review
base/operators.jl:1

const Fix1 = Fix{1}

nsajko nsajko commented on code on Feb 14, 2026 13:55 UTC
Code Review
base/operators.jl:1

const Fix2 = Fix{2}

nsajko nsajko commented on Feb 14, 2026 13:55 UTC
Reviewer

see if this happens to fix the type alias displaying

nsajko nsajko commented on Feb 14, 2026 14:36 UTC
Author

Currently blocked by what I suppose is a bug/suboptimality in the type-printing machinery. Specifically, the type alias Base.Fix1 gets shown in an overly complicated manner. As does Base.Fix2. Everything else seems as expected and non-breaking.

So I suppose I will have to make a PR for show.jl before this PR can be considered.

adienes adienes commented on Feb 14, 2026 15:07 UTC
Contributor

this seems a little arcane / niche to me. In my subjective opinion the usage example given in the PR description is a lot more confusing to read and is not an improvement over

function func(x, y)
    for e ∈ y
        x = g(x, e)
    end
    x
end

nsajko nsajko commented on Feb 14, 2026 15:10 UTC
Author

Yeah, but that's just because imperative code is the norm in the Julia world. Functional/tacit programming is a valid style nevertheless.

ararslan ararslan commented on Feb 14, 2026 23:14 UTC
Contributor

Seems like it could live in a package? The only change in this PR that isn't just introducing new code is to make Fix a special case, but if Fix is left as-is, the changes here are completely separable.

Reviewers
Assignees
nsajko nsajko
Labels
risk: low confidence: 79.2% 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: 55.7% (MEDIUM) · Higher = larger blast radius
55.7%
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: 79.2% · Lower = rushed or shallow review
79.2%
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: 11.6% · Safe to merge
11.6%