Modify

#3540 assigned Feature Request

Implement optional ByRef parameters for functions

Reported by: TheDcoder <TheDcoder@…> Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: optional, functions, byref Cc:

Description

Hello, I know that this had been already bought up in ticket #2360 but I am going to re-request the feature with proper reasoning and support.

I would like to see optional ByRef parameters work in AutoIt. They would function something like this: If a function has been called which contains an optional ByRef parameter, the ByRef parameter should act as a "normal" non-ByRef parameter unless it has been specified in the function call.

There are several advantages to this approach:

  1. It is fully backward compatible
  2. Several functions which use ByRef parameters can be made optional
  3. This solves the problem of creating "dummy" variables which are just created for the sake of passing them to ByRef parameters.

I think this is relatively easy to implement and won't have any side effects unlike most feature requests.

If we have nothing to lose but except gain, why don't we do it? ;)

Here is some proof-of-concept code:

FuncWithOptionalByRef()
FuncWithOptionalByRef("Foo")

Func FuncWithOptionalByRef(ByRef $vFoo = "Bar")
	ConsoleWrite($vFoo & @CRLF)
EndFunc

Expected Output after the implementation of this feature:

Bar
Foo

In the latest version, the PoC code won't work because of an error: "Badly formatted function"

Attachments (0)

Change History (6)

comment:1 by TheDcoder <TheDcoder@…>, on Mar 16, 2017 at 7:39:23 AM

Ticket #3538 can be completed if this feature request was accepted!

comment:2 by TheDcoder <TheDcoder@…>, on Apr 3, 2017 at 5:43:01 AM

All discussion related to this ticket can be found at the thread which I created at the forum.

comment:3 by J-Paul Mesnage, on Dec 9, 2020 at 9:23:40 PM

Fix sent to Jon

comment:4 by J-Paul Mesnage, on Dec 9, 2020 at 9:25:07 PM

Owner: set to J-Paul Mesnage
Status: newassigned

in reply to:  1 comment:5 by mLipok, on Dec 13, 2020 at 2:46:56 AM

Replying to TheDcoder <TheDcoder@…>:

Ticket #3538 can be completed if this feature request was accepted!

@jpm what you can say about #3538 which TheDcoder mentioned above.

Last edited on Dec 14, 2020 at 8:53:24 AM by mLipok (previous) (diff)

comment:6 by J-Paul Mesnage, on Mar 16, 2024 at 12:31:10 PM

Owner: changed from J-Paul Mesnage to Jon

Modify Ticket

Action
as assigned The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.