Re: basic pointer question

2025-07-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 11, 2025 at 10:17:02PM +, WhatMeWorry via Digitalmars-d-learn wrote: > ``` > // working function > > SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess > newAccess) > { > // pertinent code only > texture = createTexture(renderer, pixelFormat, newAcces

Re: basic pointer question

2025-07-11 Thread Luna via Digitalmars-d-learn
`ref`; eg `ref SDL_Texture*`; which would be safer given that the SDL_Texture* provided then has to be a valid variable to store the pointer into. As for creating and dereferencing references; without seeing the errors in question I am not sure I can provide a good answer.

basic pointer question

2025-07-11 Thread WhatMeWorry via Digitalmars-d-learn
``` // working function SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess newAccess) { // pertinent code only texture = createTexture(renderer, pixelFormat, newAccess, width, height); return texture; } ``` The above function is working for me when I call it

Re: Newbie style question about string constants

2025-03-30 Thread FeepingCreature via Digitalmars-d-learn
On Thursday, 27 March 2025 at 06:20:25 UTC, cc wrote: I got in the habit of using `static immutable` whenever possible as enum just can't be trusted to use CTFE. ```d enum string RfuncName = fullyQualifiedName!... // Oops! Allocates on runtime every frame this is referenced enum string funcName

Re: Newbie style question about string constants

