AutoHotkey: uncommon syntax features

Talk about anything
User avatar
jeeswg
Posts: 6902
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 ... 4143#p4143
Last edited by jeeswg on 30 Jul 2018, 11:49, edited 10 times in total.
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
nnnik
Posts: 4500
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: 6902
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.)
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
nnnik
Posts: 4500
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: 6902
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)
instance of a class object
But only instances of class objects typically support obj.key in many/most languages. (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.
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
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey: uncommon syntax features

04 Oct 2018, 07:12

Links comparing programming languages:

Comparison of programming languages (syntax) - Wikipedia
https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)
Comparison of programming languages (string functions) - Wikipedia
https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)
Operator (computer programming) - Wikipedia
https://en.wikipedia.org/wiki/Operator_(computer_programming)#Operator_features_in_programming_languages
Operators in C and C++ - Wikipedia
https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

[mathematics functions in different languages]
Math Functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=54366&p=238635#p238635

Category:Programming language comparisons - Wikipedia
https://en.wikipedia.org/wiki/Category:Programming_language_comparisons
Category:Comparison of individual programming languages - Wikipedia
https://en.wikipedia.org/wiki/Category:Comparison_of_individual_programming_languages

Bonus link:
Print Hello World without semicolon in C/C++ - GeeksforGeeks
https://www.geeksforgeeks.org/print-hello-world-without-semicolon-in-ccpp/
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Off-topic Discussion”

Who is online

Users browsing this forum: No registered users and 30 guests