Code: Select all
#IncorporateIf (A_AhkVersion < "2")
#NoEnv
#IncorporateIfEnd
- #Include can do a lot of this, but perhaps people might like this idea also.
Code: Select all
#IncorporateIf (A_AhkVersion < "2")
#NoEnv
#IncorporateIfEnd
Code: Select all
#IncorporateIf (A_AhkVersion < "2")
++ asd + asd+ sd asd~@~ ; valid due to "#IncorporateIf"
#IncorporateIfEnd
I agree.What you propose is disgusting.
Relying on #If a lot is one of the major reasons C and C++ lost to Java.
just stop.AutoHotkey v2 aims to improve the usability and convenience of the language and command set by sacrificing backward compatibility.
The extra work is put in only to achieve something that otherwise wouldn't be feasible, or would be achieved by some other means with (perhaps) even more work. #if does not create more work; writing one or both branches of the #if is just part of the work done to achieve some goal.#if creates more work for developers because the developer needs to write both sides of the branch.
Compatibility is mainly a side-effect of a number of other factors, such as the value I put in reusing familiar constructs rather than requiring new ones to be learned, the cost of change being greater than the cost of doing nothing, and general resistance to change where the value of that change is unclear.AutoHotkey v2 aims, to an extent, to minimise the number of AutoHotkey v1.1/v2 two-way compatibility issues.
Each and every new release aims to improve the program in some way. It is only natural that at least some of the changes which can be made to both versions are made, as long as I have any motivation to work on v1.1.AutoHotkey v1.1 aims, to an extent, to facilitate writing code that is forwards compatible with AutoHotkey v2.
other languages use better mechanisms - any mechanism is better than a huge else if ladder.The extra work is put in only to achieve something that otherwise wouldn't be feasible, or would be achieved by some other means with (perhaps) even more work. #if does not create more work; writing one or both branches of the #if is just part of the work done to achieve some goal.
It creates more work than a better way to create compatability across version - For example by providing proper APIs that dont rely on any specific implementation.For instance, having #if in C++ does not create more work for me. Having multiple build configurations which utilize #if - ANSI/Unicode x86/x64 exe/SC - creates more work. Without #if it wouldn't be worthwhile, and you would have only Unicode 32-bit exe (or perhaps the original ANSI build).
AutoHotkeys current #if is very different from C++ #if to the point where I would say that they are only related by name.As should be evident if you consider how AutoHotkey itself uses #if
The main uses of #if with their better alternatives:there are more uses to it than just supporting multiple versions of AutoHotkey. An author could use it for whatever purpose they want.
That doesn't change anything there are still 2 paths that can be taken even if there is no #else (go inside the #if/don't go inside the #if). You need to ensure that both sides are valid which is the actual work, not the typing.It should be obvious that it is not necessary to write both sides of the branch, just as it is not necessary when using if (expression). #ifdef or #ifndef is oftentimes used without #else.
Code: Select all
try global A_ComSpec := ComSpec
Code: Select all
#if cond
global a_comspec := comspec
#endif
Users browsing this forum: No registered users and 40 guests