| View previous topic :: View next topic |
| What do you think of this idea? |
| It's a good idea. |
|
75% |
[ 12 ] |
| It's a bad idea. |
|
0% |
[ 0 ] |
| I like cheese. |
|
25% |
[ 4 ] |
|
| Total Votes : 16 |
|
| Author |
Message |
Piz
Joined: 15 Feb 2008 Posts: 43
|
Posted: Fri Apr 18, 2008 12:34 pm Post subject: Allow Functions in Addition to Labels for Timers, Etc. |
|
|
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 |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 761 Location: Florida
|
Posted: Fri Apr 18, 2008 7:08 pm Post subject: Re: Allow Functions in Addition to Labels for Timers, Etc. |
|
|
| 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 |
|
 |
TheIrishThug
Joined: 19 Mar 2006 Posts: 419
|
Posted: Fri Apr 18, 2008 7:35 pm Post subject: |
|
|
| 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 |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Fri Apr 18, 2008 8:14 pm Post subject: |
|
|
| 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 |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 761 Location: Florida
|
Posted: Fri Apr 18, 2008 8:37 pm Post subject: |
|
|
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 |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Fri Apr 18, 2008 10:20 pm Post subject: |
|
|
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 |
|
 |
Azerty
Joined: 19 Dec 2006 Posts: 72 Location: France
|
Posted: Tue May 27, 2008 3:29 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
|