Re: Sort Associative Array by Key

2023-02-09 Thread ProtectAndHide via Digitalmars-d-learn
On Thursday, 9 February 2023 at 07:19:08 UTC, Alexander Zhirov wrote: foo.byPair .array .sort!((a, b) => a.key < b.key) .map!(a => a.value); Is it possible to specify in `map` to return the result `[a.key] = a.value`? To make the result look like `[key:[val], key:[val]]` Wow. This is an

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 13:32:46 UTC, zjh wrote: On Wednesday, 8 February 2023 at 12:12:57 UTC, thebluepandabear wrote: but I still think the language has potential in the future I don't know if they have a sense of crisis. Now `D` in tiebo ranks `50`. I wouldn't say they have or

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

2023-02-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:31:03 UTC, thebluepandabear wrote: I am actually taking a computer science class and I need to create desktop apps to pass and get through school. This is pretty easy in D. Like what specific kind of desktop app?

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

2023-02-09 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:10:59 UTC, zjh wrote: On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: they are always unwilling to add facilities useful to others, `D`'s community is small, this is the reason! yeah right let's implement everything that people propose

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:50:48 UTC, Adam D Ruppe wrote: On Thursday, 9 February 2023 at 12:31:03 UTC, thebluepandabear wrote: I am actually taking a computer science class and I need to create desktop apps to pass and get through school. This is pretty easy in D. Like what specific k

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:55:41 UTC, Guillaume Piolat wrote: On Wednesday, 8 February 2023 at 12:10:59 UTC, zjh wrote: On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: they are always unwilling to add facilities useful to others, `D`'s community is small, this is the reason

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: Hi, In Java/C# you can create purely static classes. ... Last time, someone proposed to add `private` like `C++'s`, and then it was the same,they are always unwilli

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:55:41 UTC, Guillaume Piolat wrote: yeah right let's implement everything that people propose I like the concept of C++: I provide `facilities`, you can use it or not. Not that you can only do it `like this`! This is the only way. What's more, people put f

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:07:56 UTC, thebluepandabear wrote: yeah the whole module behaviour with `private` is just a massive turn off tbh, it needs to be changed to match the Java style They don't even admit the smaller the encapsulation, the better.

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:32:36 UTC, zjh wrote: They don't even admit the smaller the encapsulation, the better. Our predecessors used D very early. At first, they were very `excited`. But `later`, they left because some people in D were too `stubborn`. You can provide `facilities`,

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:41:27 UTC, zjh wrote: Our predecessors used D very early. At first, they were very `excited`. But `later`, they left because some people in D were too `stubborn`. Therefore, the community is very small. Our predecessors are `very smart` people, and they `l

How to debug/set breakpoint a dynamic library.so ?

2023-02-09 Thread mw via Digitalmars-d-learn
The dynamic library.so is built from D (with pyd), and invoked from Python. I'm just wondering How to debug/set breakpoint a dynamic library.so ? Can someone give an example? Thanks.

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:49:03 UTC, zjh wrote: .. There are too `few newcomers` to D, and D must change. If I can, I think `'D++'` is a good idea! Learn from a `successful` language! The typical feature of `C++` is that you have it. Although I don't have it now, I will have it so

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 14:03:41 UTC, zjh wrote: If I can, I think `'D++'` is a good idea! Learn from a `successful` language! Don't be afraid of D becoming complex. C++ is already `super complex`. Aren't there more and more people still using it? Therefore, I don't approve of the

Re: ImportC "no include path set"

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Thursday, 9 February 2023 at 06:07:35 UTC, Elfstone wrote: Maybe Walter doesn't care about Windows enough, but I thought it'd be a must to add basic tests (say, "dmd hello.c") to run on all the platforms before release. Unlikely, since his text editor [doesn't even compile on Linux](https

toString best practices

2023-02-09 Thread Paolo Invernizzi via Digitalmars-d-learn
Hello everybody, Let's assume there's an implementation of a templated struct like this: ``` 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 if (isOutputRange!(W, char)) { put

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

2023-02-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:00:04 UTC, thebluepandabear wrote: For my school I am commissioned to create many types of software. I tried to have a look at some of the gui kits in D but there was no tutorial for how to use them and they seemed as if they are lacking features in comparison

Re: staticMap but with two arguments

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 12:04, John Chapman wrote: > rather than write it manually for each N? import std.meta : AliasSeq; template pickArgs(size_t totalElements, size_t argsPerElement, size_t whichElement, args...) { alias pickArgs = AliasSeq!();

Re: How to debug/set breakpoint a dynamic library.so ?

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 06:00, mw wrote: The dynamic library.so is built from D (with pyd), and invoked from Python. I'm just wondering How to debug/set breakpoint a dynamic library.so ? Can someone give an example? Thanks. I may be totally off on this but I think it is as simple as the following: gdb

Re: Sort Associative Array by Key

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 23:19, Alexander Zhirov wrote: >> foo.byPair >> .array >> .sort!((a, b) => a.key < b.key) >> .map!(a => a.value); > > Is it possible to specify in `map` to return the result `[a.key] = > a.value`? To make the result look like `[key:[val], key:[val]]` map can return a tuple and std.ar

Re: ImportC "no include path set"

2023-02-09 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 14:08:47 UTC, bachmeier wrote: this looks like one of those "death by paper cut" things. It has the smell of a rough edge that needs fixing. It's the one reason I haven't even tried ImportC. I still wonder why I need to provide those headers while for linking M

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

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 04:07, zjh wrote: > Last time, someone proposed to add `private` like `C++'s`, We've discussed the 'private' topic very many times already. C++'s private necessitate the 'friend' keyword, which comes with it's own problems. Besides, D has zero problems with its private implementati

Re: staticMap but with two arguments

2023-02-09 Thread John Chapman via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: I could not figure out eliminating the hard-coded 4. Can we introspect the parameter list of a template like 'fun' in the example? If we could, then we could get 4 that way. Thank you for this. I don't mind hard-coding the N argu

Re: staticMap but with two arguments

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 12:45, John Chapman wrote: > On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: >> I could not figure out eliminating the hard-coded 4. Can we introspect >> the parameter list of a template like 'fun' in the example? If we >> could, then we could get 4 that way. > > Thank y

MongoDB and vibe troubles.

2023-02-09 Thread seany via Digitalmars-d-learn
Please consider the code: mClient = connectMongoDB("127.0.0.1"); auto db = mClient.getDatabase("webAppMaster"); writeln(db); auto users = db["users"]; writeln(users); This follows this example: https://github.com/vibe-d/vibe.d/blob/master/examples/m

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

2023-02-09 Thread ProtectAndHide via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: On 2/8/23 04:07, zjh wrote: > Last time, someone proposed to add `private` like `C++'s`, We've discussed the 'private' topic very many times already. C++'s private necessitate the 'friend' keyword, which comes with it's own prob

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

2023-02-09 Thread Hipreme via Digitalmars-d-learn
On Thursday, 9 February 2023 at 22:34:29 UTC, ProtectAndHide wrote: On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: On 2/8/23 04:07, zjh wrote: > Last time, someone proposed to add `private` like `C++'s`, We've discussed the 'private' topic very many times already. C++'s priv

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

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 14:34, ProtectAndHide wrote: > You mentioned previously that D implements various things in > unprincipled ways. I think you will continue misunderstanding that term. What it means is, D does not insist on certain programming paradigms over others. For example, you can code in struct

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:17:15 UTC, Adam D Ruppe wrote: On Thursday, 9 February 2023 at 13:00:04 UTC, thebluepandabear wrote: For my school I am commissioned to create many types of software. I tried to have a look at some of the gui kits in D but there was no tutorial for how to use

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
btw. When a newbie to D raises ideas, suggestions, etc... and you counter them with (in essence) 'we don't need that in D, but go write a dip if you think we do' attitude, is a real turn off. yeah it seems like the community is closed off for feedback, which is concerning. namespaces/static c

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

2023-02-09 Thread thebluepandabear via Digitalmars-d-learn
In contrast, I use D every day and love its relaxed attitude towards private. the fact that private stuff is accessible from other classes in the same module is really really bad, and it's pretty detrimental to the language. let's actually think about what `private` means. when you come bac

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

2023-02-09 Thread ProtectAndHide via Digitalmars-d-learn
On Thursday, 9 February 2023 at 23:13:00 UTC, Ali Çehreli wrote: ... Well, the only thing we can say for sure now, is that since 'class', 'oop', and 'private' have all been mentioned in this thread, some 'key D people' (wink wink) will come out to derail this thread by further pointing out

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

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 15:58, thebluepandabear wrote: >> In contrast, I use D every day and love its relaxed attitude towards >> private. > > the fact that private stuff is accessible from other classes in the same > module is really really bad, and it's pretty detrimental to the language. Not everybody share

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

2023-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 2/9/23 15:59, ProtectAndHide wrote: > some 'key D > people' (wink wink) [...] > So I hand that over to you .. wink wink. You're trolling[1] again. Ali [1] https://www.merriam-webster.com/dictionary/troll#h3

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

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Thursday, 9 February 2023 at 23:51:18 UTC, thebluepandabear wrote: btw. When a newbie to D raises ideas, suggestions, etc... and you counter them with (in essence) 'we don't need that in D, but go write a dip if you think we do' attitude, is a real turn off. yeah it seems like the communit

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

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Friday, 10 February 2023 at 00:18:59 UTC, Ali Çehreli wrote: On 2/9/23 15:58, thebluepandabear wrote: >> In contrast, I use D every day and love its relaxed attitude towards >> private. > > the fact that private stuff is accessible from other classes in the same > module is really really bad,

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

2023-02-09 Thread ProtectAndHide via Digitalmars-d-learn
On Thursday, 9 February 2023 at 23:05:35 UTC, Hipreme wrote: On Thursday, 9 February 2023 at 22:34:29 UTC, ProtectAndHide wrote: On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: On 2/8/23 04:07, zjh wrote: > Last time, someone proposed to add `private` like `C++'s`, We've disc

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: On 2/8/23 04:07, zjh wrote: Besides, D has zero problems with its private implementation in the sense that there has been zero bugs related to it being that way. In contrast, I use D every day and love its relaxed attitude tow

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: In contrast, I use D every day and love its relaxed attitude towards private. I admit that you use 'D' happy, but you don't admit that I use 'D' unhappy.

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 February 2023 at 00:58:51 UTC, zjh wrote: I admit that you use 'D' happy, but you don't admit that I use 'D' unhappy. Right,just `forkit`. The `minority` language is more closed than the big language! If you think about it, you will know that the `'D'` ranking should fall!

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

2023-02-09 Thread ProtectAndHide via Digitalmars-d-learn
On Friday, 10 February 2023 at 00:18:59 UTC, Ali Çehreli wrote: Not everybody shares that view. So, there must be something deeper here: maybe some people are blind (including me), or others have expectations that they carry from other languages, or something else... But look at the contrast:

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

2023-02-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 February 2023 at 02:04:06 UTC, ProtectAndHide wrote: "Before practicing Zen, mountains were mountains and rivers were rivers. While practicing Zen, mountains are no longer mountains and rivers are no longer rivers. After realization, mountains are mountains and rivers are rivers

Re: How to debug/set breakpoint a dynamic library.so ?

2023-02-09 Thread mw via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:26:59 UTC, Ali Çehreli wrote: On 2/9/23 06:00, mw wrote: The dynamic library.so is built from D (with pyd), and invoked from Python. I'm just wondering How to debug/set breakpoint a dynamic library.so ? Can someone give an example? Thanks. I may be tota

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

2023-02-09 Thread Max Samukha via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: Besides, D has zero problems with its private implementation in the sense that there has been zero bugs related to it being that way. That is how a Python aficionado would defend the absence of visibility attributes therein. "W