Forum > General
Array of Integer as parameter accepts Integers
TRon:
@marcov:
thank you for the verifcation
@jamie:
So in your view there is not an issue with the following ?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Foo(a: array of integer);beginend; procedure Foo(a: integer);beginend;
I do see a problem there but perhaps that is just me ?
@simone:
you might perhaps be in the minority but I would call it an abomination 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.
simone:
Tron, I agree. I'm glad there's at least one authoritative forum member who thinks the same way I do on this point.
440bx:
That Foo example really shows why the compiler should _not_ accept an integer variable as a single element array. It is ambiguous.
The compiler chooses the Foo with the integer parameter but, there is no indication of any kind that is the choice it makes.
The compiler should require the [] to eliminate the ambiguity its absence creates. The fact that it doesn't require it should be considered a bug.
@simone,
add 1 (me) to the count of members that agree with you.
jamie:
No, I don't see a problem with it, Compiler still generates an array which can be tested in code.
the brackets are only there to enclose multiple entries. either way, an array is created.
I'll step out the spotlight on this one because I would rather the compiler allow reduce syntax as much as possible.
alpine:
@simone
Count me also.
Navigation
[0] Message Index
[#] Next page
[*] Previous page