> > * Use postfix syntax for pointer dereference, like in Pascal: > > (~rect).area() becomes rect~.area() . That reads left-to-right > > with nary a precedence mistake. > > > > While Rust?s auto-dereference feature and type checker will > > sometimes catch that mistake, it's better to just fix the failure > > mode. All security holes in the field got past the type checker > > and unit tests. > > > > Do you realise that `~rect` means "create an owned box [a pointer] that > contains `rect`" and isn't not a dereference in Rust? (That is performed > by `*rect`.) > > I would add that if pointer dereference were a suffix operator, it would have to be changed from * to (e.g.) ~. Why? Because if foo* means "dereference foo" then it becomes ambiguous whether "foo * - bar" means (foo*)-bar "dereference foo and subtract bar" or foo*(-bar) "multiply foo by negated bar". Due to this ambiguity, it is difficult for a language to simultaneously have
1. Operators that can be prefix or infix, and 2. Operators that can be infix or suffix. To avoid the ambiguity, one can introduce an operator like ~ that is prefix or suffix but never infix.
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev