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

2023-02-19 Thread thebluepandabear via Digitalmars-d-learn
But in any case, it should be class private. There have now been three pages produced by three people all agreeing with each other. At what point does it start being spam? Having a discussion !== spam.

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

2023-02-18 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 19 February 2023 at 00:21:42 UTC, ProtectAndHide wrote: On Saturday, 18 February 2023 at 21:23:24 UTC, ProtectAndHide wrote: The more I look at D, the more I like C++. I should correct that. The more I look at D, the more I like C++, C#, Java, Kotlin, Swift, Javascript .. and the

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

2023-02-18 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 19 February 2023 at 00:21:42 UTC, ProtectAndHide wrote: On Saturday, 18 February 2023 at 21:23:24 UTC, ProtectAndHide wrote: The more I look at D, the more I like C++. I should correct that. The more I look at D, the more I like C++, C#, Java, Kotlin, Swift, Javascript .. and the

Re: ELIZA Chatbot Implementation From C to D Lang

2023-02-18 Thread thebluepandabear via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:03:34 UTC, ron77 wrote: 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... this is nothing compared to chatgpt ;)

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

2023-02-16 Thread thebluepandabear via Digitalmars-d-learn
So let me just say: I think D does it right. D does not have class encapsulation; it has module encapsulation. This is by design, and the design is good. The design is terrible...

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

2023-02-16 Thread thebluepandabear via Digitalmars-d-learn
But at stop mispresenting what I'm saying. What I've stated above, is what I'm saying.. no more.. no less. Well said. Its not that hard to understand, folks.

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

2023-02-15 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 20:06:18 UTC, bachmeier wrote: On Wednesday, 15 February 2023 at 07:13:41 UTC, thebluepandabear wrote: Time to move on to OCaml programmers telling us D doesn't have floating point arithmetic because there's no `+.` operator. that's not the same thing though,

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

2023-02-14 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 02:14:30 UTC, Mike Parker wrote: On Wednesday, 15 February 2023 at 01:16:00 UTC, thebluepandabear wrote: I think what you could say is that D lacks _encapsulation_ which is also an OOP concept. So D is partially OOP but not fully OOP due to there being no e

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

2023-02-14 Thread thebluepandabear via Digitalmars-d-learn
Time to move on to OCaml programmers telling us D doesn't have floating point arithmetic because there's no `+.` operator. that's not the same thing though, you've created a great false equivalence! Congrats.

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

2023-02-14 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 01:15:09 UTC, thebluepandabear wrote: On Tuesday, 14 February 2023 at 15:34:17 UTC, bachmeier wrote: On Tuesday, 14 February 2023 at 10:16:47 UTC, ProtectAndHide wrote: In any case, there is nothing 'picky' about wanting to be able to explicately 'declare' a

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

2023-02-14 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 14 February 2023 at 15:34:17 UTC, bachmeier wrote: On Tuesday, 14 February 2023 at 10:16:47 UTC, ProtectAndHide wrote: In any case, there is nothing 'picky' about wanting to be able to explicately 'declare' a member of my class type as being private. That to me, is what a programm

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

2023-02-14 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 14 February 2023 at 10:16:47 UTC, ProtectAndHide wrote: On Tuesday, 14 February 2023 at 08:15:37 UTC, Kagamin wrote: My point is you know you're just picky. Well.. it seems to me, that your 'point' is to just have a go at me. In any case, there is nothing 'picky' about wanting t

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
For a language that claims to supprot OOP, and does public by default, and no way to declare type private... I mean... wow! agree, it should definitely be `private` by default... if `private` was implemented properly lmao

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
What attracts me to D, is the inability to program outside of a class in C#. I think they are trying to find ways to make this happen, but I wouldn't hold my breath. programming outside of a class is overrated though in my opinion. i've never seen a usecase for it in an object oriented langu

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
That's not entirely correct. I don't use any Apple hardware products. Never have, and never will. I use Swift on Linux only. There are of course some library features of Swift tied to Apple products. But I have no need for those library features. As a standalone language, Swift can (IMO) a

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
I'm not an advocate of any style in particular. I'm happy to use any style that is clear to understand and use, suitable, and can provide reasonable guarantees around memory safety and correctness. But a language that claims to support OOP but doesn't even have type privacy, is a bit of joke

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
I think the 'real' problem, is that some core D people just refuse to allow D to provide such an option to the programmer. I think a lot of it has to do with the fact that heaps of D programmers write procedural code and don't care about any object oriented features, that's because they're 'o

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
A good example of a language that does everything right is C#. If C# wasn't tied to Microsoft, it would honestly be pretty much the perfect language. Java is also pretty good, but it has its downsides.

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

