On 11/30/13 1:24 AM, Kevin Ballard wrote:
Speaking of `new (x + y)`, has any thought been given to
differentiating `new (expr)` from placement-new?

Yeah, this came up. We can just define new followed by `(` to resolve in favor of placement new.

Given all this, my inclination at this point is to say that trying
to
piggyback on C++ programmers' familiarity of `new` is actually a really
bad idea, as Rust's allocation operator differs in a few important ways
from C++. In fact, offhand I can't think of any language with a `new
`operator that uses it for something other than invoking a class
constructor.

Well, there aren't many languages with allocation operators period: the vast majority of languages implicitly allocate on the heap. Of those languages with an allocation operator that isn't a function, it's universally `new` as far as I know.

The other suggestion that's been floated that satisfies all of these constraints is `alloc`, and honestly, if `new` is that unpopular maybe we should just switch to that. It's not that I'm unconcerned about `new()(1 + 2)` being weird: it's that I'm more concerned about what's not going to make C++ programmers run away.

Patrick

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to