On 06/02/2018 02:44 PM, greatsam4sure wrote:
> is it possible to define infix function in D
>
> 3.min(5)// 3: where min is a function, works in D
> 3 min 5 // does not work.
This is called universal function call syntax (UFCS) in D. The idea is
simple: You can pull the first argument out as if
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
Sorry for the typo
is it possible to define infix function in D
3.min(5)// 3: where min is a function, works in D
3 min 5 // does not work.
thanks in advance
This is a horrible abuse of D's operator overloading discovered
by Fee
On Saturday, 2 June 2018 at 22:01:02 UTC, Ali Çehreli wrote:
On 06/02/2018 02:44 PM, greatsam4sure wrote:
> is it possible to define infix function in D
>
> 3.min(5)// 3: where min is a function, works in D
> 3 min 5 // does not work.
This is called universal function call syntax (UFCS) in D. T
On Saturday, 2 June 2018 at 22:09:49 UTC, Neia Neutuladh wrote:
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
Sorry for the typo
is it possible to define infix function in D
3.min(5)// 3: where min is a function, works in D
3 min 5 // does not work.
thanks in advance
This i
On Saturday, 2 June 2018 at 22:09:49 UTC, Neia Neutuladh wrote:
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
[...]
This is a horrible abuse of D's operator overloading discovered
by FeepingCreature in the distant past.
You have to delimit your custom infix operator with sl
On Saturday, 2 June 2018 at 23:17:48 UTC, Simen Kjærås wrote:
On Saturday, 2 June 2018 at 22:09:49 UTC, Neia Neutuladh wrote:
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
Sorry for the typo
is it possible to define infix function in D
3.min(5)// 3: where min is a function, w
On Saturday, 2 June 2018 at 23:17:48 UTC, Simen Kjærås wrote:
unittest
{
import std.algorithm.comparison;
alias min = Operator!(std.algorithm.comparison.min);
assert(1 /min/ 3 == 1);
}
Why not:
alias Δ = Operator!(std.algorithm.comparison.min);
assert(1 /Δ/ 3 == 1);
To improve
On Saturday, 2 June 2018 at 22:01:02 UTC, Ali Çehreli wrote:
On 06/02/2018 02:44 PM, greatsam4sure wrote:
> is it possible to define infix function in D
> 3.min(5)// 3: where min is a function, works in D
> 3 min 5 // does not work.
This is called universal function call syntax (UFCS) in D.
Ali
u can use infix function with 1arg without any parentheses.
UPD
with 2args
arg1 `infix func` arg2
latter I told about UFCS with 1arg
`UFCS func` arg1