len = 1, size = 4
0 = 00000001
len = 1, size = 4
0 = 0000FFFF
len = 1, size = 4
0 = 00010000
len = 1, size = 4
0 = 075BCD15
len = 4, size = 16
0 = 00000001
1 = 0000FFFF
2 = 00010000
3 = 075BCD15
Seems like an Integer can be passed to a procedure that accepts an Array of Integers. Why is that?Yes, this is not reflected in the documentation.
Within the body of a routine, open array parameters are governed by the following rules.I have bold the last point. FPC extended this action not only for variables, but also for constants, but only those for which the type is set.
- They are always zero-based. The first element is 0, the second element is 1, and so forth. The standard Low and High functions return 0 and Length - 1, respectively. The SizeOf function returns the size of the actual array passed to the routine.
- They can be accessed by element only. Assignments to an entire open array parameter are not allowed.
- They can be passed to other procedures and functions only as open array parameters or untyped var parameters. They cannot be passed to SetLength.
- Instead of an array, you can pass a variable of the open array parameter's base type. It will be treated as an array of length 1.
Seems like an Integer can be passed to a procedure that accepts an Array of Integers. Why is that?
@simone:
...as the example clearly shows that you can't rely on the behaviour because as soon as you overload your code behaves differently (and without any warning or indication). imho useless and dangerous behaviour.
Creating another incompatibility to Delphi?
%)
Delphi Seattle refuses the example code with "constants cannot be used as open array arguments". For all four of the ones without [].
Please, test on FPC 32x.There is not a point in testing it if integer in Delphi has a different meaning.
it's noticeable that compatibility with Delphi isn't a consistent requirement. Sometimes it is, sometimes it isn't.