nif: how to check if a resource is given as an arg

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

nif: how to check if a resource is given as an arg

Benoit Chesneau-2
Is there any better method than first trying enif_get_resource to check if a resourcce is given as an argument? What would be the impact of doing it? Should I use an explicit function instead of trying to match it?

- benoit
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: nif: how to check if a resource is given as an arg

Sverker Eriksson-4
In OTP-20 you can compare one resource term to another and get a match
if they refer to the same resource instance.

Beyond that, enif_get_resource is the *only* way to check if a term is a
resource.

/Sverker


On 09/23/2017 09:52 PM, Benoit Chesneau wrote:
> Is there any better method than first trying enif_get_resource to check if a resourcce is given as an argument? What would be the impact of doing it? Should I use an explicit function instead of trying to match it?
>
> - benoit
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions