Modify ↓
Opened on Nov 6, 2012 at 2:02:43 PM
Last modified on Mar 16, 2024 at 10:43:03 AM
#2278 assigned Feature Request
Varargs
| Reported by: | Matt Diesel | Owned by: | Jon |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | varargs, params | Cc: |
Description
A syntax like C# would probably be the easiest, example would be:
Foo(42, 24, "Hello", "World", "!!!")
Func Foo($x, $y, Params $bar)
For $i = 0 To UBound($bar) - 1
ConsoleWrite($bar[$i] & @LF)
Next
EndFunc
Attachments (0)
Change History (6)
follow-up: 4 comment:1 by , on Nov 6, 2012 at 6:08:17 PM
comment:2 by , on Jul 21, 2013 at 11:32:31 PM
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
comment:3 by , on Sep 3, 2013 at 10:39:55 PM
| Resolution: | Rejected |
|---|---|
| Status: | closed → reopened |
comment:4 by , on Aug 20, 2014 at 1:04:24 PM
I would suggest this syntax.
Func f (...$argArray) ; Use the argument array. EndFunc
It is done the same way in other languages.
// C++
template <typename... types>
void f (types &&... argArray);
template <int... sizes>
void print (const char (&... arrayReferences) [sizes]);
// JS
function apply (f, ...argArray) { /* ... */ }
It would be useful to allow ByRef and Const before the ellipsis (_ArrayConcatenate (ByRef $to, Const ByRef ...$from)).
comment:5 by , on Oct 23, 2020 at 2:08:37 PM
| Owner: | set to |
|---|---|
| Status: | reopened → assigned |
I introduce a new keyword in Func() definition to allow handling the variable number of parameter
f(1, 2) Func f (ByVarArgs $argArray) For $i = 1 to @NumParams ; use $argArray[$i] Next EndFunc
Fix sent to Jon
comment:6 by , on Mar 16, 2024 at 10:43:03 AM
| Owner: | changed from to |
|---|
Note:
See TracTickets
for help on using tickets.

Maybe like this.
Func Foo($x, $y, ...) For $param In @Params ConsoleWrite($param & @LF) Next EndFunc