why was LoopParse (no space) removed?

Discuss the future of the AutoHotkey language
Helgef
Posts: 3227
Joined: 17 Jul 2016, 01:02
Contact:

Re: why was LoopParse (no space) removed?

07 Jan 2018, 13:56

Internallly, certainly LoopParse would be easier to detect compared to Loop Parse, in the sense that LoopParse doesn't need to be distinguished from Loop [Count] where the count expression starts with a variable named, eg, Parse. These examples are a bit ridiculous ofc, but still, it is not very nice,

Code: Select all

Parse := 2
var := 3
; Interpreted as a parsing loop
Loop Parse + var
	Msgbox "Loop 1:`t" A_index "`t" A_LoopField
; Interpreted as Loop count
Loop Parse+var 
	Msgbox "Loop 2:`t" A_index "`t" A_LoopField

; Load time error - not interpreted as loop count due to variable named 'Parse'
;Loop Parse . var 
;	Msgbox "Loop 3:`t" A_index "`t" A_LoopField

Having no particularly good reasons for allowing a comma here may mean this leads to removing the comma entirely, or maybe not
I prefer it without the comma, for some reason I've become unfond of initial commas :think: :)

Cheers.
User avatar
jeeswg
Posts: 5279
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

10 Apr 2018, 18:06

- I'm preparing some core function libraries for sharing.
- Is it feasible for Loop Count, for Count to be 'can be an expression' in AHK v1? Or is there some obstacle? I.e. that parameter 1 would be 'can be an expression' when Loop has only 1 parameter. Cf. WinMove which has special handling for when exactly 2 parameters are specified.
- That way virtually all of the loops would be two-way compatible, and I could fix any parsing loops (temporarily, with a comment) to use a for loop with StrSplit for full two-way compatibility.
lexikos
Posts: 6201
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: why was LoopParse (no space) removed?

11 Apr 2018, 23:08

Count cannot be an expression for the reason noted in the documentation.
User avatar
jeeswg
Posts: 5279
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

11 Apr 2018, 23:17

- Ah I see, the old-style File loop can also be one-parameter only.
- So I suppose for something like this to happen, it would need a directive. Thanks.

- [EDIT:] Another thing that could be helpful:

Code: Select all

for _, A_LoopField in StrSplit(vText, ",")
User avatar
jeeswg
Posts: 5279
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

22 Aug 2018, 14:08

I think this could work. I hope people like it.

Code: Select all

;AHK v2 only:
Loop expression

;AHK v1/v2 two-way compatible:
Loop integer ;e.g. Loop 3
Loop (expression) ;e.g. Loop (obj.Length()) ;must start with '(' and end with ')'
LoopFiles ...
LoopParse ...
LoopRead ...
LoopReg ...

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 4 guests