Re: opDispatch doesn't play nice with inheritance

2018-11-17 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 19:01:45 UTC, Ali Çehreli wrote: On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > opDispatch is special in that it allows for functions to be added to a > class or struct when undefined overtly but used elsewhere but it seems > those functions sadly are final. >

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 18 November 2018 at 00:51:51 UTC, drug wrote: On 18.11.2018 1:26, Adam D. Ruppe wrote: That's because the compiler passes it a hidden pointer to refer to the context outside. The compiler could perhaps be smarter about it, and see if those methods actually refer to the context, bu

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
On 18.11.2018 1:26, Adam D. Ruppe wrote: That's because the compiler passes it a hidden pointer to refer to the context outside. The compiler could perhaps be smarter about it, and see if those methods actually refer to the context, but it seems to simply say if the method is there, it might

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 21:33:37 UTC, drug wrote: Another problem I'm trying to resolve is that if I define struct S outside of unittest or inside of unittest but using static qualifier AllMembers does not return "this". Also if struct S do not have methods AllMembers also doesn't retu

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 17 Nov 2018 21:16:13 +, aliak wrote: > Could do. But it's not scalable. I'd have to comment out all the > unittests that call the template function with a T that allocates inside > the @nogc template (if I understood you correctly that it) I meant something like: void debugln(T...

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
On 18.11.2018 0:09, Adam D. Ruppe wrote: On Saturday, 17 November 2018 at 20:54:24 UTC, drug wrote: https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing? I'm not sure what it is supposed to do, but since this i

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Saturday, 17 November 2018 at 17:48:43 UTC, Neia Neutuladh wrote: On Sat, 17 Nov 2018 13:55:24 +, aliak wrote: You can use "debug blah" to hide inside functions that are attributed, but when you have an attributed function that calls a template, attribtues of which are supposed to be in

Re: Making external types available to mixins

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 17:58:54 UTC, John Chapman wrote: Has anyone had a similar need and come up with a solution? You might be able to just pass it the Calendar type, and then fetch its parent module and get the ICalendarFactory from there (assuming they are defined in the same mo

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 20:54:24 UTC, drug wrote: https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing? I'm not sure what it is supposed to do, but since this is kinda special - it is a keyword for the

Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing?

Re: Making external types available to mixins

2018-11-17 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 17 Nov 2018 17:58:54 +, John Chapman wrote: > The idea is that users could type (for example) makeWith!`Calendar`(…) > instead of the longer makeWith!ICalendarFactory(…). Your project might define a hundred types named ICalendarFactory; the compiler can't figure out which one you're t

Making external types available to mixins

2018-11-17 Thread John Chapman via Digitalmars-d-learn
The following code doesn't compile because the generated type name needs to be available inside the mixin's scope, whereas it's actually in another module. auto makeWith(string className, Args…)(auto ref Args args) { mixin("return makeWith!(I", className, "Factory)(args);"); // Fowarded to i

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 17 Nov 2018 13:55:24 +, aliak wrote: > You can use "debug blah" to hide inside functions that are attributed, > but when you have an attributed function that calls a template, > attribtues of which are supposed to be inferred, it seems to fail. You can explicitly mark a templated funct

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:46:00 UTC, Nicholas Wilson wrote: On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: auto assumeNoGC(T)(return scope T t) @trusted { /* ... */ } Sawweet! Thanks, that made the pri

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:55:24 UTC, aliak wrote: You can use "debug blah" to hide inside functions that are attributed, but when you have an attributed function that calls a template, attribtues of which are supposed to be inferred, it seems to fail. Maybe a bug if it's supposed t

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:43:20 UTC, Stanislav Blinov wrote: On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: Sawweet! Thanks, that made the printing possible! You're welcome ;) Still, try a more recent compiler. This works fine: void foo() @nogc { debug {

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: auto assumeNoGC(T)(return scope T t) @trusted { /* ... */ } Sawweet! Thanks, that made the printing possible! "scope" is const from what I understand right? It work

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: Sawweet! Thanks, that made the printing possible! You're welcome ;) Still, try a more recent compiler. This works fine: void foo() @nogc { debug { import std.stdio; writefln("%d", 42); } } "scope" is const

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Friday, 16 November 2018 at 13:03:40 UTC, Zoadian wrote: debug { import std.stdio; writeln(args); } As mentioned in the original post, that does not work.

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: At 'point 1', you just take by value. If `t` ends up being a closure, D will allocate. That's where it breaks the @nogc. Solution: auto assumeNoGC(T)(return scope T t) { /* ... */ } Now you take (and return) a `scope` t, in

Re: D money data type compatible with postgresql money

2018-11-17 Thread Daniel Kozák via Digitalmars-d-learn
On Saturday, 17 November 2018 at 12:35:45 UTC, Daniel Kozák wrote: On Saturday, 17 November 2018 at 11:48:56 UTC, Václav Kozák wrote: Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do i

Re: D money data type compatible with postgresql money

2018-11-17 Thread Daniel Kozák via Digitalmars-d-learn
On Saturday, 17 November 2018 at 11:48:56 UTC, Václav Kozák wrote: Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do it? Should I use some library (which?)? Thanks. You could use row.

Re: D money data type compatible with postgresql money

2018-11-17 Thread Alex via Digitalmars-d-learn
On Saturday, 17 November 2018 at 11:48:56 UTC, Václav Kozák wrote: Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do it? Should I use some library (which?)? Thanks. At code.dlang.org

D money data type compatible with postgresql money

2018-11-17 Thread Václav Kozák via Digitalmars-d-learn
Hello, I have a column of type money in my database. I need to pull the data from the db in my vibe.d backend, but it can't handle such data type. How can I do it? Should I use some library (which?)? Thanks.

Re: subsystem:windows and writeln

2018-11-17 Thread Andre Pany via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:36:01 UTC, Domain wrote: When I link the app with /subsystem:windows, and all writeln and writefln will cause a enforcement failed (stdio.d:2889). I think this is unacceptable. Another option is to enhance / correct the third party component if possible. You

Re: interrupting a function

2018-11-17 Thread Alex via Digitalmars-d-learn
On Saturday, 17 November 2018 at 08:17:36 UTC, Paul Backus wrote: You could run the calculation in another thread and use std.concurrency.receiveTimeout [1] to stop waiting for the result after a certain amount of time. [1] https://dlang.org/phobos/std_concurrency.html#.receiveTimeout Ah.

Re: interrupting a function

2018-11-17 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 17 November 2018 at 06:19:25 UTC, Alex wrote: It can happen, that the input params are correct, however, the calculation lasts too long. Is there a way, to measure the execution time of foo (á la benchmark) and then, if some execution time limit is exceeded to interrupt the calcula