3 ms·
> "str is an array 10 of pointers to char" Wow, imagine if it was possible to actually use a language like that do declare the type of the variable like that?
by Joker_vD 3mo ago
> "str is an array 10 of pointers to char"
Wow, imagine if it was possible to actually use a language like that do declare the type of the variable like that? Something like
str: array [0..9] of ^Char;
or even
var str [10]*uint8
Just imagine...
- HarHarVeryFunny 3mo agoYeah, Pascal is very readable, and ^Char is nicer than char* even if inconsistently concise (might expect "pointer to Char").
- xigoi 3mo agoOr even var str: array[10, ptr char]
- Joker_vD 3mo agoEh, or that, I guess. I personally would rather not squish the type of the elements together with the dimensions, but it can work like that, sure. Especially if you use square brackets for generic instantiation, so your example is semantically close to std::array<char*, 10> of C++. But if the language uses the square brackets (almost) exclusively for array indexing, then having simply "[10]" prefix as a shorthand for "array of 10 of ..." à la Zig/Go is quite reasonable. Then again, Go does use square brackets both for instantiation of generics and for array-related operations so... I guess they had the syntax of map types as a precedent.
- xigoi 3mo ago> Especially if you use square brackets for generic instantiation, so your example is semantically close to std::array<char*, 10> of C++. Yes, it is like that.