> On Dec 16, 2020, at 12:49 PM, Ben Ramsey wrote:
>
>> On Dec 16, 2020, at 10:54, Mike Schinkel wrote:
>>
>> If we allow "switch {...}" to represent "switch (true){...}" then the value
>> switch compares will be hidden and less obvious to a developer if they are
>> forgetting to consider
On Sat, 19 Dec 2020, 02:48 Larry Garfield, wrote:
> On Fri, Dec 18, 2020, at 1:40 PM, Olle Härstedt wrote:
> > What about matching on a variable's type?
> >
> > ```
> > match {
> > $var: string => "is a string"
> > $var: array => "something else"
> > }
> > ```
> >
> > This could be used with
On Fri, Dec 18, 2020, at 1:40 PM, Olle Härstedt wrote:
> What about matching on a variable's type?
>
> ```
> match {
> $var: string => "is a string"
> $var: array => "something else"
> }
> ```
>
> This could be used with flow-sensitive typing, e.g. assume the type of $var
> being string in th
What about matching on a variable's type?
```
match {
$var: string => "is a string"
$var: array => "something else"
}
```
This could be used with flow-sensitive typing, e.g. assume the type of $var
being string in the string block. Psalm works like this for if-statements.
Also consider the ca
On Thu, Dec 17, 2020, at 10:23 AM, Sara Golemon wrote:
> On Wed, Dec 16, 2020 at 6:50 PM someniatko wrote:
> >
> > `match` is an expression, where as if-else construction is not. This
> > allows for combining it with a potential future feature of single line
> > functions and methods. For example
> Le 17 déc. 2020 à 17:23, Sara Golemon a écrit :
>
> On Wed, Dec 16, 2020 at 6:50 PM someniatko wrote:
>>
>> `match` is an expression, where as if-else construction is not. This
>> allows for combining it with a potential future feature of single line
>> functions and methods. For example (
On Wed, Dec 16, 2020 at 6:50 PM someniatko wrote:
>
> `match` is an expression, where as if-else construction is not. This
> allows for combining it with a potential future feature of single line
> functions and methods. For example (hypothetical syntax is used):
>
> ```
> $getNumber = fn(int $num
On Wed, Dec 16, 2020, at 6:49 PM, someniatko wrote:
> `match` is an expression, where as if-else construction is not. This
> allows for combining it with a potential future feature of single line
> functions and methods. For example (hypothetical syntax is used):
>
> ```
> function getNumberKind(i
`match` is an expression, where as if-else construction is not. This
allows for combining it with a potential future feature of single line
functions and methods. For example (hypothetical syntax is used):
```
function getNumberKind(int $number) => match {
$number > 0 => NumberKind::POSITIVE,
> On Dec 16, 2020, at 10:54, Mike Schinkel wrote:
>
> If we allow "switch {...}" to represent "switch (true){...}" then the value
> switch compares will be hidden and less obvious to a developer if they are
> forgetting to consider switch's evaluation behavior. For some people this
> would in
> On Dec 15, 2020, at 12:18 PM, Larry Garfield wrote:
>
> On Tue, Dec 15, 2020, at 3:00 AM, Nikita Popov wrote:
>> On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield
>> wrote:
>>
>>> I present to Internals this tiny RFC to follow up on the match()
>>> expression RFC from earlier in the year. There
On Tue, Dec 15, 2020 at 1:37 PM Andreas Leathley wrote:
> ```php
>
$this->handler = match {
> null === $var => 'null',
> true === $var => 'true',
> false === $var => 'false',
> is_string($var) => '"'.$var.'"',
> is_callable($var) => 'callable',
>
On 15.12.20 20:08, Sara Golemon wrote:
Or even better with existing syntax:
```php
$this->handler = match($var) {
null, true, false => json_encode($var),
default => \is_string($var) ? "\"$var\"" : \rtrim(\print_r($var, true)),
};
I appreciate that this is a specific counter-example to your
On Mon, Dec 14, 2020 at 5:30 PM Andreas Leathley wrote:
> With match this becomes much more concise:
>
> ```php
> $this->handler = function ($var): string {
> return match {
> null === $var => 'null',
> true === $var => 'true',
> false === $var => 'false',
>
On Tue, Dec 15, 2020, at 3:00 AM, Nikita Popov wrote:
> On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield
> wrote:
>
> > I present to Internals this tiny RFC to follow up on the match()
> > expression RFC from earlier in the year. There was solidly positive
> > support for this shortcut previously
Hi internals
> With match this becomes much more concise:
>
> ```php
> $this->handler = function ($var): string {
> return match {
> null === $var => 'null',
> true === $var => 'true',
> false === $var => 'false',
> \is_string($var) => '"'.$var.'"',
>
On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield
wrote:
> I present to Internals this tiny RFC to follow up on the match()
> expression RFC from earlier in the year. There was solidly positive
> support for this shortcut previously but it was removed for simplicity at
> the time, with the intent t
On Tue, 15 Dec 2020, 00:30 Andreas Leathley, wrote:
> I checked in my vendor directory for currently used switch(true) usages,
> there were 96 matches. It is often used when handling an unknown value
> and needing to display or convert it, as there the structure of a switch
> is easier to scan co
I checked in my vendor directory for currently used switch(true) usages,
there were 96 matches. It is often used when handling an unknown value
and needing to display or convert it, as there the structure of a switch
is easier to scan compared to other comparisons like ifs (at least it is
for me).
On Mon, Dec 14, 2020 at 1:23 PM Sara Golemon wrote:
>
> On Mon, Dec 14, 2020 at 2:24 PM Doug Nelson wrote:
>
> > Both you and Sara at different points have talked about thinking was bad
> > practice, but I've not read anything compelling about why it should be
> > considered as such.
> >
> >
> I'
Den 2020-12-14 kl. 22:23, skrev Sara Golemon:
On Mon, Dec 14, 2020 at 2:24 PM Doug Nelson wrote:
Both you and Sara at different points have talked about thinking was bad
practice, but I've not read anything compelling about why it should be
considered as such.
I'm not a full -1 on the conce
On 14.12.20 18:33, Larry Garfield wrote:
I present to Internals this tiny RFC to follow up on the match() expression RFC
from earlier in the year. There was solidly positive support for this shortcut
previously but it was removed for simplicity at the time, with the intent to
bring it back la
I don't understand what's the advantage of the short match? Why would
I ever want to use it?
If I ever saw this kind of code in my codebase then I would
immediately refactor it to use if statements. That is just abuse of
match statement in my opinion. If someone wants to abuse match syntax
like thi
On Mon, Dec 14, 2020 at 2:24 PM Doug Nelson wrote:
> Both you and Sara at different points have talked about thinking was bad
> practice, but I've not read anything compelling about why it should be
> considered as such.
>
>
I'm not a full -1 on the concept (especially as match(true) has the
conv
Another situation in which _ might be useful. match (_) { ... }
On Mon, 14 Dec 2020, 21:43 Marco Pivetta, wrote:
> Hey Doug,
>
>
>
>
> On Mon, Dec 14, 2020, 21:24 Doug Nelson wrote:
>
> > Hi Marco,
> >
> > Is there any chance you can elaborate on why you feel it's a bad idea?
> >
> > Both you a
Hey Doug,
On Mon, Dec 14, 2020, 21:24 Doug Nelson wrote:
> Hi Marco,
>
> Is there any chance you can elaborate on why you feel it's a bad idea?
>
> Both you and Sara at different points have talked about thinking was bad
> practice, but I've not read anything compelling about why it should be
Hi Marco,
Is there any chance you can elaborate on why you feel it's a bad idea?
Both you and Sara at different points have talked about thinking was bad
practice, but I've not read anything compelling about why it should be
considered as such.
Kind regards,
Doug Nelson
On Mon, 14 Dec 2020 at 1
Hey Larry,
On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield
wrote:
> I present to Internals this tiny RFC to follow up on the match()
> expression RFC from earlier in the year. There was solidly positive
> support for this shortcut previously but it was removed for simplicity at
> the time, with
I present to Internals this tiny RFC to follow up on the match() expression RFC
from earlier in the year. There was solidly positive support for this shortcut
previously but it was removed for simplicity at the time, with the intent to
bring it back later. It's now later.
https://wiki.php.net
29 matches
Mail list logo