Some external libraries take strings as arguments where
one is allowed to pass a 0 (null pointer) instead of an actual
string. Most of the time this means that some default value
will be used instead.
Currently there are two solutions, one is not using pseudotypes
which requires manual conversion and the other using an
uninitialized string variable like so:
As pseudotypes are mostly used for interfacing with external
functions and since a null-pointer is actually a valid "empty
string" in PureBasic, I propose to allow passing a literal 0
for a pseudotype-argument. I do not think that this functionality
would also be useful for normal string type arguments. Hence
this request is only for pseudotypes.
u.s = ""
bla(u) ; <- the same
bla(0) ; <- not the same!
bla(s) ; <- the same as bla(0)
Currently there is some inconsistent behaviour. If I compile
in UNICODE mode, then any conversion to p-unicode will
be ignored (OK). But if I switch to compiling in ASCII mode,
it seems that even for the uninitialized string a conversion
to unicode is done and PB actually allocates a new string.
For my proposal to work, all pseudotype-conversions mustnot
touch a null-pointer (uninitialized string) and just pass it
on to the C function as a null-pointer.
If the PB team is not inclined to implement this request,
please remove the inconsistency and always
do a conversion
even if it is a ASCII-ASCII conversion so we never get to
pass a null-pointer by accident.