[Gambas-user] Explictly sized array parameters in method signatures?

adamnt42 at ...626... adamnt42 at ...626...
Wed Jan 28 02:02:31 CET 2015


Hmm, I've never tried this before.

Suppose a function GetCurrent(DateRange as Date[]),  now intuitively DateRange is an array of 2 dates. No-one would be silly enough to pass an array with more than two elements would they?  My cynical nature says yes they could/would.

I could ignore the array length and just use DateRange[0] and DateRange[1] as the limits but that may produce confusing outcomes, or an error if DateRange contains only one element.

I would like to define the function as GetCurrent(DateRange as Date[2]) but this is apparently a syntax error.

Obviously, in this trivialised example, I could check the bounds of the passed array in the function body, I just expected that the runtime would  check an explicitly sized array parameter. The real function is (of course) much more complex. The function requires an array of Dates[3][2] and another 5 parameters, some of which are optional.

Any thoughts?

Bruce

-- 
B Bruen <adamnt42 at ...3379... (sort of)>




More information about the User mailing list