Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread Tejas via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:52:18 UTC, HuskyNator wrote: On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 3:58 PM, Ali Çehreli wrote: Hmm. Perhaps the guideline should be "all destructors must be @nogc". That one I agree with. -Steve

Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread HuskyNator via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return what one would expect. I don't know if this matters either,

Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread HuskyNator via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 20:16:51 UTC, Dennis wrote: On Wednesday, 18 May 2022 at 20:05:05 UTC, HuskyNator wrote: This will print: ``` 0 50 nan ``` Which compiler and flags are you using? For me it just prints 50, you might be stumbling on some (old) bugs in the DMD backend with

Re: Installing DMD on linux via snap

2022-05-18 Thread Jordi Sayol via Digitalmars-d-learn
El 18/5/22 a les 17:24, matheus via Digitalmars-d-learn ha escrit: Yesterday I needed to install DMD on a fresh installed version of Linux, so since I was using Xubuntu I decided to use snap. $ sudo wget

Re: vibe.d ubuntu 22.04 ssl linking error

2022-05-18 Thread Gavin Gray via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 20:41:53 UTC, Gavin Gray wrote: After upgrading to ubuntu 22.04, I get the linker error below for a project that previously built successfully. OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022) LDC - the LLVM D compiler (1.27.1): based on DMD

vibe.d ubuntu 22.04 ssl linking error

2022-05-18 Thread Gavin Gray via Digitalmars-d-learn
After upgrading to ubuntu 22.04, I get the linker error below for a project that previously built successfully. OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022) LDC - the LLVM D compiler (1.27.1): based on DMD v2.097.2 and LLVM 12.0.1 built with LDC - the LLVM D compiler

Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread Dennis via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 20:05:05 UTC, HuskyNator wrote: This will print: ``` 0 50 nan ``` Which compiler and flags are you using? For me it just prints 50, you might be stumbling on some (old) bugs in the DMD backend with floating point registers. Examples of such bugs are:

Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 18, 2022 at 08:05:05PM +, HuskyNator via Digitalmars-d-learn wrote: [...] > ```d > module app; > import std.stdio; > > struct A { > float[1] vec; > this(float[1] n) { > this.vec = n; > } > } > > void main(string[] args) { > A c = A([50.0f]);

Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread HuskyNator via Digitalmars-d-learn
I came across strange, seemingly non-deterministic, behaviour today. I simplified it the best I could below. I entice you to run the following piece of code. ```d module app; import std.stdio; struct A { float[1] vec; this(float[1] n) { this.vec = n; }

Re: class destructors must be @disabled?

2022-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 5/18/22 12:45, Steven Schveighoffer wrote: > Not cleaning it up because you're afraid of destructors is not the answer. Fine. The GC allocation issue remains. It looks like one of the following should be observed: a) @disable ~this() for all classes so that we are safe from the

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 2:58 PM, H. S. Teoh wrote: On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] No. Class destructors are for cleaning up non-GC resources. As long as you stick to those, you can safely run them. Structs that get put into classes have

Re: class destructors must be @disabled?

2022-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 5/18/22 11:35, Steven Schveighoffer wrote: > Structs that get put into classes have to run their destructors > properly, otherwise, you will have horrible inconsistencies. Does that suggest a different guideline: "Careful with structs in classes." That goes against orthogonality

Re: class destructors must be @disabled?

2022-05-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > No. Class destructors are for cleaning up non-GC resources. As long as > you stick to those, you can safely run them. > > Structs that get put into classes have to run their destructors >

Re: class destructors must be @disabled?

2022-05-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 18, 2022 at 11:02:01AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > HORROR: > > Now, a big one that I've just realized. > > - The two guidelines above (the "don't touch class members" one and > the "don't allocate" one) miss an important fact that they apply >

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 2:02 PM, Ali Çehreli wrote: Of course, we still should and do have the power to shape our programs any way we want but I think '@disable ~this();' should be added to classes as a general rule unless the programmer knows it will work otherwise. What do you think? No. Class

class destructors must be @disabled?

2022-05-18 Thread Ali Çehreli via Digitalmars-d-learn
I am writing these in view of class objects commonly being constructed as GC-owned objects. GUIDELINES: We've seen the following points mentioned in these forums. - (This one is just a complication.) Classes don't have destructors anyway; they should be called finalizers. - Don't allocate

Re: Installing DMD on linux via snap

2022-05-18 Thread Alain De Vos via Digitalmars-d-learn
You could try on linux, apt-cache search dmd apt-cache search ldc apt-cache search ldc2

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-18 Thread zoujiaqing via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 15:33:09 UTC, Steven Schveighoffer wrote: On 5/18/22 2:13 AM, bauss wrote: On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote: https://dlang.org/changelog/2.100.0.html#deprecation_delete My code: ```D import std.stdio; class HttpClient { string

Re: Installing DMD on linux via snap

2022-05-18 Thread matheus via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 15:27:57 UTC, rikki cattermole wrote: Snap package source: https://github.com/dlang-snaps/dmd.snap/ Hasn't been updated in 3 years. I see... and even that I found my answer elsewhere, this problem was already discussed there:

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 2:13 AM, bauss wrote: On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote: https://dlang.org/changelog/2.100.0.html#deprecation_delete My code: ```D import std.stdio; class HttpClient { string get(string url) {     return ""; } string delete(string

Re: Installing DMD on linux via snap

2022-05-18 Thread rikki cattermole via Digitalmars-d-learn
Snap package source: https://github.com/dlang-snaps/dmd.snap/ Hasn't been updated in 3 years.

Installing DMD on linux via snap

2022-05-18 Thread matheus via Digitalmars-d-learn
Hi, Even my problem is already solved, I'm passing this information because I don't know if you are aware. Yesterday I needed to install DMD on a fresh installed version of Linux, so since I was using Xubuntu I decided to use snap. sudo snap install dmd Then a warning appeared saying that

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-18 Thread zoujiaqing via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 06:13:45 UTC, bauss wrote: Considering the deprecation period has ended then IMO it should be able to be used as an identifier. I would consider this a bug. I hope this is a bug ;)

Re: Why are structs and classes so different?

2022-05-18 Thread forkit via Digitalmars-d-learn
On Sunday, 15 May 2022 at 21:33:24 UTC, Ali Çehreli wrote: I still think my answer is the real one. My implied question remains: Why does C++ have struct and class disticnction? I know they have different default access specifications but does that warrant two kinds? Here is a

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-18 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote: https://dlang.org/changelog/2.100.0.html#deprecation_delete My code: ```D import std.stdio; class HttpClient { string get(string url) { return ""; } string delete(string url)

Re: Question on shapes

2022-05-18 Thread JG via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 00:10:55 UTC, Alain De Vos wrote: Let's say a shape is ,a circle with a radius ,or a square with a rectangular size. I want to pass shapes to functions, eg to draw them on the screen, draw(myshape) or myshape.draw(); But how do i implement best shapes ? You could