Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-21 Thread tyson andre
Hi Mike Shinkel, > >> Hmm. I must have missed that thread as I was definitely following the list > >> at that time. > >> > >> But I found the thread, which only had three (3) comments from others: > >> > >> https://externals.io/message/112639 > >> > >> From Levi Morrison it seems his objectio

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-21 Thread Mike Schinkel
> On Sep 19, 2021, at 8:55 AM, tyson andre wrote: > > Hi Mike Schinkel, >> >> Hmm. I must have missed that thread as I was definitely following the list >> at that time. >> >> But I found the thread, which only had three (3) comments from others: >> >> https://externals.io/message/112639 >>

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-20 Thread tyson andre
Hi Peter Bowyer, > That is a fair point. Vector is an overloaded and common word. For me a > vector will always default to an entity characterized by a magnitude and a > direction, because that's what I learned and used for years. The next > definition I learned was the Numpy one. > > That for me

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-20 Thread Peter Bowyer
Hi Tyson, On Sat, 18 Sept 2021 at 16:46, tyson andre wrote: > Many of php's names are based on the naming choices in libraries made in > C/C++. > So using https://cplusplus.com/reference/vector/vector/ for my RFC > https://wiki.php.net/rfc/vector > seems like the most natural naming choice, > an

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-19 Thread tyson andre
Hi Mike Schinkel, > >> Given there seems to be a lot of concern about the approach the RFC > >> proposes would it not address the concerns about memory usage and > >> performance if several methods were added to SplFixedArray instead (as > >> well as functions like indexOf(), contains(), map()

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Mike Schinkel
Hi Tyson, Thanks for the reply. > On Sep 18, 2021, at 7:26 PM, tyson andre wrote: > > Hi Mike Schinkel, > >> Given there seems to be a lot of concern about the approach the RFC proposes >> would it not address the concerns about memory usage and performance if >> several methods were added t

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Mike Schinkel
Hi Larry, > On Sep 18, 2021, at 12:03 PM, Larry Garfield wrote: > > Rather than go point by point, I'm going to respond globally here. > > I am frequently on-record hating on PHP arrays, and stating that I want > something better. The problems with PHP arrays include: > > 1. They're badly pe

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread tyson andre
Hi Mike Schinkel, > Given there seems to be a lot of concern about the approach the RFC proposes > would it not address the concerns about memory usage and performance if > several methods were added to SplFixedArray instead (as well as functions > like indexOf(), contains(), map(), filter(), J

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Matthew Brown
On Sat, 18 Sept 2021 at 12:04, Larry Garfield wrote: > > I am frequently on-record hating on PHP arrays, and stating that I want > something better. The problems with PHP arrays include: > > 1. They're badly performing (because they cannot be optimized) > 2. They're not type safe > 3. They're mu

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread tyson andre
Hi Larry Garfield, > Rather than go point by point, I'm going to respond globally here. > > I am frequently on-record hating on PHP arrays, and stating that I want > something better.  The problems with PHP arrays include: > > 1. They're badly performing (because they cannot be optimized) > 2.

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Pierre Joye
Hi Tyson, On Sat, Sep 18, 2021, 10:46 PM tyson andre wrote: > Hi Peter Bowyer, > > > Many of php's names are based on the naming choices in libraries made in > C/C++. > So using https://cplusplus.com/reference/vector/vector/ for my RFC > https://wiki.php.net/rfc/vector > seems like the most natu

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Larry Garfield
On Fri, Sep 17, 2021, at 8:49 PM, tyson andre wrote: > > > Improving collection/set operations in PHP is something near and dear to my > > heart, > > so I'm in favor of adding a Vector class or similar to the stdlib. > > > > However, I am not a fan of this particular design. > > > > As Levi not

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread tyson andre
Hi Peter Bowyer, > > > To echo Pierre, a Vector needs to be of a single guaranteed type. > > > Yes, this gets us back to the generics conversation again, but I presume > > (perhaps naively?) there are ways to address this question without getting > > into full-blown generics. > > > > Yep, as you s

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-18 Thread Peter Bowyer
On Sat, 18 Sept 2021 at 02:49, tyson andre wrote: > > To echo Pierre, a Vector needs to be of a single guaranteed type. > > Yes, this gets us back to the generics conversation again, but I presume > (perhaps naively?) there are ways to address this question without getting > into full-blown gener

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Mike Schinkel
> On Sep 16, 2021, at 10:09 PM, tyson andre wrote: > > Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. > > PHP's native `array` type is rare among programming language in that it is > used as an associative map of values

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre Joye
Hi Tyson, On Sat, Sep 18, 2021, 10:21 AM tyson andre wrote: > > This proposal already has a fixed-sized type - that type is `mixed` (or > `zval` internally), like ArrayObject, WeakMap, etc. already have in their > values. > (Similar to how basic Java collections (e.g. ArrayList​) are all > colle

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
Hi Pierre Joye, > Not sure you care or read my reply but I had to jump in one more time here :) > > On Sat, Sep 18, 2021 at 8:49 AM tyson andre wrote: > > > setSize is useful in allocating exactly the variable amount of memory > > needed while using less memory than a PHP array. > > `setSize(

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre Joye
Good morning, Not sure you care or read my reply but I had to jump in one more time here :) On Sat, Sep 18, 2021 at 8:49 AM tyson andre wrote: > setSize is useful in allocating exactly the variable amount of memory needed > while using less memory than a PHP array. > `setSize($newSize, 0)` wou

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
> Improving collection/set operations in PHP is something near and dear to my > heart, > so I'm in favor of adding a Vector class or similar to the stdlib. > > However, I am not a fan of this particular design. > > As Levi noted, this being a mutable object that passes by handle is asking > fo

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
Hi Max Semenik, > Since Ds was mentioned, I've added it to your benchmark (code and complete > results at https://gist.github.com/MaxSem/d0ea0755d6deabaf88c9ef26039b2f27): > > Appending to array:         n= 1048576 iterations=      20 memory=33558608 > bytes, create+destroy time=0.369 read time

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Levi Morrison via internals
> * Whether or not contains() needs a comparison callback in my mind depends > mainly on whether or not the operator overloading RFC passes. If it does, > then contains() can/should use the __compareTo() method on objects. If it > doesn't, then there needs to be some other way to compare non-i

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Larry Garfield
On Thu, Sep 16, 2021, at 9:09 PM, tyson andre wrote: > Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. > > PHP's native `array` type is rare among programming language in that it > is used as an associative map of values,

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Max Semenik
On Fri, Sep 17, 2021 at 5:10 AM tyson andre wrote: > Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. Thank you so much, Tyson - I love your proposal. Since Ds was mentioned, I've added it to your benchmark (code and comple

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre Joye
Hi Tyson, Back on my laptop so I will answer my question myself as I read the source code. Please, really, that should be part of the RFC content. Half of the questions here are about APIs, goals, etc. RFC should be specifications as much as possible. On Fri, Sep 17, 2021 at 12:43 PM Pierre Joye

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Levi Morrison via internals
> I'd considered using a signature of `setSize(int $size, mixed $value = null)` > to allow using something other than null > but decided to leave that to a followup proposal if it passed. Rust and C++ both accept a value to pad, there's no reason to restrict this to only null. Go ahead and make t

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
Hi Christian Schenider, > First of all: I don't have a strong opinion on a Vector class being useful or > necessary. > > But I have two comments about this RFC: > > 1. Using the very generic name Vector without any prefix/namespace seems > dangerous and asking for BC breaks. I downloaded the

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
Hi Levi Morrison, > I mean that there isn't a way to provide a custom way to compare for > equality. One way to accomplish this is to have a signature like: > >    function contains(T $value, ?callable(T, T):bool $comparator = null): bool > > The same goes for `indexOf`. It'd make much more sen

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre
Le 17/09/2021 à 14:54, tyson andre a écrit : Aside: https://github.com/TysonAndre/pecl-teds#iterable-functions starts doing that, but evaluating eagerly instead of using generators. I still don't think there's enough functionality yet to re-propose that. Nice to know this, I wasn't aware it even

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread tyson andre
Hi Pierre, > That's nice, and I like it, but like many people I will argue about the > API itself. > > One thing is that there's many methods in there that would totally fit > generic collection common interfaces, and in that regard, I'd be very > sad that it would be merged as is. It isn't an

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Olle Härstedt
On Thu, Sep 16, 2021 at 8:10 PM tyson andre wrote: > > Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. > > PHP's native `array` type is rare among programming language in that it is >

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre
Le 17/09/2021 à 04:09, tyson andre a écrit : Hi internals, I've created a new RFC https://wiki.php.net/rfc/vector proposing to add `final class Vector` to PHP. Hello, That's nice, and I like it, but like many people I will argue about the API itself. One thing is that there's many methods

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Pierre Joye
Good afternoon Christian, On Fri, Sep 17, 2021 at 3:07 PM Christian Schneider wrote: > > Am 17.09.2021 um 04:09 schrieb tyson andre : > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > > `final class Vector` to PHP. > > > First of all: I don't have a strong opinion on

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-17 Thread Christian Schneider
Am 17.09.2021 um 04:09 schrieb tyson andre : > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. First of all: I don't have a strong opinion on a Vector class being useful or necessary. But I have two comments about this RFC: 1) Using the ve

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Pierre Joye
Hello Tyson, Vector support would be very good. JIT can do a lot with them if we have a clean Vector implementation, or even without JIT. What is your base inspiration for Vector? I do like the pretty standard C++ Vector implementation: https://www.cplusplus.com/reference/vector/vector/ Where a

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Matthew Brown
I can also give some in-the-trenches perspective of vec's utility, having spent the last month and a half writing Hack. vec is a really useful data structure to be able to use explicitly in code. It makes code that uses it easier to understand. The main benefit over Vector is that it could be used

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Matthew Brown
On Thu, 16 Sept 2021 at 23:33, tyson andre wrote: > Yeah, as mentioned in > https://wiki.php.net/rfc/vector#adding_a_native_type_instead_is_vec , it > would require a massive amount of work. > > - A standard library for dealing with `vec`, filtering it, etc > - Userland libraries and PECLs would

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Levi Morrison via internals
> > - `contains` also doesn't have a comparator. > > I was considering proposing `->any(callable)` and `->all(callable)` > extensions if this passed. > I'm not quite sure what you mean by a comparator for contains. There'd have > to be a way to check if a raw closure is contained. I mean that th

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread tyson andre
Hey Marco Pivetta, > Would it perhaps make sense to drag in php-ds, which has matured quite a bit > over the years? I'm referring to:  > https://www.php.net/manual/en/class.ds-sequence.php > > Is what you are suggesting with `Vector` different from it? > > Note: For some reason, I can't quote y

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread tyson andre
Hi Levi Morrison, > I'm okay with a final Vector class in general. I don't love the > proposed API but don't hate it either. Feedback on that at the end. > > What I would _love_ is a `vec` type from hacklang, which is similar to > this but pass-by-value, copy-on-write like an array. Of course, th

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Levi Morrison via internals
On Thu, Sep 16, 2021 at 8:10 PM tyson andre wrote: > > Hi internals, > > I've created a new RFC https://wiki.php.net/rfc/vector proposing to add > `final class Vector` to PHP. > > PHP's native `array` type is rare among programming language in that it is > used as an associative map of values, b

Re: [PHP-DEV] RFC: Add `final class Vector` to PHP

2021-09-16 Thread Marco Pivetta
Hey Tyson, Would it perhaps make sense to drag in php-ds, which has matured quite a bit over the years? I'm referring to: https://www.php.net/manual/en/class.ds-sequence.php Is what you are suggesting with `Vector` different from it? Note: For some reason, I can't quote your post and then reply,