Pointer ofNull method naming
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Nov 13 08:28:40 UTC 2019
On 13/11/2019 02:48, Ty Young wrote:
> 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?
I'm ok with making the documentation more precise (I'm not sure I like
ofTyped()). Can you please clarify a bit what you mean by 'filler' ?
Like passing null ptr to a struct setter?
(p.s. in these cases we have been also discussing bringing back special
treatment for Java null, so that null is re-interpreted to Pointer.ofNull)
Maurizio
More information about the panama-dev
mailing list