Re: Function which returns a sorted array without duplicates

2023-01-22 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 22 January 2023 at 23:26:45 UTC, dan wrote: So what i was missing was std.array. Of course you can use the uniq from Phobos. But since we already use array, you should also try the 3rd classic version: ```d import std.algorithm; import std.array; // qef. version: private S[] so

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

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:36:36 UTC, thebluepandabear wrote: I haven't been programming for a long time, but most of the other languages I used had such a namespace feature. Kotlin has something called an `object` which is essentially a namespace and it is great. The benefits of addi

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

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:11:17 UTC, thebluepandabear wrote: Sorry don't like that solution specifically. That's because it is a procedural implementation, not an OOP-style one. I don't know how much of the D community writes procedurally but I'm personally an OOP-type of guy. A cl

Re: vibe.d community/forum/whatever ?

2023-01-22 Thread Rey Valeza via Digitalmars-d-learn
On Monday, 30 August 2021 at 02:39:06 UTC, someone wrote: https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/ I've been reading vibe.d tour and some documentation today to get some first impressions. https://vibed.org/community pointed to the link above ... but it seems it is ful

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

2023-01-22 Thread Ali Çehreli via Digitalmars-d-learn
On 1/22/23 16:21, thebluepandabear wrote: > Again, stuffing it into a module is not the same thing as a namespace. That is correct but it is also one answer of D's to namespaces. There are others. For example, structs and classes provide namespacing as well. > The user can just bypass this by

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

2023-01-22 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:27:29 UTC, Adam D Ruppe wrote: On Monday, 23 January 2023 at 00:21:12 UTC, thebluepandabear wrote: there's nothing in the language currently that would 'force' the user Why do you hate freedom? It's not a freedom issue, it's a library-design issue. Some libr

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

2023-01-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:21:12 UTC, thebluepandabear wrote: there's nothing in the language currently that would 'force' the user Why do you hate freedom?

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

2023-01-22 Thread thebluepandabear via Digitalmars-d-learn
That way of naming a global function is essentially a poor man's^W^Wexcuse me, I mean, C's way of working around the lack of a proper namespacing / module system. In D, we do have a proper module system, so you could just call the function `drawLine` and put it in a file named Algo.d, then you

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

2023-01-22 Thread thebluepandabear via Digitalmars-d-learn
Something interesting. I know that D has C++ SFML bindings, although they are unmaintained. I was interested to see how they would 'implement' the C++ namespaces of SFML, and - boy was I surprised. Reading through `DSFML`, I see `final abstract class` getting used to implement SFML's `Keyb

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

2023-01-22 Thread thebluepandabear via Digitalmars-d-learn
// app.d import API = api; void main() { API.draw(); } ``` Another thing that I don't like about that solution, is that it doesn't 'force' the user to write in a namespace-like style. C++ `namespaces` force you to (I believe), and so does `static class` from Java/C#. D is both an o

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

2023-01-22 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 22 January 2023 at 18:30:59 UTC, ryuukk_ wrote: On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: D is not java/C#, it's better than that! ```D // api.d void draw(){} // app.d import API = api; void main() { API.draw(); } ``` Sorry don't like that s

Re: Function which returns a sorted array without duplicates

2023-01-22 Thread dan via Digitalmars-d-learn
On Sunday, 22 January 2023 at 07:33:01 UTC, evilrat wrote: On Sunday, 22 January 2023 at 04:42:09 UTC, dan wrote: I would like to write a function which takes an array as input, and returns a sorted array without duplicates. ```d private S[] _sort_array( S )( S[] x ) { import std.al

Re: Function which returns a sorted array without duplicates

2023-01-22 Thread Ali Çehreli via Digitalmars-d-learn
On 1/21/23 23:33, evilrat wrote: > And IIRC you probably don't need `dup` Unfortunately, no. Skipping .dup is only possible if we are allowed to sort the original array. > as sort produces a lazy range. sort() returns a SortedRange but it can't be lazy. Even if it were, the first call to .f

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

2023-01-22 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: D is not java/C#, it's better than that! ```D // api.d void draw(){} // app.d import API = api; void main() { API.draw(); } ```

Re: Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread evilrat via Digitalmars-d-learn
On Sunday, 22 January 2023 at 18:16:35 UTC, Hipreme wrote: Nope. Those DFLAGS environment variable is used to affect projects such as my dependencies. For example, my dependency needs to be built using my own runtime. The dflags defined in the dub.json only affect the current project, not its

Re: Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread Hipreme via Digitalmars-d-learn
On Sunday, 22 January 2023 at 17:06:13 UTC, evilrat wrote: On Sunday, 22 January 2023 at 16:57:56 UTC, Hipreme wrote: The way to use dub's packages is by using the DFLAGS. With DFLAGS, I can set the import path to my own DRuntime and own std. That way I can make the dependencies behave more o

Re: Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread evilrat via Digitalmars-d-learn
On Sunday, 22 January 2023 at 16:57:56 UTC, Hipreme wrote: The way to use dub's packages is by using the DFLAGS. With DFLAGS, I can set the import path to my own DRuntime and own std. That way I can make the dependencies behave more or less the same, this is an example of what is being done n

Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread Hipreme via Digitalmars-d-learn
I have been working with WebAssembly for at least 1 entire month into getting my entire Game Engine and DRuntime ported to it. As I'm almost reaching the point of the new announcement, I come here to show how I've done DUB's dependency compatibility with a custom runtime. The way to use dub's

Re: Is there a way to get a template’s parameters and constraints?

2023-01-22 Thread Adam Ross Walker via Digitalmars-d-learn
On Friday, 20 January 2023 at 17:15:31 UTC, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? Apologies, I missed the key part of your question. But I think the above can be adapted if you were so inclined.

Re: Is there a way to get a template’s parameters and constraints?

2023-01-22 Thread Adam Ross Walker via Digitalmars-d-learn
There is a way but it's horrible. You can take the `.stringof` and parse the result. I knocked this up for something but it's not well tested and there are probably templates that it handles incorrectly. I'm not claiming this is any good, I just happened to have it. ```d enum TemplateParam