[rust-dev] Placement new and the loss of `new` to keywords

Kevin Ballard kevin at sb.org
Fri Nov 29 21:56:23 PST 2013


I am very saddened by the fact that we're apparently reserving `new` as a keyword, and even more by the fact that the proposed placement new syntax is `new(foo) bar`. This looks exactly like C++, and it goes against the strong precedence we already have of using new() as a static function for types. Path::init("foo") looks extremely wrong to me.

Surely there's another syntax we can use for placement new that doesn't involve reserving `new` as a keyword? Here's a few random ideas (where "val" is the value expression and "place" is the place expression):

~in(place) val
in(place) ~val
~val in place  (assuming this isn't somehow ambiguous)
~~val in place (the existing ~~val would have to be written ~(~val))
~~(place) val  (the existing ~~val would have to be written ~(~val))
~<place> val
~=place val
~>place val    (this looks like an arrow pointing to the place)
~>(place) val

Personally I think `~in(place) val` is perfectly fine. It's not the prettiest of syntaxes, but placement new should be very rare, and this allows us to avoid reserving `new` and continue to use ~ as the allocation operator.

-Kevin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4118 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20131129/0320acc9/attachment-0001.p7s>


More information about the Rust-dev mailing list