Pretty please: Named arguments

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 28 05:48:48 PST 2011


On 2/28/11 2:22 AM, Bekenn wrote:
> On 2/28/2011 12:04 AM, Jonathan M Davis wrote:
>> You could be linking to code where you don't _have_ the source and
>> don't _have_
>> the names of the variables. It's all done by the function signature in
>> C, C++,
>> Java, C#, D, etc. The names of the variables are completely irrelevant to
>> calling the function, and so any linkers that follow C conventions (as
>> with
>> happens with D) _must_ be able to deal with function calls based on their
>> signatures. That doesn't necessarily mean that it would be
>> _impossible_ to find a
>> way to have named arguments in D, but it makes it _far_ harder.
>>
>> - Jonathna M Davis
>
> Again, I don't see why that's a problem; you can't call a function if
> you don't have a function declaration somewhere (perhaps in a .di file).
> The compiler would do parameter name lookup based on the current
> module's view of the function space.
>
> If you truly don't have a declaration, then that means you're calling
> through a function pointer or a delegate. Again, no problem: either a)
> the function pointer or the delegate specifies names for the arguments,
> or b) it doesn't, in which case you simply can't use named arguments.
>
> I'm absolutely not suggesting that parameter names should be part of the
> ABI, nor am I suggesting that function declarations must present
> parameter names; if names aren't available to the module at compile
> time, then you can't use named arguments. Where's the problem?

I don't see any.

One more thing, order of evaluation should still be left-to-right, not 
in order of arguments. This means the feature cannot be a syntactic 
rewrite (not a big issue, but definitely something to keep in mind).


Andrei


More information about the Digitalmars-d mailing list