Re: Providing implicit conversion of

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 17:15:55 UTC, bachmeier wrote: I get incorrect results, and when I'm lucky, my program segfaults because I accessed something I shouldn't. When I'm not, it silently and happily gives me the wrong answer. Maybe a compiler warning (not error) would help with detecti

Re: std.sumtype nested SumTypes

2024-01-22 Thread Paul Backus via Digitalmars-d-learn
On Monday, 22 January 2024 at 21:11:17 UTC, NonNull wrote: I'd like SumType to combine the implicit tags so there's only one tag. SumType does not do this automatically (because sometimes you might want to keep the inner SumTypes separate), but you can do it yourself like this: alias

Re: std.sumtype nested SumTypes

2024-01-22 Thread NonNull via Digitalmars-d-learn
On Monday, 22 January 2024 at 16:35:39 UTC, ryuukk_ wrote: On Monday, 22 January 2024 at 16:16:56 UTC, NonNull wrote: I am defining a new value type (small struct) from some old value types that are already `SumType`s. So I want to have some `SumType`s as some of the alternative types in anot

Re: Providing implicit conversion of

2024-01-22 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 22 January 2024 at 01:14:06 UTC, Steven Schveighoffer wrote: On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote: The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in

Re: Providing implicit conversion of

2024-01-22 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 22 January 2024 at 16:39:10 UTC, Nick Treleaven wrote: Memory safety issues are a worse class of bug than arithmetic bugs. The latter are reproducible if you feed them the same input. Memory safety bugs are reproducible with the tools like `valgrind`. Whereas arithmetic overflow bu

Re: Providing implicit conversion of

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 16:39:10 UTC, Nick Treleaven wrote: I've said multiple times that it's silly to spend so much time on memory safety if the language is going to allow stuff like this without a simple way to prevent it. Memory safety issues are a worse class of bug than arithmetic

Re: Providing implicit conversion of

2024-01-22 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 22 January 2024 at 01:14:06 UTC, Steven Schveighoffer wrote: The language should not allow unary unsigned anything. This is unlikely to get fixed, just due to the nature of D's philosophy when it comes to C compatibility. It would also break a lot of existing code. I think the b

Re: std.sumtype nested SumTypes

2024-01-22 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 22 January 2024 at 16:16:56 UTC, NonNull wrote: I am defining a new value type (small struct) from some old value types that are already `SumType`s. So I want to have some `SumType`s as some of the alternative types in another `SumType`. How how efficient this is, including space

std.sumtype nested SumTypes

2024-01-22 Thread NonNull via Digitalmars-d-learn
I am defining a new value type (small struct) from some old value types that are already `SumType`s. So I want to have some `SumType`s as some of the alternative types in another `SumType`. How how efficient this is, including space efficient?

Re: Setting field of struct object

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:56:59 UTC, zjh wrote: On Monday, 22 January 2024 at 15:51:37 UTC, zjh wrote: I spent `too much time` on D. And some of the inherent `drawbacks` of `C++` are too hateful. It's a package deal. Everything in C++ is there because there were benefits when they a

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:51:37 UTC, zjh wrote: I spent `too much time` on D. And some of the inherent `drawbacks` of `C++` are too hateful.

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:47:23 UTC, bachmeier wrote: Sounds like you should be using C++. Why are you here? I spent `too much time` on D.

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:14:32 UTC, Bkoie wrote: D is totally different from C++ in D you usually you wont construct the struct directly use alias as. Stop being `unconventional` and quickly copy their `good things`. Otherwise, the `development speed` of the D language is really `too

Re: Setting field of struct object

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:45:45 UTC, zjh wrote: On Monday, 22 January 2024 at 15:33:01 UTC, ryuukk_ wrote: it only took me 1 project to never want to touch C++ again.. D language used to have no `copy constructor`, isn't it now added in again? You have to admit the good aspects of `

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:33:01 UTC, ryuukk_ wrote: it only took me 1 project to never want to touch C++ again.. D language used to have no `copy constructor`, isn't it now added in again? You have to admit the good aspects of `C++`. You should take a look at the `latest C++`. C++ ha

Re: Setting field of struct object

2024-01-22 Thread ryuukk_ via Digitalmars-d-learn
I should note that it only took me 1 project to never want to touch C++ again.. that must be telling something, either about the language, or me, or both lol

Re: Setting field of struct object

2024-01-22 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the `D

Re: Setting field of struct object

2024-01-22 Thread Bkoie via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the `DRY` principle! Moreover, as the `package level, module level, class level, member level`, D lang

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the `DRY` principle! Moreover, as the `package level, module l

Re: Providing implicit conversion of

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 06:43:17 UTC, thinkunix wrote: Gavin Gray via Digitalmars-d-learn wrote: The following code:   ulong charlie = 11;   long johnstone = std.algorithm.comparison.max(0, -charlie);   writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): jo

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: D language violates integrity. Because D has no `class level` limit. These are all not `serious states`. It seems that D language is not `professional`.

Effective String to Date conversion?

2024-01-22 Thread atzensepp via Digitalmars-d-learn
Dear D-gurus, being new to D I am trying my first steps and the language is quite intuitive and appealing. When reading a file and creating a hash for the reocrds I want to get only the most recent ones. For this I need to convert Date/Time-Strings to comparable DateTime-Objects. The code belo

Re: Setting field of struct object

2024-01-22 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=e

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: VS:`C++` ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` It's not much different in D. ;) ```d import std; struct Person { string name, email; ulong age; } void main() { auto p = P

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote: It's common OOP style in some frameworks. With latest D you can also just use named parameters: ```d import std; struct Person { /*private*/ string name, email; /*private*/ ulong age; } void main() { auto p = Person(

Re: Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=e

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=email; return this; } auto withAge(ulong age) { thi

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:35:01 UTC, Joel wrote: I've lost interest in the video, looks like horrible syntax (F#). Nonetheless, this usually used with Objects (new class/struct instances), like so: ```d import std; struct Person { string name, email; ulong age; auto withNa

Re: Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: I've been watching a video (YouTube - "Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023") with something like the following code. This only sets the first method call, so I'm wanting to know how to make this work, for the s

Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
I've been watching a video (YouTube - "Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023") with something like the following code. This only sets the first method call, so I'm wanting to know how to make this work, for the subsequent methods. ```d import std; struct Person {