On Wed, Nov 20, 2013 at 10:27 AM, Patrick Walton <[email protected]>wrote:

> On 11/20/13 10:23 AM, David Piepgrass wrote:
>

 <snip>


>  It seems to me that the majority of languages have recognized that
>> references are easier to work with than pointers, and not just because you
>> can write "foo.f()" instead of "foo->f()". That is, I don't think
>> auto-deref (where foo.f() means (*foo).f()) is enough to eliminate the pain
>> of working with pointers instead of references.
>>
>
> This is because in most languages all object types are reference types and
> they rely on a GC, following Lisp.
>

But const references work out pretty well in C++, and it'd be hard to
accuse C++ of relying on GC.



> Would it help to define ~T, &T and @T as reference types rather than
>> pointer types? I'm sure there are some obvious objections, but perhaps the
>> problems could be ironed out by someone with a better grasp of Rust.
>>
>
> Doesn't work with custom smart pointers.
>

I'm sure something can be worked out for smart pointers with the help of
some kind of "AutoDeref" trait.



I'd also like to comment on the removal of "move". While I recognize
>> explicit moves everywhere might be inconvenient, I have noticed that
>> newbies on the list (including myself) are often confused by them. Would a
>> compromise be in order, in which moves are implicit except when passing
>> parameters to methods? I like Bill Byers' suggestion for call-site
>> parameters of the form "move x", "mut x" and just "x" for implicit copy /
>> borrow. Patrick mentioned the annoyance of writing
>>
>>   let move x = move foo(move y);
>>
>> but
>>
>>
>>   let x = foo(move y);
>>
>> doesn't sound so onerous, and it says something important about foo()
>> that someone reading the code might not realize.
>>
>
> -1. It'd be inconsistent to require it only in parameter position.
>

Well, it *would* be kind of consistent with Rust's policy "type inference
everywhere, except in function parameters".

Also, - look at this thread - people are concerned about ambiguous
mutability and moved-ness properties of function parameters, not about
ambiguity of the level of indirection.

I think that reference semantics for pointers combined with "foo(mut x);
foo(move y)';" would address the former while not introducing more syntax
noise required to disambiguate the latter.

Vadim
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to