Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread thebluepandabear via Digitalmars-d-learn
So the answer to your question is, use it when it has a payoff - for you. If that's the case, I've probably come to my own conclusion: that it's not worth it as it's not giving me any payoff for the extra code. Thanks.

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 23:30:38 UTC, thebluepandabear wrote: On Tuesday, 22 November 2022 at 22:40:54 UTC, []() {}() wrote: On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: As a newcomer, I'd be interested in hearing everyones thoughts. Everyones thoughts? You

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

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 10:10:48 UTC, Sergey wrote: .. I saw some posts at forum about private-class-scope, but community of core-D is fine with module-unit approach I think. That's fair enough. I fully support 'majority rules' (if that's what's happening here). But it could limit

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 22:40:54 UTC, []() {}() wrote: On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: As a newcomer, I'd be interested in hearing everyones thoughts. Everyones thoughts? You sure about that ;-) anyho To Const or Not to Const?

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread via Digitalmars-d-learn
On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: As a newcomer, I'd be interested in hearing everyones thoughts. Everyones thoughts? You sure about that ;-) anyho To Const or Not to Const? https://www.artima.com/articles/const-rtti-and-efficiency

Re: Can't assign extern(C) function pointer to D variable?

2022-11-22 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 21:32:43 UTC, Hipreme wrote: You need to create an alias containing your callback type. Thanks both!! I have all the pieces of the puzzle. I'm actually staying with the wrapping template solution. (Because the strongly typed one turns out too convoluted, and

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

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 21:00:58 UTC, []() {}() wrote: "Being able to declare a “friend” that is somewhere in some other file runs against notions of encapsulation." (This is the motivation for that article it seems). I completely disagree with the assertion. C++ Friend notion

Re: Can't assign extern(C) function pointer to D variable?

2022-11-22 Thread ag0aep6g via Digitalmars-d-learn
On 22.11.22 22:11, XavierAP wrote: I was surprised when it didn't compile, though I immediately found it understandable... Already read through https://dlang.org/spec/interfaceToC.html and https://wiki.dlang.org/Bind_D_to_C Is it really the case (that an extern(C) function pointer cannot be

Re: Can't assign extern(C) function pointer to D variable?

2022-11-22 Thread Hipreme via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 21:11:37 UTC, XavierAP wrote: I was surprised when it didn't compile, though I immediately found it understandable... Already read through https://dlang.org/spec/interfaceToC.html and https://wiki.dlang.org/Bind_D_to_C [...] You need to create an alias

Can't assign extern(C) function pointer to D variable?

2022-11-22 Thread XavierAP via Digitalmars-d-learn
I was surprised when it didn't compile, though I immediately found it understandable... Already read through https://dlang.org/spec/interfaceToC.html and https://wiki.dlang.org/Bind_D_to_C Is it really the case (that an extern(C) function pointer cannot be assigned to a D variable)? Or is it a

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

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 20:36:51 UTC, []() {}() wrote: From a software engineering perspective, what justification can their possibly be, for allowing (by default, and with no language mechanism to prevent it) any code in the same module as this class (including a tightly coupled,

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

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 10:10:48 UTC, Sergey wrote: Based on this (not too old) post the idea remains the same and approved by Walter’s experience: https://dlang.org/blog/2018/11/06/lost-in-translation-encapsulation/ I saw some posts at forum about private-class-scope, but community

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread XavierAP via Digitalmars-d-learn
On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: A question I have been thinking about whilst using D is how often I should be using const. Many people claim that all variables should be const by default, but whether or not it is really needed is debatable and oftentimes

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread Kagamin via Digitalmars-d-learn
On Friday, 18 November 2022 at 17:57:25 UTC, H. S. Teoh wrote: You're looking at it the wrong way. The kind of issues having const would solve is like when your function takes parameters x, y, z, and somewhere deep in the function you see the expression `x + y*z`. If x, y, and z are const,

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

2022-11-22 Thread Sergey via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 03:04:03 UTC, []() {}() wrote: 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: "Little Scheme" and PL Design (Code Critique?)

2022-11-22 Thread JG via Digitalmars-d-learn
On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu wrote: I just pushed a D implementation of "[Little Scheme](https://mitpress.mit.edu/9780262560993/the-little-schemer/)", which is a limited educational version of [Scheme](https://en.wikipedia.org/wiki/Scheme_(programming_language)),