- @Helgef: Yes, I noticed a problem in the context of ternary operators, but the problem was a more general one. The problem appeared to relate to lists of items between parentheses, and so functions were also worth investigating.
- Admittedly various things that worked in AHK v1 may have given me false expectations of AHK v2.
- However, things like
var := 1,, var:=2 or
var := (1,,1), that don't work, you may have thought they might work.
- To be clear, () v. nothing gave *different errors*, see 'two different errors' above, the error wasn't simply that the third item in a ternary was missing, there was some other problem. I was trying to work out what it was.
- Thanks for the 'may be omitted from the middle' quote, I saw it in both the AHK v1 and v2 documentations, but it doesn't mention trailing parameters.
-
f(()), I guessed right, cheers. (It gives an error.)
- @coffee: FileAppend's Text parameter being optional does come as a surprise. RegWrite's Value parameter is stated as mandatory in the AHK v2 documentation, but appears to be optional.
- AHK itself uses the error message: 'Error: Blank parameter'. Admittedly 'blank' is ambiguous, although it's hard to improve on this term. Potentially it means: no parameter, or, a blank string.
- Btw I believe you may have some interesting recollections on the source code, you seem to have looked at it quite carefully. I'd be most interested on any comments you might have re. parsing scripts, SendInput v. ControlSend, and, hotkey handling, for example. If you wanted to start a new post on any source code views.
- Concerns re. trailing parameters aren't purely academic/imaginary:
Code: Select all
MyFunc(,"b","c","d","e")
;MyFunc(,"b","c","d",) ;doesn't work in AHK v1
oArray := [,"b","c","d",,"f"]
;oArray := [,"b","c","d",] ;doesn't work in AHK v1
oArray.Pop()
MyFunc(oArray*)
MyFunc(o*)
{
MsgBox(Format("{} {} {} {} {}", o*) " " o.Length())
;MsgBox, % Format("{} {} {} {} {}", o*) " " o.Length()
}
- @Helgef and @coffee: It's true that being able to omit trailing parameters like that, isn't really needed. I was trying to establish what was/wasn't possible with functions. The fact is, that, over the time I've been using AHK, the possibilities have been continually shifting.
- Also, I'm working on a functions tutorial, and it seemed a simple proposition to begin with, but it keeps getting fiddlier and fiddlier, as further nuances emerge.
- Two key points I was looking for:
[when could parameters be omitted in custom functions]
Functions
https://autohotkey.com/docs/Functions.htm
[v1.0.90+]: Optional parameters may be omitted from the middle of the parameter list when calling the function, as shown below. For dynamic function calls and method calls, this requires [v1.1.12+].
[when could parameters be omitted for use with objects][re. ComObjMissing:]
ComObjActive()
https://autohotkey.com/docs/commands/ComObjActive.htm
[v1.1.12+]: This function is obsolete. Instead, simply write two consecutive commas, as in Obj.Method(1,,3)