Re: Permitting trailing commas in closure use() declarations

From: Date: Wed, 24 Jun 2020 15:25:03 +0000
Subject: Re: Permitting trailing commas in closure use() declarations
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-110716@lists.php.net to get a copy of this message
> On Jun 24, 2020, at 10:22, tyson andre <tysonandre775@hotmail.com> wrote: > > Hi internals, > > https://wiki.php.net/rfc/trailing_comma_in_parameter_list > mentioned > >> https://wiki.php.net/rfc/list-syntax-trailing-commas >> Trailing Commas In List Syntax was a previous proposal to support optional trailing commas in all >> list-like structures. >> >> Nothing has substantially changed since those RFCs in technical terms, but I think the >> aforementioned style > for breaking up large parameter lists has become more accepted in the >> meantime, and features like Constructor Property Promotion are going to increase its use further. > > So I'm wondering if anyone's interested in revisiting this: > > - It'd be easy to forget that function parameters support trailing commas, but not closure > uses, especially if you're new to the language. > - Supporting trailing commas in multi-line declarations would make version control history > easier > - if you had a closure for which fn wouldn't work (a list > of values *and references* to use, or a list of statements), > it'd be convenient to split it up across multiple lines > > e.g. > > ``` > $incrementing_id = 0; > return \array_map(static function (array $map) use ( > $function, > $some_data_structure, > $some_flag, > &$incrementing_id, > ): ReturnType { > ``` +1 for consistency with allowing trailing commas in all places like this. Cheers, Ben

Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
« previous php.internals (#110716) next »