Amazing brand spanking new programming concept: Parameter Paths!

BBasile via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 21 03:28:30 PDT 2015


On Friday, 21 August 2015 at 00:29:35 UTC, TheHamster wrote:
> Parameter paths, a thousand words summed up:
> [...]
> Essentially it could reduce overhead of writing common sets of 
> overloaded functions.


unfortunately, with std.traits a template can be shorter and it 
will cover more type (all built-in numeric type, so natively 
comparable)

[Templates]
T Max(T a, T b) if (isNumeric!T)  { return (a < b) ? b : a; }

vs

[Parameter Paths]
auto Max(int a|float a, int b|float b) { return (a < b) ? b : a; }

And by the way with a TypeTuple (oh sorry...an AliasSeq...) there 
are also other options to write a short constraint.


More information about the Digitalmars-d mailing list