-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: sizeof: add synthetic, pointer-like types #40169
Comments
This is an implementation detail, not specified by the Go spec. The size of slice I'm also wondering what the use cases for these constants would be? In particular, are there use cases where user code is simplified by having (e.g.) |
The desire is to expose as much The main use case I see is access to these values as compile time constants. I was not part of the initial proposal, so may be missing some purposes. |
I think if there's a need for sizes of types beyond what's currently proposed for package sizeof, we should just add a new builtin Edit: This counter-proposal is further expanded upon (including a working proof-of-concept CL for cmd/compile) here: #29982 (comment) |
@ianlancetaylor: can you add this to the proposals project? |
@arnottcr Done. |
Putting on hold with the other sizeof issue (#29982). |
The (approved) proposal #29982, excludes complex and dynamic types from the new
sizeof
package. For primitive, value-like types (structs and arrays), this is in required, since they are of variable length. But synthetic, pointer-like types (channels, functions, interfaces, maps, slices, and strings) instead point to their data and are of constant size. Can we add the following types:Technically one can calculate the
unsafe.Sizeof
any of these types today, but the intention of thesizeof
package is to make that unsafe interface less necessary. Furthermore, while these types are more complex, we can add test cases to ensure that new architectures or changes to the implementation of these types are reflected insizeof
.The text was updated successfully, but these errors were encountered: