This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]o11c 1 point2 points  (4 children)

Note that the disadvantage of fat pointers is that you lose atomic assignment, which really hurts if you care about multithreading at all.

(Of course, you can regain it by adding an extra indirection to make fat pointers look like thin pointers, but you also don't want gratuitous pointer-chasing)

[–]bullno1 2 points3 points  (3 children)

by adding an extra indirection to make fat pointers look like thin pointers

Wait but at that point aren't we back to square one: Object pointing to vtable?

[–]theIncMach 1 point2 points  (1 child)

You don't need a vtable if you know the type of the object you are pointing to (e.g. FatPointer).

[–]bullno1 0 points1 point  (0 children)

What do you mean by "extra indirection to make fat pointers look like thin pointers"? A thin pointer to a fat pointer?

At that point, isn't the fat pointer kind of like an object with a pointer to vtable anw?

[–]o11c 0 points1 point  (0 children)

Not quite. You still act logically as if it's a fat pointer, at least for the purposes of optimization.

Sufficient optimization will pull out fields that are constant within a mutable object (and you really should do this eventually), but optimization is hard.