digitalmars.D.learn - UFCS confusion
Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line:createSet(createVector(langSize, index)).length;which works, into this line:createVector(langSize, index).createSet.length;receiving the error "Error: no property createSet for type int[]", when the signature for createSet is:static auto createSet(in int[] vector) pureWhat am I missing here? I'm sure it's stupidly obvious but it expects one argument, so I'm just calling it without parentheses.
Jul 13 2018
On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote:Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line:Do you try to call member functions? UFCS only works with free functions, meaning declared at module level. https://dlang.org/spec/function.html#pseudo-membercreateSet(createVector(langSize, index)).length;which works, into this line:createVector(langSize, index).createSet.length;receiving the error "Error: no property createSet for type int[]", when the signature for createSet is:static auto createSet(in int[] vector) pureWhat am I missing here? I'm sure it's stupidly obvious but it expects one argument, so I'm just calling it without parentheses.
Jul 13 2018
On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote:On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote:I'm not intentionally trying to call member functions, no. The functions are all static functions of a class, but the chaining of them using UFCS doesn't seem to work.Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line:Do you try to call member functions? UFCS only works with free functions, meaning declared at module level. https://dlang.org/spec/function.html#pseudo-membercreateSet(createVector(langSize, index)).length;which works, into this line:createVector(langSize, index).createSet.length;receiving the error "Error: no property createSet for type int[]", when the signature for createSet is:static auto createSet(in int[] vector) pureWhat am I missing here? I'm sure it's stupidly obvious but it expects one argument, so I'm just calling it without parentheses.
Jul 13 2018
On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote:On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote:OK, static functions of a class are static *member* functions, they are not free functions.On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote:I'm not intentionally trying to call member functions, no. The functions are all static functions of a class, but the chaining of them using UFCS doesn't seem to work.[...]Do you try to call member functions? UFCS only works with free functions, meaning declared at module level. https://dlang.org/spec/function.html#pseudo-member
Jul 13 2018
On Friday, 13 July 2018 at 11:17:32 UTC, Radu wrote:On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote:Oh, really? Well that will explain it then. I was sure I had used this syntax before but perhaps not. Thanks for your help!On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote:OK, static functions of a class are static *member* functions, they are not free functions.On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote:I'm not intentionally trying to call member functions, no. The functions are all static functions of a class, but the chaining of them using UFCS doesn't seem to work.[...]Do you try to call member functions? UFCS only works with free functions, meaning declared at module level. https://dlang.org/spec/function.html#pseudo-member
Jul 13 2018
On Friday, 13 July 2018 at 11:37:09 UTC, Michael wrote:On Friday, 13 July 2018 at 11:17:32 UTC, Radu wrote:try this: import std.functional : pipe; createVector(langSize, index).pipe!createSet.length;On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote:Oh, really? Well that will explain it then. I was sure I had used this syntax before but perhaps not. Thanks for your help!On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote:OK, static functions of a class are static *member* functions, they are not free functions.On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote:I'm not intentionally trying to call member functions, no. The functions are all static functions of a class, but the chaining of them using UFCS doesn't seem to work.[...]Do you try to call member functions? UFCS only works with free functions, meaning declared at module level. https://dlang.org/spec/function.html#pseudo-member
Jul 16 2018