Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Marco Pivetta
Just throwing it in here while commuting, so it's a top-post with no references. Saw it yesterday on reddit (!!! Reddit being useful for once !!!): $callback = |$x| => $x ** 2; On 31 Jan 2017 22:44, "Bob Weinand" wrote: > > > Am 31.01.2017 um 19:41 schrieb Christoph M.

Re: [PHP-DEV] PHP's support to contravariance and covariance

2017-01-31 Thread Marco Pivetta
On 1 Feb 2017 12:27 a.m., "Christoph M. Becker" wrote: On 31.01.2017 at 21:47, Levi Morrison wrote: >> Is there anything else that I am missing? > > Sadly, yes. Consider the following snippet: > > class A { > function method(): B; > } > > class B extends A

Re: [PHP-DEV] Re: Reseeding rand()/mt_rand()

2017-01-31 Thread Yasuo Ohgaki
Hi all, On Wed, Feb 1, 2017 at 5:48 AM, Andrea Faulds wrote: > Yasuo Ohgaki wrote: > >> My current objective is to make existing API to work, so resource may be >> used >> to set/get PRNG state. >> > > I would prefer it if we not introduce a new usage of resources. An object >

[PHP-DEV] [RFC][Accepted] HashContext as Object

2017-01-31 Thread Sara Golemon
Voting on https://wiki.php.net/rfc/hash-context.as-resource has closed. The RFC has passed 15 to 0. Implementation specific selection: Frozen (9-6) I'll merge the diff later tonight or tomorrow. -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit:

Re: [PHP-DEV] [RFC] Comparable

2017-01-31 Thread Ryan Pallas
On Tue, Jan 31, 2017 at 3:48 PM, Fleshgrinder wrote: > Hi :) > > I have a few questions regarding the comparable RFC: > > https://wiki.php.net/rfc/comparable > > Couldn't find the thread in my history and thus cannot respond directly > to any of the past threads. Maybe not

Re: [PHP-DEV] [RFC] Deprecate and Remove Bareword (Unquoted) Strings

2017-01-31 Thread Johannes Schlüter
On Tue, 2017-01-31 at 23:46 +0100, Johannes Schlüter wrote: > Hi, > > On Sun, 2017-01-29 at 19:33 +, Rowan Collins wrote: > > Currently, if the constant FROB_ACTIVE is not defined, the code "echo > > FROB_ACTIVE;" results in an E_NOTICE and the string 'FROB_ACTIVE' > > being displayed. I

[PHP-DEV] [RFC] Comparable

2017-01-31 Thread Fleshgrinder
Hi :) I have a few questions regarding the comparable RFC: https://wiki.php.net/rfc/comparable Couldn't find the thread in my history and thus cannot respond directly to any of the past threads. Maybe not that bad after more than a year of silence. :) My question might sound silly but I am

Re: [PHP-DEV] [RFC] Deprecate and Remove Bareword (Unquoted) Strings

2017-01-31 Thread Johannes Schlüter
Hi, On Sun, 2017-01-29 at 19:33 +, Rowan Collins wrote: > Currently, if the constant FROB_ACTIVE is not defined, the code "echo > FROB_ACTIVE;" results in an E_NOTICE and the string 'FROB_ACTIVE' > being displayed. I would like to propose that this be changed to an > E_WARNING in PHP 7.2,

Re: [PHP-DEV] [RFC][VOTE] Trailing commas in all list syntax

2017-01-31 Thread Christian Schneider
Am 30.01.2017 um 04:17 schrieb Yasuo Ohgaki : > Unless there is critical reason not to implement it that I don't know of, I > prefer to allow trailing commas like array universally/consistently. I agree that consistency would be preferable here. Syntax subtleties where

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Bob Weinand
> Am 31.01.2017 um 19:41 schrieb Christoph M. Becker : > > On 31.01.2017 at 19:16, Michael Morris wrote: > >> On Tue, Jan 31, 2017 at 12:29 PM, Larry Garfield >> wrote: >> >>> My question is why there's no mention of HHVM short closures, or the >>>

Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions

2017-01-31 Thread Rowan Collins
On 31/01/2017 20:41, Andrea Faulds wrote: That's the idea. I'd prefer it if auto-capture was not restricted to single-expression functions (“arrow functions”). Though arrow functions make most sense with auto-capture, it doesn't need to be stricted to them. I respectfully disagree

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Bob Weinand
> Am 31.01.2017 um 21:45 schrieb Andrea Faulds : > > Hi Marc, > > Marc Bennewitz wrote: >> - Also I like the "use" keyword you have to define your variables >> >>-> Would it be helpful to allow "function () use (*) {}" to inline >> all available variables? > > I did think of

Re: [PHP-DEV] Re: Reseeding rand()/mt_rand()

2017-01-31 Thread Andrea Faulds
Hi, Yasuo Ohgaki wrote: My current objective is to make existing API to work, so resource may be used to set/get PRNG state. I would prefer it if we not introduce a new usage of resources. An object would suffice. *** Initialize and Create new PRNG state resource *** resource

Re: [PHP-DEV] PHP's support to contravariance and covariance

