DenialAdams / roland

Roland programming language
https://www.brick.codes/roland
Apache License 2.0
46 stars 0 forks source link

Malloc should return &unit instead of &u8? #122

Closed DenialAdams closed 5 months ago

DenialAdams commented 9 months ago

I'm actually not sure what the best thing here is. unit is closer to void in C, but void in C will auto-cast

Returning &unit would prevent people from accidentally using the pointer without casting? seems weak, but maybe

DenialAdams commented 5 months ago

I've decided to leave it. I like u8.

The big issue, I think, is what happens when we add an aligned malloc?

malloc_aligned(sz: usize, align: usize) -> ?

if we return &u8, the type system would disallow casting it to i.e. &u64.

Could add alignment tracking to the type system, but that seems mucho not worth it.

Could make alignment casting into a best-effort intraprocedural warning (with carve-outs for malloc_aligned)

Could just add a transmute_noalignchk and make people use it

IDK