AutoHotkey: uncommon syntax features

Talk about anything
User avatar
jeeswg
Posts: 4965
Joined: 19 Dec 2016, 01:58
Location: UK

AutoHotkey: uncommon syntax features

29 Jul 2018, 08:17

- AutoHotkey has certain syntax features, and I was wondering if they exist in other common languages.
- (For the record, I really like some of these features e.g. !!, ~=, obj.key, flexible if statements, class/map crossover.)
- (I may add to this list in future. Do mention any other examples.)

- var1 := var2 [':=' for assignment, not '=']
- var1 <> var2 [equivalent to var1 != var2] [Excel sheets use this]
- var1 := !!var2 [the ability to do multiple logical nots, one alternative is a 'bool' (to bool) function]
- ~= [RegExMatch, see link lower down]
- = (as comparison operator) [Excel sheets use this]
- ; (as comment symbol)
- ` (as escape character) [a great idea since '\' interferes with paths and RegEx]
- obj.key := var (for linear/associative arrays) [in many languages you can only do 'obj[key] := var']
- When you create an object based on a custom class, you can assign any key to it like an associative array/map/dictionary. [This can be prevented by using a __Set meta-function.]
- Very flexible if statements. [Do any other languages have such flexible if statements?]
- A Mod function.

Other more common features, that AutoHotkey has, that not all major languages have:
- assign to a variable within an expression (Python lacks this)
- functions allow ByRef parameters
- functions allow default parameter values
- trailing semicolons not used
- ternary operator

Some common/uncommon features that AutoHotkey doesn't have:
- % (for modular arithmetic) [use Mod]
- ^ (for power) [use **] [Excel sheets use ^ for power] [AutoHotkey uses ^ for bitwise-exclusive-or]
- Pow [use **]

Links:
[birth of ~=]
Wishes for ~= (RegExMatch) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=496&p=4143#p4143
Last edited by jeeswg on 30 Jul 2018, 11:49, edited 10 times in total.
User avatar
nnnik
Posts: 3201
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoHotkey: uncommon syntax features

29 Jul 2018, 08:34

- var1 := var2 [':=' for assignment, not '=']
thats not very uncommon
- obj.key := var [in many languages you can only do 'obj[key] := var']
not uncommon either
- When you create an object based on a custom class, you can assign any key to it like an associative array/map/dictionary.
Thats an attribute of prototype based OOP and again it's not that uncommon
Recommends AHK Studio
User avatar
jeeswg
Posts: 4965
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey: uncommon syntax features

29 Jul 2018, 08:38

Thanks for your input nnnik. Btw could you add any examples to your post if possible, thanks. (These things can be hard to search for.)
User avatar
nnnik
Posts: 3201
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AutoHotkey: uncommon syntax features

29 Jul 2018, 09:24

Well := is from Pascal and = is from C.
While most major languages use =, := is not that uncommon if you compare all languages.

object.key is not uncommon at all. In AHK the object fulfills 3 roles. 2 of them are array and Object in a OOP sense.
Accessing Objects in classes is commonly done via obj.key where as obj[key] is used for arrays.

Another example for prototype based programming is javascript.
Recommends AHK Studio
User avatar
jeeswg
Posts: 4965
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey: uncommon syntax features

29 Jul 2018, 10:02

- Thanks v. much re. Pascal, I wouldn't have known that.
- Yes I find this surprising, the 3 roles:
linear array (list/vector)
associative array (map/dictionary)
class object
But only class objects typically support obj.key. (AutoHotkey allows obj.key for all 3.)
Do you know of any other languages that combine the three roles into one like AutoHotkey?
- It's interesting because you find that AutoHotkey has features from all sorts of languages.
- If anyone can pinpoint any truly unique features or especially uncommon features of AutoHotkey, that would be interesting.

Return to “Offtopic”

Who is online

Users browsing this forum: Jereklind, Spikea and 8 guests