> 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.

I much prefer `new` to `alloc`. It *is* a shame that `foo::new()` has to
change, but `alloc` is much grosser than `init`. And maybe we can think of
a better naming convention for constructors... perhaps `foo::make()`.

Honestly, `new` seems ideal here. Easier to type than `~` and easier on the
eyes than `alloc`. The only argument that I can think of against it would
be if its semantics are different enough from C++ that it would cause more
confusion than it alleviates.


On Sat, Nov 30, 2013 at 4:54 PM, Patrick Walton <[email protected]>wrote:

> 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
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to