Re: Empty subject in match and switch constructions

From: Date: Sun, 02 Feb 2025 13:40:03 +0000
Subject: Re: Empty subject in match and switch constructions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-126271@lists.php.net to get a copy of this message
Hi Dmitrii On Sun, Feb 2, 2025 at 1:05 PM Dmitry Derepko <xepozzd@gmail.com> wrote: > > I’m thinking about making match (true) and switch (true) be more lightweight by removing the > subject “(true)” and making matching “true condition” by default. > So $var = match (true) { … } can be used as $var = match { … }. There's an old RFC draft for this that never went anywhere. I believe the feedback was mixed, but there's no way to know how it would have turned out since it never went into voting. Given it's inactive, it should be ok for you to take over. https://wiki.php.net/rfc/short-match https://externals.io/message/112496 > when construction is overwhelming, but some features are > totally handy, such as checking for class of the subject: > when (obj) { > is Class1 -> … > is Class2 -> … > else -> ... > } > > Which was implemented by Ilija Tovilo in: > https://github.com/php/php-src/compare/master...iluuu1994:pattern-matching This is a really old draft. The RFC itself is mostly up to date. The implementation is still WIP. https://wiki.php.net/rfc/pattern-matching Ilija

« previous php.internals (#126271) next »