View Single Post
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 05-30-2016 , 06:41   Re: Returning null handle in native
Reply With Quote #9

It's certainly an interesting behavior, unique to the typelessness of SourcePawn and how the native API works. In other languages, null could not be used in this context (doesn't make sense to cast a null pointer to something else), but in this case where a native should be able to return null but can't because null isn't castable. Null is semantically equivalent to Handle:0 (INVALID_HANDLE), but null is not syntactically equivalent.

I think my best bet is the multi-cast approach mentrioned by @Miu, even if it's a bit ugly, but the cleanest would be modifying a byref param with return value (no casting null here), but that's different syntax which I don't like

Last edited by Tirant; 05-30-2016 at 06:42.
Tirant is offline