﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
4101	Requesting consistency of the default value of $iStart/$iEnd in _Array* functions	anonymous		"Currently, the default value of {{{$iStart}}}/{{{$iEnd}}}/{{{$iStart_Row}}}/{{{$iEnd_Row}}} of the following _Array functions is 0 (zero):
{{{_ArrayBinarySearch}}}, {{{_ArrayFindAll}}}, {{{_ArrayReverse}}}, {{{_ArraySearch}}}, {{{_ArrayShuffle}}}, {{{_ArraySort}}}, {{{_ArrayTrim}}}

The default value of {{{$iStart}}}/{{{$iEnd}}}/{{{$iStart_Row}}}/{{{$iEnd_Row}}} of the following functions is -1:
{{{_ArrayExtract}}}, {{{_ArrayMax}}}, {{{_ArrayMaxIndex}}}, {{{_ArrayMin}}}, {{{_ArrayMinIndex}}}, {{{_ArraySwap}}}, {{{_ArrayToClip}}}, {{{_ArrayToString}}}


The inconsistency is one thing, but the more important thing is, zero is a valid value of index, right?

Consider this example:
{{{
Func FindSomething(ByRef $aArray, $sValue, $iStart, $iEnd)
	If Not IsArray($aArray) Or UBound($aArray) == 0 Then Return -1
	If $iStart < 0 Then $iStart = 0
	If $iEnd < 0 Then $iEnd = UBound($aArray) - 1
	If $iEnd < $iStart Then Return -1
	Local $iIndex = _ArraySearch($a, $sValue, $iStart, $iEnd)
	If @error Then Return -1
	Return $iIndex
EndFunc
}}}
This function's logic seems almost correct, except for when {{{$iStart}}} and {{{$iEnd}}} are 0.

Cases when calling {{{FindSomething()}}}:
	If {{{$iStart}}}/{{{$iEnd}}} are 1, it searches only {{{$aArray[1]}}}, correct.
	If {{{$iStart}}}/{{{$iEnd}}} are 2, it searches only {{{$aArray[2]}}}, correct.
	If {{{$iStart}}}/{{{$iEnd}}} are 0, it searches all items, incorrect.
	
That means, to make that function correct, the user has to individually handle the case of {{{$iStart}}}/{{{$iEnd}}} = 0 and write different code to search only the {{{$aArray[0]}}} for matches, how inconvenient 😒

And yeah, this may be a script breaking change if the user explicitly uses 0 as the default value instead of the keyword {{{Default}}} 😆"	Feature Request	new		AutoIt		None		_ArrayBinarySearch _ArrayFindAll _ArrayReverse _ArraySearch _ArrayShuffle _ArraySort _ArrayTrim	
