Re: how to define infix function

2019-04-11 Thread KnightMare via Digitalmars-d-learn
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

Re: how to define infix function

2019-04-11 Thread KnightMare via Digitalmars-d-learn
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

Re: how to define infix function

2018-06-04 Thread Andrea Fontana via Digitalmars-d-learn
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

Re: how to define infix function

2018-06-03 Thread Meta via Digitalmars-d-learn
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,

Re: how to define infix function

2018-06-03 Thread greatsam4sure via Digitalmars-d-learn
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

Re: how to define infix function

2018-06-02 Thread Simen Kjærås via Digitalmars-d-learn
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

Re: how to define infix function

2018-06-02 Thread greatsam4sure via Digitalmars-d-learn
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.

Re: how to define infix function

2018-06-02 Thread Neia Neutuladh via Digitalmars-d-learn
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

Re: how to define infix function

2018-06-02 Thread Ali Çehreli via Digitalmars-d-learn
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