D2 Closure

bearophile bearophileHUGS at lycos.com
Mon Feb 22 04:47:48 PST 2010


Nick Sabalausky:

> "Michel Fortin
> >> f (a, b, default, default, e);
> f (a, b, , , e)

The syntax with just commas is shorter but you can miss commas, so I prefer the version with the default keyword, because it's more syntactically visible by the programmer's eye. Here saving the 'default' keystrokes doesn't look like an improvement.

I'd like to have named function arguments, even if partially implemented (there are cases with delegates/function pointers where you need to do more changes if you want to fully support named arguments, I've discussed this in the past. Such cases can be omitted in the first implementation of this feature), because in some situations they can increase code readability, and code readability can lower bug count and increase coding speed. (I don't know how the last C# has implemented this feature).

Named arguments and that syntax to omit default arguments in the middle can be used for similar purposes:
void foo(int a=1, int b=2, int c=3) {...}
foo(5, , 3);
foo(5, default, 3);
foo(a=5, c=3);
foo(5, c=3);

But this feature can be added later, I think it's an additive change. What's instead more important to discuss first are features for D2 that can't be just be added later, because they aren't just additive changes because they need changes not backwards compatible with D1 (or with the precedent version of D2). This is how the list of changes in Python3 was chosen: the minimal number of changes that are not backwards compatible with Python2.x minus the additive changes. All the other things that can be just added were postponed to Python3.1 or later. This is a good design strategy that I have not seen explicitly expressed in this newsgroup :-( I am sorry for not thinking and writing this comments few months ago, because now it's not that useful.

Bye,
bearophile



More information about the Digitalmars-d mailing list