Command syntax - "This parameter can be an expression"

Discuss the future of the AutoHotkey language
topsoftbe
Posts: 3
Joined: 17 Jan 2016, 07:16

Re: Command syntax - "This parameter can be an expression"

18 Jan 2016, 04:13

jNizM wrote:End of Commands and more Functions would be nice

From:

Code: Select all

MsgBox % "Output: " VarOut
MsgBox 64,, % "Output: " VarOut
MsgBox 64, % "Title - " Name, % "Output: " VarOut
To:

Code: Select all

MsgBox("Output: " VarOut)
MsgBox(64,, "Output: " VarOut)
MsgBox(64, "Title - " Name, "Output: " VarOut)
I completely agree with you...In your example there is a clear distinction between text and variables, as it should be.
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Command syntax - "This parameter can be an expression"

18 Jan 2016, 05:01

Code: Select all

MsgBox(64, "Title - " Name, "Output: " VarOut)
is already supported in v2 - see: Command(), or am I missing something?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Command syntax - "This parameter can be an expression"

18 Jan 2016, 05:11

Would not it be clearer, less confused and easier for new and beginner to learn and remember one thing like just the function syntax?
So how about remove the command syntax in v2? (e.g. MsgBox in v2)

I personal see no benefit for the command over the function syntax why we should have both.


*Sorry for my crap eng. It's hard for me to write what I think and mean.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Command syntax - "This parameter can be an expression"

18 Jan 2016, 05:22

It has been discussed already, no chance. Quite the contrary: "All functions can now be called as commands, including library functions which haven't been manually #included."
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Command syntax - "This parameter can be an expression"

18 Jan 2016, 08:02

jNizM wrote:Would not it be clearer, less confused and easier for new and beginner to learn and remember one thing like just the function syntax?
I personal see no benefit for the command over the function syntax why we should have both.
This would mean beginners need to learn expressions first before using AutoHotkey which is confusing when you are not a programmer.
Imagine below simple script would go over 1000 lines, users would need to write around 7500 more characters, even with suggested additional Gui functions you would need to write 5750 additional characters, that is just crazy.
It is like in AutoIt where you have to write $ before every variable to indicate that it is a variable, having only functions would mean to move in same direction (writing hundreds of useless characters).

Code: Select all

; Command syntax 79 characters
Gui,Add,Text,w100,Test
Gui,Add,Edit,w100,Test
Gui,Add,Button,w100,Test
Gui,Show

; Function syntax 109 characters
Gui("Add","Text","w100","Test")
Gui("Add","Edit","w100","Test")
Gui("Add","Button","w100","Test")
Gui("Show")

; Even with your shorthand functions
; 75 characters
GuiAdd,Text,w100,Test
GuiAdd,Edit,w100,Test
GuiAdd,Button,w100,Test
GuiShow

; Function syntax 98 characters
GuiAdd("Text","w100","Test")
GuiAdd("Edit","w100","Test")
GuiAdd("Button","w100","Test")
GuiShow()
User avatar
Gio
Posts: 1247
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Command syntax - "This parameter can be an expression"

22 Jan 2016, 11:10

Here is how learning the syntaxes occured to me:

AHK was the first programming language i learned and i clearly remember i grasped the way commands worked long before functions. However, most of the built-in functionality at the time was in fact based on command syntax, which means i HAD to grasp commands first, so i cannot really say that learning functions first would've been harder.

Also, even though i say i understood the way commands worked first, it actually took me much much longer to undestand it enougth to be able to easily figure out if a parameter needed expression syntax or not (i.e., even if a parameter was expecting a variable, i would still try enclosing it in percent signs first, which obviously resulted in no good).

So i guess that letting function syntax be the only syntax available seems to be the most reasonable idea for simplifying the syntax and avoiding newb confusion.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 104 guests