Stream: t-lang/wg-unsafe-code-guidelines

Topic: rc-terminology


gnzlbg (Sep 15 2019 at 13:26, on Zulip):

For ptr_eq we could just say: "Returns true if the two pointers compare equal. "

gnzlbg (Sep 15 2019 at 13:27, on Zulip):

for, e.g., strong_count(), instead of:

gnzlbg (Sep 15 2019 at 13:27, on Zulip):

Gets the number of strong (Rc) pointers to this value.

maybe we can just say

Gets the number of strong (Rc) pointers to this place.

gnzlbg (Sep 15 2019 at 13:29, on Zulip):

We don't have a definition of object anywhere, so using "reference-counted object" without such a definition feels weird

gnzlbg (Sep 15 2019 at 13:35, on Zulip):

Also, is the Rc even required to point to a valid T ? (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1df78c20870b2791ecb7fd5bd7840d6d) ?

RalfJ (Sep 16 2019 at 10:10, on Zulip):

We don't have a definition of object anywhere, so using "reference-counted object" without such a definition feels weird

we could expand the Rc docs to explain this. we currently have

The type Rc<T> provides shared ownership of a value of type T, allocated in the heap.

so we could expand that and introduce any terminology we need.

gnzlbg (Sep 16 2019 at 10:47, on Zulip):

@RalfJ one thing that confuses me is that "place" is currently defined as a "pointer"

gnzlbg (Sep 16 2019 at 10:47, on Zulip):

I think that the word we are looking for here is "allocation"

gnzlbg (Sep 16 2019 at 10:47, on Zulip):

A "place" is a pointer to a typed allocation, where the Rc stores the T is an "allocation", and what ptr_eq does is compare the addresses of the two allocations

gnzlbg (Sep 16 2019 at 10:49, on Zulip):

Do we have a definition of allocation in the ucg reference ? maybe we could add one and relate them to place in the glossary

gnzlbg (Sep 16 2019 at 10:49, on Zulip):

When people use object in the C++ object they mean a Rust value put in an allocation that's behind a place (giving the content of the allocation a type)

gnzlbg (Sep 16 2019 at 10:49, on Zulip):

the allocation itself is untyped

RalfJ (Sep 16 2019 at 10:55, on Zulip):

A "place" is a pointer to a typed allocation, where the Rc stores the T is an "allocation", and what ptr_eq does is compare the addresses of the two allocations

a place can also point inside an allocation, i.e., only reference parts of it

RalfJ (Sep 16 2019 at 10:55, on Zulip):

also allocations are not typed in Rust. memory in general isn't. only values (and places) are.

gnzlbg (Sep 16 2019 at 10:58, on Zulip):

Yes, which is why an Rc is similar to a Place, but it does not point to a place (it points to somewhere inside an allocation, it actually points to some offset after the start of an allocation, the ref count is stored before that offset in the same allocation)

gnzlbg (Sep 16 2019 at 10:59, on Zulip):

@RalfJ so we might want to be more clear about what "points to an allocation" means

gnzlbg (Sep 16 2019 at 11:00, on Zulip):

does it mean "points to the beginning of an allocation"?

gnzlbg (Sep 16 2019 at 11:00, on Zulip):

"points to somewhere inside it" ?

gnzlbg (Sep 16 2019 at 11:01, on Zulip):

I think that unless it is clarified, it can mean any of those, and therefore saying that the Rc points to an allocation containing a T is ok.

gnzlbg (Sep 16 2019 at 11:01, on Zulip):

It does not point to the beginning of such an allocation, but it does point to the beginning of a T within it

RalfJ (Sep 16 2019 at 11:09, on Zulip):

RalfJ so we might want to be more clear about what "points to an allocation" means

I'd just not talk about "pointing to an allocation" in Rc docs

gnzlbg (Sep 16 2019 at 12:50, on Zulip):

What would you say?

RalfJ (Sep 16 2019 at 13:01, on Zulip):

not sure, but not that^^

RalfJ (Sep 16 2019 at 13:02, on Zulip):

or something where both interpretations are basically correct

RalfJ (Sep 16 2019 at 13:03, on Zulip):

e.g. ptr_eq testing if both Rc "point to the same allocation" or so

gnzlbg (Sep 16 2019 at 15:34, on Zulip):

I'd just not talk about "pointing to an allocation" in Rc docs
e.g. ptr_eq testing if both Rc "point to the same allocation" or so

:laughter_tears:

gnzlbg (Sep 16 2019 at 15:34, on Zulip):

I'd be fine with that.

centril (Sep 16 2019 at 20:31, on Zulip):

"points to the same allocation" seems good, can't go wrong, I think

Last update: Nov 20 2019 at 11:25UTC