Quote:
Originally Posted by Tirant
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.
|
That's not really true. You can look at it from the C# perspective: you can null reference types, but not value types. Here in the new SourcePawn API, you can look at integers, floats, characters and booleans (and arrays?) as value types, and handles as reference types. When you assign one handle to another, you are not copying the object but rather copying the reference, so both handles point to the same object.
In my opinion, it's understandable why null can't be cast to these primitive types.
EDIT:
@SM Devs, could we have something like the following?
PHP Code:
typeset NativeCall
{
function int(Handle plugin, int numParams),
function Handle(Handle plugin, int numParams)
};
So people can choose to either return a value of primitive type or of Handle type. Handles are just cells(ints) after all.