DIP 1030--Named Arguments--Community Review Round 1 Discussion

Jon Degenhardt jond at noreply.com
Sun Feb 9 02:15:36 UTC 2020


On Sunday, 9 February 2020 at 02:03:42 UTC, Adam D. Ruppe wrote:
> On Sunday, 9 February 2020 at 01:47:35 UTC, Jon Degenhardt 
> wrote:
>> Now my question - I know function parameters names can be 
>> retrieved by type introspection. What I don't know is the ways 
>> those names can be used such that programs can break if a 
>> parameter names change. Can you give some examples?
>
> We can do named parameters in a library already, something like:
>
> void func(int param) { }
>
> int item;
>
> callNamed!(func, param => item)(); // possible today. It pulls 
> param name of func and from the given lambda to match up the 
> item.
>
> If func's param name were to change, that callNamed would fail, 
> just like with this dip.

That's a useful example, thanks! It doesn't change my overall 
opinion though. I like the DIP, even this downside. However, it 
would be an improvement if there was a way for the developer of a 
function to disable named parameter invocation.

Or perhaps a way to discourage it, for example, a compile-time 
warning about no-backward compatibility for parameter names.


More information about the Digitalmars-d mailing list