A_MajorAHKVersion

Propose new features and changes
User avatar
nnnik
Posts: 3459
Joined: 30 Sep 2013, 01:01
Location: Germany

A_MajorAHKVersion

13 Aug 2018, 10:09

Since making it possible to use built in variables in #Include the amounts of possiblities for #Include and A_ variables have increased quite a lot.
One use-case for these new features would be supporting severall versions of AHK by switching between includes automatically.
Sadly currently only the variable A_AHKVersion relates to the version of AHK that is used.
And you cannot simply differ between v1 and v2 inside #Include using that.

The variable A_MajorAHKVersion would return the most significant part of the AHK version information.
It would return whether the version is v1 or v2 (or potentially v3 in the future).

The variable A_AhkFork could also be added - for AHKs main fork its just empty.
That would make it easier for libraries to support side forks (like AHK_H).
However I dont think its that important.

I could look into implementing this if you generally approve the idea.

For reference - where I got the idea from:
https://autohotkey.com/boards/viewtopic ... 92#p233392
Recommends AHK Studio
User avatar
jeeswg
Posts: 5276
Joined: 19 Dec 2016, 01:58
Location: UK

Re: A_MajorAHKVersion

13 Aug 2018, 10:37

- Some ideas:
- A_AhkVersionMajor.
- Add the ability to do a conditional #Include.
- Perhaps this is better, as being forced to #Include files is generally very undesirable, versus keeping everything within one file which is preferable:
an equivalent to C++'s #if #else #endif - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=51373
- Special try blocks that don't crash the script. (The ordinary script start-up error checking would not be applied to such code, however, if an attempt was made to run such code (by an inappropriate AHK version), e.g. using a command with too few parameters, or an undefined function, the script would throw an error.)

- Whatever solutions are considered. I think that 'A_AhkVersionMajor', equal to 1 or 2 (or 3 ...), alongside the existing 'A_AhkVersion', would be very useful.
Last edited by jeeswg on 13 Aug 2018, 10:53, edited 1 time in total.
Helgef
Posts: 3226
Joined: 17 Jul 2016, 01:02
Contact:

Re: A_MajorAHKVersion

13 Aug 2018, 10:47

Maybe #include syntax in v2 will change. V2 shouldn't keep the syntax just to be compatible with v1. So I'd ask that before I'd make this wish.

Cheers.
User avatar
jeeswg
Posts: 5276
Joined: 19 Dec 2016, 01:58
Location: UK

Re: A_MajorAHKVersion

13 Aug 2018, 10:59

- @Helgef: Good point that #Include might change in future.
- For me the larger point is this. People just want to be able write AHK v1 code that they know will also work in AHK v2. And such people are willing to make many efforts to shape their AHK v1 code to make it possible.
- If that means an '#AhkV2CompatibilityMode' directive for AHK v1 scripts so that you can use AHK v2-style #Include lines in AHK v1, that could be an answer.
- The problem then becomes, would such a directive crash AHK v2 scripts.
- I'm reassured that other people are facing the same compatibility quandaries that I did, and feel sympathetic towards them. It's going to happen more and more.
Helgef
Posts: 3226
Joined: 17 Jul 2016, 01:02
Contact:

Re: A_MajorAHKVersion

13 Aug 2018, 11:14

I do not think many people wants to make much or hardly any effort at all for something like that.
User avatar
nnnik
Posts: 3459
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A_MajorAHKVersion

13 Aug 2018, 11:19

Yeah it would be nice if I could benchmark both AHK v1 and v2 but if I cannot make my library compatible it will stay v1.
Also I dont think that adding a new type of directive is necessary.
@Helgef while I would look forward to a change in #Include I highly doubt that the project is at a stage where that would happen anymore. (maybe in v3)
Nonetheless I think the variable has many use cases apart from just including.
Recommends AHK Studio
User avatar
jeeswg
Posts: 5276
Joined: 19 Dec 2016, 01:58
Location: UK

Re: A_MajorAHKVersion

01 Sep 2018, 11:39

- @nnnik: Here it says you look for the second dot, that would give 1.0/1.1/2.0 not 1/2.
Added A_AhkMajorVersion for v2 by nnnik · Pull Request #114 · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/pull/114
- So #Include would have to handle x.x not simply x.

- Also x.x is typically 'major.minor':
Software versioning - Wikipedia
https://en.wikipedia.org/wiki/Software_ ... ng_systems
GetVersion function (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
- Thus the variable should be A_MajMinAhkVersion or A_AhkVersionMajMin. So perhaps a name like A_AhkVersionMain or A_AhkVersionCore would be better.
- To call it 'Major' seems incorrect.

- Also if you put the word 'Major'/'Main' *AFTER* 'Version', the variables are more easily findable on the variables list.

- Doing something similar for A_OSVersion, would be worth considering. Returning x.x for A_AhkVersionMain and A_OSVersionMain seems like the most useful approach so far.
User avatar
nnnik
Posts: 3459
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A_MajorAHKVersion

01 Sep 2018, 13:51

Since you are replying to my topic I had to have a look at your post.
That is in fact a valid remark and I will take my time to explain my considerations here.

Major.Minor.Release is the system that Wikipedia is promoting.
But in AHK we use 4 numbers: (At least in v1)
When I try to assign the names that wikipedia assigned to corresponding places in our system I would do it like this:
"Major.undef.Minor.Release"
As you can see that second number is not part of the wikipedia system.
Therefore it is undefined or open for definition.

When I think of the use cases of an A_MajorVersion variable I would think of checking for unique feature sets or using special includes.
At least thats what I thought it was good for when creating it.
And the difference between v1.0 and v1.1 with regards to feature sets and the special includes needed are major.
Assuming that this system will stay the same thing could happen for v2.

Therefore I included that second digit in the variable A_AhkMajorVersion.
Recommends AHK Studio
User avatar
jeeswg
Posts: 5276
Joined: 19 Dec 2016, 01:58
Location: UK

Re: A_MajorAHKVersion

01 Sep 2018, 15:42

- Ah, I meant to ask, AHK v1 uses an 'x.x.xx.xx' form. Is there any documentation that specifies what each item is?
- To me (and others), 'x.x' for the AHK version and 'x.x' for the OS version would be equally useful.
- For the OS version at least, 'Major' would be an inappropriate term for 'x.x' ('major.minor'). So to have symmetry, I would suggest 'Main' or any other appropriate and aesthetic word.
- So A_AhkVersionMain and A_OSVersionMain, (or potentially A_MainAhkVersion/A_MainOSVersion, A_AhkMainVersion/A_OSMainVersion,) or something better.
- I've updated my Wish List 2.0 to reflect this. Cheers.
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789

[EDIT:]
This thread: A_MajorAhkVersion ['A_MajorOSVersion' wouldn't make sense for 'x.x']
GitHub link: A_AhkMajorVersion ['A_OSMajorVersion' wouldn't make sense for 'x.x']
Perhaps instead: A_AhkVersionMain / A_OSVersionMain [for 'x.x']

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 4 guests