[v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
iseahound
Posts: 1459
Joined: 13 Aug 2016, 21:04
Contact:

[v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

15 Jan 2024, 20:24

[Moderator's note: Topic moved from Bug Reports.]
Not sure if it's a bug when the parenthesis are omitted when the function call has []

Code: Select all

a := []
a.push "test"
MsgBox a[1]

m := Map()
m['a'] := []
m['a'].push "test"
MsgBox m['a'][1]
just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

16 Jan 2024, 07:29

If it isn't a bug a 'Common source of confusion:' note should be added to the docs.

(I always voted to remove the 'command syntax' as far as possible in v2!)
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

17 Jan 2024, 11:17

just me wrote:
16 Jan 2024, 07:29
(I always voted to remove the 'command syntax' as far as possible in v2!)
+1
when i was initially building the v2 converter i would never convert to the command syntax variant, to discourage users from using it. not sure what other contributors have done since

lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

19 Jan 2024, 06:01

Let go of the past; there is no command syntax in v2. Command syntax was never usable with methods in v1.

a.push "test" is a method call statement.
Parentheses can also be omitted when calling a method in this same context, but only when the target object is either a variable or a directly named property, such as myVar.myMethod or myVar.myProp.myMethod.
Source: Scripting Language | AutoHotkey v2

If it isn't a bug a 'Common source of confusion:' note should be added to the docs.
Exactly where and how might a user find such a note? The "Function Call Statement" section (quoted above) already explicitly states the conditions under which parentheses can be omitted. Is there some other part of the documentation which might lead the user to believe they can call a method without parentheses?
just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

19 Jan 2024, 07:04

If the return value of the function is not needed and the function name is written at the start of the line (or in other contexts which allow a statement, such as following else or a hotkey), the parentheses can be omitted.
IMO, all of that can be should have been eliminated in v2 to avoid confusion. But that did not happen, It therefore makes no sense to continue discussing it.

To avoid such errors you've always the option of not using the can bes.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

19 Jan 2024, 07:16

I think it might be a pity for V2 that it hasn't "kill" all.
lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0.11; v2.1-alpha.8] Command Syntax doesn't work when there are brackets in the command?

19 Jan 2024, 07:52

just me wrote:
19 Jan 2024, 07:04
IMO, all of that can be should have been eliminated in v2 to avoid confusion. But that did not happen, It therefore makes no sense to continue discussing it.
We weren't discussing it, were we? I didn't bring it up.
To avoid such errors you've always the option of not using the can bes.
I completely agree.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: docterry, mikeyww, nenyorp, niCode, vmech and 27 guests