Partial Function Application

PHP 8.6's ? placeholder — a call expression with holes returns a Closure that only runs once the remaining arguments arrive, contrasted with fixing some arguments in 10 languages.

C C23

C23
#include <stdio.h>

static int version_compare(const char *v, int bmaj, int bmin) {
    int a[2] = {0, 0};
    sscanf(v, "%d.%d", &a[0], &a[1]);
    if (a[0] != bmaj) return a[0] > bmaj;
    return a[1] >= bmin;
}

/* C has no closures: partial application is a hand-written wrapper
   (or a function pointer to one) with the fixed argument baked in */
static int at_least_86(const char *v) { return version_compare(v, 8, 6); }

int main(void) {
    printf("%d\n", at_least_86("8.6.0"));
    printf("%d\n", at_least_86("8.5.0"));
    return 0;
}
Output
1
0

C++ C++26

C++26
#include <cstdio>

static bool version_compare(const char *v, int bmaj, int bmin) {
    int a[2] = {0, 0};
    sscanf(v, "%d.%d", &a[0], &a[1]);
    if (a[0] != bmaj) return a[0] > bmaj;
    return a[1] >= bmin;
}

int main() {
    // lambda capture is C++'s partial application: the fixed argument
    // lives inside the closure object, not in the call
    auto atLeast86 = [](const char *v) { return version_compare(v, 8, 6); };
    std::printf("%d\n", atLeast86("8.6.0") ? 1 : 0);
    std::printf("%d\n", atLeast86("8.5.0") ? 1 : 0);
    return 0;
}
Output
1
0

C# v11.0.100

v11.0.100
using System;

// a local function fixes the base; the lambda keeps the open argument
bool VersionCompare(string version, int baseMajor, int baseMinor)
{
    var p = version.Split('.');
    int maj = int.Parse(p[0]);
    int min = p.Length > 1 ? int.Parse(p[1]) : 0;
    if (maj != baseMajor) return maj > baseMajor;
    return min >= baseMinor;
}

Func<string, bool> atLeast86 = v => VersionCompare(v, 8, 6);
Console.WriteLine(atLeast86("8.6.0"));
Console.WriteLine(atLeast86("8.5.0"));

Func<string, string> repeat3 = s => string.Concat(Enumerable.Repeat(s, 3));
Console.WriteLine(repeat3("ab"));
Output
True
False
ababab

Go v1.27.4

v1.27.4
package main

import (
	"fmt"
	"strings"
)

func versionCompare(version string, baseMajor, baseMinor int) bool {
	var maj, min int
	fmt.Sscanf(version, "%d.%d", &maj, &min)
	if maj != baseMajor {
		return maj > baseMajor
	}
	return min >= baseMinor
}

func main() {
	// Go has no partial-application syntax: closures with captured
	// arguments are the idiom, one wrapper per fixed set
	atLeast86 := func(v string) bool { return versionCompare(v, 8, 6) }
	fmt.Println(atLeast86("8.6.0"))
	fmt.Println(atLeast86("8.5.0"))

	repeat3 := func(s string) string { return strings.Repeat(s, 3) }
	fmt.Println(repeat3("ab"))
}
Output
true
false
ababab

Java v27.0.1

v27.0.1
import java.util.function.IntPredicate;
import java.util.function.UnaryOperator;

public class Main {
    static boolean versionCompare(String version, int baseMajor, int baseMinor) {
        String[] p = version.split("\\.");
        int maj = Integer.parseInt(p[0]);
        int min = p.length > 1 ? Integer.parseInt(p[1]) : 0;
        if (maj != baseMajor) return maj > baseMajor;
        return min >= baseMinor;
    }

    public static void main(String[] args) {
        // lambdas capture effectively-final locals: Java's partial application
        IntPredicate atLeast86 = v -> versionCompare("8." + v, 8, 6);
        System.out.println(atLeast86.test(6));
        System.out.println(atLeast86.test(5));

        UnaryOperator<String> repeat3 = s -> s.repeat(3);
        System.out.println(repeat3.apply("ab"));
    }
}
Output
true
false
ababab

JavaScript v26.13.1

v26.13.1
function versionCompare(base, op, version) {
  const v = version.split(".").map(Number);
  const b = base.split(".").map(Number);
  const ok = v[0] > b[0] || (v[0] === b[0] && v[1] >= b[1]);
  return op === ">=" ? ok : !ok;
}
// bind fixes a PREFIX of arguments — no placeholders in the middle
const atLeast86 = versionCompare.bind(null, "8.6", ">=");
console.log(atLeast86("8.6.0"));
console.log(atLeast86("8.5.0"));

const repeat3 = (s) => s.repeat(3); // arrow captures: partial by hand
console.log(repeat3("ab"));
Output
true
false
ababab

PHP v8.6.0

v8.6.0
// `?` leaves a placeholder; PHP returns a Closure awaiting that argument
$atLeast86 = version_compare(?, '8.6', '>=');
var_dump($atLeast86(PHP_VERSION));
var_dump($atLeast86('8.5.0'));
var_dump(get_class($atLeast86));

// several `?` at once fill in left to right; `...` collects the rest
$tag = sprintf('<%s>%s</%s>', ?, ?, ?);
echo $tag('b', 'hi', 'b'), "\n";

