Additional Binary Operators

Manu turkeyman at gmail.com
Sun Mar 3 06:42:32 PST 2013


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 at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130304/ecae0bd1/attachment.html>


More information about the Digitalmars-d mailing list