Reply to post: Possibilities...

Named arguments squeak into PHP 8.0, 7 years after first RFC

Chris Gray 1

Possibilities...

Another way for boolean parameters is to define an enumeration type for each parameter. Lots of typing once, but nice for the calls. If you define the enumeration tags nicely, then it is all perfectly clear. I didn't do that in any of my languages, however, because of scope issues with the tags, etc.

Having parameters with default values is likely OK, so long as you don't allow the function to change the defaults. If the defaults are always, e.g., 0, 0.0, false, "", then I expect readability is OK. As a bonus, you can add parameters and most calls don't require changes.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon