Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Available for testing: enhancements to function-calling


  • Please log in to reply
14 replies to this topic
Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Obsolete: See v1.1.12.

 

New features available for testing:

  • Optional parameters can be omitted by writing two consecutive commas, as in InStr(a, b,, 2).  Unlike previous versions, this works for objects (including COM objects) and built-in functions.  [a,,b] can be used to create a sparse array.
  • Object properties can be set using variadic syntax, as in x[y*] := z.  Previously this required z to contain the array of parameters.

Download - includes ANSI, Unicode and x64 exe files.
Source



fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Very nice, these changes will make it easier to design functions; and also use them happy.png
Also, what's up with the odd version number? I suppose it stands for vLatestStableVersion-NumberOfCommitsAhead+gLatestCommitHash.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

Works great! I ran it with a variety of large and complex scripts without any issues.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

fincs: The version number is based on the output of git describe, so yes, it is as you supposed.  It eliminates all effort and thought on my part, allowing me to completely automate the process of releasing test versions.

 

Uberi: Thanks for testing.



just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011
  • Object properties can be set using variadic syntax, as in x[y*] := z.  Previously this required z to contain the array of parameters.

Would you please provide an example on how it should be used? (I don't get it!)


Prefer ahkscript.org for the time being.


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

If you don't get it, you don't need it, so don't use it.

 

y := [1, 2], x[y*] := z would be equivalent to x[1, 2] := z.  The change is mostly to allow variadic __Set implementations to pass a variable number of parameters (between []).



faqbot
  • Members
  • 997 posts
  • Last active:
  • Joined: 10 Apr 2012
Very nice - thanks.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
The ANSI and Unicode binaries' filenames are interchanged.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Fixed.



just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011

..., you don't need it, ...

 

 

I think you're right, as always.

 

Previously this required z to contain the array of parameters.

 


Prefer ahkscript.org for the time being.


jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

...this works for objects (including COM objects) ...


Very nice! No more storing ComObj() as an underscore:
A1 := xl.Range("A1")
B1 := xl.Range("B1")
xl.Cells.Sort(A1, 1, B1,, 2,,, 1) ;// :-)

;// _ := ComObj()
;// xl.Cells.Sort(A1, 1, B1, _, 2, _, _, 1) ;// :-(
Any plans to modify optional params on the func defenition side for this? ie - optional parmas in the middle of the parm list, or being able to determine if an optional param was actualy passed w/o checking the default value?

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007

being able to determine if an optional param was actualy passed w/o checking the default value?

+1. I sometimes miss this. IsMissing() anyone? This may have major implications as it basically introduces a new datatype for AHK's expression evaluation code to handle (currently SYM_MISSING exists but only in function calls). Also, it wouldn't be possible to have a default value as the var would be overwritten therefore making it impossible to check for SYM_MISSING; this would require special syntax in the parameter list. Alternatively this may be implemented using a new internal flag in the Var type, and WasMissing() (happy.png) would check for it.

optional parmas in the middle of the parm list

-1. I don't think this is a good idea.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Any plans to modify optional params on the func [definition] side for this? ie - optional [params] in the middle of the [param] list, or being able to determine if an optional param was [actually] passed w/o checking the default value?

 

No.  You can work around the lack of either feature by using a variadic function.  The only exception I am aware of is that ByRef parameters can't be variadic.



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

The only exception I am aware of is that ByRef parameters can't be variadic.

 

Yes - this is primarily what I was looking for. Figured I'd ask since you stated ByRef variadic params wouldn't be implemented soon, if ever. Of course we can still use optional params with an extremely unique default value (EDIT) - such as:

Fn(ByRef out="…") {
	Msgbox % "User did " (out="…"? "NOT":"") " pass a value or variable reference."
}

Thanks again for the updates.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

You can already use IsByRef(param) to detect whether the caller passed a variable reference to a ByRef parameter.  However, you can't detect whether the value was defaulted or explicitly passed, as in Fn() vs Fn("") where the declaration is Fn(ByRef param := "") or Fn(param := "").