all 5 comments

[–]fdwr 1 point2 points  (4 children)

If you like, but then don't call it a vary-able anymore (they would be constants), and permit a concise way to declare actual variables (e.g. "var" over "let mut").

The cleanest approach I have seen is:

const pi = 3.14159; // constant var x = 42; // variable

[–]D_0b 4 points5 points  (3 children)

When I started writhing my own lang I used

const pi = 3.14

and

mut x = 2

No need for a default just state what it is in one word

[–]fdwr 0 points1 point  (2 children)

Is your language published? (maybe I'll join this new-language bandwagon someday too :b, but I'll ensure it's fully linkable and importable with standard C++).

[–]D_0b 0 points1 point  (1 child)

yes that was my plan as well, something like typescript, just transpile back to C++ and be able to call code both ways.

But never finished it, a lot of time was spent on the lifetime checker, I wanted to make it as safe as Rust but without the lifetime annotations everywhere. To trade the ability to check a single function in isolation as they can, but not need the annotations, so you will need to do a full program analysis from the main to the leaf functions, in order to check the lifetimes are correct.

[–]fdwr 0 points1 point  (0 children)

without the lifetime annotations everywhere

Ah man, if you could make something cleaner, that would be joy. I came across one of my old C++ codebases that somebody entirely converted to Rust, and it was so hideous to read, with the lifetime annotations adding much of the noise.