Re: [Early Feedback] Pattern matching

From: Date: Wed, 26 Jun 2024 07:54:58 +0000
Subject: Re: [Early Feedback] Pattern matching
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On Wed, Jun 26, 2024, at 00:19, Morgan wrote:
> On 2024-06-26 08:24, Rob Landers wrote:
> > On Tue, Jun 25, 2024, at 20:23, Ilija Tovilo wrote:
> 
> >> If null array values were indeed unobservable, then [] would be === to
> >> [null] (or at least ==), and a foreach over [null] would result in 0
> >> iterations. But neither of those are the case.
> > 
> > I think there is a difference between an empty array and a null, and 
> > that is (hopefully) self-evident. I’m talking about the infinite nulls 
> > IN the array. You can write a for loop of all possible keys until the 
> > end of the universe, and all you will get is null. This is fairly easy 
> > to prove. I'll wait... :p
> > 
> What about the difference between an empty array an an array that 
> contains a null (Ilija's example)?
> 
> echo count([]);
> echo count([null]);
> echo count([null, null]);
> echo count([null, null, null]);
> echo count([null, null, null, null]);
> ...
> 
> You're arguing that these are all the same array?
> 

If you are accessing them by index, yes, they are all the same array. There is no observable
difference. I think we already covered that count() would show the difference between them since
it’s actually a count of known indices:

for($i = 0; $i < 4; $i++) var_dump([]);

Will output 4 nulls. 


— Rob


Thread (79 messages)

« previous php.internals (#123859) next »