Re: Allowing NULL for some internal functions

From: Date: Mon, 07 Feb 2022 12:34:04 +0000
Subject: Re: Allowing NULL for some internal functions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-116993@lists.php.net to get a copy of this message
On 07/02/2022 12:05, Craig Francis wrote:
And specifically with NULL, strings in C are a "one-dimensional array of characters terminated by a null character", so you could say that NULL is very similar to an empty string - maybe that helps address the "pretend its a string" objection?
In this case we're talking about the difference between a char* that points to a 1 byte buffer containing '\0' and a char* that itself points to NULL. Trying to perform string operations on a null pointer in C would equally blow up. With regards to your framework comment, any framework worth its salt will also have the option to provide a default value other than null when the value is not provided. It is the responsibility of the user to make use of this functionality to provide the correct type for what the soon-to-be-called function is expecting. Mark Randall

« previous php.internals (#116993) next »