tekknolagi / stackx

MIT License
2 stars 0 forks source link

Built-in Types #5

Open KCreate opened 7 years ago

KCreate commented 7 years ago

What types should come built-in with the compiler?

My proposal would be to have the following primitive types included.

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.

tekknolagi commented 7 years ago

I guess we should also talk about higher-order types (kinds?) as well:

etc

KCreate commented 7 years ago

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?

tekknolagi commented 7 years ago

Do people often complain about C's pre-defined array type/syntax?

KCreate commented 7 years ago

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.

tekknolagi commented 7 years ago

Yep!

tekknolagi commented 7 years ago

I would call the other kind "lists", perhaps

KCreate commented 7 years ago

Is it a good idea to ship pre-defined "higher-level" data structures with the compiler? Wouldn't that go into a stdlib?

tekknolagi commented 7 years ago

I think stdlib, yes.

KCreate commented 7 years ago

I've updated the main comment.

tekknolagi commented 7 years ago

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.

tekknolagi commented 7 years ago

@KCreate what types will random integers have? Like if I do 5+6 will those be u8s? Bigger?

akkartik commented 7 years ago

The default types for number literals are int and float in C/C++. What does Rust do?

akkartik commented 7 years ago

Arrays strike me as a fundamental datatype. The one change I made in Mu was to always have them include their length.

tekknolagi commented 7 years ago

Following a quick search, from https://github.com/rust-lang/rust-by-example/issues/832 it looks like default is u32 and ... not sure.

akkartik commented 7 years ago

Ok, so same as C then.

tekknolagi commented 7 years ago

I would prefer we use f32, f64 rather than float, double if we're naming the int sizes the way we are.

KCreate commented 7 years ago

@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.

KCreate commented 7 years ago

Also, take a look at how crystal does it