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

Discuss the future of the AutoHotkey language
HotKeyIt
Posts: 1666
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] [Download] (Script.ahk)GeSHi © Codebox Plus

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] [Download] (Script.ahk)GeSHi © Codebox Plus

While (Expression,MoreExpressions,A_Index<3),MsgBox(A_Index)


What do you think?
User avatar
fincs
Posts: 500
Joined: 30 Sep 2013, 14:17
GitHub: fincs
Location: Seville, Spain
Contact:

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

27 Oct 2014, 07:42

+1
fincs
Windows 10 x64 Build 17134 / AutoHotkey v1.1.29.01
Get SciTE4AutoHotkey v3.0.06.01 - [My project list]
lexikos
Posts: 6042
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

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

27 Oct 2014, 20:33

Makes sense.
User avatar
joedf
Posts: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

27 Oct 2014, 20:56

No argument against it here...
just me
Posts: 5431
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: 1666
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] [Download] (Script.ahk)GeSHi © Codebox Plus

; 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: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
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++;}
just me
Posts: 5431
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: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
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:
User avatar
jNizM
Posts: 2318
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

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

29 Oct 2014, 02:14

Code: [Select all] [Download] GeSHi © Codebox Plus

010101110110100001111001001000000110111001101111011101000010000001101001011011100010000001000010011010010110111001100001011100100111100100111111
[AHK] 1.1.29.01 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
joedf
Posts: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

29 Oct 2014, 02:39

Code: [Select all] [Download] GeSHi © Codebox Plus

53 61 6d 65 20 73 68 69 7a 7a 6c 65 21 20 3b 29
Translator: xlate
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

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

29 Oct 2014, 07:38

How about For-loop?
just me
Posts: 5431
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: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
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
guest3456
Posts: 2359
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: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
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
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

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: 318
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
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: 6396
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

30 Oct 2014, 01:55

hoppfrosch wrote:Same here - readability rules! ;-)

Noooooooeeeess!!!! ;)
User avatar
fincs
Posts: 500
Joined: 30 Sep 2013, 14:17
GitHub: fincs
Location: Seville, Spain
Contact:

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

30 Oct 2014, 04:11

Claiming that

Code: [Select all] [Download] GeSHi © Codebox Plus

while wb.Busy, Sleep 10

is less readable than

is IMO extremely ludicrous.
fincs
Windows 10 x64 Build 17134 / AutoHotkey v1.1.29.01
Get SciTE4AutoHotkey v3.0.06.01 - [My project list]

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: HakitoJin and 4 guests