2017-01-31 Thread Levi Morrison
> Is there anything else that I am missing? Sadly, yes. Consider the following snippet: class A { function method(): B; } class B extends A { function method(): C; } class C extends B {} When checking that B::method satisfies the requirements of A::method

Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions

2017-01-31 Thread Andrea Faulds
Hi Marc, Marc Bennewitz wrote: - Also I like the "use" keyword you have to define your variables -> Would it be helpful to allow "function () use (*) {}" to inline all available variables? I did think of that, but it's not as concise as not having to specify `use` at all. You could

Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions

2017-01-31 Thread Andrea Faulds
Hi, David Walker wrote: On Mon, Jan 30, 2017 at 18:12 Andrea Faulds wrote: Is it necessary to introduce a new keyword, fn? I think you'd get a similar benefit from: function($x) => $arr[$x] Likewise, is it necessary to restrict auto-capture to the => syntax? Couldn't we

Re: [PHP-DEV] PHP's support to contravariance and covariance

2017-01-31 Thread Rasmus Schultz
We were talking about this exact issue at work today. Supporting this for interfaces would be particularly useful - if an implementation better than satisfies the requirements defined by an interface, it should be able to implement that interface. I'd be very happy to see an RFC for this :-)

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Christoph M. Becker
On 31.01.2017 at 19:16, Michael Morris wrote: > On Tue, Jan 31, 2017 at 12:29 PM, Larry Garfield > wrote: > >> My question is why there's no mention of HHVM short closures, or the >> previous RFC to take that approach. See: >> >>

[PHP-DEV] Re: [RFC][Discuss] Arrow Functions

