Smart pointers instead of GC?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Feb 4 20:22:22 PST 2014


On 2/4/14, 5:34 PM, Frank Bauer wrote:
> On Wednesday, 5 February 2014 at 00:50:55 UTC, Walter Bright wrote:
>> Again, what happens with:
>>
>>     T identity(T t) { return t; }
>>
>> ? I.e. the transference of the argument pointer type to the return type?
>
> As far as I see, in Rust the pointer type is lost on the return value as
> well, if your function takes a reference (borrowed pointer). But you can
> do:
>
> fn identity(x: &T) -> T {
>      return *T;
> }
>
> fn main() {
>      let a = ~T;
>      let r = ~identity(a);
> }
>
> That is: pass by reference and return a value type.

Looks like a major weakness.

Andrei



More information about the Digitalmars-d mailing list