Niklas,

there are several relevant points that you raised up, thanks :)

 

Q - «How is the active usage and how are frameworks related to making it not an 
object but something entirely new instead? »

A - Before Php starting to slightly evolves from a procedural way (the begins 
of wordpress, phpBB, etc) to a full OOP way(Symfony, Doctrine, Yii and other 
MVC-based frameworks). Everyone now implements its own Collection type based on 
a super-interfaced object for the same final result: A set of 
Iterable/Traversable data. When you work on a rich-framework projects that 
makes use of multiples libraries, you sometime discover a bunch of 
“Collections” objects from different vendors and realize that all those 
Collection objects are designed for the same exact way. 

 

Q - “Why not? Previously you mentioned Traversable and Countable, which are 
both interfaces, you mentioned it should be passed like an object.”

A - I mentioned that it should be passed by reference for more convenience and 
optimization, the way that objects are passed by actually. The Collection type 
is designed to not be an array nor an object. But a type of its own, mixing the 
interests of arrays and objects for working with sets of data.

 

Q - “We also have built-in classes. Maybe you want to have a look at 
https://github.com/php-ds/extension?” 

A – It’s an extension, not a part of the core, also it seem to not be very 
“popular”, s sysadmin may not be aware that the extension exists. Also it’s not 
exactly the kind of variable type I am talking about.

 

Q - “Apart from generics, efficient data structures are already implemented in 
https://github.com/php-ds/extension, so maybe we want to move that into core 
instead of starting from scratch here.”

A - You right, a part of the work could be forked from this project even if 
like I said it’s exactly the kind of variable type I am talking about. This 
could be anyway a base of work to start with.

 

Q - “Why PHP 8? Because of the BC break? Having it as simple objects doesn't 
have any BC impact and would be perfectly fine in any PHP 7.x release.”

A - Like I said, I’m seeing it as a new type of variable, introducing a new 
reserved of keyword with a slightly different way to work with.

 

Cheers,

Georges

 

 

 

De : Niklas Keller [mailto:m...@kelunik.com] 
Envoyé : samedi 28 janvier 2017 19:55
À : Georges.L <geol...@gmail.com>
Cc : PHP Internals <internals@lists.php.net>
Objet : Re: [PHP-DEV] Fwd: Type Collection

 

2017-01-28 17:49 GMT+01:00 Georges.L <geol...@gmail.com 
<mailto:geol...@gmail.com> >:

Hello Niklas,

 

This something very pertinent that you noticed. Thanks you for pointing it out.

 

Q - “sounds like everything you want is typed arrays”

A- It’s much more than simple typed arrays. I forgot to mention that those 
“Collection” would be passed, like objects, by reference. Meaning to a 
memory-optimized type as it does not make local copies of the variable.

 

Q – “What's wrong with having it as object as long as it's implemented 
efficiently”

A – 

1 It’s semantically much more appropriated. Collections of data is becoming 
something actively used in php since those frameworks are born all over.

 

How is the active usage and how are frameworks related to making it not an 
object but something entirely new instead?

 

2 An object IMO is not intended to be used as “array of others object”. It’s a 
design issue following a lack of this variable type in php.

 

Why not? Previously you mentioned Traversable and Countable, which are both 
interfaces, you mentioned it should be passed like an object.

 

3 It’s native to php, meaning that’ll be faster as its core-optimized, 
especially with huge Collection of data. Doctrine users will understand this 
sentence.

 

We also have built-in classes. Maybe you want to have a look at 
https://github.com/php-ds/extension?

 

4 This will allows frameworks to make use of a native Collection, instead of 
doing their own ones. Nowadays each framework are using their one Collection 
object which is not standardized at all since they all make the same use of the 
Collection.

 

Now I agree with something:

This will be.a.huge.work behind the scenes. Not only for Php developpers, but 
also for testers, documenters, etc.

 

Apart from generics, efficient data structures are already implemented in 
https://github.com/php-ds/extension, so maybe we want to move that into core 
instead of starting from scratch here.

 

This could be a major point of interest for Php8, lot of things moved in the 
good way since Php 7. We can keep going by improving the code's semantic and 
evolve in the way of framework makers.

 

Why PHP 8? Because of the BC break? Having it as simple objects doesn't have 
any BC impact and would be perfectly fine in any PHP 7.x release.

 

Regards, Niklas 

Reply via email to