Re: [RFC] Named parameters

From: Date: Sun, 29 Mar 2015 12:28:39 +0000
Subject: Re: [RFC] Named parameters
Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

What happened to this RFC? This is a really great idea for php.

For example this function:

function getIdByTitle($title, $insert = false) {
	// find record
	// If no record find and $insert === true, insert new record and return the id
	// Return false
}

Reading over some old code, this way it would be a lot easier to understand what that second
parameter boolean = true is: 
	getIdByTitle('sample', insert = true)

than this way: 
	getIdByTitle('sample', true)


Also great for skipping default parameters.


About syntax: $insert => true seems kind of confusing: 
	$insert = true;
	getIdByTitle('sample', $insert => $insert)

My preference would be either - getIdByTitle('sample', insert = $insert) or
getIdByTitle('sample', insert: $insert) with no parameter name prefixes.

—---
Gints Murāns


Thread (46 messages)

« previous php.internals (#85527) next »