functions: terminology: not ByRef/static/variadic

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

functions: terminology: not ByRef/static/variadic

03 Aug 2017, 15:09

I am preparing a little something re. functions. I was wondering if anyone had any advice on terminology.

Here are all the key concept words for functions that I've found:
- scope: local/global/super-global variables
- static variables (v. 'forgotten' variables)
- ByRef variables (v. 'copied' variables) [perhaps: ByRef parameters v. ByVal parameters?]
- variadic functions (v. 'fixed number of parameters' functions)

I noticed here:
How to Convert Temperature (K) to RGB: Algorithm and Sample Code – Tanner Helland (dot) com ... ithm-code/
the use of 'ByRef' and 'ByVal'.

Anyhow I'm looking for any common words/phrases that are the opposites of: static, ByRef and variadic. And also, to ask whether anything passed to a function that isn't ByRef is therefore ByVal, or if there are other ByXXX possibilities in AHK/other programming languages.

Btw do mention if there are any other key function concepts in AHK/other programming languages, not listed above. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Posts: 1553
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: functions: terminology: not ByRef/static/variadic

03 Aug 2017, 16:07

I'd personally not want to get into other languages.. There are so many variances, even just regarding variables.

By default, any passed parameter is copied from the original variable to a temporary, local variable. Note that with objects, you're passing a reference, so there's virtually no difference (it will edit the object as it would edit a regular variable using ByRef).

The opposite of variadic is simply one parameter (regular). Every function has an arity, which is the sum of all given parameters (the number of, not relevant of the parameters values). When you have a variadic function, it as an indefinite arity, or indefinite amount of parameters. Otherwise, it has a definite arity, as all parameters are statically defined.

Not sure what you mean by 'forgotten variable', but static variables simply keep their value between calls of a function or class, while keeping to the local scope of it's respective structure. A permanent local variable. The opposite would simply be a regular local variable.

Scopes are very, very important to keep variables organized. Having been working with JavaScript recently, which has a very strange, global-like namespace for everything, I no longer take such for granted. Local variables are local to their respective namespace, which can be a function, class, or part of 'main'. In C++, it's a bit more organized, with using actual subroutines for actually running things. They're essentially functions, but they're not necessarily intended to be re-used. Outside of the subroutines is the global namespace. Any variables specified there may be accessed by any other subroutine, but not functions. Stating a variable as global in the global namespace makes it super-global, which means that it can be accessed from functions. Functions may also state the variable as global to a regular global (stating so for a super-global would be redundant) to have them access the variable from the global namespace, whether it exists already or not. All of these then compile and supersede each other in certain hierarchy. Super-globals take precedence over everything. If a super-global is stated, you can no longer use the variable name anywhere else to assign it to a different namespace. In AHK, I'm not sure if the global is actually global, or inside of main(). I could go look at the source to figure that out, but I haven't had the need. Regardless, we can assume that if we open a script and define a variable, not inside anything, that it's considered global, which can then be referenced from functions or classes using the global prefix, making them the middle hierarchy. Local variables may only be used inside of their namespace, such as a function, so they are the lowest of the hierarchy and therefore can't supersede anything.

Not sure if that's what you were looking for, but hope it helped.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
Posts: 4663
Joined: 17 Jul 2016, 01:02

Re: functions: terminology: not ByRef/static/variadic

03 Aug 2017, 17:05

Hello jeeswg and Masonjar13 :wave:
do mention if there are any other key function concepts
I'd say call and return are key function concepts.


Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], davegish, dox, GabeCalderon, geoffh, Green Astronaut, HiSoKa, JoeWinograd, millansoft, sanmaodo, TAC109, XMCQCX, yalsch and 51 guests