Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Larry Garfield
On Sun, Jan 3, 2021, at 2:25 PM, Marc wrote: > >> You already provide a lookup mechanism with `MyEnum::from()` - I don't > >> see a real use-case for proving a pre build map. The main use case I see > >> is to list all possible enum values but this doesn't require a map and a > >>

Re: [PHP-DEV] Re: [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2021-01-03 Thread Larry Garfield
On Sun, Jan 3, 2021, at 12:17 PM, tyson andre wrote: > Hi internals, > > > I've created the RFC https://wiki.php.net/rfc/is_list > > > > This adds a new function `is_list(mixed $value): bool` that will return true > > if the type of $value is array and the array keys are `0 .. > >

Re: [PHP-DEV] [RFC] Bundling ext/simdjson into core

2021-01-03 Thread Jakub Zelenka
Hi, On Thu, Dec 31, 2020 at 1:30 AM Máté Kocsis wrote: > Hi Remi and Jakub, > >> > I agree it's too early as the library is young and won't be available in >>> many distros. The PECL path is better in this case IMO as it will allow >>> some time . >> >> > In my opinion, this is a case where

Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a`

2021-01-03 Thread tyson andre
Hi Rowan Tommins, > > - The benefit is that dumping the result of expressions improves the > > default experience. > >    psysh wouldn't be installed by default when a new developer is learning > >php through the php manual, or when sshed into a remote server. > > It doesn't feel to me that

Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Marc
Hi Ilija, On 03.01.21 12:54, Ilija Tovilo wrote: Hi Marc I don't have a really good use-case for float values. It just seems weird to me that a ScalarEnum doesn't support all scalars. Using the enum value as array key for `cases()` works with your current proposal but if we later want to

Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a`

2021-01-03 Thread Rowan Tommins
On 03/01/2021 16:11, tyson andre wrote: - The benefit is that dumping the result of expressions improves the default experience. psysh wouldn't be installed by default when a new developer is learning php through the php manual, or when sshed into a remote server. It doesn't feel to me

[PHP-DEV] Re: [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2021-01-03 Thread tyson andre
Hi internals, > I've created the RFC https://wiki.php.net/rfc/is_list > > This adds a new function `is_list(mixed $value): bool` that will return true > if the type of $value is array and the array keys are `0 .. count($value)-1` > in that order. > > It's well-known that PHP's `array` data type

Re: [PHP-DEV] Does PHP ever stack allocate?

2021-01-03 Thread Sara Golemon
On Sun, Jan 3, 2021 at 10:37 AM Olle Härstedt wrote: > Thanks Sara! I realize I should have been more precise: Can PHP > allocate non-reference counted memory that automatically is freed when > leaving scope, similar to what Go does with escape analysis? > It seems like you're conflating

Re: [PHP-DEV] Does PHP ever stack allocate?

2021-01-03 Thread tyson andre
Hi Olle, > Thanks Sara! I realize I should have been more precise: Can PHP > allocate non-reference counted memory that automatically is freed when > leaving scope, similar to what Go does with escape analysis? > > Article describing the Go mechanism: >

Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals

2021-01-03 Thread Olle Härstedt
2021-01-03 16:55 GMT, Larry Garfield : > On Sun, Jan 3, 2021, at 8:28 AM, Olle Härstedt wrote: > >> >> I like that you connect higher level design patterns with language >> >> design. This is the way to go, IMO. Personally, I'd prefer support for >> >> the Psalm notation `@psalm-readonly`, which

Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals

2021-01-03 Thread Larry Garfield
On Sun, Jan 3, 2021, at 8:28 AM, Olle Härstedt wrote: > >> I like that you connect higher level design patterns with language > >> design. This is the way to go, IMO. Personally, I'd prefer support for > >> the Psalm notation `@psalm-readonly`, which is the same as your > >> initonly. Clone-with

Re: [PHP-DEV] Does PHP ever stack allocate?

2021-01-03 Thread Olle Härstedt
2021-01-03 16:15 GMT, Sara Golemon : > On Fri, Jan 1, 2021 at 3:18 PM Olle Härstedt > wrote: > >> Or is everything reference counted with heap allocation? Since PHP has >> escape analysis, this could be used to use the stack instead, and kill >> the >> memory when the scope ends. If PHP uses the

Re: [PHP-DEV] Does PHP ever stack allocate?

2021-01-03 Thread Sara Golemon
On Fri, Jan 1, 2021 at 3:18 PM Olle Härstedt wrote: > Or is everything reference counted with heap allocation? Since PHP has > escape analysis, this could be used to use the stack instead, and kill the > memory when the scope ends. If PHP uses the stack, can this be seen in the > opcode? > >

Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a`

2021-01-03 Thread tyson andre
> Reading through the linked earlier mail, you have quite a few additional > hooks in mind, which might need a significant amount of additional userland > code (such as a parser implementation) to usefully implement. At that point > I'm wondering what the benefit of this hybrid approach is,

Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals

2021-01-03 Thread Olle Härstedt
2021-01-02 16:06 GMT, Larry Garfield : > On Fri, Jan 1, 2021, at 5:51 PM, Olle Härstedt wrote: > >> >> The web dev discourse is >> >> one-sided with regard to immutability, >> > >> > Yes, if you've heard any of the regular whining about PSR-7 being an >> > immutable object you'd think it's

Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Ilija Tovilo
Hi Marc > I don't have a really good use-case for float values. It just seems > weird to me that a ScalarEnum doesn't support all scalars. > > Using the enum value as array key for `cases()` works with your current > proposal but if we later want to allow floats, bool whatever then we got > a

Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals

2021-01-03 Thread Rowan Tommins
On 2 January 2021 21:25:08 GMT+00:00, Larry Garfield wrote: >If a stream is not seekable, then it would have to consume and destroy >$fp in the process (unset it). So: > >[$line1, $fp2] = read_line($fp); >[$line2, $fp2] = read_line($fp); > >The second line would throw an error that $fp "has

Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Marc
On 03.01.21 11:56, Marc wrote: > On 29.12.20 16:42, Larry Garfield wrote: >> On Tue, Dec 29, 2020, at 2:48 AM, Marc wrote: >>> On 28.12.20 21:21, Larry Garfield wrote: Hello, Internalians! After considerable discussion and effort, Ilija and I are ready to offer you round 2 on

Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Mike Schinkel
> On Dec 31, 2020, at 12:15 PM, Larry Garfield wrote: > > On Thu, Dec 31, 2020, at 6:53 AM, Rowan Tommins wrote: >> On 30/12/2020 21:24, Aleksander Machniak wrote: >>> My argument is that, from an end-user perspective, I don't really see >>> why Unit and Scalar enums have to have different

Re: [PHP-DEV] [RFC] Enumerations, Round 2

2021-01-03 Thread Marc
On 29.12.20 16:42, Larry Garfield wrote: > On Tue, Dec 29, 2020, at 2:48 AM, Marc wrote: >> On 28.12.20 21:21, Larry Garfield wrote: >>> Hello, Internalians! >>> >>> After considerable discussion and effort, Ilija and I are ready to offer >>> you round 2 on enumerations. This is in the spirit

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-03 Thread Marc
On 01.01.21 20:22, Go Kudo wrote: > Hi Marc, and sorry for the late reply. Email has been marked as spam... > >> I would expect the Random number generator to implement from Iterator > using an integer for current() value >> and providing utility functions (simple functions or methods of another