Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Funny enough, it's one of the the things I really hate.
It's an ambiguation for the sake of simplification.
I'm not really fond of it in Python, too btw.
What happens can be seen in Python.
You have functions with too many parameters and as such are variadic...
And since they're variadic, you'll have a shitton of fun figuring out required vs non required arguments, typing errors (null? 0? empty string?) to set required arguments to a value and so on.
The trend to syntactic sugar is a thing that will lead to bad code TM...
And most of it is to save a few keystrokes.
The constructor syntax eg is imho a nightmare. It looks shit. -
Can’t say I’ve ever missed named arguments in PHP. In fact, I stand with @IntrusionCM here that it’s one of those things they maybe should’ve just left out..
-
bagfox8724yThings have been said already and I love that JS doesn’t have it. Just use objects instead if it’s really needed.
-
myss45284yYep, same for me, I also hate it in python, good luck figuring out which args are required..
-
I don't have an issue with named arguments in itself, but the inevitable consequence is people feel entirely justified in writing functions with 10+ arguments because "hey, they're all named so it's clear, right?!"
The last thing the average PHP dev needs is an excuse to write crappier code. -
If you need independently optional arguments, just use an options object. Named arguments don't work well in python and the only scenario where I can imagine they're good is if you want independently optional arguments in a strictly typed language without defining a struct.
-
hjk10157314yI love the idea. As 'function($required, null, true);' is not really descriptive but I'm afraid that it is going to be abused.
Any code that has a boolean flag is probably a named parameter in my PHP 8 code. -
Named arguments is for amateurs and any need for it shows that the code is badly written.
Related Rants
PHP now has named arguments. Welcome to the 20th century.
rant
php
you're new here please let me show you around
welcome