Named parameters in function call
Paul Backus
snarwin at gmail.com
Wed Sep 9 11:48:28 UTC 2020
On Tuesday, 8 September 2020 at 13:28:22 UTC, Cecil Ward wrote:
>
> I wonder if there is any way in which we could combine this
> with strong typing of some sort (how?) to detect errors such as
> int xcoord;
> int ycoord;
>
> myfunc( x : ycoord, y : xcoord, color : blue ) [3]
>
> where the arguments are the wrong way around. Would have to
> change the types of the xcoord and ycoord variables somehow,
> something I have asked about earlier.
import std.typecons: Typedef;
alias XCoord = Typedef!(int, int.init, "XCoord");
alias YCoord = Typedef!(int, int.init, "YCoord");
auto myfunc(XCoord x, YCoord y) { ... }
More information about the Digitalmars-d-learn
mailing list