On 19/10/13 10:37, Jerry Morrison wrote:
* 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`.)
* Don’t let ; default its second operand. Require an explicit value,
even if (). That fixes an opportunity to goof that might be
frequent among programmers used to ending every statement with a ;.
`;` isn't a binary operator, and anyway `a; b` doesn't affect the
behaviour of `b` at all. Could you describe what you mean a little more?
(Also the type system means that writing `fn foo() -> int { 1; }` (with
the extra & incorrect semicolon) is caught immediately.)
* AIUI, let mut x, y defines 2 mutable variables but |mut x, y|
defines mutable x and immutable y. This is harder to learn and
easier to goof.
`let mut x, y` doesn't exist at the moment precisely because of the
confusion; one has to write `let mut x; let mut y;`. (Relatedly There is
a proposal to make `mut <ident>` a valid pattern, so that `let (mut x,
y)` is valid: https://github.com/mozilla/rust/issues/9792 )
Thanks for listening!
--
Jerry
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev