GCC has min and max operators, and the syntax is very clever:
  min = a <? b;
  max = a >? b;
Ie, a shorthand of the ?: operator, in a similar way that C# has '??' (another really nice shorthand).


On 2 March 2013 10:20, bearophile <bearophileHUGS@lycos.com> wrote:
Maybe #* #max #min? (Also usable with a "=" prefix, #=* #=max #=min).

Sorry, I meant postfix:

#*= #max= #min=

So instead of:

foo = min(foo, bar);
foo = foo.min(bar);

You write:

foo #min= bar;

(This syntax is generalizable to any diadic function. But I don't think D has to go there.)


An alternative syntax:

@* @max @min @*= @max= @min=

Another alternative syntax for the second multiplication operator:

auto M3 = M1 ^* M2;

Having all future D scientific libraries use the same nice and clean standard operator has some advantages.

Bye,
bearophile