dart-lang / dart-lang/language
Obtaining a tuple of actual function arguments
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
The issue of forwarding was raised on multiple occasions during dart history.
The tuple of actual arguments can help, it's just a matter of finding a good syntax. The first thing that comes to mind is `$arguments`:
```
myFunction(int a, int b, {String s=""}) {
anotherFunction(...$arguments); // forwarding
anotherFunction(...$arguments with (_, 10, "Hello"));
}
```
There's a related issue: how to declare tuple type based on the argument list of existing function?
I can't find any prior example of anything like that in dart. One obvious variant is:
```
typedef MyTupleType=someFunction.$arguments
```
which I don't like because it works (kinda) only in the context of typedef, but is no good as a type expression - e.g. this declaration is weird:
```
someFunction.$arguments myTuple; // variable of type someFunction.$arguments
```
Another variant can be
```
(...someFunction.$arguments) myTuple;
```
but this is too fancy.
EDIT: If dart introduces compile-time macros like `#nameOf(foo.bar)` then the natural idea would be to define yet another macro for the function argument tuples, with a more articulate syntax
```
#tupleTypeOf(myFunction) tuple=(1, 2, s="hello");
```
or something to that effect
Contributor guide
Research direction
Start by reading the issue discussion and its examples for forwarding actual arguments and deriving tuple types. No source files, tests, or entry points are identified. Done would require an agreed language design and syntax, followed by the necessary specification and implementation work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100