| View previous topic :: View next topic |
| Author |
Message |
Piz
Joined: 16 Feb 2008 Posts: 46
|
Posted: Wed Feb 27, 2008 2:40 am Post subject: A_CallerFunc |
|
|
In the same vein as A_ThisFunc, how about A_CallerFunc?* Not the current function, but the one that called the current function.
*I'm not married to the name, just illustrating the idea. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5697
|
Posted: Wed Feb 27, 2008 8:41 am Post subject: |
|
|
| Code: | Func1( "Hello" )
Func1( Str ) {
Func2( Str, A_ThisFunc )
}
Func2( Str, A_CallerFunc ) {
MsgBox,0, %A_CallerFunc%, %Str%
} |
Am I missing something ?  |
|
| Back to top |
|
 |
Piz
Joined: 16 Feb 2008 Posts: 46
|
Posted: Wed Feb 27, 2008 12:58 pm Post subject: |
|
|
| SKAN wrote: | Am I missing something ?  |
A bit. I want to avoid having to pass A_ThisFunc as a parameter in order for a function to know what called it: | Code: | Func1("Hello")
Func1(str)
{
Func2(str)
}
Func2(str)
{
msgBox 0, %A_CallerFunc%, %Str%
}
|
With the new capability I'm suggesting, the above will produce the same result as yours. (Of course at present it won't work.) |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 383 Location: Berlin
|
Posted: Sun Mar 02, 2008 7:49 pm Post subject: |
|
|
| I have same thoughts about a built-in A_CallerFunc. The user should not need to pass A_ThisFunc or know about this. |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 900
|
Posted: Mon Mar 03, 2008 12:21 am Post subject: |
|
|
| I'm having a hard time imagining when you would use this. Honestly it doesn't seem like a very good idea to make a function that "cares" where it's called from. It would be more confusing than useful IMHO. Though I'm curious to hear what you would use this feature for if you had it. |
|
| Back to top |
|
 |
Piz
Joined: 16 Feb 2008 Posts: 46
|
Posted: Mon Mar 03, 2008 12:50 am Post subject: |
|
|
| ManaUser wrote: | | I'm having a hard time imagining when you would use this. Honestly it doesn't seem like a very good idea to make a function that "cares" where it's called from. It would be more confusing than useful IMHO. Though I'm curious to hear what you would use this feature for if you had it. | It could be useful for debugging and maintaining log files, to name two simple examples.
Let me turn it around on you - why would you write a function that requires you to pass in A_ThisFunc as a parameter? And if there's no reason to do that, why have A_ThisFunc at all? |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1332
|
Posted: Mon Mar 03, 2008 12:53 am Post subject: |
|
|
| Quote: | | why have A_ThisFunc at all? |
you shouldnt  |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 900
|
Posted: Mon Mar 03, 2008 1:49 am Post subject: |
|
|
| Piz wrote: | | Let me turn it around on you - why would you write a function that requires you to pass in A_ThisFunc as a parameter? And if there's no reason to do that, why have A_ThisFunc at all? |
Now that you mention it, I can't think of a real good reason for that either. It was probably added mostly because there was already A_ThisLabel and A_ThisHotkey. |
|
| Back to top |
|
 |
|