While i like auto magic eg you could let region analysis work out the pointer type , borrowed pointers etc ,however you need to be very careful . C# uses ref but autoboxing is a major issue , you dont know when the struct is boxed ( there are some places besides the obvious virt call ) and then you incur boxing costs defeating the whole point of value types . The vast majority of C# developers only use structs for a few corner cases eg a type holding a few values ( many dont use value types at all) , they could go further but often it will get boxed somewhere and kill the benefits so why go through the hassle.
Ben On Wed, Nov 20, 2013 at 9:35 AM, Vadim <vadi...@gmail.com> wrote: > If the function is not going to mutate it, I don't really care if it's > by-ref or by-value. That's why I said "const T&", not "T&". Well, > except for the case when a function caches a reference to something which I > later mutate. But borrow checking will prevent that. > > I would also be totally fine with letting the compiler figure out how > immutable arguments are passed (based on data type size, existence of > destructors, and whatnot). This might not be the best idea for binary > compatibility of public APIs, but I don't see why it can't be done with > crate-private functions. > > > > > On Tue, Nov 19, 2013 at 5:07 PM, Ziad Hatahet <hata...@gmail.com> wrote: > >> > Personally I would prefer if & in Rust worked similar to const T& in c++ >> >> In that case, you would not be able to tell whether a function argument >> was passed by value or by reference. I actually like this feature about >> Rust (C# has it too with the `ref` keyword). >> >> -- >> Ziad >> >> >> On Tue, Nov 19, 2013 at 4:54 PM, Vadim <vadi...@gmail.com> wrote: >> >>> So why did Rust adopt auto-moving instead of explicit moving? If the >>> second example had to be written as foo(move a) there would be no >>> confusion. The and the third example should arguably be sort(mut >>> a.as_mut_slice()). >>> >>> Personally I would prefer if & in Rust worked similar to const T& in c++ >>> (i.e. for most intents and purposes you can treat a reference as a value), >>> otherwise half of the arguments on each function call will have to be >>> adorned with ampersands. >>> >>> Can we have it such that foo(a) would be guaranteed to not mutate or >>> move a and require "mut" or "move" prefix otherwise? >>> >>> >>> _______________________________________________ >>> Rust-dev mailing list >>> Rust-dev@mozilla.org >>> https://mail.mozilla.org/listinfo/rust-dev >>> >>> >> > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev