www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Keyword arguments / Named parameters library implementation

reply Matthias Walter <xammy xammy.homelinux.net> writes:
Hi,

I've written a small module (at the moment called utils.keywordargs)
which simulates keyword arguments (aka named parameters). The
documentation can be found here,

http://xammy.xammy.homelinux.net/~xammy/utils_keywordargs.html

while the code is at

http://xammy.xammy.homelinux.net/~xammy/keywordargs.d

or in a better readable format: http://pastebin.com/AfqKKziW


There was some discussion about introducing them in the language a while
ago. One argument against keyword arguments was that the names become
part of the interface. This wouldn't be different when using my
implementation, but as the names are compile-time strings, handling
different versions of a library is just a matter of putting the right
string constant into the keyword argument template.

Any comments? Is something like that interesting for phobos? If yes, I'd
suggest to put it on github to make further work easier.

Best regards,

Matthias
Mar 19 2012
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Matthias Walter:

 I've written a small module (at the moment called utils.keywordargs)
 which simulates keyword arguments (aka named parameters). The
 documentation can be found here,
Regardless the implementation quality of your code, I wait for the real thing :-) Bye, bearophile
Mar 19 2012
parent reply Matthias Walter <xammy xammy.homelinux.net> writes:
On 03/19/2012 07:53 PM, bearophile wrote:
 Matthias Walter:
 
 I've written a small module (at the moment called utils.keywordargs)
 which simulates keyword arguments (aka named parameters). The
 documentation can be found here,
Regardless the implementation quality of your code, I wait for the real thing :-)
I understand "the real thing" as a language implementation of keyword arguments instead of a library "workaround", right?
Mar 20 2012
parent reply bearophile <bearophileHUGS lycos.com> writes:
Matthias Walter:

 I understand "the real thing" as a language implementation of keyword
 arguments instead of a library "workaround", right?
Right. Even if your code is good, named arguments are a feature that needs to be built-in, or it will not happen. Creative usage of the language has its limits. Bye, bearophile
Mar 20 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 3/20/12 7:14 AM, bearophile wrote:
 Matthias Walter:

 I understand "the real thing" as a language implementation of
 keyword arguments instead of a library "workaround", right?
Right. Even if your code is good, named arguments are a feature that needs to be built-in, or it will not happen. Creative usage of the language has its limits.
I think we're very far away from them. Andrei
Mar 20 2012
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Andrei Alexandrescu:

 I think we're very far away from them.
What do you mean? Do you mean that Matthias Walter's implementation is very far from being a good enough implementation of named arguments? :-) (I have not said that named arguments are necessary. I have said that I think it's not probable that a library implementation of them will be good enough.) Hugs, bearophile
Mar 20 2012
parent =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <xtzgzorex gmail.com> writes:
On 20-03-2012 17:01, bearophile wrote:
 Andrei Alexandrescu:

 I think we're very far away from them.
What do you mean? Do you mean that Matthias Walter's implementation is very far from being a good enough implementation of named arguments? :-) (I have not said that named arguments are necessary. I have said that I think it's not probable that a library implementation of them will be good enough.) Hugs, bearophile
I have to agree that a library implementation cannot provide what the language would be able to here. Just the requirement that functions with named arguments must be templatized makes the strategy more or less unusable for class hierarchies. -- - Alex
Mar 20 2012
prev sibling parent bearophile <bearophileHUGS lycos.com> writes:
Andrei Alexandrescu:

bearophile:
 Right. Even if your code is good, named arguments are a feature that
 needs to be built-in, or it will not happen. Creative usage of the
 language has its limits.
I think we're very far away from them.
With a less sleepy brain I understand, your "them" refers to the limits. I agree that probably there are several creative uses to be invented still of the currently present D features. But I don't think the creative use of the current D features will give us good enough named parameters :-) Bye, bearophile
Mar 21 2012
prev sibling parent "timotheecour" <thelastmammoth gmail.com> writes:
Hi, It seems these links are unavailable now:
 http://xammy.xammy.homelinux.net/~xammy/utils_keywordargs.html
 http://xammy.xammy.homelinux.net/~xammy/keywordargs.d
Sep 09 2012