DIP 1019--Named Arguments Lite--Community Review Round 2

Paul Backus snarwin at gmail.com
Fri Jun 7 16:00:05 UTC 2019


On Thursday, 6 June 2019 at 19:17:38 UTC, Jonathan Marler wrote:
> Languages like python that uses kwargs don't expose the names 
> of all parameters.  They are able to pick and choose which 
> parameters should be named.  This allows them to keep that 
> layer of protection/encapsulation for the parameters where the 
> name doesn't matter to the caller, just like when you have 
> private fields where the name doesn't matter to an outside 
> component.

Point of fact: python allows any parameter to be passed by name, 
not just kwargs:

     def f(x, y):
       return x - y

     print(f(y=2, x=5)) # prints "3"

The only languages I'm aware of with named arguments that require 
parameters to be explicitly marked as named in the function 
definition are Common Lisp [1] and Scheme [2]. In these 
languages, named parameters are entirely distinct from positional 
parameters--named parameters may only be passed by name, and 
positional parameters may only be passed by position.

[1] 
https://ccrma.stanford.edu/courses/220b-winter-2005/topics/commonlisp/arguments.html
[2] https://srfi.schemers.org/srfi-89/srfi-89.html


More information about the Digitalmars-d mailing list