// named-argument placeholder: bind the label, leave the value open
$repeat = str_repeat(string: ?, times: 3);
echo $repeat('ab'), "\n";

// a list of partials becomes a list of one-argument predicates
$checks = [version_compare(?, '8.6', '>='), version_compare(?, '8.5', '>=')];
var_dump(array_map(fn ($f) => $f('8.6.0'), $checks));

// placeholder in method-call position: reuse one object with a bound option
$f = (new DateTime('2026-11-19'))->format(?);
echo $f('Y-m-d'), "\n";
Output
bool(true)
bool(false)
string(7) "Closure"
<b>hi</b>
ababab
array(2) {
  [0]=>
  bool(true)
  [1]=>
  bool(true)
}
2026-11-19

Python v3.15.2

v3.15.2
from functools import partial

def version_compare(version: str, base: str, op: str) -> bool:
    v = tuple(int(x) for x in version.split("."))
    b = tuple(int(x) for x in base.split("."))
    return {"<=": v <= b, ">=": v >= b, "==": v == b}[op]

# partial freezes trailing args; the open one stays positional
at_least_86 = partial(version_compare, base="8.6", op=">=")
print(at_least_86(version="8.6.0"))
print(at_least_86(version="8.5.0"))

repeat3 = partial(lambda s, n: s * n, n=3)
print(repeat3("ab"))
Output
True
False
ababab

Rust v1.99.1

v1.99.1
fn version_compare(version: &str, base: &str, op: &str) -> bool {
    let v: Vec<u32> = version.split('.').filter_map(|x| x.parse().ok()).collect();
    let b: Vec<u32> = base.split('.').filter_map(|x| x.parse().ok()).collect();
    match op {
        ">=" => v >= b,
        "<=" => v <= b,
        _ => v == b,
    }
}

fn main() {
    // a closure captures the fixed arguments; the rest stay parameters
    let at_least_86 = |v: &str| version_compare(v, "8.6", ">=");
    println!("{}", at_least_86("8.6.0"));
    println!("{}", at_least_86("8.5.0"));

    let tag = |a: &str, m: &str, c: &str| format!("<{}>{}</{}>", a, m, c);
    println!("{}", tag("b", "hi", "b"));
}
Output
true
false
<b>hi</b>

TypeScript v26.13.1

v26.13.1
function versionCompare(base: string, op: string, version: string): boolean {
  const v = version.split(".").map(Number);
  const b = base.split(".").map(Number);
  const ok = v[0] > b[0] || (v[0] === b[0] && v[1] >= b[1]);
  return op === ">=" ? ok : !ok;
}
// the type spells out the remaining-argument shape after binding
const atLeast86: (v: string) => boolean = versionCompare.bind(null, "8.6", ">=");
console.log(atLeast86("8.6.0"));
console.log(atLeast86("8.5.0"));

const repeat3 = (s: string): string => s.repeat(3);
console.log(repeat3("ab"));
Output
true
false
ababab

Language differences

C: no closures (example): partial application means a hand-written wrapper or function pointer with the fixed argument baked into the body; the closest idiom is a trampoline bound to a struct — all manual.

C++: lambda capture (example): the capture list packs fixed arguments into the closure object, more flexible than a C wrapper (by value, by reference, this); std::bind with std::placeholders::_1 is the standard library's explicit placeholder scheme (C++11), though modern style prefers lambdas.

C#: local function plus lambda (example): the Func delegate type spells out how many arguments remain; no placeholder syntax, so the idiom is wrapping in a lambda or currying.

Go: no partial-application syntax (example): the idiom is closures with captured arguments — one wrapper per fixed set; the function type func(string) bool is exactly the post-application shape, and http.HandlerFunc is that pattern in the standard library.

Java: lambda capture (example): capturing effectively-final locals is partial application; no placeholders, and functional interfaces like IntPredicate/UnaryOperator carry the shape of the remaining arguments.

JavaScript: Function.prototype.bind fixes an argument PREFIX (example): bind cannot leave a hole in the middle — keeping the last argument open requires designing signatures fixed-first or passing undefined as a hack; arrow-function captures are partial application by hand. Ramda's curry/partial fills in real placeholders.

PHP: the 8.6 RFC partial_function_application_v2 (example): ? leaves holes anywhere in a call expression, including named arguments, and ... collects the rest; the expression is validated against the signature at creation (too many holes throws ArgumentCountError immediately); the product is an ordinary Closure — the 8.1 first-class callable strlen(...) is its fully-applied special case, and arrow fn() is the neighboring syntax that packs captures too — together the three form the functions-as-values spectrum.

Python: functools.partial (example): freezes trailing and keyword arguments, leaving the rest in place; no placeholders (middle holes need a hand-written lambda); partial objects compose, letting you fix arguments in stages.

Rust: closure capture (example): move/borrow captures carry the fixed arguments while the rest stay ordinary parameters; no placeholder syntax, with Fn/FnMut/FnOnce describing the call shape.

TypeScript: same as JS bind (example): the type system makes the remaining-parameter shape explicit as (v: string) => boolean, and library types such as ramda's __ placeholder can express middle holes.