News for hackers. Stuff that matters.
Re:a[low:high:max] in Golang – A Rare Slice Trick by klodolph on Saturday March 18, 2023 @05:08PM (#35213127)
Const is a hard language feature to design well. There are a lot of pitfalls in the way const is used in C++ and TypeScript (I’m including “readonly” in the discussion).

Rust gets it right, but Rust is relatively complicated.

The languages which are most similar to Go are Java and C#, both of which also lack const types, or have a very limited version of constness.

Re:a[low:high:max] in Golang – A Rare Slice Trick by TwentyPosts on Sunday March 19, 2023 @05:10AM (#35217290)
What are some of these pitfalls in C++'s const design? I assume the issue is that it's difficult to guarantee const correctness as long as you have the ability to fiddle with pointers?

Function signatures showing when a parameter gets modified and when not (such as in Rust, or even in properly const-speckled C++) would benefit Go, but I'm not sure how difficult it'd be to implement that. I could see it being difficult considering that one of Go's core features (slices) results in opaque and overlapping memory ownership.