[PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Andrea Faulds
Hi Dan, Dan Ackroyd wrote: https://wiki.php.net/rfc/closurefromcallable Here's some further thoughts on this RFC. I don't like that it's a function. Closure is a class, classes can have static and instance methods, and closure() looks like something that should be a method on Closure. In

Re: [PHP-DEV] Strings, invalid escape sequences and parse errors

2015-10-04 Thread Andrea Faulds
Hey Sara, Sara Golemon wrote: On Fri, Oct 2, 2015 at 6:53 AM, Bishop Bettini wrote: Option (b) sounds reasonable, but there's probably A Solid Reason it was implemented that way AIUI, the "solid reason" was because it's dangerous to fail silently where you have high confidence that something

Re: [PHP-DEV] [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Ben Scholzen 'DASPRiD'
On 29.09.2015 16:23, Dan Ackroyd wrote: Hello internals, I'd like to start a discussion of a proposal to allow closures to be created in user-land without having to use a whole lot of reflection code. https://wiki.php.net/rfc/closurefromcallable Thanks to Joe and Bob for the assistance in the

Re: [PHP-DEV] Strings, invalid escape sequences and parse errors

2015-10-04 Thread Andrea Faulds
Hi, Tom Worster wrote: I agree with Sara all the way except the opinion that it's too late to fix this bug with option B, which I think is the right one. I simply don't know if it is too late or not so I suggest Peter enter a bug report and see what happens. If it's too late for 7.0.0 do it in

[PHP-DEV] Re: PHP 7.1 - should we add a random_str() function?

2015-10-04 Thread Andrea Faulds
Hey Scott, Scott Arciszewski wrote: This is probably answerable by a quick yes/no and shouldn't need a ton of bikeshedding, but if that happens anyway I apologize in advance. I think random_bytes() and random_int() are great; they provide a much-needed building block in PHP 7.0. However, I do w

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

2015-10-04 Thread Andrea Faulds
Hey Levi, Levi Morrison wrote: I messaged the list about this feature before I had the RFC written up for it. The RFC[1] is slightly different from what I proposed in the previous thread, so please read the RFC to make sure you understand what is being proposed before replying here. Here's a sm

Re: [PHP-DEV] [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Marco Pivetta
As mentioned already by Andrea: why not just a named constructor on the closure class, like `Closure::fromCallable(callable $callable)`? Much simpler, easier to find, etc etc... On Sep 29, 2015 11:23, "Dan Ackroyd" wrote: > Hello internals, > > I'd like to start a discussion of a proposal to allo

Re: [PHP-DEV] PHP 7.1 - should we add a random_str() function?

2015-10-04 Thread Leigh
On Wed, 30 Sep 2015 17:15 Scott Arciszewski wrote: This is probably answerable by a quick yes/no and shouldn't need a ton of bikeshedding, but if that happens anyway I apologize in advance. I think random_bytes() and random_int() are great; they provide a much-needed building block in PHP 7.0. H

Re: [PHP-DEV] [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Pavel Kouřil
On Sun, Oct 4, 2015 at 12:41 PM, Marco Pivetta wrote: > As mentioned already by Andrea: why not just a named constructor on the > closure class, like `Closure::fromCallable(callable $callable)`? > Much simpler, easier to find, etc etc... > On Sep 29, 2015 11:23, "Dan Ackroyd" wrote: > >> Hello in

Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Dan Ackroyd
On 4 October 2015 at 09:54, Andrea Faulds wrote: > If we want to make it avoid duplication, > okay, then it could be a static method. Okay, I'll update the RFC to be `Closure::fromCallable()` rather than a function. I was hoping to have something less verbose than that, but you're probably right

Re: [PHP-DEV] [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Dan Ackroyd
On 4 October 2015 at 10:16, Ben Scholzen 'DASPRiD' wrote: > > you could just do this: > > return function ($data) { return $this->genericValidation($data); } > > you could just do this: > > return function ($data) { return $this->genericValidation($data); } Yes, there are workarounds possible th

Re: [PHP-DEV] [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Dan Ackroyd
Hi Pavel, On 4 October 2015 at 11:31, Pavel Kouřil wrote: > > and what about changing the empty ctor of Closure to > __construct(callable $callable)? > > And the usage would be new Closure([$this, 'abc']);? > I'm going to change the RFC to use the 'named constructor' Closure::fromCallable which

Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Stanislav Malyshev
Hi! > I don't like that it's a function. Closure is a class, classes can have > static and instance methods, and closure() looks like something that > should be a method on Closure. In fact, it creates a closure, which a > constructor would usually do. If we want to make it avoid duplication, > ok

Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Michael Wallner
On 4 Oct 2015 21:50, "Stanislav Malyshev" wrote: > > Hi! > > > I don't like that it's a function. Closure is a class, classes can have > > static and instance methods, and closure() looks like something that > > should be a method on Closure. In fact, it creates a closure, which a > > constructor

[PHP-DEV] RFC proposal.

2015-10-04 Thread somebody anon
Hi PHP community. I am a developer with few years experience in PHP and now want to propose some addition to default "filesystem" extension. There's money_format and number_format functions to format money and number values in human-readable format, but there is not any "size_format" function that

Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Stanislav Malyshev
Hi! > I think the origin of this intention is, that calling a callable just > by `$callable()` does not work consistently -- see the other RFC by > Dan -- Maybe we should fix $callable() then? :) I see no reason why $() shouldn't work on all callables. That's why they are "callable" after all. >

Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable

2015-10-04 Thread Dan Ackroyd
On 4 October 2015 at 23:02, Stanislav Malyshev wrote: > Hi! > > That being said, I'm not sure how much need is for this - i.e. you can > always make a closure by just doing function() { return $this->blah(); } > if you need it. As I said before (and as the RFC says), there are ways to work around