Named constructors
rikki cattermole
rikki at cattermole.co.nz
Fri Jan 11 11:25:39 UTC 2019
On 12/01/2019 12:24 AM, JN wrote:
> On Friday, 11 January 2019 at 07:53:56 UTC, rikki cattermole wrote:
>> On 11/01/2019 3:35 AM, JN wrote:
>>> Also, named/keyword arguments shouldn't be an issue in regards to
>>> overloading and argument order. Every language I know that has
>>> named/kw arguments allows either only keyword arguments or keywords
>>> arguments at the end of the argument list. You can do:
>>>
>>> foo(x=10)
>>> foo(10, 20, z=30)
>>>
>>> but you can't do:
>>>
>>> foo(x=10, 20)
>>>
>>> because it'd be ambiguous.
>>
>> Actually every example there is ambiguous and problematic in D.
>> It conflicts with AssignExpression which is identical in syntax and
>> usage!
>
> well, it's because I used the equality sign, languages like C# use :,
>
> I guess:
>
> foo(x:10, 20)
>
> would be better?
Yup no ambiguity, that is why my named parameter DIP uses it :)
More information about the Digitalmars-d
mailing list