Page 1 of 1

Syntactic simplification for hotstring multiline

Posted: 28 Sep 2017, 08:56
by concepter
I propose to omit the return directive at the end of a multi-line hotstring definition when there is only one calling line to a function.
One case is that shown in the following link:
https://autohotkey.com/boards/viewtopic.php?t=36262
In fact, when we have only one call line to a function, the return directive could be considered implicit and therefore superfluous to have a compact and readable code.
From:

Code: Select all

::word::
	functionX(var)
	return
To:

Code: Select all

:F:word:: functionX(var)
introducing a directive F (or equivalent) at the beginning of the hotstring :F:word:: to interpret the right part not as a string but as a function.
If it was possible to introduce this modification even in AHK v1, for testing, it would be great!

Re: Syntactic simplification for hotstring multiline

Posted: 04 Oct 2017, 07:03
by _3D_
Evolution of language going to opposite and in the future maybe can`t be possible to write more that one command in the same line.
v2.0-a081-cad307c
if expression, expression ;no longer possible

Re: Syntactic simplification for hotstring multiline

Posted: 04 Oct 2017, 08:31
by jeeswg
I don't have a personal need for this, but the idea is potentially useful, and the syntax proposal of a new letter, although not necessarily the letter 'F' or 'f', is a good one.

I did think of 'F'/'f' at first, before seeing that you suggested it, but this could be made more general, possibly 'X' or 'x' for expression.

Code: Select all

;E.g. you could do:
:X:word::Func1(), Func2(), Func3()

;You can already do:
q::Func1(), Func2(), Func3()
At present, a workaround would be:

Code: Select all

oArray := {abc:1, def:2, ghi:3}
:*:abc::
:*:def::
:*:ghi::
MsgBox, % A_ThisHotkey
vFunc := oArray[SubStr(A_ThisHotkey, 4)]
Func%vFunc%()
return

Func1()
{
	MsgBox, % A_ThisFunc
}
Func2()
{
	MsgBox, % A_ThisFunc
}
Func3()
{
	MsgBox, % A_ThisFunc
}

Re: Syntactic simplification for hotstring multiline  Topic is solved

Posted: 26 Mar 2018, 03:40
by lexikos
The 'X' option was implemented in v1.1.28 and v2.0-a089.