extern: a unit parameter contributes no argument, wherever it sits (#123) - #125
Merged
Conversation
) A leading unit in a multi-parameter extern fired the nullary zero-argument-call rule and applied the remaining arguments to the result (abs()(-5)), while a mid-list unit travelled as None (max(3, None, 5)): three shapes, three meanings. Now one rule — a unit parameter contributes no Python argument. The nullary call is unchanged, abs(-5) and max(3, 5) fall out, partial application closes over a lambda that accepts and ignores a future unit, receiver methods and bare references drop units the same way, and the parser's ...-slot arithmetic counts only non-unit arguments, so threading.Thread(daemon = true, target = ...) behind a leading unit now parses and emits a single call. Also carries the VS Code Marketplace ledger line to 0.8.0 (uploaded 2026-08-30), per the one-ledger-PR rule. Closes #123
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#123's table showed three shapes with three meanings: a nullary extern called with zero arguments (right), a leading unit splitting the call (
unit -> int -> int = absemittedabs()(-5)— the zero-argument rule fired and the remaining arguments applied to its result), and a mid-list unit travelling asNone(max(3, None, 5)). This lands the issue's requested rule: aunitparameter contributes no Python argument, wherever it sits, which subsumes the nullary case instead of special-casing it.extern_unit_slotsreplacesnullary_externs: the positions of plainunitparameters along the curried list (distinct from thunk slots, which are function-typedunit -> a).build_call_unitshandles every arity: full application emits one call with the units dropped (abs(-5),max(3, 5)); over-application folds extras as everywhere else; partial application closes over a lambda —functools.partialcannot drop aunitthat has not arrived, the lambda accepts and ignores it (pick 4→lambda _pf_k0, _pf_k1: max(4, _pf_k1)). A dropped argument that could have effects still runs, as its own statement, with neighbours hoisted to keep left-to-right order.unit_dropping_lambda(the all-unit case keeps today'slambda *_:shape); receiver methods, property folds andreceiver_lambdadrop units the same way; the unit block now also thunk-wraps, which the old nullary path never did....-slot arithmetic counts only non-unit arguments, so the extern the finding actually wanted —unit -> (unit ->{io} unit) -> Thread = threading.Thread(daemon = true, target = ...)— now parses, and emitsthreading.Thread(daemon=True, target=lambda: f(None))in one call (verified end to end with a running thread). An all-unit type still rejects a slot with the existing message.The mid-list
None→ dropped change is breaking in principle; nothing in the repo, lessons or tests relied on it, and the issue makes the design argument (int -> unit -> int -> intmost plausibly meantmax(3, 5)).Docs:
DESIGN.md§6 states the one rule and the amended slot arithmetic;ROADMAP.mditem 24. Also carries the VS Code Marketplace ledger line to 0.8.0 (uploaded 2026-08-30), per the one-ledger-PR rule.Closes #123