Pointer ofNull method naming
Ty Young
youngty1997 at gmail.com
Wed Nov 13 02:48:23 UTC 2019
Hi,
After using Panama for awhile I've ran into more than a few situations
where I've ended up using Pointer.ofNull as a filler Pointer for data
I'm not actually interested in but have to pass a Pointer for it anyway.
After looking through the source code, it turns out that this is not
only convenient from my end as an API user but fairly fast and memory
efficient: the Pointer being returned is just a type casted
"BoundedPointer" singleton.
Because of this wider use case than simply being a "null" Pointer, IMO,
"ofNull" isn't a very appropriate name and should be changed to
something that is more general in nature to fit its wider use cases. An
alternative would be something like "Pointer.ofTyped". This would better
name to convey the wider uses case of the Pointer.ofNull functionality.
Of course, I can see the argument being made to keep it as is since many
functions explicitly state to pass a null Pointer to get a size or
something first, in which case the Pointer.ofNull name is clearly
better. So instead of renaming, maybe it should just be documented that
it can be used for filler? Thoughts?
More information about the panama-dev
mailing list