Liste des Groupes | Revenir à cl c |
On 11/07/2024 13:22, bart wrote:
If the original array has type T[N], then the T is passed, but the N is lost. The [] is also lost:; it turns into *. But in C, that doesn't matter too much; it can still index that object!
Not it isn't. The fact that I can do this:(Here I'm talking about info attached to the parameter name; the type itself may still have that N. Have I mentioned that C is mess?)You've mentioned very clearly that your understanding of C is a mess. C itself is quite simple here,
and the rules are not hard to understand.Ha ha ha! Of course you would say that. Let me try that same example:
I'm defining a fixed-size array of 4 ints. It can be passed to a function expecting exactly that type, OR to a function expecting an unbounded array (OR to a function expecting a slice of 'int').type T = [4]intThat is completely different. Your language has a way to attach the size of an array into a type, and the characteristics follow that type declared in the function prototype. That's fine, but it is a different thing entirely from saying that it is passed with the array itself. What you are doing here is much the same as wrapping a C array in a struct and passing that (as a value).
Oh, what makes you say that?Here my language uses the type []T (or [0]T). The empty bounds serve rhe same purpose as void* type: they will match any array bounds.OK, so you do the same as C but with a different syntax. Presumably you think your syntax is vastly nicer than that of C, and will get your knickers in a twist if anyone says differently, but "niceness" is a matter of opinion.
You are still not passing indefinitely sized arrays by reference.
I haven't mentioned syntax at all. I've talked about type systems and array passing, and how, when I enumerated 3 kinds of parameter passing in my language, C's parameter passing most matched either number (1) or (3) of mine depending on parameter type. (3) was pass-by-reference.>And yet, strangely, the world has been quite happy using C for half a century while I have yet to hear anyone say your language looks great.
In this case, while those 3 characteristics are still passed, the length one is not useful as it's always 0. Additional info is needed.
>
>So perhaps your confusion here lies in a misunderstanding of how arrays as passed in your own language, and you have carried that confusion over to C.>
Actually my language has a much tidier and more orthogonal type system, and there are no discontinuities such as expressions suddenly decaying to pointers whenever they threaten to yield an array type.
>
As such, it would much easier to teach, and could serve as a model against which C can be compared, and points of deviance noted.
I have some doubts that /you/ do!It combines the A and N parameters commonly passed to functions, into a composite object. It is not entirely different!Yes, it is.
>
This thread would be so much simpler if you knew what you were talking about, or at least accepted that other people do.
Les messages affichés proviennent d'usenet.