AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Allow Functions in Addition to Labels for Timers, Etc.

 
Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  

What do you think of this idea?
It's a good idea.
75%
 75%  [ 12 ]
It's a bad idea.
0%
 0%  [ 0 ]
I like cheese.
25%
 25%  [ 4 ]
Total Votes : 16

Author Message
Piz



Joined: 15 Feb 2008
Posts: 43

PostPosted: Fri Apr 18, 2008 12:34 pm    Post subject: Allow Functions in Addition to Labels for Timers, Etc. Reply with quote

I would like to see the ability to use functions in addition to labels for setTimer and anywhere else labels can be specified as target code to be invoked, with a standard list of parameters that will be passed to the function when it's called.

Currently, every time I set a target label all I do is immediately call a function anyway - I try to avoid gosubs of any kind no matter what language I'm using.
Back to top
View user's profile Send private message
Rhys



Joined: 17 Apr 2007
Posts: 761
Location: Florida

PostPosted: Fri Apr 18, 2008 7:08 pm    Post subject: Re: Allow Functions in Addition to Labels for Timers, Etc. Reply with quote

Piz wrote:
I try to avoid gosubs of any kind no matter what language I'm using.
Why would you do this? I'm in the process of learning programming and kind of like being able to break things up into different parts by assigning different labels to them.
_________________
[Join IRC!]
Back to top
View user's profile Send private message
TheIrishThug



Joined: 19 Mar 2006
Posts: 419

PostPosted: Fri Apr 18, 2008 7:35 pm    Post subject: Reply with quote

GoTo and GoSub can result in code that is hard to follow if there is too much jumping around. You also leave yourself open to some variable troubles as things are not scoped.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Fri Apr 18, 2008 8:14 pm    Post subject: Reply with quote

It is good to have both. I voted for yes. Often, in complex scripts, I am also trieng to avoid subroutines and do need them only for wrapping function calls.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rhys



Joined: 17 Apr 2007
Posts: 761
Location: Florida

PostPosted: Fri Apr 18, 2008 8:37 pm    Post subject: Reply with quote

I think I've been using the idea of a function and a subroutine somewhat interchangeably.

I've used functions very little because I didn't want to be bothered with learning how to use them since I've done pretty well using subs... I can see where a few of my scripts would have been easier to write/follow when using a function instead of a subroutine, though.

Thanks for the info.
_________________
[Join IRC!]
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Fri Apr 18, 2008 10:20 pm    Post subject: Reply with quote

In my mind, a labeled subroutine is just a place, but a function is a thing to do.

For example, "Brothel" would be a label, while "Paid_Entertainer" would be a function.

Although you can do lots of things at a brothel, there are some things that a paid entertainer can do, places they can go, etc, that a brothel just can't accommodate.

For instance, how would a timer handle a function with a return value ? And how would it be different from
Code:
SetTimer, Somewhere, 1000
Somewhere:
var := SomeFunction( things )
return
???
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Tue May 27, 2008 3:29 pm    Post subject: Reply with quote

Hi all

Why I'd like to be able to call functions instead of labels for timers & al ?

Simple : I like not to have lingering global vars. So when I need a var in the timer code, the Timer branch calls a function in which I can declare locals which will not linger when timer code ends.

I'd really like to avoid label-to-function wrapping code.
Piz wrote:
with a standard list of parameters that will be passed to the function when it's called
or with nothing at all Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group