Open Akuli opened 10 months ago
Another idea: Add compiler warnings for common constness mistakes, like trying to mutate a string literal, and keep the syntax as is. I like the simplicity of pointer syntax without constness, and I think it is a good choice for Jou.
When working with pointers, you can avoid many bugs by marking them as const or mutable. For example, string literals should never be modified, so their type in C is
const char *
, which means that"hello"[2] = 'x'
will fail to compile. (Actually it is a mutablechar *
pointer for historical reasons, but ideally it would beconst char *
.)Jou could do something similar, but I want the syntax to be as obvious as possible. For example, I think it would be good to require a
mut
orconst
keyword instead of making one of them the default (Rust's default is const pointer, C's default is mutable).Some syntax ideas: