Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Larry Garfield
On Sun, Mar 10, 2019, at 7:16 PM, Bob Weinand wrote: > > Am 10.03.2019 um 22:44 schrieb Larry Garfield : > > > > Hello, peoples. I know it's been discussed once or twice before on the > > list, many years ago, but not recently. I therefore feel OK putting forth > > the following draft

Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Alexandru Pătrănescu
Hi Larry, I'm still digesting the syntax and people have already said about it the most important things. I mostly wanted to mention that I think comprehensions should return \Iterator instead of \Generator. There is nothing that stopped us from having lazy iterators, even before generators were

Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread G. P. B.
On Sun, 10 Mar 2019 at 22:45, Larry Garfield wrote: > Hello, peoples. I know it's been discussed once or twice before on the > list, many years ago, but not recently. I therefore feel OK putting forth > the following draft proposal for Comprehensions, aka "compact generators", > in PHP: > >

Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Bob Weinand
> Am 10.03.2019 um 22:44 schrieb Larry Garfield : > > Hello, peoples. I know it's been discussed once or twice before on the list, > many years ago, but not recently. I therefore feel OK putting forth the > following draft proposal for Comprehensions, aka "compact generators", in PHP: > >

Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Wes
Hi! proposed syntax: > $gen = [for $list as $x if $x % 2 yield $x*2]; > current php + short closures: $gen = () => foreach($list as $x) if($x % 2) yield $x * 2; 1- parentheses could be optional around control structures, so `if(true){}` could be simply `if true{}` 2- "for" could accept the

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
On 10/03/2019 21:09, Marco Pivetta wrote: Still feasible though: PRs to https://github.com/Roave/Dont/tree/master/src/Dont welcome Indeed. Many things in a language are sugar for something that could be done in a more complex way; it's a judgement call which ones are worth including, and

Re: [PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Bruce Weirdan
> array_map and array_filter combined This example has array_map and array_filter in wrong order (duplicated once or twice below as well). The RFC proposes to allow multiple `for`s in comprehensions, and really could benefit from an example of such usage.

[PHP-DEV] RFC Draft: Comprehensions

2019-03-10 Thread Larry Garfield
Hello, peoples. I know it's been discussed once or twice before on the list, many years ago, but not recently. I therefore feel OK putting forth the following draft proposal for Comprehensions, aka "compact generators", in PHP: https://wiki.php.net/rfc/comprehensions Sara Golemon has written

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Marco Pivetta
Still feasible though: PRs to https://github.com/Roave/Dont/tree/master/src/Dont welcome On Sun, 10 Mar 2019, 21:56 Rowan Collins, wrote: > On 10/03/2019 20:19, Dan Ackroyd wrote: > > trait LockedClass > > { > > public function __set($name, $value) > > { > > throw new \Exception("Property

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
On 10/03/2019 20:19, Dan Ackroyd wrote: trait LockedClass { public function __set($name, $value) { throw new \Exception("Property [$name] doesn't exist for class [" . get_class($this) . "] so can't set it"); } public function __get($name) { throw new \Exception("Property [$name] doesn't exist

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
On 10/03/2019 20:19, Dan Ackroyd wrote: I believe those two parts of the RFC are completely possible already in user-land with a trait similar to the one below. What would be the compelling case for making it be a keyword, rather than the user-land implementation that is already achievable?

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
On 10/03/2019 19:46, Marco Pivetta wrote: @rowan: I've stated it multiple times in the past, but if the mechanism is to be removed, then it should be replaced with a language-level concept of laziness then. 1) I'm all for adding a language-level concept of laziness. It feels like it could

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Dan Ackroyd
On Sun, 10 Mar 2019 at 18:35, Rowan Collins wrote: > > Hi all, > > - Attempting to set a property on the instance which was not declared in > the class (or inherited from one of its parent classes) will throw an > error, and the instance will not be modified. > - Attempting to read a property on

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Paul Jones
> On Mar 10, 2019, at 13:35, Rowan Collins wrote: > > Hi all, > > I'd like to present a new RFC for "locked classes": classes which restrict > dynamically adding or removing properties from their instances. Nice. This would help enforce at least one element of immutability in userland;

Re: [PHP-DEV] Re: Merging new hash algorithm (crc32c) into PHP 7.3 and maybe 7.2?

2019-03-10 Thread Gabriel Caruso
As both PHP 7.2 and 7.3 has been out for a while, -1 on this one. Best, On Sun, 10 Mar 2019 at 15:50 Andrew Brampton wrote: > Hey PHP Team, > > bump. Would I be able to get this small, and self contained change included > into 7.3 and/or 7.4? > > thanks > Andrew > > On Tue, 5 Mar 2019 at 08:01,

Re: [PHP-DEV] print with newline

2019-03-10 Thread Joe Watkins
As a function it has parity with fputs ... even though fputs doesn't have the same behaviour the two can be considered complimentary, and you would want to be able to cuf(a) puts like fputs. Regardless an RFC may go ahead without optimized implementation. Cheers Joe On Sun, 10 Mar 2019, 20:28

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Marco Pivetta
Typical scenario (works for either of the properties - note that typed properties that aren't nullable and have no default value also behave the same way): class Foo { private int $a; private $b; public function __construct() { unset($this->b); } public function

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
On 10/03/2019 18:56, Gabriel O wrote: Isn’t unset() currently only way to remove reference? This part is hence very problematic. Hm, that's an interesting case to consider, thanks! At the moment, the following code breaks the reference between $a->foo and $bar, but also deletes the entire

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Larry Garfield
On Sun, Mar 10, 2019, at 1:52 PM, Marco Pivetta wrote: > Hi Rowan, > > Overall good idea, except that I disagree with the `unset()` being > disabled: that bit is strictly required for lazy-loading purposes, and > mostly harmless for userland ("normal" people don't do it, libraries do it). > >

Re: [PHP-DEV] print with newline

2019-03-10 Thread Thomas Punt
> From: Steven Penny > Sent: 04 March 2019 15:30 > To: internals@lists.php.net > Subject: Re: [PHP-DEV] print with newline > > I think the best option is a new function like "puts" or "posix_puts". I'm fairly neutral on the feature, but I disagree with this being a function. It should be a

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
Hi Marco, On 10/03/2019 18:51, Marco Pivetta wrote: Overall good idea, except that I disagree with the `unset()` being disabled: that bit is strictly required for lazy-loading purposes, and mostly harmless for userland ("normal" people don't do it, libraries do it). To me, the unset()

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Gabriel O
Isn’t unset() currently only way to remove reference? This part is hence very problematic. > On 10. Mar 2019, at 19:35, Rowan Collins wrote: > > Hi all, > > I'd like to present a new RFC for "locked classes": classes which restrict > dynamically adding or removing properties from their

Re: [PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Marco Pivetta
Hi Rowan, Overall good idea, except that I disagree with the `unset()` being disabled: that bit is strictly required for lazy-loading purposes, and mostly harmless for userland ("normal" people don't do it, libraries do it). Besides that (blocker for me), if this RFC would be enforced in my

[PHP-DEV] Re: Merging new hash algorithm (crc32c) into PHP 7.3 and maybe 7.2?

2019-03-10 Thread Andrew Brampton
Hey PHP Team, bump. Would I be able to get this small, and self contained change included into 7.3 and/or 7.4? thanks Andrew On Tue, 5 Mar 2019 at 08:01, Andrew Brampton wrote: > Hi, > > I've recently sent a pull request > , to add a new hashing >

[PHP-DEV] RFC: Locked Classes

2019-03-10 Thread Rowan Collins
Hi all, I'd like to present a new RFC for "locked classes": classes which restrict dynamically adding or removing properties from their instances. While it can be useful, the ability to set an object property which is not part of the class definition can also lead to subtle bugs. Banning

[PHP-DEV] Wiki RFC karma request

2019-03-10 Thread Guilliam Xavier
Hello, I'd like to do some work on the Nullable Casting RFC (encouraged by its author). Could someone grant the wiki user guilliamxavier the necessary karma? Thanks in advance. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit:

[PHP-DEV] Base_convert changes

2019-03-10 Thread Scott Dutton
Hi, I have just put a pull request together to make some changes to base_convert, the changes are as follows: 1, Allow conversion of negative numbers (fixes https://bugs.php.net/bug.php?id=55393) 2, Raise a notice when passing in invalid chars as input, currently they are just silently