Populating an AnyExistentialContainer
#40
NSExceptional
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
A struct Big {
let w: Int
let x: Int
let y: Int
let z: Int
}
func thing() {
// swift_allocObject
let bigThing: Any = Big(w: 0, x: 1, y: 2, z: 3)
// swift_release
} |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be nice if there were an inverse function of
AnyExistentialContainer.projectValue()
that accepts a pointer and does all the proper checks to read the correct number of bytes and store the value!I see there are two initializers that take type metadata, but without this helper function we are left to reading how you implemented
projectValue()
to figure out how to store data in the container ourselvesEdit: after thinking about it more, maybe this should be a discussion, since it is not obvious to me how memory management of
Any
works for heap objects when you create it yourself… O_o Like, when is aHeapObject
allocated for anAny
container when the value isn't stored inline?Can you convert this to a discussion for me @Azoy?
Beta Was this translation helpful? Give feedback.
All reactions