2023-02-10 Thread thebluepandabear via Digitalmars-d-learn
I think the 'real' problem, is that some core D people just refuse to allow D to provide such an option to the programmer. For what reason, I cannot fathom, since Swift can do this just fine. I think it's some kind of bias against a particular style of programming that some don't want to see oc

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 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
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
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 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 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 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-08 Thread thebluepandabear 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, I've already switched to Java because of this. but I still t

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

2023-02-08 Thread thebluepandabear via Digitalmars-d-learn
C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-) Java as well.

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

2023-02-08 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 09:00:40 UTC, thebluepandabear wrote: C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-) J

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
Thanks. update: just set up a Manjaro vm and it seems to work, I guess I'll have no choice but to switch to Manjaro then if I want to use sfml

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

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
I do not agree, that a compiler that allows a programmer to misuse a type, should be seen as 'a feature'. If that's the kind of 'power' D programmers want, then D is not for me. Eh, I don't think I would _quit_ D because of this issue, but it's definitely something that bothers me (more so

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

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 5 February 2023 at 23:53:35 UTC, Ali Çehreli wrote: On 2/5/23 14:40, ProtectAndHide wrote: > On Sunday, 5 February 2023 at 10:51:51 UTC, thebluepandabear wrote: >> >> It's not a terrible workaround to be honest. >> > > The 'terrible' part is this: > > - the compiler will allow yo

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

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 5 February 2023 at 23:50:35 UTC, Ali Çehreli wrote: On 2/5/23 02:57, thebluepandabear wrote: > When dealing with contexts, or for when you want a clear context in your > codebase, namespaces can be a life saver Can you give an example of a D problem that namespaces could solve? I ha

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

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 5 February 2023 at 10:51:51 UTC, thebluepandabear wrote: { @disable this(); static this() { Message = "Hello!"; } static: string Message; void drawLine() {}; } It's not a terrible workaround to be honest. `static class` does have a use when i

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

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
{ @disable this(); static this() { Message = "Hello!"; } static: string Message; void drawLine() {}; } It's not a terrible workaround to be honest. `static class` does have a use when it's nested, so it might create some conflicts if such a feature (lik

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote: On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear wrote: "Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void app.loadDyn(

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread thebluepandabear via Digitalmars-d-learn
"Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void app.loadDyn() [0x55d86edd1931] source/app.d:24 _Dmain [0x55d86edd1954] ``` Oh yeah, that's another bug I had. You would need to downgrade the

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
I have tested on arch linux and everything works fine, i'll try to setup a linux mint / ubuntu VM tomorrow Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able to find the root cause of the issue.

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
Could someone (that uses Linux) perhaps try and emulate my bug to see if it's an issue with the bindings or on my system? That would be greatly appreciated! Steps: 1. Open up the terminal and type in `sudo apt-get install libcsfml-dev` 2. Create a new D project and add the following to `dub

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
On Friday, 3 February 2023 at 19:44:07 UTC, bachmeier wrote: On Friday, 3 February 2023 at 12:23:40 UTC, thebluepandabear wrote: On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear wrote: On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote: On Friday, 3 February 2023 at 10:15:3

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear wrote: On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote: On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear wrote: I recently did a fresh install of CSFML and I am getting this errors when running my csfml D bindi

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote: On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear wrote: I recently did a fresh install of CSFML and I am getting this errors when running my csfml D bindings program: ``` object.Exception@source/app.d(38): Fatal error(s)

SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
I recently did a fresh install of CSFML and I am getting this errors when running my csfml D bindings program: ``` object.Exception@source/app.d(38): Fatal error(s) encountered whilst calling `loadSFML()` function: ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: cannot open share

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

2023-01-30 Thread thebluepandabear via Digitalmars-d-learn
Why do you want a type? I want a type because it gives clear context as to what family the method(s) belongs to, and helps make the code more idiomatic and easy to understand.

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

2023-01-30 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 30 January 2023 at 21:50:03 UTC, thebluepandabear wrote: Use a struct and put `static:` after the opening brace. That's what GC is in core.memory. Using a `struct` for a purely static type would still allow the user to create instances of that `struct`. To bypass that, you'd have t

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

2023-01-30 Thread thebluepandabear via Digitalmars-d-learn
Use a struct and put `static:` after the opening brace. That's what GC is in core.memory. Using a `struct` for a purely static type would still allow the user to create instances of that `struct`. To bypass that, you'd have to disable the default constructor -- that then becomes ugly, hackish

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

2023-01-29 Thread thebluepandabear via Digitalmars-d-learn
I hate a world with the classes. I can do almost anything I want without the classes. The software world soared above C without classes. SDB@79 As I said in my email to you -- each to their own. There's no point in arguing about whether OOP is the best method of doing things or procedural i

Re: How to a link to a C library to create static bindings?

2023-01-27 Thread thebluepandabear via Digitalmars-d-learn
When I do run with dub I just get: ``` Program exited with code -11 ```

How to a link to a C library to create static bindings?

2023-01-27 Thread thebluepandabear via Digitalmars-d-learn
Hello, I am wanting to create my own C bindings to CSFML, and I have been extremely struggling with this. There is no resources or tutorials for how to do this so I am basically on my own. First thing I looked at was `dstep` which helps translate C header files to D language, so I ran `dst

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-26 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 26 January 2023 at 11:46:07 UTC, matheus wrote: On Tuesday, 24 January 2023 at 03:42:34 UTC, thebluepandabear wrote: ... if not please tell me and I will remove this... How you would do that? Matheus. The forums don't have a delete feature. I am used to most forums having a de

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

2023-01-24 Thread thebluepandabear via Digitalmars-d-learn
symbols. So let the users use them that way. There's no need to force them to type out the namespace all the time. It's certainly not an OOP vs. procedural issue, as namespaces have nothing to do with OOP. Thanks, appreciate your perspective.

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-24 Thread thebluepandabear via Digitalmars-d-learn
The example shows calls to `update()` in the setters and in the constructor. The D method for binding this looks like `void sfShape_update(sfShape* shape);`. Ur a legend bro... It fixed it... Calling this in the `Rectangle` constructor: ```D class RectangleShape : Shape { this(Vector2f s

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-24 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 06:32:35 UTC, Christian Köstlin wrote: On 24.01.23 04:59, thebluepandabear wrote: Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads woul

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread thebluepandabear via Digitalmars-d-learn
Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads would be greatly... greatly apprecaited...

Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread thebluepandabear via Digitalmars-d-learn
Hello everyone 👋, hope everyone is having a good day. Hopefully I am allowed to ask technical questions here, if not please tell me and I will remove this. I am trying to create object oriented wrappers around `bindbc.sfml`, this is because I don't like the C-style syntax of CSFML. The C-s

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 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: Non-ugly ways to implement a 'static' class or namespace?

2023-01-20 Thread thebluepandabear via Digitalmars-d-learn
ll a function without instantiating said class, as functions act on the class object. Ok, thanks. I think D should implement something similar to `static class` but I doubt it will happen.

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

2023-01-20 Thread thebluepandabear via Digitalmars-d-learn
Hi, In Java/C# you can create purely static classes. These are classes whose methods are all static, the classes cannot be derived from or instantiated: ``` static class Algo { void drawLine(Canvas c, Pos from, Pos to) { .. }; } ``` Class in use: ``` Algo.drawLine(new Canvas(), new

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread thebluepandabear via Digitalmars-d-learn
roduct/learning-d/9781783552481?_ga=2.241359490.1811075590.1674153096-1605518740.1674153096 or Adam's book https://www.packtpub.com/product/d-cookbook/9781783287215?_ga=2.198287279.1811075590.1674153096-1605518740.1674153096 They're older than 2019, but I don't think much of the material they

Re: Are there more up-to-date D template tutorials?

2023-01-18 Thread thebluepandabear via Digitalmars-d-learn
Help would be appreciated. Regards, thebluepandabear A bit off topic/ranty but I did find the book by Ali on D extremely useful, but it was good as an 'introduction'. I feel like when it comes to more advanced features (such as templates, mixins, ranges, concurrency, etc) there are no resour

Are there more up-to-date D template tutorials?

2023-01-18 Thread thebluepandabear via Digitalmars-d-learn
Hello, The GitHub repo which helps introduce new users about D templates (https://github.com/PhilippeSigaud/D-templates-tutorial) seems to be quite outdated. As a beginner to D I have been struggling to learn about D templates, I haven't been able to find any up-to-date D template resources

Re: How to access private variable of outer class from an inner struct

2023-01-15 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 15 January 2023 at 13:23:20 UTC, matheus wrote: On Sunday, 15 January 2023 at 12:44:51 UTC, thebluepandabear wrote: ... How will the variable `outer` become the reference to the current `X` object (if that makes sense?). Does the compiler do it automatically? I think you'll need t

Re: How to access private variable of outer class from an inner struct

2023-01-15 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 15 January 2023 at 12:37:43 UTC, Paul Backus wrote: On Sunday, 15 January 2023 at 12:26:15 UTC, thebluepandabear wrote: If I have the following code: ```D class X { private int num; struct Y { // how to access num? } } ``` How would I access `num` from `Y`? Whe

How to access private variable of outer class from an inner struct

2023-01-15 Thread thebluepandabear via Digitalmars-d-learn
If I have the following code: ```D class X { private int num; struct Y { // how to access num? } } ``` How would I access `num` from `Y`? Whenever I try to I get a compilation error. I believe that it's possible for nested/inner classes, but I don't know if it's possible

(Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread thebluepandabear via Digitalmars-d-learn
(Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` inside another module, since `ObjDerived` can still access the members

Re: Coding Challenges - Dlang or Generic

2023-01-09 Thread thebluepandabear via Digitalmars-d-learn
I know. Someone's going to say why don't YOU do it:) regards, The official book on D by Ali has many coding challenges. There isn't any need to create a website for D coding challenges or incorporate it into an existing website since D has under 1% of the market share.

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-08 Thread thebluepandabear via Digitalmars-d-learn
: create a copy of the value that is currently present in one particular iteration of the `foreach` by creating a function literal that takes your `struct` as a paramter. This works because structs are value types, so passing it to the function creates a copy. Thanks, your solution seems to b

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-08 Thread thebluepandabear via Digitalmars-d-learn
Fixing this will improve the quality of the language for newcomers such as myself greatly. This not only confuses newcomers but it gave a false illusion of a bug within the code :/

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-08 Thread thebluepandabear via Digitalmars-d-learn
A nested function (or perhaps an inline lambda) is needed to force the allocation of a dynamic context for the capture. This is an embarrassment. Why hasn't this been fixed yet? :-( T I agree that this needs to get fixed immediately, it seems to be bugging me another time as well. I belie

Re: Why does this code only work with `std.conv.to` whilst not with `cast`?

2023-01-08 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 8 January 2023 at 12:35:38 UTC, matheus wrote: On Sunday, 8 January 2023 at 11:29:10 UTC, thebluepandabear wrote: ... There is an explanation here: https://forum.dlang.org/post/tqukutfzeaxedunuv...@forum.dlang.org But in any case I'd like to point it out that I think you could d

Why does this code only work with `std.conv.to` whilst not with `cast`?

2023-01-08 Thread thebluepandabear via Digitalmars-d-learn
I've been writing some code and I have been experimenting with casting. I've found that sometimes only `std.conv.to!` does the job over casting, and I am unsure why this is the case as I assumed that they are both the same. I have the following interface: ```D interface ICustomDrawable {

Re: Is there a way to enforce UFCS?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
them or remove them. I agree, forbidding function call syntax would be a great usecase for `@property`. It will probably never get implemented though.

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
``` These two solutions should compile to approximately the same runtime code, with optimizations enabled. So, it's really down to personal preference; the former is more explicit about what the computer is to do, while the latter is more concise. Thanks! Works great.

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
Have fun reading this : https://issues.dlang.org/show_bug.cgi?id=21929 Thanks for the code suggestion although it still doesn't fix the bug. I am curious as to what those brackets do as well.

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 5 January 2023 at 17:36:55 UTC, H. S. Teoh wrote: On Thu, Jan 05, 2023 at 11:55:33AM +, thebluepandabear via Digitalmars-d-learn wrote: [...] ```D foreach (BoardSize boardSize; arr) { Button button = new Button(); button.text = format("%sx%s", boardSize[0], b

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
Update some time later: the only way (oof!) around this seems to be using a `static foreach` with arrays: ```D Button[3] b; static foreach (indx, BoardSize boardSize; arr) { b[indx] = new Button(); b[indx].text = format("%sx%s", boardSize[0], boardSize[1]); b[indx].onButtonClick

How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread thebluepandabear via Digitalmars-d-learn
I am using CSFML D bindings and I have created my own sort of UI library for drawing elements onto the screen. One of the classes I've created is a `Button` class, which contains a delegate called `onButtonClick` which is called when the button is clicked on by the user. Up until now, everyt

Re: Is there a way to enforce UFCS?

2023-01-04 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 4 January 2023 at 14:21:46 UTC, bauss wrote: On Wednesday, 4 January 2023 at 03:42:28 UTC, thebluepandabear wrote: ... My question is: is there a way to enforce UFCS-syntax? None of your code actually uses UFCS. This is UFCS: ``` class Foo { int bar; } void setBar(Foo foo,

Re: Why does this code only work with `T` and not `typeof(T)`?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 4 January 2023 at 04:42:08 UTC, Ali Çehreli wrote: On 1/3/23 20:11, thebluepandabear wrote: > if I replace the `isDrawable` template with the > following (using `typeof`), the code does not compile: It must be because T is already a type. It's the same reason why the following co

Why does this code only work with `T` and not `typeof(T)`?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
I am using the CSFML D bindings, and I am creating my own `draw` template function. I first check that the object passed in is of the appropriate type, and if it is, I call the appropriate function: ```D template isDrawable(T) { enum isDrawable = is(T == sfCircleShape*) || is(T == sfRect

Is there a way to enforce UFCS?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
Say you have the following class which represents a dog 🐶: ```D class Dog { @property { string name(); void name(string name) { _name = name; } } private { string _name; } } ``` And you have the following code with constructs a `Dog`

Re: Is there such a JSON parser?

2023-01-01 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 1 January 2023 at 23:28:12 UTC, torhu wrote: I need to parse some JSON data into various data structures, so I'm looking for a parser based on events or ranges. One that doesn't just load the file and build a data structure that represents the whole thing. So not std.json, at least.

Re: Compile time vs run time -- what is the difference?

2022-12-28 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 28 December 2022 at 09:10:38 UTC, areYouSureAboutThat wrote: On Wednesday, 28 December 2022 at 02:31:45 UTC, thebluepandabear wrote: .. Other errors are only able to be spotted during run time such as exceptions, dividing by zero, assert blocks. With regards to the 'assert bloc

Compile time vs run time -- what is the difference?

2022-12-27 Thread thebluepandabear via Digitalmars-d-learn
I am reading through the free book on learning D by Ali Çehreli and I am having difficulties understanding the difference between compile time execution and run time execution in D language. What I do understand is that compile time and run time are the two processes that your code goes throug

Does 'ref' turn into a pointer during compile time?

2022-12-21 Thread thebluepandabear via Digitalmars-d-learn
Say you have the following function that takes in a `ref` parameter: ```D void modify(ref int num) { num += 5; } ``` Does the compiler turn that into the code below? ```D void modify(int* num) { num += 5; } ``` I was just wondering whether or not this is the case because I don't thin

Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn
No worries, hopefully a mod will explain why. I don't like when posts get removed for no reason :|

Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 19 December 2022 at 22:07:15 UTC, Ali Çehreli wrote: On 12/19/22 13:45, thebluepandabear wrote: > On Monday, 19 December 2022 at 21:41:45 UTC, thebluepandabear wrote: >> Why did my replies here to someone else get deleted? > > Myself and this other person's reply to this thread randoml

Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 19 December 2022 at 21:41:45 UTC, thebluepandabear wrote: Why did my replies here to someone else get deleted? Myself and this other person's reply to this thread randomly got removed for no reason, I would appreciate an explanation 😕

Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn
Why did my replies here to someone else get deleted?

Re: Is there such concept of a list in D?

2022-12-18 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 18 December 2022 at 22:17:04 UTC, j wrote: On Saturday, 10 December 2022 at 05:46:26 UTC, thebluepandabear wrote: In most languages there is some sort of `List` type, is that the same for D? What you're probably talking about is called a union in the C world. There is a nice (fre

Re: How is this code invalid?

2022-12-16 Thread thebluepandabear via Digitalmars-d-learn
T Thanks, I've tried to mark it with `@safe` and it did give me a warning. I was also wondering, why is this code valid? ```D int[] numbersForLaterUse; @safe void foo(int[] numbers) { numbersForLaterUse = numbers; } ```

How is this code invalid?

2022-12-16 Thread thebluepandabear via Digitalmars-d-learn
I am reading the fantastic book about D by Ali Çehreli, and he gives the following example when he talks about variadic functions: ```D int[] numbersForLaterUse; void foo(int[] numbers...) { numbersForLaterUse = numbers; } struct S { string[] namesForLaterUse; void foo(string[] names.

Re: Graphical progressive fill

2022-12-11 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 11 December 2022 at 06:50:44 UTC, Joel wrote: I've been trying to fill in areas with a colour but can't work it out. I want something like the effect where it fills with diamonds. Not all at once but building up in the main program loop. # # # # #

Why can't rvalues be passed to a 'ref' parameter?

2022-12-10 Thread thebluepandabear via Digitalmars-d-learn
Hello, I am not really understanding why rvalues cannot be passed to a 'ref' parameter, the explanation in the book about D I am reading was not clear: "The main reason for this limitation is the fact that a function taking a ref parameter can hold on to that reference for later use, at a ti

Re: Is there such concept of a list in D?

2022-12-09 Thread thebluepandabear via Digitalmars-d-learn
On Saturday, 10 December 2022 at 05:54:09 UTC, Steven Schveighoffer wrote: On 12/10/22 12:46 AM, thebluepandabear wrote: In most languages there is some sort of `List` type, is that the same for D? D doesn't focus on interfaces, we have concepts, like ranges. Sorry, it's hard to answer your q

Is there such concept of a list in D?

2022-12-09 Thread thebluepandabear via Digitalmars-d-learn
In most languages there is some sort of `List` type, is that the same for D?

  1   2   >