Skip to content

Conversation

@MasonProtter
Copy link
Contributor

I know this can be a bit implementation-detail-ey, but I think in practice it's good to be able to know if an object is backed by a pointer or if it's inline allocated. This is also a function used a lot by certain packages, so it'd be good if we made it public API.

I'm very open to suggestions on how to make the docstring more appropriate or not make promises the language devs don't want to make.

@vtjnash
Copy link
Member

vtjnash commented Nov 17, 2025

I think in practice it's good to be able to know if an object is backed by a pointer or if it's inline allocated

This might be good to know, but this is a very bad way to query that. The function might be better named "sometimes_allocated_inline", since it doesn't tell you if it is allocated inline, just if it potentially sometimes might be in some uses. It also doesn't tell you that much about whether it can throw an UndefVarError, since that is also a different query defined differently elsewhere in the manual.

@MasonProtter
Copy link
Contributor Author

The function might be better named "sometimes_allocated_inline", since it doesn't tell you if it is allocated inline, just if it potentially sometimes might be in some uses.

But as a field of a struct or an element of an Array, it's accurate, right? Base at least seems to make the assumption in various places that !allocatedinline(T) implies the object is pointer-backed. If this is not always accurate for struct fields or array elements then it'd be quite important to share that knowledge, and inform the packages that are using this.

It also doesn't tell you that much about whether it can throw an UndefVarError, since that is also a different query defined differently elsewhere in the manual.

I assume you mean UndefRefError? If we're uncomfortable with associating the presence / absence of undefined references with allocatedinline I'm happy to just drop the part of the docstring that mentions that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants