FYI: Be careful with imports when using public:
Salih Dincer
salihdb at hotmail.com
Wed Oct 11 03:53:07 UTC 2023
On Tuesday, 10 October 2023 at 07:43:26 UTC, Jonathan M Davis
wrote:
> ... In this particular case, the confusing result is that
> trying to call functions in std.range.primitives (such as
> walkLength or moveFront) on an instance of Foo using UFCS will
> result in the code not compiling (whereas using the normal
> function call syntax works just fine), and the error messages
> don't make it all clear as to why, so it took me quite a while
> to figure out what the problem was.
I didn't experience any compilation errors or import problems
either. Moreover, I also tried selective import. For example:
```d
--main.d--
import publicCase;
import std.stdio;
void main() {
auto s = S(" No Problem ");
s.wordCount.writeln(": ", s);
// 2: S(" No Problem ")
}
--publicCase.d--
module publicCase;
struct S
{
private:
string str;
public:
import std.range.primitives;// : walkLength;
import std.algorithm;// : splitter;
size_t length() => str.length;
size_t wordCount() => str.splitter.walkLength;
}
```
SDB at 79
More information about the Digitalmars-d
mailing list