Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread RTM via Digitalmars-d-learn
On Saturday, 18 February 2023 at 06:55:49 UTC, ProtectAndHide wrote: More likely is comes from my experience .. otherwise I wouldn't be surprised ;-) Now that's a screaming sign: https://media.licdn.com/dms/image/C4D12AQEymZALzWVDXQ/article-cover_image-shrink_600_2000/0/1629008577928?e=21474

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread zjh via Digitalmars-d-learn
On Saturday, 18 February 2023 at 06:55:49 UTC, ProtectAndHide wrote: No, I think D is not for me. They don't care about the needs of `D` users! They won't listen ,even if you said it thousand times.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread ProtectAndHide via Digitalmars-d-learn
On Saturday, 18 February 2023 at 06:12:47 UTC, RTM wrote: No offense, but it looks like your surprise comes from your inexperience. More likely is comes from my experience .. otherwise I wouldn't be surprised ;-) btw. I love the way that Brayan Martinez (Senior Developer with Azure, Spr

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread ProtectAndHide via Digitalmars-d-learn
On Friday, 17 February 2023 at 22:58:19 UTC, ProtectAndHide wrote: Actually, I just now understand 'why' (as opposed to 'how') private works in D the way it does. In D, private within a module is (more-or-less) like static used in C outside of a function. That is, in C it restrains the v

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread ProtectAndHide via Digitalmars-d-learn
On Friday, 17 February 2023 at 04:58:17 UTC, RTM wrote: Data hiding is overrated. ... Actually, data hiding is at the core of using objects, and objects are at the core of doing OOP. " Hiding internal state and requiring all interaction to be performed through an object's methods is known

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:42:19 UTC, Ali Çehreli wrote: // Two different steps auto g1 = r.map!((int n) => n * n); auto g2 = r.map!((int n) => n * 10); // The rest of the algoritm auto result = choose(condition, g1, g2) .array; Now that's a handy c

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:44:20 UTC, H. S. Teoh wrote: Here's an actual function taken from my own code, that returns a different range type depending on a runtime condition, maybe this will help you? Thanks, this was helpful. I keep forgetting to expand my horizons on what can be ret

Re: [OT] (Go) Do I read it right?

2023-02-17 Thread ryuukk_ via Digitalmars-d-learn
On Thursday, 16 February 2023 at 18:15:28 UTC, Kagamin wrote: https://github.com/dominikh/go-tools/issues/917 How go programmers cope with this feature? The idea is nice, they do not use exceptions, but the implementation is very poor as you can see From what i read, they have plans to impr

Re: Debugging memory leaks

2023-02-17 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 18:21:34 UTC, Hipreme wrote: I want to know if there is some way to debug memory leaks in runtime. I have been dealing with that by using a profiler and checking D runtime function calls. Usually those which allocates has high cpu usage so it can be easy for

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread Ali Çehreli via Digitalmars-d-learn
On 2/17/23 09:30, Chris Piker wrote: > operatorG needs > to be of one of two different types at runtime std.range.choose may be useful but I think it requires creating two variables like g1 and g2 below: import std.range; import std.algorithm; void main(string[] args) { const condition =

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 17, 2023 at 05:30:40PM +, Chris Piker via Digitalmars-d-learn wrote: [...] > In order to handle new functionality it turns out that operatorG needs > to be of one of two different types at runtime. How would I do > something like the following: > > ```d > auto virtualG; // <-- p

Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
Hi D I have a main "loop" for a data processing program that looks much as follows: ```d sourceRange .operatorA .operatorB .operatorC .operatorD .operatorE .operatorF .operatorG .operatorH .copy(destination); ``` Where all `operator` items above are InputRange structs that tak

ELIZA Chatbot Implementation From C to D Lang

2023-02-17 Thread ron77 via Digitalmars-d-learn
Hello, I succeeded in converting an ELIZA code from C to D, and here are the results. although I'm sure there are better ways to code it or to convert it... ```d /* eliza.c * ys * original code by Weizenbaum, 1966 * this rendition based on Charles Hayden's Java implementation from http://ch

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread ProtectAndHide via Digitalmars-d-learn
On Friday, 17 February 2023 at 09:56:26 UTC, RTM wrote: On Friday, 17 February 2023 at 06:56:08 UTC, ProtectAndHide Thirty years passed since. Lessons were learned. Out of three PLs of the newer generation (Rust, Swift, Go), two are not OOP, basically. And no private/public/protected: https

Re: toString best practices

2023-02-17 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 12:15:18 UTC, Bastiaan Veelo wrote: On Thursday, 9 February 2023 at 17:49:58 UTC, Paolo Invernizzi wrote: ``` import std.format, std.range.primitives; struct Point(T) { T x, y; void toString(W)(ref W writer, scope const ref FormatSpec!char f) const

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread RTM via Digitalmars-d-learn
Funny, seems I have old news: Rust adopted D-like module visibility. https://doc.rust-lang.org/reference/visibility-and-privacy.html pub(in path), pub(crate), pub(super), and pub(self) In addition to public and private, Rust allows users to declare an item as visible only within a given scope

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread RTM via Digitalmars-d-learn
On Friday, 17 February 2023 at 06:56:08 UTC, ProtectAndHide wrote: What is 'Object-Oriented Programming'? (1991 revised version) Bjarne Stroustrup https://www.stroustrup.com/whatis.pdf Thirty years passed since. Lessons were learned. Out of three PLs of the newer generation (Rust, Swift, Go