In Rust "new(place) expr" means "call a special method on 'place' to create 
room for 'expr', then evaluate 'expr' with its destination set to that newly 
created location". A full description of "destination" is beyond the scope of 
this email :) But for function calls in particular, it means the hidden return 
pointer is set to the newly allocated location.

Patrick

"Gábor Lehel" <illiss...@gmail.com> wrote:
>On Sat, Nov 30, 2013 at 10:26 PM, Patrick Walton
><pcwal...@mozilla.com>wrote:
>
>> On 11/30/13 1:17 PM, Patrick Walton wrote:
>>
>>> Especially since the replacement
>>>> convention, as seen in PR #10697, is pretty bad (namely, using
>::init()
>>>> instead of ::new(); init() to me seems as though it should merely
>>>> initialize a value, not construct a new value. Heck, the old Path
>>>> convention of using Path(..) is better than Path::init(..)).
>>>>
>>>
>> Honestly, I'm not in love with `init` either. I don't find it
>particularly
>> intuitive, and alternatives are welcome. But I do think that using a
>sigil
>> for allocation and the lack of placement new are problems that needs
>fixing.
>
>
>Pretty basic question, but: what does placement new in a Rust context
>even
>mean, precisely? The very same thing as in C++?
>
>Because in C++ allocation and placement new are pretty orthogonal. If
>you
>write `new Foo`, it means: allocate memory for a Foo and run its
>constructor in that memory. If you write `new (foo) Foo`, it means:
>*don't*
>allocate memory, just construct a Foo directly into `foo`, which is
>some
>existing piece of memory I provide. So while `new` is the allocation
>operator, placement new is in fact just a funny syntax for running
>constructors. Which I think is confusing as heck.
>
>All of that leading up to: if these are different things, mightn't it
>make
>sense for Rust to use different syntax for them?
>
>(And if placement new in Rust is different from placement new in C++,
>then
>what's the difference?)
>
>
>
>>
>>
>> Patrick
>>
>> _______________________________________________
>> Rust-dev mailing list
>> Rust-dev@mozilla.org
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>
>
>
>-- 
>Your ship was destroyed in a monadic eruption.

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to