Lexikos, thanks so much for the quick and very helpful answer. I'm embarrassed to say that all this time I've only been reading:
https://autohotkey.com/v2/v2-changes.htm
as a supersessor to just the regular v1 chm... and thinking that the two together gave me a complete picture of the latest with v2. Boy, was I wrong! Thanks for reminding me that this documentation exists. I will be doing more reading tonight, to make sure my not-so-complete picture is actually complete with your latest and greatest thoughts.
For what it's worth (maybe not much), I like the choice you've made to bind
return to the last sub-expression. It seems more intuitive to me too. I like to use it in short functions that set byrefs as well as returning a value -- especially when the ultimate return value depends on something derived from one of the byref sets. I know I could guarantee the execution order by putting the byref sets in a line above, but somehow (especially for short functions), I really like seeing the final byref sets and the ultimate return in that final line.
Related to this, I was wondering if you have time to answer two quick follow-ups...
1.
Python-style tuple unpacking. Because this is a language designed for non-programmers, I'm guessing that there will never be a sufficient use-case for Python-like tuple unpacking for multi-assignments and/or multi-returns, correct? There are often times when it would be nice to have
x, y := getpoint(inputs) or
r, g, b := getcolors(inputs) (where the return value of said functions is a simple array) without having to explicitly use/unpack an object. As you've reminded us in the past, nice-to-have/useful isn't always enough to justify the work and/or complication to the language -- and I'm guessing that's the case here, right? I'm also guessing that because AHK allows assignments within expressions (which Python doesn't), it would make parsing those statements significantly more challenging for the interpreter.
2.
Custom iterators with >2 byrefs. Ever since you turned me on to customizing iterators with your Fibonacci example, I've tried to customize/rework the iterators of my most-used objects to be more intuitive. Would it be overcomplicating the language or difficult to extend the
for k,v in obj syntax to optionally allow more than two vars, assuming a custom enumerator exists wtih the
next(byref v1, byref v2, byref v3) defining more than two byref params? For example, it would be very convenient and very readable to be able to do:
Code: Select all
for red, green, blue in colors
for street, city, state, zip in addresses
for pos, len, val in custom_matches
...
It seems like the functionality is close to that today. I think you can have multiple byrefs in next(), but you can't use the
for...in syntax to access anything beyond two of them. Correct? Do you feel like extending to more than two vars overcomplicates things or wouldn't be worth the implementation work?
Thanks again for all the help and all the work you do to make AHK such a great language!