This would make for some interesting/confusing calling conventions. It
would also mean &T and &mut T would no longer share a representation; &int
would simply be int, but &mut int would still have to be a pointer.
Borrowing &mut T to &T would be a dereference if T is pointer size or
smaller? The only reliable way of taking an address would be taking &mut
because & would fail for some types. Transmuting *something to &something
or back would fail for some types, unless we make transmute smarter.

I think for our sanity it would be best to let LLVM perform this kind of
magic when it figures out we won't notice the difference.

On Mon, Jul 29, 2013 at 4:47 PM, Gábor Lehel <illiss...@gmail.com> wrote:

> On Sun, Jul 28, 2013 at 11:54 PM, Daniel Micay <danielmi...@gmail.com>
> wrote:
> > On Sun, Jul 28, 2013 at 4:54 PM, Brian Anderson <bander...@mozilla.com>
> wrote:
> >> FWIW I prefer the terms box and reference. I don't really understand the
> >> idea that only * is 'semantically a pointer' though.
> >
> > Unique boxes can be implemented without a pointer as long as the type
> > is no larger than the slot needed to contain a pointer-size object.
> > The pointer itself just isn't part of the type's contract, since
> > there's no pointer arithmetic.
>
> Hmm. Given immutability, in the absence of Cell or destructors, ditto
> for &T and @T? Do we even specify that it will be pointer-sized?
>
> Kind of amusing: you could have &&&&@@~~@@~~int with the same
> representation as int, and "dereferencing" at each level just
> transmute(self).
>
> It may look like this is only of theoretical interest, because no one
> in their right mind would pass int by pointer, but it would be a
> useful optimization for generic code - for the same reason.
>
> --
> Your ship was destroyed in a monadic eruption.
> _______________________________________________
> 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

Reply via email to