Re: Setting field of struct object

2024-05-14 Thread Menjanahary R. R. via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote: On Monday, 22 January 2024 at 08:35:01 UTC, Joel wrote: [...] Nonetheless, this usually used with Objects (new class/struct instances), like so: ```d import std; [...] Fluent Interface 😀

Re: Setting field of struct object

2024-02-01 Thread TheTeaLady 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-02-01 Thread Anonymouse 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) { this

Re: Setting field of struct object

2024-02-01 Thread TheTeaLady via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:47:23 UTC, bachmeier wrote: 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

Re: Setting field of struct object

2024-01-25 Thread zjh via Digitalmars-d-learn
On Thursday, 25 January 2024 at 08:46:34 UTC, Renato wrote: ```d void main() { Person p = { "Joe", "j...@ab.com", 30}; writeln(p); } ``` I just tested it and it works. It's `great`!

Re: Setting field of struct object

2024-01-25 Thread Renato 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 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: 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`.

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 {