Will D ever get optional named parameters?

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 15 04:50:04 PDT 2014


On Wed, 15 Oct 2014 11:21:43 +0000
via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On Tuesday, 14 October 2014 at 21:21:23 UTC, 岩倉 澪 wrote:
> > Something like:
> > void foo(int a = 42, int b = 0){}
> > foo(@default, 7); //rewritten to foo(42, 7);
> 
> It is useful to have "_" mean "I don't care" when you have 
> tuples. So you would then write:
> 
> "foo( _ , 7 )" and " _,y = get_point()"

it better be "__" (two underscores). the rationale is simple: "__" is
clearly reserved for internal use, so it can has any meaning we need
without breaking any code. 'cause single underscore now can be used as
placeholder in `foreach (_; 0..42)`, *AND* still can be accessed as
normal var. besides, nested foreach with '_' is not working. but "__"
can generate unique temporary variable each time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141015/855dafe0/attachment.sig>


More information about the Digitalmars-d mailing list