[Wish] funcReturn() - Any location,immediately return its call function

Discuss the future of the AutoHotkey language
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

[Wish] funcReturn() - Any location,immediately return its call function

18 Jul 2016, 05:44

If any location within the function, we can immediately return it. our script becomes simple.

Compare them

Older:

Code: Select all

Cycle(j,V){
	global
	loop
	{
		if f:=sort[j, A_Index, 1]
		{
			w:=sort[j, A_Index, 2]
			if sort[j, A_Index, 4]
			{
				if (%w% ~= sort[j, A_Index, 3]) and !Rondo(f "_" V)
					return
			}
			else    if sort[j, A_Index, %w%] and !Rondo(f "_" V)
					return
		}
		else    return  true
	}
}
funcReturn():

Code: Select all

Cycle(j,V){
	global
	loop
		(f:=sort[j, A_Index, 1])
			? (w:=sort[j, A_Index, 2],(sort[j, A_Index, 4]
				? (%w% ~= sort[j, A_Index, 3]) and !Rondo(f "_" V) ?FuncReturn():""
				: sort[j, A_Index, %w%] and !Rondo(f "_" V) ?FuncReturn():""))
			: FuncReturn(true)
}
guest3456
Posts: 3469
Joined: 09 Oct 2013, 10:31

Re: [Wish] funcReturn() - Any location,immediately return its call function

18 Jul 2016, 09:55

basically you want to use return in an expression

i made the mistake of thinking that was possible here:
https://autohotkey.com/boards/viewtopic.php?f=5&t=20252

but i disagree highly that using ternary makes the script "simple" :)

Guest

Re: [Wish] funcReturn() - Any location,immediately return its call function

18 Jul 2016, 12:26

guest3456 wrote:but i disagree highly that using ternary makes the script "simple" :)
+1
I would hate to have to debug the funcReturn() version if I hadn't looked at the code in a while.
Just because you can do something doesn't mean you should.
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: [Wish] funcReturn() - Any location,immediately return its call function

18 Jul 2016, 13:57

You can not seem to perceive its charm. :D
But I still think, if there is this function, some scenes will be very convenient.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 22 guests