Skip to content

Rename @ to GC<T> #9796

Closed
Closed
@brson

Description

@brson

Don't have time to put a full description here, but here are some random notes.

Update this with the actual plan once we know it.

We didn't really decide anything today; just discussing how to move GC into the libs. Here are the notes.

- pcwalton: want to talk about GC, DSTs
  - `my_smart_pointer.as_ref().some_method()`
  - If we have `GC<Mut<T>>`
    - `my_smart_pointer.as_ref().as_ref().some_method()`
- You could do `fn foo(Foo<self>, ...)`
- Absolute minimum things for 1.0 if we wanted to do `@T` => `GC<T>`
  - change `@T` to `GC<T>`
  - change `@T` constructor to placement new, `in`
  - generalize explicit self to accept smart pointer declarations
    like `GC<self>`, `GC<Mut<self>>`

Unclear to me if this should work:
- GC<[T]>
- ~[T], &[T] ==>

- GC<Trait> <-- this would be nice to have, but maybe it can wait
- GC<~Trait> <-- potential workaround

- Eventually we'd probably want an overloaded `*`, but we can (for now) make GC a lang item and just do built-in deref

trait Trait {
fn foo(GC<Mut>, ...)
fn bar(&self, ...)
fn baz(&mut self, ...)
fn xyz(self, ...)
}
fn boo(Anything<I<Want>>, ...)

obj: GC<Mut>
obj.foo()
obj.as_ref().bar() <-- explicit freeze?
obj.as_mut_ref().baz() <-- explicit mut borrow?

impl Trait for GC<Mut> {
fn foo(GC<Mut) {
self: GC<Mut<GC<Mut>>>
}
fn bar(&self) {
self: &GC<Mut>
}
...
fn xyz(self) {
self: GC<Mut>
}
}


brson asks what about `fn foo(&RC<self>, ...)`.
nmatsakis: why not? should be possible to make it work
brson: would allow you to take RC<self> "by ref" (not cloning)

Nominating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions