Modify

Opened 6 years ago

Last modified 5 years ago

#2278 reopened Feature Request

Varargs

Reported by: Mat Owned by:
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 (4)

comment:1 follow-up: Changed 6 years ago by trancexx

Maybe like this.

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

comment:2 Changed 6 years ago by Jon

  • Resolution set to Rejected
  • Status changed from new to closed

comment:3 Changed 6 years ago by Mat

  • Resolution Rejected deleted
  • Status changed from closed to reopened

comment:4 in reply to: ↑ 1 Changed 5 years ago by anonymous

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)).

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as reopened The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.