|
|
Subscribe / Log in / New account

The winding road to PHP 8's match expression

The winding road to PHP 8's match expression

Posted Sep 2, 2020 21:41 UTC (Wed) by mathstuf (subscriber, #69389)
In reply to: The winding road to PHP 8's match expression by professor
Parent article: The winding road to PHP 8's match expression

> Yes, because I know when i want the behaviour!

This mentality works for solo projects (and even then, more towards the one-off end of things). In my experience, having such sharp tools laying around with opt-in safety mechanisms make code review and later maintenance much harder. An explicit `fallthrough;` statement would have been a better solution rather than `break;`. Why? I find fallthrough to be the rarer case. Sure, Duff's device is cool and all, but I've written one maybe once? Seen it only a few other times? Making it have a few more keyword instances would have been fine (especially since your indentation is already all kinds of whack most of the time, doing `fallthrough; case …` would probably have worked).

> "i want everything on a silver plate and stuff i dont know about is someone else´s fault and thefor bad design" is just weird

I know about it and I even use it sometimes. I still comment when I explicitly mean for fallthrough to happen because I'm not the only one working on the code in question (even if another person isn't, years-later me might have to figure out what the code in question is doing anyways).


to post comments

The winding road to PHP 8's match expression

Posted Sep 2, 2020 22:29 UTC (Wed) by professor (subscriber, #63325) [Link]

You are perhaps right in a modern sense indeed.. Not everyone is like you though.

This part i dont understand at all..

"Sure, Duff's device is cool and all, but I've written one maybe once? Seen it only a few other times? Making it have a few more keyword instances would have been fine (especially since your indentation is already all kinds of whack most of the time, doing `fallthrough; case …` would probably have worked)."


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds