Pretty please: Named arguments

Bekenn leaveme at alone.com
Mon Feb 28 00:22:12 PST 2011


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?


More information about the Digitalmars-d mailing list