Re: D equivalent of C++ explicit

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote: On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s `explicit` keyword in D? No, because all constructors are

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-19 Thread nov via Digitalmars-d-learn
On Friday, 20 August 2021 at 04:27:34 UTC, Jesse Phillips wrote: For me, this code generates the Message Box. Does this happen for you? no errors https://run.dlang.io/is/4tlm3p ```D void main() { try { import std.stdio: File; File file = File(__FILE__,"r");

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-19 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 19 August 2021 at 13:47:56 UTC, Ruby The Roobster wrote: On Thursday, 19 August 2021 at 03:25:31 UTC, Jesse Phillips wrote: tell me what went wrong. I am using DMD 2.097.2 : ```d case WM_CREATE: //Executed on creation of the window... try { import core.stdc.stdio;

Re: "...cannot be interpreted at compile time" I can't find the source of the error!

2021-08-19 Thread Pablo De Nápoli via Digitalmars-d-learn
On Friday, 20 August 2021 at 02:51:16 UTC, jfondren wrote: On Friday, 20 August 2021 at 02:30:53 UTC, Pablo De Nápoli wrote: Any idea of which could be the cause of trouble or on how to get more specific diagnosis? With no extra arguments I get a "compile time context created here"

Re: "...cannot be interpreted at compile time" I can't find the source of the error!

2021-08-19 Thread jfondren via Digitalmars-d-learn
On Friday, 20 August 2021 at 02:30:53 UTC, Pablo De Nápoli wrote: Any idea of which could be the cause of trouble or on how to get more specific diagnosis? With no extra arguments I get a "compile time context created here" addendum. Does that not show up for you or does the line not make

"...cannot be interpreted at compile time" I can't find the source of the error!

2021-08-19 Thread Pablo De Nápoli via Digitalmars-d-learn
I am trying to write a D wrapper for libmpdec (https://www.bytereef.org/mpdecimal/). I get the following message (compiling with dmd with -v and -verrros=context) semantic2 cuenta mpdec/decimal.d(35,20): Error: `mpd_new` cannot be interpreted at compile time, because it has no

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 19 August 2021 at 15:38:19 UTC, evilrat wrote: On Thursday, 19 August 2021 at 15:12:03 UTC, Ferhat Kurtulmuş Btw, based on https://github.com/dlang/druntime/blob/master/src/object.d#L4209: import core.lifetime; import core.stdc.stdio; import core.stdc.stdlib; extern (C) void

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 19 August 2021 at 15:38:19 UTC, evilrat wrote: On Thursday, 19 August 2021 at 15:12:03 UTC, Ferhat Kurtulmuş This is cool, but even in unit tests for malloc wrapper there is only simple case with class without references to another class and no dtor. If you examine the entire

Re: D equivalent of C++ explicit

2021-08-19 Thread Tejas via Digitalmars-d-learn
On Thursday, 19 August 2021 at 18:11:20 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote: On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to

Re: D equivalent of C++ explicit

2021-08-19 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote: On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s `explicit` keyword in D? No, because all constructors are

Re: D equivalent of C++ explicit

2021-08-19 Thread Tejas via Digitalmars-d-learn
On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s `explicit` keyword in D? No, because all constructors are explicit in D. Oh... then I guess I'll have to manually

Re: D equivalent of C++ explicit

2021-08-19 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s `explicit` keyword in D? No, because all constructors are explicit in D.

D equivalent of C++ explicit

2021-08-19 Thread Tejas via Digitalmars-d-learn
As the topic says: Is there an equivalent to C++'s `explicit` keyword in D?

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Tejas via Digitalmars-d-learn
On Thursday, 19 August 2021 at 09:39:26 UTC, evilrat wrote: On Thursday, 19 August 2021 at 08:25:23 UTC, Bienlein wrote: Oops, I just realized that you can also not call emplace when @nogc is present. Well that is at least consistent with not either being able to call destroy ;-). So, I

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 15:12:03 UTC, Ferhat Kurtulmuş wrote: On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: [...] I just wanted to leave this here.

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: [...] I just wanted to leave this here. https://github.com/AuburnSounds/Dplug/blob/master/core/dplug/core/nogc.d

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-19 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 19 August 2021 at 03:25:31 UTC, Jesse Phillips wrote: tell me what went wrong. I am using DMD 2.097.2 This is an error message you'll get from Windows if the file is locked (open by another application). Odd. This works if I use a console application. It also works if I use C

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
This works, vit. Thanks! I thought it wouldn't, because your code still makes use of embrace. But it somehow worked, although I don't understand why ... ;-). I also added a constructor using the same approach as your destructor and this also worked: this(int otherNum) @nogc {

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 08:25:23 UTC, Bienlein wrote: Oops, I just realized that you can also not call emplace when @nogc is present. Well that is at least consistent with not either being able to call destroy ;-). So, I guess this means that you can forget about manually allocating

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread vit via Digitalmars-d-learn
On Thursday, 19 August 2021 at 08:25:23 UTC, Bienlein wrote: On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: class C { int num; ~this() { writeln("~this"); }

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: class C { int num; ~this() { writeln("~this"); } } void foo() // @nogc { auto mem =

How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
Hello, I allocate some instance of class C manually and then free the memory again: class C { int num; ~this() { writeln("~this"); } } void foo() // @nogc { auto mem = cast(C)malloc(__traits(classInstanceSize, C)); auto c =