Generic (void *)int

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Feb 18 12:44:42 UTC 2019


On 18/02/2019 12:36, Jorn Vernee wrote:
> That would work; I guess the main question I'm asking is if pointer 
> literals should always belong to the global scope, or if there needs 
> to be some more fine-grained Scope for them, e.g. by passing one as an 
> argument:
>
>     static Pointer<?> literal(Scope theScope, long value) {
>         ...
>     }
>
Well, I think if we were really adding such an API - you would want it 
as an instance method on Scope:


Scope::literal(long value)


And this could throw if the Scope is not a native scope.

But as Mark pointed out - this is such a corner use case that I'm unsure 
about the value of such an API, especially given that a workaround is 
possible here.

Of course jexract should be a bit better with pointer constants in 
#define (it currently ignores them). Once that issue is addressed, you 
can easily define your custom constant pointers by defining custom 
headers which #include the desired one, so that you can create as many 
custom-valued pointers as you like? Between that and the API-based 
workaround (for more dynamic and less constant-y) use cases, I think 
this use case should be covered enough?

Maurizio


> Jorn
>
> Maurizio Cimadamore schreef op 2019-02-18 13:31:
>> On 18/02/2019 11:38, Jorn Vernee wrote:
>>> One of the questions is; to what Scope do these literals belong? Do 
>>> we allow users to pass in a Scope? I think with the assumption that 
>>> "pointer literals are just special values", it makes sense to have 
>>> their Scope just be null, since no actual memory is managed.
>>
>> global scope?
>>
>> Maurizio


More information about the panama-dev mailing list