How do you implement complementary "A*(A*A) = A^3" operator overloads (I'm getting strange results)

2024-08-19 Thread Daniel via Digitalmars-d-learn
type_theory.d: ``` module type_theory; import std.conv; import prod; class Type { public: Prod opBinary(string op="*")(Type r) { alias l = this; return new Prod(l, r); } Type opBinary(string op="^")(int k) in { assert (k > 0); } do { if (k == 1)

Re: How do you implement complementary "A*(A*A) = A^3" operator overloads (I'm getting strange results)

2024-08-19 Thread Daniel via Digitalmars-d-learn
On Monday, 19 August 2024 at 09:42:44 UTC, Daniel Donnelly, Jr. wrote: type_theory.d: ``` module type_theory; import std.conv; import prod; [...] I had to put `while (k > 1)` instead of `while (k > 0)` and it works. I still though can't get it to work with the obvious recursive formula of `

How do you typically debug / write D code (Visual Studio - known to be broken in Error pane etc), VScode - I get this error...

2024-08-19 Thread Daniel via Digitalmars-d-learn
I give up on Visual Studio VisualD plugin as it's had the same issues for over five years, and currently my program runs from the command line, but VisualD complains with a 528 nonsensical errors. So I investigated using VScode instead (I do need a debugger), and I get this: ``` Couldn't fi

Re: How do you typically debug / write D code (Visual Studio - known to be broken in Error pane etc), VScode - I get this error...

2024-08-19 Thread Daniel via Digitalmars-d-learn
On Monday, 19 August 2024 at 13:05:55 UTC, ryuukk_ wrote: What's your OS? Debugging works very nice with vscode: ```json { "name": "game: client", "type": "lldb", "request": "launch", "program": "${workspaceFolder}/bin/game",

Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-10 Thread Daniel via Digitalmars-d-learn
https://dlang.org/spec/cpp_interface.html According to that C++ / D .object files can interoperate both ways, but one has to be compiled before the other, order depending on direction. My question is, can you have a class C (C++) use a class D (Dlang) in such a way that D can also use C as i

How could I fix (debug) the VisualD plugin so that it actually works with the folders / files seen in Windows 10 file man.?

2022-09-12 Thread Daniel via Digitalmars-d-learn
As you may already know if you want to move a file or rename a folder in VisualD, you can't simply do it. I've even had to edit the project file with Notepad++ in order to repair it. So, I'm humbly asking how can we fix this? I'm considering doing something in C++ which I'd rather not becaus

Re: Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-12 Thread Daniel via Digitalmars-d-learn
On Sunday, 11 September 2022 at 02:14:51 UTC, zjh wrote: On Saturday, 10 September 2022 at 22:07:32 UTC, Ali Çehreli wrote: On 9/10/22 13:04, Daniel Donnell wrote: > https://dlang.org/spec/cpp_interface.html At DConf, Manu indicated that that page is outdated and that D's C++ support is actual

Re: Real simple question... for good programmers

2022-10-22 Thread Daniel via Digitalmars-d-learn
On Saturday, 22 October 2022 at 22:01:09 UTC, Enjoys Math wrote: On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote: string[] tokens = userSID.output.split!isWhite; writeln("tokens = ", tokens); tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""

Re: is dmd a virus?

2022-10-22 Thread Daniel via Digitalmars-d-learn
On Saturday, 22 October 2022 at 13:29:00 UTC, Salih Dincer wrote: On Saturday, 22 October 2022 at 09:49:28 UTC, Salih Dincer wrote: On Saturday, 22 October 2022 at 07:40:39 UTC, MGW wrote: is dmd a virus? https://www.virustotal.com report: Cybereason --> Malicious.779f29 VBA32 --> BScope.Troj

How do you return a subclass instance from a base class method?

2022-11-16 Thread Daniel via Digitalmars-d-learn
I have SubclassOf derived from PosetRelation. For any poset relation, the transitivity law applies, however, I'd like to return the correct type: ``` PosetRelation transitivity(PosetRelation R, PosetRelation S) { if (R.op == S.op) { if (R.right is S.left)

Re: How do you return a subclass instance from a base class method?

2022-11-16 Thread Daniel via Digitalmars-d-learn
``` PosetRelation transitivity(PosetRelation R, PosetRelation S) { // These if conditions are typically ordered from easiest to // most involved-to-check. if (R.op == S.op && is(typeof(R) == typeof(S)) && R.right == S.left) { return new typeof(R)( R.left, S

Re: How do you return a subclass instance from a base class method?

2022-11-16 Thread Daniel via Digitalmars-d-learn
On Thursday, 17 November 2022 at 05:21:05 UTC, MorteFeuille123 wrote: On Thursday, 17 November 2022 at 04:25:13 UTC, Daniel Donnelly, Jr. wrote: [...] You can use TypeInfoClass: [...] I don't get it - you never made use of b1 or b2...

Re: How do you return a subclass instance from a base class method?

2022-11-16 Thread Daniel via Digitalmars-d-learn
On Thursday, 17 November 2022 at 05:34:49 UTC, zjh wrote: On Thursday, 17 November 2022 at 04:25:13 UTC, Daniel Donnelly, Jr. wrote: ... `crtp`, will it work? Can't use CRTP, because once you choose a derived class to pass into the template system, how do you pass in subclasses of that cla

How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.

2022-12-01 Thread Daniel via Digitalmars-d-learn
``` dstring s = ""; for (dchar i='ₐ'; i < 'ₜ'; i++) s ~= i; writeln(s); ``` Doesn't work. The result I get is shit: ΓéÉΓéæΓéÆΓéôΓéöΓéòΓéûΓéùΓéÿΓéÖΓéÜΓé¢

How do we display Unicode in Visual D console output?

2023-07-29 Thread Daniel via Digitalmars-d-learn
Right now, fresh install of VS and Visual D, all up-to-date. Can't display ∈, so how can we fix this? There is no project setting for Unicode chars. Thanks! EnjoysMath

Dlang installer with VSCode broken

2023-11-05 Thread Daniel via Digitalmars-d-learn
ERRORS: -- \2023-11-05 22:21:07.370 [warning] Via 'product.json#extensionEnabledApiProposals' extension 'ms-dotnettools.dotnet-interactive-vscode' wants API proposal 'languageConfigurationAutoClosingPairs' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (che

Dub generated a visuald project for me that includes pegged + dqt (Qt widgets). Basic linking error fix?

2024-03-31 Thread Daniel via Digitalmars-d-learn
``` Build started at 7:16 PM... -- Build started: Project: d--, Configuration: debug x64 -- Building C:\Users\fruit\OneDrive\Desktop\Code\StateMachine\D--\d--.exe... LINK : fatal error LNK1181: cannot open input file 'Qt5Widgets.lib' Building C:\Users\fruit\OneDrive\Desktop\Code\StateM

Re: Dub generated a visuald project for me that includes pegged + dqt (Qt widgets). Basic linking error fix?

2024-03-31 Thread Daniel via Digitalmars-d-learn
I see now. https://github.com/tim-dlang/dqt has examples of where these libs are found within Qt itself.

Test thread

2021-05-20 Thread Daniel via Digitalmars-d-learn
Hi, I'm just testing whether I can post here. Thank you.

Re: Test thread

2021-05-20 Thread Daniel via Digitalmars-d-learn
On Thursday, 20 May 2021 at 22:54:18 UTC, Daniel Donnelly, Jr wrote: Hi, I'm just testing whether I can post here. Thank you. Okay it worked. I am installing Visual D now. I am going to write a program that tries to guess a mathematical model of data using < 10 operators. I won't include

Re: Test thread

2021-05-20 Thread Daniel via Digitalmars-d-learn
D could be the greatest thing on the planet. Like Python, D will take over the world of coding.

Re: derelict-gl3 + derelict-glfw3 + derelict-util (version?) - need instructions on handling basic package version dependency conflicts

2025-04-05 Thread Daniel via Digitalmars-d-learn
On Thursday, 3 April 2025 at 04:43:59 UTC, Mike Parker wrote: On Thursday, 3 April 2025 at 04:41:14 UTC, Daniel Donnelly, Jr. wrote: [...] Derelict is no longer maintained. It was replaced by the BindBC project and that's what you should be using. As for the issue, in case you see it somewh

I think there's an issue with dub / visuald (not dagon), but how can I get dagon Tutorial1 Simple App to build?

2025-04-05 Thread Daniel via Digitalmars-d-learn
I posted this issue in the GitHub issue tracker: https://github.com/gecko0307/dagon/issues/100 But it looks like it has something to do with dub changing folder structure (so that the shaders folder isn't immediately where it should be). Any idea how to fix this?

How does one use toString() inside of the class's hash function? Compiler error

2025-04-05 Thread Daniel via Digitalmars-d-learn
``` module def; class Def { public: this(string latex) { this.latex = latex; } this() { this.latex = ""; } override string toString() const { return latex; } string opUnary(string op="*")() const { return toString(); } override bo

How do I call a context objects destructor or some type of exit() function automatically upon exiting a with {} scope?

2025-04-01 Thread Daniel via Digitalmars-d-learn
I thought the destructor might automatically be called after with (new Context()) {} but it's not. Is there some sort of entry/exit functions like in Python?

Re: How do I call a context objects destructor or some type of exit() function automatically upon exiting a with {} scope?

2025-04-01 Thread Daniel via Digitalmars-d-learn
On Tuesday, 1 April 2025 at 17:33:02 UTC, Ali Çehreli wrote: On 4/1/25 10:08 AM, Mike Parker wrote: > ``` > scope ctx = new Context; > ``` > > This will allocate the class instance on the stack so the destructor > will be called when the scope exits. Another option is to call the destructor expl

How does D lang handle multithreaded applications and static members of classes?

2025-04-01 Thread Daniel via Digitalmars-d-learn
Say I have a static context stack in my class Context, will each new thread receive their own copy of the static member or do I have to account for multiple threads and do it myself?

Re: How do I call a context objects destructor or some type of exit() function automatically upon exiting a with {} scope?

2025-04-01 Thread Daniel via Digitalmars-d-learn
On Tuesday, 1 April 2025 at 17:08:27 UTC, Mike Parker wrote: On Tuesday, 1 April 2025 at 16:54:50 UTC, Daniel Donnelly, Jr. wrote: [...] You've used `new`, which means it's allocated with the GC. In that case, your destructor is a finalizer and may or may not be called at any point during th

VisualD: how to stop Visual Studio from putting "ref" notes everywhere in my code?

2025-04-22 Thread Daniel via Digitalmars-d-learn
It's not part of the text and I can make each one go away but it comes back, and they're in random locations. Is this a feature? I would like to disable it. How can I do that...

How do you get basic hello world app with Derelict-GLFW to build?

2025-04-02 Thread Daniel via Digitalmars-d-learn
Errors: ``` ..\..\..\..\..\..\AppData\Local\dub\packages\derelict-gl3\2.0.0-beta.8\derelict-gl3\source\derelict\opengl\impl.d-mixin-94(152): Deprecation: using `in` parameters with `extern(Windows)` functions is deprecated ..\..\..\..\..\..\AppData\Local\dub\packages\derelict-gl3\2.0.0-beta.8\d

derelict-gl3 + derelict-glfw3 + derelict-util (version?) - need instructions on handling basic package version dependency conflicts

2025-04-02 Thread Daniel via Digitalmars-d-learn
When trying all 3 of these libraries together (just adding them with e.g. `derelict-gl3` so latest version) I get: ``` C:\Users\fruit\OneDrive\Desktop\MathProjects\DerelictTest\derelicttest2>dub generate visuald Error Unresolvable dependencies to package derelict-util: derelict-gl3 1.0.24 dep

Re: How does D lang handle multithreaded applications and static members of classes?

2025-04-02 Thread Daniel via Digitalmars-d-learn
On Wednesday, 2 April 2025 at 08:33:05 UTC, Inkrementator wrote: On Tuesday, 1 April 2025 at 23:01:23 UTC, Daniel Donnelly, Jr. wrote: Say I have a static context stack in my class Context, will each new thread receive their own copy of the static member or do I have to account for multiple thr

Best way to get a dub generate visuald-generated visuald project to be a .lib / .obj for static linking?

2025-06-17 Thread Daniel via Digitalmars-d-learn
I messed with the settings in the VisualD project settings from within visual studio: Compiler: DMD Output Type: Library Subsystem: Windows Output Path: (absolute path to my project root folder) Intermediate Path: (ditto)\obj Files to Clan: *.cmd;*.build;*.sep (deleted *.obj) Compilation: Separa