Open KCreate opened 7 years ago
I guess we should also talk about higher-order types (kinds?) as well:
etc
Ah yes! Totally forgot these. I do want structs and unions.
I don't think a pre-defined array type would make sense. What if people are not happy with our implementation?
Do people often complain about C's pre-defined array type/syntax?
Oh, you mean array types as in being fixed-length and with no predefined methods for them.
Yea that would be good to have as well.
Yep!
I would call the other kind "lists", perhaps
Is it a good idea to ship pre-defined "higher-level" data structures with the compiler? Wouldn't that go into a stdlib?
I think stdlib, yes.
I've updated the main comment.
Are you sure about the lack of need for fixed-length array? We have the opportunity to avoid some mistakes that currently exist in other programming languages.
@KCreate what types will random integers have? Like if I do 5+6
will those be u8
s? Bigger?
The default types for number literals are int
and float
in C/C++. What does Rust do?
Arrays strike me as a fundamental datatype. The one change I made in Mu was to always have them include their length.
Following a quick search, from https://github.com/rust-lang/rust-by-example/issues/832 it looks like default is u32
and ... not sure.
Ok, so same as C then.
I would prefer we use f32
, f64
rather than float
, double
if we're naming the int sizes the way we are.
@tekknolagi Agreed, f32 and f64 are better. Also default types should be i32 and f32. If the number literal won't fit into a i32, make it a i64.
I'll have to think about including the length in arrays.
Also, take a look at how crystal does it
What types should come built-in with the compiler?
My proposal would be to have the following primitive types included.
u8
,i8
u16
,i16
u32
,i32
u64
,i64
f32
,f64
struct
,union
We won't need a type for a fixed-length array since we can represent that with a pointer to the element type. All other types would then just be typedefs / mapped / aliased to these primitives.