2017-01-31 Thread Levi Morrison
On Mon, Jan 30, 2017 at 10:55 AM, Levi Morrison wrote: > Bob Weinand and I are happy to announce that the [Arrow Functions][1] > RFC is moving into the public discussion phase. We have been > collaborating on this RFC for many months now and finally have a > proposal we are happy

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread David Rodrigues
I guess that should avoid the usage of fn() or function() before arguments (or then make it optional, but I don't like to give much options). Some possibilites: array_map(($x) return $x + 1); // or array_map(($x) = $x + 1); // or array_map(($x) => $x + 1); // or array_map(($x) { $x + 1 });

[PHP-DEV] PHP's support to contravariance and covariance

2017-01-31 Thread guilhermebla...@gmail.com
Hi internals, During my regular open source work, I realized that PHP yet do not support contravariance and covariance for user classes. Some examples that I found that could be really easy to implement and useful to end user are highlighted here: - contravariance.php - https://3v4l.org/I3v0u -

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Michael Morris
On Tue, Jan 31, 2017 at 12:29 PM, Larry Garfield wrote: > On 01/31/2017 05:14 AM, Bob Weinand wrote: > >> >>> In the case that regular closures got auto-capture, would a `use($foo, $bar, $baz)` segment on a closure still be honoured (i.e. disable auto-capture),

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Larry Garfield
On 01/31/2017 05:14 AM, Bob Weinand wrote: In the case that regular closures got auto-capture, would a `use($foo, $bar, $baz)` segment on a closure still be honoured (i.e. disable auto-capture), and would it have any impact (positive or negative) on performance/memory usage? After several

Re: [PHP-DEV] [RFC] Deprecate and Remove Bareword (Unquoted) Strings

2017-01-31 Thread Paul Jones
> have drafted an RFC rather than trying to fit all the detail into one e-mail: > https://wiki.php.net/rfc/deprecate-bareword-strings > > Please read my proposal, and let me know your thoughts. I have placed the RFC > "under discussion", but will be happy to modify it based on feedback, and am

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Yasuo Ohgaki
Hi Levi, On Tue, Jan 31, 2017 at 8:38 PM, Yasuo Ohgaki wrote: > On Tue, Jan 31, 2017 at 2:55 AM, Levi Morrison wrote: > >> This RFC proposes syntax and semantics to simplify this common usage to: >> >> fn($x) => $arr[$x] >> > > Could you explain why fn()

[PHP-DEV] Re: Reseeding rand()/mt_rand()

2017-01-31 Thread Christoph M. Becker
On 30.01.2017 at 17:29, Andrea Faulds wrote: > Christoph M. Becker wrote: > >> Just a quick idea: >> >> > >> class PNRG { >> public function __construct($seed = null) {…} >> public function get() {…} >> } > > I've long favoured an API along these lines. One size does not fit all, > you

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Niklas Keller
Nicolas Grekas schrieb am Di., 31. Jan. 2017, 13:45: > > > > As noted in the RFC, this isn't possible due to ambiguities with array > > keys and yield expressions with keys. > > > > There are not ambiguities technically, so it is possible if we want to: > > $a = [

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Nicolas Grekas
> > As noted in the RFC, this isn't possible due to ambiguities with array > keys and yield expressions with keys. > There are not ambiguities technically, so it is possible if we want to: $a = [ $y => 'b', ($x) => $x + 1, // key, value pair ]; $a = [ $y => 'b', (($x) => $x +

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Niklas Keller
Alain Williams schrieb am Di., 31. Jan. 2017, 13:20: > On Tue, Jan 31, 2017 at 01:06:25PM +0100, Nicolas Grekas wrote: > > Or just drop any "fn" or "function" keyword, eg > > > > ($x, $y) => foo($x, $y); > > > > array_map(($x) => $x + 1); > > That has the great advantage of

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Michał Brzuchalski
2017-01-31 13:20 GMT+01:00 Alain Williams : > On Tue, Jan 31, 2017 at 01:06:25PM +0100, Nicolas Grekas wrote: > > Or just drop any "fn" or "function" keyword, eg > > > > ($x, $y) => foo($x, $y); > > > > array_map(($x) => $x + 1); > > That has the great advantage of being much

[PHP-DEV] [VOTE] Deprecate and remove INTL_IDNA_VARIANT_2003

2017-01-31 Thread Christoph M. Becker
Hi everybody! I've just opened the voting for the "Deprecate and remove INTL_IDNA_VARIANT_2003" RFC: Voting ends on 2017-02-14T12:30Z. Thanks in advance for participating in the vote! -- Christoph M. Becker -- PHP

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Alain Williams
On Tue, Jan 31, 2017 at 01:06:25PM +0100, Nicolas Grekas wrote: > Or just drop any "fn" or "function" keyword, eg > > ($x, $y) => foo($x, $y); > > array_map(($x) => $x + 1); That has the great advantage of being much as Javascript does this.

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Yasuo Ohgaki
On Tue, Jan 31, 2017 at 9:06 PM, Nicolas Grekas < nicolas.grekas+...@gmail.com> wrote: > Or just drop any "fn" or "function" keyword, eg > > ($x, $y) => foo($x, $y); > > array_map(($x) => $x + 1); > > ? > I like your syntax if it cannot be like ES2015 syntax. -- Yasuo Ohgaki yohg...@ohgaki.net

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Nicolas Grekas
Or just drop any "fn" or "function" keyword, eg ($x, $y) => foo($x, $y); array_map(($x) => $x + 1); ?

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Niklas Keller
2017-01-31 12:14 GMT+01:00 Bob Weinand : > Hey, > > > Am 31.01.2017 um 11:23 schrieb Michael Wallner : > > > > On 31/01/17 05:53, Stephen Reay wrote: > >> Hi Andrea, All, > >> > >>> On 31 Jan 2017, at 08:12, Andrea Faulds wrote: > >>> > >>> Is it

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Yasuo Ohgaki
Hi Levi, On Tue, Jan 31, 2017 at 2:55 AM, Levi Morrison wrote: > This RFC proposes syntax and semantics to simplify this common usage to: > > fn($x) => $arr[$x] > Could you explain why fn() cannot be removed like ES2015. Rowan's syntax sounds attractive to me if fn() cannot

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Bob Weinand
Hey, > Am 31.01.2017 um 11:23 schrieb Michael Wallner : > > On 31/01/17 05:53, Stephen Reay wrote: >> Hi Andrea, All, >> >>> On 31 Jan 2017, at 08:12, Andrea Faulds wrote: >>> >>> Is it necessary to introduce a new keyword, fn? >>> >>> I think you'd get a similar

Re: [PHP-DEV] Re: Reseeding rand()/mt_rand()

2017-01-31 Thread Yasuo Ohgaki
Hi Andrea, On Tue, Jan 31, 2017 at 1:29 AM, Andrea Faulds wrote: > > Christoph M. Becker wrote: > > Just a quick idea: >> >> > >> class PNRG { >> public function __construct($seed = null) {…} >> public function get() {…} >> } >> >> > I've long favoured an API along these

Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions

2017-01-31 Thread Michael Wallner
On 31/01/17 05:53, Stephen Reay wrote: > Hi Andrea, All, > >> On 31 Jan 2017, at 08:12, Andrea Faulds wrote: >> >> Is it necessary to introduce a new keyword, fn? >> >> I think you'd get a similar benefit from: >> >>function($x) => $arr[$x] >> >> Likewise, is it necessary to

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Ilija Tovilo
I agree. Using the prefix `function` kind of defeats the purpose of the whole RFC. There are three things that contribute to the boilerplate of closures: - The `function` keyword - The `return` keyword - The `use` clause The RFC eliminates two and reduces one to about 25%. I also

[PHP-DEV] Re: Reseeding rand()/mt_rand()

2017-01-31 Thread Yasuo Ohgaki
Hi Christoph, On Mon, Jan 30, 2017 at 10:20 PM, Christoph M. Becker wrote: > Just a quick idea: > > > class PNRG { > public function __construct($seed = null) {…} > public function get() {…} > } > Object based implementation is a lot cleaner. I'm willing to write

Re: [PHP-DEV] [RFC][Discuss] Arrow Functions

2017-01-31 Thread Nikita Nefedov
On Mon, 30 Jan 2017 20:55:07 +0300, Levi Morrison wrote: Bob Weinand and I are happy to announce that the [Arrow Functions][1] RFC is moving into the public discussion phase. We have been collaborating on this RFC for many months now and finally have a proposal we are happy to