Re: Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
On Thursday, 24 January 2019 at 22:02:36 UTC, bauss wrote: On Thursday, 24 January 2019 at 21:25:45 UTC, Paul Backus wrote: So, I'm not sure what the best solution here is. The best solution is just to pass a copy since there's no absolute need for a reference to be passed. But if I will

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-24 Thread FrankLike via Digitalmars-d-learn
On Thursday, 24 January 2019 at 12:19:44 UTC, Kagamin wrote: Try workarounds here: https://issues.dlang.org/show_bug.cgi?id=1448 https://issues.dlang.org/show_bug.cgi?id=2742 How do I set the font? Please.

Re: Am I missing with ref in this code?

2019-01-24 Thread bauss via Digitalmars-d-learn
On Thursday, 24 January 2019 at 21:25:45 UTC, Paul Backus wrote: So, I'm not sure what the best solution here is. The best solution is just to pass a copy since there's no absolute need for a reference to be passed.

Re: Am I missing with ref in this code?

2019-01-24 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 24 January 2019 at 16:04:06 UTC, Suliman wrote: Error: static assert: "Cannot convert arguments '(MyUrl)' to function arguments '(MyUrl*)'." You've forgotten to change the call site to pass a pointer. However, it turns out that even if you do that, vibe will not allow you to

Re: Is there something special required to use Appender.clear

2019-01-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/19 7:35 AM, FeepingCreature wrote: On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote: On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: Sorry if this is a stupid question, but is there something special required to call Appender.clear?  When I attempt even just

Re: Is there something special required to use Appender.clear

2019-01-24 Thread Ali Çehreli via Digitalmars-d-learn
On 01/24/2019 04:35 AM, FeepingCreature wrote: > On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote: >> On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: >>> Sorry if this is a stupid question, but is there something special >>> required to call Appender.clear? When I

Re: Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
It's because runWorkerTask internally passes its arguments along to the function by value: https://github.com/vibe-d/vibe.d/blob/master/core/vibe/core/core.d#L364 The workaround is to pass a pointer instead: void getServiceStatus(MyUrl* url) { // ... } // ...

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-24 Thread FrankLike via Digitalmars-d-learn
On Thursday, 24 January 2019 at 12:19:44 UTC, Kagamin wrote: Try workarounds here: https://issues.dlang.org/show_bug.cgi?id=1448 https://issues.dlang.org/show_bug.cgi?id=2742 Ok,thank you. import std.stdio; import core.sys.windows.windows; import std.process:executeShell; extern(Windows) bool

Re: Am I missing with ref in this code?

2019-01-24 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 24 January 2019 at 15:28:19 UTC, Suliman wrote: I am doing very small link-checker. Here is' code https://run.dlang.io/is/p8whrA I am expecting that on line: writefln("url: %s, status: %s", url.url, url.status); I will print link and it's status. But I am getting only: url:

Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
I am doing very small link-checker. Here is' code https://run.dlang.io/is/p8whrA I am expecting that on line: writefln("url: %s, status: %s", url.url, url.status); I will print link and it's status. But I am getting only: url: http://127.0.0.1:8081/hck, status: url: http://127.0.0.1:8081/hck2,

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 24 January 2019 at 12:58:15 UTC, JN wrote: Doh. Of course. I feel so dumb. I just had it at @disable this();, then replaced @disable with private without thinking to add {} Give me a nickel for every time I've made an edit like that...!

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread JN via Digitalmars-d-learn
On Thursday, 24 January 2019 at 12:52:47 UTC, Arafel wrote: You are declaring the constructor, but not defining it, i.e. you're telling the compiler that it's in some other compilation unit. The compiler won't complain, but the linker will. If you replace: [...] with: [...] it should

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread Arafel via Digitalmars-d-learn
You are declaring the constructor, but not defining it, i.e. you're telling the compiler that it's in some other compilation unit. The compiler won't complain, but the linker will. If you replace: private this(); with: private this() {} it should work. A. On 1/24/19 1:48 PM, JN

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread JN via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 19:41:44 UTC, Alex wrote: On Wednesday, 23 January 2019 at 19:26:37 UTC, JN wrote: class Foo { static Foo makeFoo() { Foo f = new Foo(); return f; } } void main() { Foo f = Foo.makeFoo(); } For a code like this. I'd like all

Re: Is there something special required to use Appender.clear

2019-01-24 Thread FeepingCreature via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote: On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: Sorry if this is a stupid question, but is there something special required to call Appender.clear? When I attempt even just a simple use I am getting compile errors

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-24 Thread Kagamin via Digitalmars-d-learn
Try workarounds here: https://issues.dlang.org/show_bug.cgi?id=1448 https://issues.dlang.org/show_bug.cgi?id=2742

Re: opEquals() non-standard return type

2019-01-24 Thread Jacob Shtokolov via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 17:28:37 UTC, H. S. Teoh wrote: The best way to do this is to use a string DSL or a delegate as template argument. For example: auto result = User.filter!q{ User.name == "John" }; or: auto result = User.filter!(u => u.name == "John"); I

Re: opEquals() non-standard return type

2019-01-24 Thread Jacob Shtokolov via Digitalmars-d-learn
On Thursday, 24 January 2019 at 00:47:37 UTC, Ali Çehreli wrote: Yeah, that can't work. Remove the bool-returning one and your code works with the 'alias this' above. Wow, this is an amazing workaround! I didn't think about it in that way. It perfectly solves the issue. Thank you!

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-24 Thread FrankLike via Digitalmars-d-learn
On Thursday, 24 January 2019 at 07:48:44 UTC, FrankLike wrote: Hi,everyone, for example: import std.stdio; import std.process:executeShell; extern(C) int setlocale(int,char*); static this() { import core.stdc.wchar_; import core.stdc.stdio;