[Wish] One line while loop (similar to if)

Discuss the future of the AutoHotkey language
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

[Wish] One line while loop (similar to if)

27 Oct 2014, 07:23

Currently in v2 the last expression is used for While loop evaluation:

Code: Select all

While Expression,MoreExpressions,A_Index<3
  MsgBox % A_Index
I would love to be able to write While loop in one line, so it works the same way as if statement.

Code: Select all

While (Expression,MoreExpressions,A_Index<3),MsgBox(A_Index)
What do you think?
User avatar
fincs
Posts: 527
Joined: 30 Sep 2013, 14:17
Location: Seville, Spain
Contact:

Re: [Wish] One line while loop (similar to if)

27 Oct 2014, 07:42

+1
fincs
Windows 11 Pro (Version 22H2) | AMD Ryzen 7 3700X with 32 GB of RAM | AutoHotkey v2.0.0 + v1.1.36.02
Get SciTE4AutoHotkey v3.1.0 - [My project list]
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

27 Oct 2014, 20:56

No argument against it here...
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Wish] One line while loop (similar to if)

28 Oct 2014, 01:43

Readability?
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Wish] One line while loop (similar to if)

28 Oct 2014, 12:52

just me wrote:Readability?
It's up to the user I would say :)

Code: Select all

; both not good to read:
While (Expression,MoreExpressions,A_Index<3),v:=A_Index*2,a:=Func(v)
While Expression,MoreExpressions,A_Index<3
v:=A_Index*2,a:=Func(v)

; one liner is not as good to read but still okay in my view
While   (Expression, MoreExpressions,      A_Index<3),      v:=A_Index*2, a:=Func(v)
While   Expression,MoreExpressions,      A_Index<3
   v:=A_Index*2, a:=Func(v)
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

28 Oct 2014, 13:03

But I mean, if while is Optionally "one-liner"
I don't see the issue here. :P
Also, like C, new lines are basically not needed, which is pretty cool.
Eg while(x<100){x++;}
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 01:13

joedf wrote:Also, like C, new lines are basically not needed, which is pretty cool.
And the same is true for indentation. :roll:
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 02:11

just me wrote:
joedf wrote:Also, like C, new lines are basically not needed, which is pretty cool.
And the same is true for indentation. :roll:
;) Yes, Readability is bad! Avoid it at all costs! Write Machine code in HEX instead! :HeHe:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 02:14

Code: Select all

010101110110100001111001001000000110111001101111011101000010000001101001011011100010000001000010011010010110111001100001011100100111100100111111
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 02:39

Code: Select all

53 61 6d 65 20 73 68 69 7a 7a 6c 65 21 20 3b 29
Translator: xlate
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 07:38

How about For-loop?
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 11:05

Well, a new suggestion for the rebranding then: O(neline)S(cript)L(anguage). ;)
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 11:41

XD ok ok, yes eehh what about for-loop?, thx coco
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 12:55

no argument for it imo

also someone is gonna have to explain to me why multiple comma separated expressions are allowed within the 'while' parens

i'm with just me on the readability issue

User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 13:07

But it's optional! You don't have to use it! My point is that readability is also optional, that's why I'm saying there's no argument :P
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
Contact:

Re: [Wish] One line while loop (similar to if)

29 Oct 2014, 18:45

guest3456 wrote:also someone is gonna have to explain to me why multiple comma separated expressions are allowed within the 'while' parens
while accepts an expression and just like if, return, := and similar, multi-comma expressions are allowed. Same goes for For-loop.

As fore readability, this might be overkill, how about coming up with a style guideline similar to Python's. There's no need for users to follow the guideline but it'll come in handy for lib scripts, new users, etc.
User avatar
hoppfrosch
Posts: 443
Joined: 07 Oct 2013, 04:05
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: [Wish] One line while loop (similar to if)

30 Oct 2014, 00:34

Same here - readability rules! ;-)
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [Wish] One line while loop (similar to if)

30 Oct 2014, 01:55

hoppfrosch wrote:Same here - readability rules! ;-)
Noooooooeeeess!!!! ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
fincs
Posts: 527
Joined: 30 Sep 2013, 14:17
Location: Seville, Spain
Contact:

Re: [Wish] One line while loop (similar to if)

30 Oct 2014, 04:11

Claiming that

Code: Select all

while wb.Busy, Sleep 10
is less readable than

Code: Select all

while wb.Busy
    Sleep, 10
is IMO extremely ludicrous.
fincs
Windows 11 Pro (Version 22H2) | AMD Ryzen 7 3700X with 32 GB of RAM | AutoHotkey v2.0.0 + v1.1.36.02
Get SciTE4AutoHotkey v3.1.0 - [My project list]

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: Descolada and 31 guests