2025-03-26 Thread cc via Digitalmars-d-learn
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote: Hello, What's the recommended D way to declare a string constant? Say, for example, for a path used inside a class constructor? I've seen const string, immutable, enum etc... Is this the place for these kinds of questions? Is there a D

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-21 Thread WhatMeWorry via Digitalmars-d-learn
On Friday, 21 March 2025 at 13:41:18 UTC, Dennis wrote: On Thursday, 20 March 2025 at 16:18:32 UTC, WhatMeWorry wrote: Yup. That was the problem. Thank you. You guys are a sharp. From dmd version 2.111, there will be a better error message in this case. https://github.com/dlang/dmd/pull/210

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-21 Thread Dennis via Digitalmars-d-learn
On Thursday, 20 March 2025 at 16:18:32 UTC, WhatMeWorry wrote: Yup. That was the problem. Thank you. You guys are a sharp. From dmd version 2.111, there will be a better error message in this case. https://github.com/dlang/dmd/pull/21046

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-20 Thread WhatMeWorry via Digitalmars-d-learn
Yup. That was the problem. Thank you. You guys are a sharp.

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 20 March 2025 at 02:01:25 UTC, Jonathan M Davis wrote: On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: I thought it was always a miss. :-D At least, it's never worked for me every time I tried it. I always have to move the UFCS function to mo

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Mar 19, 2025 at 11:21:15PM +, monkyyy via Digitalmars-d-learn > wrote: > [...] > > ufcs on local functions is hit or miss; > [...] > > I thought it was always a miss. :-D At least, it's never work

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 19, 2025 at 10:26:54PM +, WhatMeWorry via Digitalmars-d-learn wrote: [...] > The above compiles and executes successfully. But the following fails > with: app.d(179,13): Error: no property `wasFound` for `i` of type > `long` > > I thought the templated function would take care of

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 19, 2025 at 11:21:15PM +, monkyyy via Digitalmars-d-learn wrote: [...] > ufcs on local functions is hit or miss; [...] I thought it was always a miss. :-D At least, it's never worked for me every time I tried it. I always have to move the UFCS function to module scope, then it wo

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 19 March 2025 at 22:26:54 UTC, WhatMeWorry wrote: ``` bool wasFound(I)(I result) { return(result != -1); } bool existPoint(Point b, int cost) { auto i = closed.countUntil(b); if(wasFound(i)) // -1 is returned if no point b is found in

simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread WhatMeWorry via Digitalmars-d-learn
``` bool wasFound(I)(I result) { return(result != -1); } bool existPoint(Point b, int cost) { auto i = closed.countUntil(b); if(wasFound(i)) // -1 is returned if no point b is found in the range ``` The above compiles and executes successfully. But

Re: Newbie style question about string constants

2025-03-17 Thread Ian via Digitalmars-d-learn
On Monday, 17 March 2025 at 08:27:17 UTC, Jonathan M Davis wrote: In any case, the normal way in D to declare a string constant is to use enum. So, that's primarily what you're going to see in most code. Whether you choose to do that in your own code is up to you. - Jonathan M Davis Hi Jo

Re: Newbie style question about string constants

2025-03-17 Thread monkyyy via Digitalmars-d-learn
On Sunday, 16 March 2025 at 15:22:04 UTC, Ian wrote: It seems that in some cases static immutable is preferred, so why not use that always then, rather than having to keep two cases in my head? Enum is the indispensable one, immutable isnt important just theres a subsection of the community t

Re: Newbie style question about string constants

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 16, 2025 9:22:04 AM MDT Ian via Digitalmars-d-learn wrote: > On Tuesday, 25 February 2025 at 00:34:45 UTC, Jonathan M Davis > wrote: > > For strings, the way that you normally do constants is with > > enum, e.g > > > > enum foo = "dlang"; > > > > An enum like this is called a m

Re: Newbie style question about string constants

2025-03-16 Thread Ian via Digitalmars-d-learn
On Tuesday, 25 February 2025 at 00:34:45 UTC, Jonathan M Davis wrote: For strings, the way that you normally do constants is with enum, e.g enum foo = "dlang"; An enum like this is called a manifest constant. And you use manifest constants for most constants in D, with the caveat that fo

Re: Newbie style question about string constants

2025-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 24, 2025 9:07:07 AM MST Ian via Digitalmars-d-learn wrote: > Hello, > > What's the recommended D way to declare a string constant? Say, > for example, for a path used inside a class constructor? I've > seen const string, immutable, enum etc... > > Is this the place for these kin

Re: Newbie style question about string constants

2025-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 24, 2025 11:19:48 AM MST Elias Batek (0xEAB) via Digitalmars-d-learn wrote: > For string constants you’ll usually want to mark them as `static > immutable`. Strings with this combination will usually be put > into read-only sections (ROM) of the resulting binaries. > > Unlike `

Re: Newbie style question about string constants

2025-02-24 Thread Elias Batek (0xEAB) via Digitalmars-d-learn
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote: Hello, What's the recommended D way to declare a string constant? Say, for example, for a path used inside a class constructor? I've seen const string, immutable, enum etc... Is this the place for these kinds of questions? Is there a D

Re: Newbie style question about string constants

2025-02-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote: Hello, What's the recommended D way to declare a string constant? Say, for example, for a path used inside a class constructor? I've seen const string, immutable, enum etc... enum vs value is a tradeoff of when a decision is made; not s

Newbie style question about string constants

2025-02-24 Thread Ian via Digitalmars-d-learn
Hello, What's the recommended D way to declare a string constant? Say, for example, for a path used inside a class constructor? I've seen const string, immutable, enum etc... Is this the place for these kinds of questions? Is there a D stack overflow? Cheers, Ian

Re: template struct question

2025-02-13 Thread WhatMeWorry via Digitalmars-d-learn
Just wanted to thank everybody for their suggestions. Ali's code provided the breakthrough: ```d import std.stdio; void main() { struct HexBoard(F,I) { this(F d, I r, I c) { diameter = d; rows = r; cols = c; } F diameter; I rows; I cols; } void displayHexBoard(HB)(HB h) { w

Re: template struct question

2025-02-13 Thread bkoie via Digitalmars-d-learn
On Wednesday, 12 February 2025 at 20:55:14 UTC, WhatMeWorry wrote: ``` void main() { struct HexBoard(F,I) { this(F d, I r, I c) {} //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! } void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier F and I

Re: template struct question

2025-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 12 February 2025 at 20:55:14 UTC, WhatMeWorry wrote: ```d void main() { struct HexBoard(F,I) { this(F d, I r, I c) {} //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! } void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier F and I

Re: template struct question

2025-02-12 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 12 February 2025 at 20:55:14 UTC, WhatMeWorry wrote: ``` void main() { struct HexBoard(F,I) { this(F d, I r, I c) {} //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! } void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier F and I

Re: template struct question

2025-02-12 Thread Ali Çehreli via Digitalmars-d-learn
On 2/12/25 12:55 PM, WhatMeWorry wrote: > struct HexBoard(F,I) > { > this(F d, I r, I c) {} > //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! > } > > void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier > F and I Would isInstanceOf be useful? (Wh

template struct question

2025-02-12 Thread WhatMeWorry via Digitalmars-d-learn
``` void main() { struct HexBoard(F,I) { this(F d, I r, I c) {} //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! } void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier F and I auto h1 = HexBoard!(float,uint)(.25, 3, 7); auto h2 = HexBoard!(dou

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread Dennis via Digitalmars-d-learn
On Friday, 10 January 2025 at 16:57:10 UTC, An wrote: If the compiler flags this as an warning -> he probably notice the problem Lag of error/warn/hint for such case is not helping Happy coding I'm trying out making it an error: https://github.com/dlang/dmd/pull/20696

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread Ali Çehreli via Digitalmars-d-learn
On 1/12/25 8:55 PM, H. S. Teoh wrote: > I wish there was some kind of syntactic sugar for assigning ctor > parameters to class members. Amen. Dart provides some help. It's under Generative Constructors here: https://dart.dev/language/constructors class Point { // Instance variables to hold

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-13 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 January 2025 at 23:44:52 UTC, WhatMeWorry wrote: You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.location ``` Thanks. I was starting to question my sanity. That error is so classic that ev

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-12 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 13, 2025 at 04:05:25AM +, Jim Balter via Digitalmars-d-learn wrote: > On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: > > On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: > > > this(Location locaction, uint f) { > > > this.location = location;

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-12 Thread Jim Balter via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in t

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-10 Thread An via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:08:31 UTC, Dennis wrote: On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in t

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-10 Thread WhatMeWorry via Digitalmars-d-learn
struct Node { uint multiplier; Location location; this(Location locaction, uint multiplier) { this.location = location * multiplier; this.multiplier = multiplier; } } I appreciate your example of the robustness of D, but if I was to make the same syntax mistake: this(Loca

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: produces: n = Node(Location(0, 0), 33) when I expected n = Node(Location(1, 2), 33) This is a simple typo (it shouldn't be 1 letter) but the code should be made smarter thanks to the capabilities of D. No more fear of writing lik

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread WhatMeWorry via Digitalmars-d-learn
You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.location ``` Thanks. I was starting to question my sanity.

Re: Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread Dennis via Digitalmars-d-learn
On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote: this(Location locaction, uint f) { this.location = location; this.f = f; } You misspelled the parameter name 'locaction', so your assignment in the constructor is a no-op: ``` this.location = this.locati

Super easy struct construction question that I'm embarrassed to ask.

2025-01-09 Thread WhatMeWorry via Digitalmars-d-learn
``` import std.stdio; struct Location { int r; int c; } struct Node { this(Location locaction, uint f) { this.location = location; this.f = f; } Location location; uint f; } void main() { Node n = Node(Location(1,2), 33); writeln("n = ", n); } --

newbie question

2024-10-31 Thread f via Digitalmars-d-learn
since i am converting from c# to d : 1. how to check template inheritance c# code interface I class A : I { void run(){}} class B : A {} void D\ (T t) : where T:B, new T() { t.run(); } d code //there should be has several check such as hasBase, hasImplements on std.traits void D(T) (int a) if

Re: newbie question

2024-10-31 Thread Sergey via Digitalmars-d-learn
On Thursday, 31 October 2024 at 09:10:32 UTC, f wrote: since i am converting from c# to d : 2. how to make built in array , std.container.slist, container.HashMap (emsi_containers) a range c# code void a(IEnumerable\ a) {} dcode void a(InputRange!string a) {} // notworking : i slice it to

Re: newbie question

2024-10-31 Thread Sergey via Digitalmars-d-learn
On Thursday, 31 October 2024 at 09:10:32 UTC, f wrote: 3. known OAuth / OIDC Api Sdk in D. there is only Jwt stuff when search code.dlang.org. https://code.dlang.org/packages/oauth https://code.dlang.org/packages/vibe-auth

Re: ImportC question

2024-10-31 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote: DMD Compiler version? SDB@79 ``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ``` First of all, be sure to get rid of that old version because a lot has cha

Re: ImportC question

2024-10-30 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 30 October 2024 at 15:17:56 UTC, DLearner wrote: On Wednesday, 30 October 2024 at 09:21:55 UTC, ryuukk_ wrote: On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote: On Monday, 28 October 2024 at 20:56:03 UTC,

Re: ImportC question

2024-10-30 Thread DLearner via Digitalmars-d-learn
On Wednesday, 30 October 2024 at 09:21:55 UTC, ryuukk_ wrote: On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote: On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote: Just trying ImportC under Windows 10: ```c #in

Re: ImportC question

2024-10-30 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote: On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote: Just trying ImportC under Windows 10: ```c #include int main() { printf("Hello world.\n"); return 0;

Re: ImportC question

2024-10-29 Thread Dennis via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 16:14:22 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote: https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022 Similar message from Powershell: Whether it's CMD/Powershell isn't impo

Re: ImportC question

2024-10-29 Thread DLearner via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote: On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote: Just trying ImportC under Windows 10: ```c #include int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc

Re: ImportC question

2024-10-29 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote: Just trying ImportC under Windows 10: ```c #include int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\.

Re: ImportC question

2024-10-29 Thread Lance Bachmeier via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 18:17:37 UTC, Richard (Rikki) Andrew Cattermole wrote: https://issues.dlang.org/show_bug.cgi?id=24308 I guess that explains why I've never run into the issue - I've been using LDC but not DMD on Windows.

Re: ImportC question

2024-10-29 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=24308

Re: ImportC question

2024-10-29 Thread Lance Bachmeier via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 16:14:22 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote: On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote: On Tuesday, 29 October 2024 at 12:23:06 UTC,

Re: ImportC question

2024-10-29 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 30/10/2024 1:23 AM, DLearner wrote: On Tuesday, 29 October 2024 at 00:10:17 UTC, Richard (Rikki) Andrew Cattermole wrote: https://github.com/dlang/dmd/blob/ dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it

Re: ImportC question

2024-10-29 Thread DLearner via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote: On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote: On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote: However, there is still a problem: ``` dmd

Re: ImportC question

2024-10-29 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote: On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote: On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote: However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\imp

Re: ImportC question

2024-10-29 Thread DLearner via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote: On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote: However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Er

Re: ImportC question

2024-10-29 Thread Lance Bachmeier via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote: However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit statu

Re: ImportC question

2024-10-29 Thread DLearner via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 00:10:17 UTC, Richard (Rikki) Andrew Cattermole wrote: https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it installed, that'll be why. Otherwise its

Re: ImportC question

2024-10-28 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it installed, that'll be why. Otherwise its related to dmd not being able to find it.

ImportC question

2024-10-28 Thread DLearner via Digitalmars-d-learn
Just trying ImportC under Windows 10: ``` #include int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preproces

Re: Boneheaded question regarding compilation...

2024-04-02 Thread Dennis via Digitalmars-d-learn
On Tuesday, 2 April 2024 at 18:21:58 UTC, Mike Shah wrote: An easier fix may be perhaps to just use 'dub' and install the glfw dependency. In my talk, I did everything from scratch (my preferred way), though I suspect using dub with glfw-d (https://code.dlang.org/packages/glfw-d) may provide le

Re: Boneheaded question regarding compilation...

2024-04-02 Thread Mike Shah via Digitalmars-d-learn
On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote: Huge fan of Mike Shah's YouTube videos regarding D and his latest for D conference: https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf So I installed github desktop app

Re: Boneheaded question regarding compilation...

2024-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote: Huge fan of Mike Shah's YouTube videos regarding D and his latest for D conference: https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf So I installed github desktop app

Boneheaded question regarding compilation...

2024-04-01 Thread WhatMeWorry via Digitalmars-d-learn
Huge fan of Mike Shah's YouTube videos regarding D and his latest for D conference: https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf So I installed github desktop app and cloned his Talks repo. There is a build command commen

Re: Question on shared memory concurrency

2024-03-05 Thread Andy Valencia via Digitalmars-d-learn
On Monday, 4 March 2024 at 18:08:52 UTC, Andy Valencia wrote: For any other newbie dlang voyagers, here's a version which works as expected using the system memory allocator. On my little i7 I get 1.48 secs wallclock with 5.26 CPU seconds. ... Using a technique I found in a unit test in std/

Re: Question on shared memory concurrency

2024-03-04 Thread Andy Valencia via Digitalmars-d-learn
On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote: On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew Cattermole wrote: ... I still hope to be able to share memory between spawned threads, and if it isn't a shared ref of a shared variable, then what would it be? Do I ha

Re: Question on shared memory concurrency

2024-03-04 Thread evilrat via Digitalmars-d-learn
On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote: On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew Cattermole wrote: A way to do this without spawning threads manually: ... Thank you! Of course, a thread dispatch per atomic increment is going to be s.l.o.w., so not

Re: Question on shared memory concurrency

2024-03-04 Thread Andy Valencia via Digitalmars-d-learn
On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew Cattermole wrote: A way to do this without spawning threads manually: ... Thank you! Of course, a thread dispatch per atomic increment is going to be s.l.o.w., so not surprising you had to trim the iterations. Bug I still hope

Re: Question on shared memory concurrency

2024-03-03 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
A way to do this without spawning threads manually: ```d import std.parallelism : TaskPool, parallel, taskPool, defaultPoolThreads; import std.stdio : writeln; import std.range : iota; enum NSWEPT = 1_000_000; enum NCPU = 4; void main() { import core.atomic : atomicLoad, atomicOp; shar

Question on shared memory concurrency

2024-03-03 Thread Andy Valencia via Digitalmars-d-learn
I tried a shared memory parallel increment. Yes, it's basically a cache line thrasher, but I wanted to see what's involved in shared memory programming. Even though I tried to follow all the rules to make true shared memory (not thread local) it appears I failed, as the wait loop at the end o

question about ctfe init importC zero length array of struct

2024-02-28 Thread Dakota via Digitalmars-d-learn
This is the type defined from c code import by importC: ```c struct A { int count; int[] i; } ``` This kind data need to be init as const to avoid runtime cost, and need to be done from D code. how can I do this ? To put code into D source, I can use "-i=package" to automatically

Re: question

2023-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote: a bug ? It helps if you explain what you're talking about so we don't have to guess. I tried the code on my computer and it worked fine. But then figuring, you must be saying something doesn't work right, I tried it on another com

Re: question

2023-12-13 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote: [...] a bug ? thanks anyway Try to define the flag as static ```d static shared(bool) isDone = false; ``` I dont know if that should be a compiler error to have local shared (I tend to think yes as locals are specific to a frame, i

question

2023-12-13 Thread fred via Digitalmars-d-learn
import core.thread; import std.concurrency; import std.stdio : w = writeln; void w2(shared(bool) *done) { while (*done == false) { Thread.sleep(100.msecs); w("print done? ", *done); } } void s2() { shared(bool) i

Re: 'typeof' question

2023-11-28 Thread DLearner via Digitalmars-d-learn
On Tuesday, 28 November 2023 at 18:43:37 UTC, Adam D Ruppe wrote: On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote: A* A_Ptr; struct B { int BFld2; typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from A_Ptr of type A*. I think what you really want is typeof(*A_Pt

Re: 'typeof' question

2023-11-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote: A* A_Ptr; struct B { int BFld2; typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from A_Ptr of type A*. I think what you really want is typeof(*A_Ptr) ASUB; the typeof thing returns the type you'd get from the cod

'typeof' question

2023-11-28 Thread DLearner via Digitalmars-d-learn
Trying to manipulate 'typeof' return strings, preferably at compile-time. e.g. to produce struct B below (intended to have an A sub-struct), from A_Ptr alone. ``` struct A { int AFld1; } A* A_Ptr; struct B { int BFld2; typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from A_

Re: Question regarding mir.csv.

2023-11-01 Thread Sergey via Digitalmars-d-learn
On Wednesday, 1 November 2023 at 20:49:16 UTC, Zz wrote: Hi, Currently using std.csv and would like to do the following using mir.csv. auto data = std.csv.csvReader!Layout(input).array; Are there any examples out there on using mir.csv? Regards, Zz you can find some examples in source cod

Question regarding mir.csv.

2023-11-01 Thread Zz via Digitalmars-d-learn
Hi, Currently using std.csv and would like to do the following using mir.csv. auto data = std.csv.csvReader!Layout(input).array; Are there any examples out there on using mir.csv? Regards, Zz

Re: Question about interface implementation

2023-05-21 Thread Theo via Digitalmars-d-learn
On Sunday, 21 May 2023 at 11:20:30 UTC, ag0aep6g wrote: On 21.05.23 12:55, Theo wrote: As for the other part, if I use an abstract base class, I *must* indicate when i'm overriding the base class method by explicately saying 'override'. I wouldn't mind if implementing interface methods requir

Re: Question about interface implementation

2023-05-21 Thread ag0aep6g via Digitalmars-d-learn
On 21.05.23 12:55, Theo wrote: As for the other part, if I use an abstract base class, I *must* indicate when i'm overriding the base class method by explicately saying 'override'. I wouldn't mind if implementing interface methods required `override` as well. I don't know if there is a ration

Re: Question about interface implementation

2023-05-21 Thread Theo via Digitalmars-d-learn
On Sunday, 21 May 2023 at 10:33:07 UTC, ag0aep6g wrote: On 21.05.23 12:28, ag0aep6g wrote: Since @trusted functions are guaranteed (by the programmer) to be safe, they are allowed to overload/implement @safe functions/prototypes. *override oh ok. so i can override a @safe interface method w

Re: Question about interface implementation

2023-05-21 Thread ag0aep6g via Digitalmars-d-learn
On 21.05.23 12:28, ag0aep6g wrote: Since @trusted functions are guaranteed (by the programmer) to be safe, they are allowed to overload/implement @safe functions/prototypes. *override

Re: Question about interface implementation

2023-05-21 Thread ag0aep6g via Digitalmars-d-learn
On 21.05.23 11:55, Theo wrote: class MerchantShip : Ship {     private int speed = 0; // If only I had 'private(this)' !!     // how do I know this method is actually an implementation of an interface method     // and not a method specific to this class?     // AND ... how come I can chan

Question about interface implementation

2023-05-21 Thread Theo via Digitalmars-d-learn
see comments in the code below. they are my questions. But feel free to ignore the comment about 'private(this)' ;-) interface Ship { @safe void setSpeed(int speed); @safe int getSpeed(); } class PirateShip : Ship { private int speed = 0; // If only I had 'private(this)' !! //

Re: quick question, probably of little importance...

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 1 May 2023 at 03:53:24 UTC, Cecil Ward wrote: On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote: [...] Correction: I can’t count. There are only two instructions in parallel with another pair running alongside, not three. The first reg, reg move counts as zero cycle

Re: quick question, probably of little importance...

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote: On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew Cattermole wrote: Don't forget ``num % 2 == 0``. None should matter, pretty much all production compilers within the last 30 years should recognize all forms of t

Re: quick question, probably of little importance...

2023-04-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 27/04/2023 11:07 AM, WhatMeWorry wrote: On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew Cattermole wrote: Don't forget ``num % 2 == 0``. None should matter, pretty much all production compilers within the last 30 years should recognize all forms of this and do the right

Re: quick question, probably of little importance...

2023-04-26 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 26, 2023 at 11:07:39PM +, WhatMeWorry via Digitalmars-d-learn wrote: > On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew > Cattermole wrote: > > Don't forget ``num % 2 == 0``. > > > > None should matter, pretty much all production compilers within the > > last 30

Re: quick question, probably of little importance...

2023-04-26 Thread WhatMeWorry via Digitalmars-d-learn
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew Cattermole wrote: Don't forget ``num % 2 == 0``. None should matter, pretty much all production compilers within the last 30 years should recognize all forms of this and do the right thing. Thanks. Fastest reply ever! And I

Re: quick question, probably of little importance...

2023-04-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Don't forget ``num % 2 == 0``. None should matter, pretty much all production compilers within the last 30 years should recognize all forms of this and do the right thing.

quick question, probably of little importance...

2023-04-26 Thread WhatMeWorry via Digitalmars-d-learn
I just need an even/odd functionality. Don't think D has a built-in operator. // Found this C code online. int isEven(int num) { return !(num & 1); } // found this in std.functional.unaryFun alias isEven = unaryFun!("(a & 1) == 0"); assert(isEven(2) && !isEven(1)); If int

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

2023-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear wrote: (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` in

(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: auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
typeof(screen.output.findSplit("")) s; Perfect. That was the "essence" of my question. But thanks to Ali, I don't have to use such esoteric syntax. D is a wonderful language, but I seem to shoot myself in the foot :)

Re: auto scope question?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 6:07 PM, WhatMeWorry wrote: I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code?  I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... {     s = screen.output.findSplit("RE

Re: auto scope question?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 15:07, WhatMeWorry wrote: > auto screen = executeShell(cmdLine); > auto s; That can't work because there is no information to infer the type of 's'. Judging from the return type of getPath, perhaps it's string[]: string[] s; This is the question we

auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code? I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... { s = screen.output.findSplit("REG_SZ"); } but that doesn't compile either

Re: Design question regarding saving changes in the original array and/or returning a new set

2022-10-23 Thread matheus via Digitalmars-d-learn
On Sunday, 23 October 2022 at 17:36:25 UTC, Paul Backus wrote: On Sunday, 23 October 2022 at 13:32:44 UTC, matheus wrote: ... You say your idea is "like passing some argument", so why not actually pass an argument? For example: ... Hi, thanks for the example, and yes I'd like to do that,

  1   2   3   4   5   6   7   8   9   10   >