Re: Question on shapes

2022-05-17 Thread forkit via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote: In you OOP example, I am curious why you chose Shape to be an interface, rather than a base class.

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Sergey via Digitalmars-d-learn
On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote: I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same algorithm and similar code the output is different. H

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Tejas via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 09:38:31 UTC, Sergey wrote: On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote: I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same

Re: Why doesn't this piece of code work?

2022-05-17 Thread SvGaming via Digitalmars-d-learn
On Monday, 16 May 2022 at 22:25:23 UTC, kdevel wrote: On Monday, 16 May 2022 at 16:53:15 UTC, SvGaming wrote: [...] [...] In main your program reads an integer: ``` int n; writef("Pick an option: "); readf(" %s", &n); ``` [...] Just tried the solution and it works perfectly! Thank

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 16 May 2022 at 18:17:03 UTC, Allen Garvey wrote: Thanks so much, that fixed the problem! You have no idea have long I have spent trying to debug this! Oh I should have checked my impl, where I did all this already! https://github.com/adamdruppe/webassembly/blob/master/arsd-webassemb

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:36:21 UTC, Adam D Ruppe wrote: Oh I should have checked my impl, where I did all this already! https://github.com/adamdruppe/webassembly/blob/master/arsd-webassembly/object.d#L263 Looks like you forgot to increment the pointer and need "*d++ = cast(ubyte) c;" the

Re: What are (were) the most difficult parts of D?

2022-05-17 Thread zjh via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 06:28:10 UTC, cc wrote: Far better to just keep your house clean every day than let the trash pile up and wait for the maid to come, IMO. Right,GC is a bad idea!

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:43:45 UTC, Siarhei Siamashka wrote: Looks like you forgot to increment the pointer and need "*d++ = cast(ubyte) c;" there. hahaha yup. And filling the buffer one byte at a time is likely slow. prolly but meh, that's where the intrinsics are nice.

Re: What are (were) the most difficult parts of D?

2022-05-17 Thread zjh via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:50:30 UTC, zjh wrote: Right,GC is a bad idea! Endless use of memory without freeing. It's totally unreasonable waste.

Re: What are (were) the most difficult parts of D?

2022-05-17 Thread bauss via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:53:40 UTC, zjh wrote: On Tuesday, 17 May 2022 at 11:50:30 UTC, zjh wrote: Right,GC is a bad idea! Endless use of memory without freeing. It's totally unreasonable waste. It's not really endless use of memory and it does free. Depending on the strategy then it

Re: Question on shapes

2022-05-17 Thread Ali Çehreli via Digitalmars-d-learn
On 5/17/22 02:30, forkit wrote: > On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote: >> > > In you OOP example, I am curious why you chose Shape to be an interface, > rather than a base class. I always have the same question. :) interface feels lighterweight, so it is an arbitrary decis

Re: Why are structs and classes so different?

2022-05-17 Thread Kevin Bailey via Digitalmars-d-learn
Hi again Ali! On Monday, 16 May 2022 at 21:58:09 UTC, Ali Çehreli wrote: I for one misunderstood you. I really thought you were arguing that struct and class should be the same. To be specific: - My *primary* concern is that: Foo foo; is undefined behavior waiting to happen, that I can't d

Re: Why are structs and classes so different?

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 14:40:48 UTC, Kevin Bailey wrote: Foo foo; is undefined behavior waiting to happen, that I can't detect at a glance. It is actually perfectly well defined - for the class, it will be null, and this will kill the program if you use it. You might not like that defi

Re: Why are structs and classes so different?

2022-05-17 Thread Ali Çehreli via Digitalmars-d-learn
On 5/17/22 07:40, Kevin Bailey wrote: > Foo foo; > > is undefined behavior waiting to happen, that I can't detect at a glance. Foo is null there. (I don't remember whether accessing through null reference is undefined or segmentation fault (on common systems).) Using foo will not do some rando

Re: Why are structs and classes so different?

2022-05-17 Thread Johan via Digitalmars-d-learn
On Monday, 16 May 2022 at 21:20:43 UTC, Ali Çehreli wrote: On 5/16/22 10:35, Johan wrote: > What is very problematic is that you cannot see the difference in > syntax. In my opinion it would have been much better if the language > required using a `*` for class types: for example `Foo* a`, and `

Re: decimal type in d

2022-05-17 Thread vit via Digitalmars-d-learn
On Monday, 16 May 2022 at 09:59:41 UTC, bauss wrote: On Monday, 16 May 2022 at 09:46:57 UTC, IGotD- wrote: On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote: [...] This also something I wondered, it should be standard in the D library. Implementing it can be done straight forward with exist

undefined reference to `const const(char)[] object.Throwable.message()

2022-05-17 Thread kdevel via Digitalmars-d-learn
I am compiling some test code which dmd v2.100.and linking against a libdecimal.a compiled in March, probably compiled with dmd v2.099.0. ``` $ dmd -g mytest.d decimal.git/libdecimal.a ``` Now the linker complains: ``` decimal.git/libdecimal.a(decimal_4f_a27.o):(.data._D7decimalQi25Invalid

Re: undefined reference to `const const(char)[] object.Throwable.message()

2022-05-17 Thread rikki cattermole via Digitalmars-d-learn
As far as I know, no D compiler guarantees compatibility between objects built on different version of itself. The change would have been[0]. [0] https://github.com/dlang/druntime/commit/c6762914682d4fa894e2b746bf4bd9ce3ec9f7cb

Re: Question on shapes

2022-05-17 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 09:30:12 UTC, forkit wrote: On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote: In you OOP example, I am curious why you chose Shape to be an interface, rather than a base class. You can inherit from multiple interfaces, but only from one base class. So

Re: What are (were) the most difficult parts of D?

2022-05-17 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 06:28:10 UTC, cc wrote: having had this leave a pretty bad taste in my mouth, I now avoid the GC whenever possible, even when I don't have to. Bad idea. You should only avoid GC if your profiling shows that it is bad in a specific piece of code (e.g. some inner loop

Re: Language server

2022-05-17 Thread Alain De Vos via Digitalmars-d-learn
I tried neovim editor & serve-d and failed. I tried kate editor & serve-d and failed. https://github.com/Pure-D/serve-d Anyone has a clue ?

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

2022-05-17 Thread zoujiaqing via Digitalmars-d-learn
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) { return ""; } } void main() {

Re: Language server

2022-05-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 01:04:16 UTC, Alain De Vos wrote: I tried neovim editor & serve-d and failed. I tried kate editor & serve-d and failed. https://github.com/Pure-D/serve-d Anyone has a clue ? I'm using [lunarvim](https://github.com/LunarVim/LunarVim). It provides you the ability t

Re: Question on shapes

2022-05-17 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 al

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

2022-05-17 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) {