#What is the difference of a many-item pointer [*]T and an Array [N]T?
1 messages · Page 1 of 1 (latest)
its a pointer to an unknown amount of items
it's also what you get when you do []T.ptr
a slice "[]T" is just a [*] and a length
an array on the other hand, is not pointers. it's a real list of T
I didn't know that
I feel like some information about arrays are missing on the docs
I mean, that seems pretty important
like what?
this lol at least I didn't see anything about this
I read the whole array section thinking of pointers
this is the standard definition of an Array in basically all languages
nothing new
did you read: https://ziglang.org/documentation/master/#Arrays
yeah
I'm used to arrays like arrays in C
which are basically pointers
sorry
really?
all my life I thought of them as pointers
nope, they just freely coerce to the pointer of the element
in C terms, [*] is basically char* hello = "hello" and [N]T is like char hello[10]
ah, just to be clear
I know that in C:
char* hello = "hello";
// is not the same as
int x[10];
but the hello right there is in fact a pointer isn't it?
the variable hello in your example is a pointer to the first element of the array
exactly
all my life I thought that all arrays
even the x in my example were in fact pointers to the first element
that's something pretty dumb, but I never actually thought about what an array is lol
I just assumed they were pointers
just a region of memory thats next to each other
yes