-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Tracking Issue for argument splatting lang experiment #153629
Copy link
Copy link
Open
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
Description
Activity
Metadata
Metadata
Assignees
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
This is a tracking issue for the lang experiment into argument splatting, for function overloading and variadic functions (including leaving out optional arguments entirely).
The feature gate for the issue is
#![feature(splat)].About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Experiment Goals
This experiment facilitates limited forms of function overloading, variadic functions, and optional arguments, by improving the existing syntax at the call site.
Rust already has "overloading at home" via the trait system, but calls to overloaded or variadic functions look strange. The goal of this experiment is to make the call sites look like ordinary function calls, and see how that impacts FFI, coherence, and ergonomics.
Eventually, overloading might improve the usability of many near-identical standard library methods.
Experiment Non-Goals
Rust already has "named arguments at home" via argument destructuring, but calls to named argument functions need to create a struct. We could make call sites look like regular function calls (but with argument names), but that is out of scope for the initial experiment.
Steps
fn foo(#[splat] (T, U, …))cmp_splat(Variadicminandmax) #160728fn (#[splat] (A, B))tofn (A, B))Other Tooling
Rustdoc:
Rustfmt:
Other Potential Experiments
Pre-Stabilization
#[rustc_splat], and lang FCP breakage from stable name collisions arising from introducing a new built-in attribute (see 1.98 beta regression due to name collision withsplat#159428)Unresolved Questions
Semantics
self,&self,&mut self,self: Pin<&mut Self›,self: CRef<Self>)Syntax & Implementation Rules
Ergonomics & Diagnostics
Future Work
Sources:
Related features
core::marker::Tuple#157987 can be used for overloadingunboxed_closures&fn_traitsfeature) #29625 eventuallyImplementation history
See the
F-splatlabel, and also: