View mode: basic / threaded / horizontal-split · Log in · Help
March 19, 2012
Keyword arguments / Named parameters library implementation
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
March 19, 2012
Re: Keyword arguments / Named parameters library implementation
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
March 20, 2012
Re: Keyword arguments / Named parameters library implementation
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?
March 20, 2012
Re: Keyword arguments / Named parameters library implementation
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
March 20, 2012
Re: Keyword arguments / Named parameters library implementation
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
March 20, 2012
Re: Keyword arguments / Named parameters library implementation
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
March 20, 2012
Re: Keyword arguments / Named parameters library implementation
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
March 21, 2012
Re: Keyword arguments / Named parameters library implementation
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
September 09, 2012
Re: Keyword arguments / Named parameters library implementation
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
Top | Discussion index | About this forum | D home