Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread FeepingCreature via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: I am creating a TUI library and I have a class with the following constant fields: ``` class Label : Renderable { const string text; const TextAlignment textAlignment; const Color color; this(Dimensions

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 02:16:16 UTC, []() {}() wrote: nevermind ;-) .. seems clear nobody wants something like this in D. https://forum.dlang.org/post/kbl20f$2np9$1...@digitalmars.com and... 20 years later ... .. .

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 02:11:20 UTC, []() {}() wrote: maybe: @complete class insteadof: @concrete class

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 00:46:34 UTC, Siarhei Siamashka wrote: .. The `counter` member variable isn't really protected from rogue accesses (if these accesses are done by the code in the same source file) and this behavior differs from C++. module CounterTest; //@concrete public

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 00:46:34 UTC, Siarhei Siamashka wrote: On Monday, 21 November 2022 at 23:41:22 UTC, thebluepandabear wrote: But why give a C++ code example? 廊 It's a D code example and it even can't be compiled by a C++ compiler. Just add the missing main function: My bad.

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 21 November 2022 at 23:41:22 UTC, thebluepandabear wrote: But why give a C++ code example? 廊 It's a D code example and it even can't be compiled by a C++ compiler. Just add the missing main function: ```D void main() { shared c = new Counter; c.incrementCounter; c.count =

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 21 November 2022 at 23:25:21 UTC, []() {}() wrote: On Monday, 21 November 2022 at 11:56:59 UTC, Ali Çehreli wrote: .. You took the question as whether to define them for class hierarchies, safety-critical systems, etc. Ali Or even in a very, very simple counter class: public

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:56:59 UTC, Ali Çehreli wrote: .. You took the question as whether to define them for class hierarchies, safety-critical systems, etc. Ali Or even in a very, very simple counter class: public synchronized class Counter { static import core.atomic;

Re: "Little Scheme" and PL Design (Code Critique?)

2022-11-21 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu wrote: * Compatibility with both Windows and Linux. What do I need to consider? - Can I create threads/processes under Windows? [core.thread][1] and [std.process][2] provide platform-independent interfaces for this that should

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:34:50 UTC, thebluepandabear wrote: Best regards, Alexandru. Thanks but I haven't reached that yet. Well, I wish you'll reach as soon as possible :)

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Ali Çehreli via Digitalmars-d-learn
On 11/20/22 14:37, [] () {} () wrote: > so, as I understand it, your're against the use of private, against the > use of class, and against the use of encapsulation. I never implied any of that. > .. good luck with your career as a software engineer (but please, for > all our sakes, don't work

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread thebluepandabear via Digitalmars-d-learn
Best regards, Alexandru. Thanks but I haven't reached that yet.

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Ali Çehreli via Digitalmars-d-learn
On 11/20/22 23:01, [] () {} () wrote: > On that basis, I might be tempted to agree with you're point of view -> > never, ever, ever, ever, use classes in D. That's not my point of view. Ali

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:20:31 UTC, Alexandru Ermicioi wrote: On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: [...] Dunno if someone mentioned, but you can minimize use of boilerplate by hiding it into mixin templates. Say you have: ```D mixin template

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: I am creating a TUI library and I have a class with the following constant fields: ``` class Label : Renderable { const string text; const TextAlignment textAlignment; const Color color; this(Dimensions