Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> It should have avoided the "∗" and "&" symbols then, IMNSHO.

Those operators aren't for pointer arithmetic…

> C# does this partially by using the "ref" keyword.

But C#'s reference parameters have no corresponding dereference operator, because they aren't first class and are limited to function parameters. As a result, most programs cannot be written without using the garbage collector in C#. In Rust, however, references can appear as first-class values, which makes them much more flexible—enough to supplant a garbage collector when combined with smart pointers—but requires that you annotate where they are created. `&` and `*` are well-known operators for this.



> Those operators aren't for pointer arithmetic…

That's the point of my suggestion! One looking at them will think they are pointer arithmetic, which is not pretty for newcomers.


Those operators aren't for pointer arithmetic in any language I know of, including Rust, C, C++, or Go. The operators for pointer arithmetic are plus and minus (technically square brackets too in C)--that's why it's called pointer arithmetic.


Ok sorry, I misused the term "pointer arithmetic" then. I think I was referring to memory indirection and the like. I find "ref" and "->" less cryptic than "&" and "*".


You can have pointers and memory indirection without being able to do arithmetic on pointers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: