Thread overview | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 13, 2014 Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
From what I've found, there was some work on this in the past (http://forum.dlang.org/thread/wokfqqbexazcguffwiif@forum.dlang.org?page=6#post-thclpgdlfxxhhfklwsoj:40forum.dlang.org), but a pull request was never made/I don't seem to find discussion about adding it as a feature anywhere. I think optional named parameters would be a nice addition, either to the core language, or something like the monadic solution from that old thread in phobos. Are there good reasons not to add something like this to the language, or is it simply a matter of doing the work? Has it been discussed much? |
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to 岩倉 澪 | On 10/13/2014 1:29 AM, "岩倉 澪" wrote:
> Are there good reasons not to add something like this to the language, or is it
> simply a matter of doing the work? Has it been discussed much?
Named parameters interact badly with overloading.
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Monday, 13 October 2014 at 08:48:11 UTC, Walter Bright wrote:
> On 10/13/2014 1:29 AM, "岩倉 澪" wrote:
>> Are there good reasons not to add something like this to the language, or is it
>> simply a matter of doing the work? Has it been discussed much?
>
> Named parameters interact badly with overloading.
How so? Can't the overload just be calculated on the subset of arguments that are given?
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Monday, 13 October 2014 at 08:48:11 UTC, Walter Bright wrote:
> Named parameters interact badly with overloading.
Good point, I hadn't thought of that!
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Monday, 13 October 2014 at 08:48:11 UTC, Walter Bright wrote:
> On 10/13/2014 1:29 AM, "岩倉 澪" wrote:
>> Are there good reasons not to add something like this to the language, or is it
>> simply a matter of doing the work? Has it been discussed much?
>
> Named parameters interact badly with overloading.
Why? Both C# and Ada support overloading and named parameters.
--
Paulo
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to 岩倉 澪 Attachments: | On Mon, 13 Oct 2014 08:29:40 +0000
"岩倉 澪" via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> I think optional named parameters would be a nice addition, either to the core language, or something like the monadic solution from that old thread in phobos.
if we'll add proper AA literals, they can be used instead. methinks.
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 13/10/14 10:47, Walter Bright wrote: > Named parameters interact badly with overloading. Nothing says that named parameters means that you can pass the arguments in any order. The linked forum post points to an implementation that requires the arguments to be passed in the regular order. -- /Jacob Carlborg |
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 10/13/14, 5:47 AM, Walter Bright wrote:
> On 10/13/2014 1:29 AM, "岩倉 澪" wrote:
>> Are there good reasons not to add something like this to the language,
>> or is it
>> simply a matter of doing the work? Has it been discussed much?
>
> Named parameters interact badly with overloading.
Could you give an example?
|
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright Attachments: | On 13/10/14 09:47, Walter Bright via Digitalmars-d wrote: > On 10/13/2014 1:29 AM, "岩倉 澪" wrote: >> Are there good reasons not to add something like this to the language, or is it simply a matter of doing the work? Has it been discussed much? > > Named parameters interact badly with overloading. Groovy handles this OK. (Python handles this fine by not having even a whiff of the possibility of overloading ;-) - -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
October 13, 2014 Re: Will D ever get optional named parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to 岩倉 澪 | On Monday, 13 October 2014 at 08:29:42 UTC, 岩倉 澪 wrote:
> From what I've found, there was some work on this in the past (http://forum.dlang.org/thread/wokfqqbexazcguffwiif@forum.dlang.org?page=6#post-thclpgdlfxxhhfklwsoj:40forum.dlang.org), but a pull request was never made/I don't seem to find discussion about adding it as a feature anywhere.
>
> I think optional named parameters would be a nice addition, either to the core language, or something like the monadic solution from that old thread in phobos.
>
> Are there good reasons not to add something like this to the language, or is it simply a matter of doing the work? Has it been discussed much?
Work-around I see a lot in C++:
---------------
bool filled = true;
drawCircle(filled);
---------------
instead of:
---------------
drawCircle(true);
---------------
|
Copyright © 1999-2021 by the D Language Foundation