Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread user1234 via Digitalmars-d-learn
On Thursday, 19 May 2022 at 10:15:32 UTC, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue = COLOR(0,0,1,1); auto white = COLOR(1,1,1,1); //etc ``` is there a way to do:

template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Chris Katko via Digitalmars-d-learn
given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue = COLOR(0,0,1,1); auto white = COLOR(1,1,1,1); //etc ``` is there a way to do: ```D auto myColor = GREY!(0.5); // where GREY!(0.5) becomes C

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread bauss via Digitalmars-d-learn
On Thursday, 19 May 2022 at 10:18:38 UTC, user1234 wrote: On Thursday, 19 May 2022 at 10:15:32 UTC, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue = COLOR(0,0,1,1); au

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread ag0aep6g via Digitalmars-d-learn
On 19.05.22 12:15, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red   = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue  = COLOR(0,0,1,1); auto white = COLOR(1,1,1,1); //etc ``` is there a way to do: ```D auto myColor = GR

Re: Unexplainable behaviour with direct struct assignment.

2022-05-19 Thread HuskyNator via Digitalmars-d-learn
On Thursday, 19 May 2022 at 04:33:01 UTC, Tejas wrote: Does this happen with LDC as well? I tried it using `LDC 1.29.0` and it prints correctly under both `--b=release` and `--b=debug` builds.

Re: Unexplainable behaviour with direct struct assignment.

2022-05-19 Thread frame via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return what one would expect. I'm still on 2098.1, Windows 10 and ge

Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn
Using -L/SUBSYSTEM:windows user32.lib Error: lld-link: error: undefined symbol: _WinMain@16 referenced by msvcrt120.lib(msvcrt_stub2.obj):(_WinMainCRTStartup) Error: linker exited with status 1

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote: Using -L/SUBSYSTEM:windows user32.lib you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use -L/subs

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn
On Thursday, 19 May 2022 at 19:35:20 UTC, Adam D Ruppe wrote: On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote: Using -L/SUBSYSTEM:windows user32.lib you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the bui

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ?

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn
On Thursday, 19 May 2022 at 20:33:34 UTC, Adam D Ruppe wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Are you using the `-L/entry:mainCRTSt

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote: Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup try the w one too. both doing the same result?

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Marcone via Digitalmars-d-learn
On Thursday, 19 May 2022 at 22:13:06 UTC, Adam Ruppe wrote: On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote: Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup try the w one too. both doing the same result? Both is doing the same

vibe.d requestHTTP in static this causes infinite loop?

2022-05-19 Thread Vijay Nayar via Digitalmars-d-learn
I've encountered an unusual behavior that I have no good explanation for. Consider the following code example: ```d import vibe.core.log : logInfo; import vibe.http.client : requestHTTP, HTTPClientRequest, HTTPClientResponse; import vibe.http.common : HTTPMethod; import vibe.stream.operations

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Chris Katko via Digitalmars-d-learn
On Thursday, 19 May 2022 at 10:35:30 UTC, ag0aep6g wrote: On 19.05.22 12:15, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red   = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue  = COLOR(0,0,1,1); auto white = COLOR(1,1,1,

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/19/22 8:12 PM, Chris Katko wrote: On Thursday, 19 May 2022 at 10:35:30 UTC, ag0aep6g wrote: On 19.05.22 12:15, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red   = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue  = C

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/19/22 8:29 PM, Steven Schveighoffer wrote: Given a CTFE function it's very easy to wrap for ensuring compile-time usage: ```d enum ctGrey(float f) = grey(f); auto myColor = ctGrey!(0.5); ``` That being said, if it's calculatable at compile time, chances are the compiler is already goi

Re: vibe.d requestHTTP in static this causes infinite loop?

2022-05-19 Thread Ali Çehreli via Digitalmars-d-learn
On 5/19/22 16:44, Vijay Nayar wrote: > If I remove the call from `static this()`, then the web call works as > normal. Any idea why calling vibe.d's `requestHTTP` function inside of a > module's static construction would cause an infinite loop? I am not experienced with vibe.d. 'static this' is

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 00:12:44 UTC, Chris Katko wrote: Yeah that occurred to me as I was falling asleep. Though, do I have to a specify ```D static auto myColor = grey(0.5); ``` to ensure it's done at compile time? It's not the end of the world, but ideally, these are static / hardcoded v

UI Library

2022-05-19 Thread harakim via Digitalmars-d-learn
I need to write a piece of software to track and categorize some purchases. It's the kind of thing I could probably write in a couple of hours in C#/Java + html/css/javascript. However, something keeps drawing me to D and as this is a simple application, it would be a good one to get back in af

Re: UI Library

2022-05-19 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote: I need to write a piece of software to track and categorize some purchases. It's the kind of thing I could probably write in a couple of hours in C#/Java + html/css/javascript. However, something keeps drawing me to D and as this is a simpl

Re: UI Library

2022-05-19 Thread harakim via Digitalmars-d-learn
On Friday, 20 May 2022 at 02:53:39 UTC, Craig Dillabaugh wrote: On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote: I need to write a piece of software to track and categorize some purchases. It's the kind of thing I could probably write in a couple of hours in C#/Java + html/css/javascript.

Re: vibe.d requestHTTP in static this causes infinite loop?

2022-05-19 Thread bauss via Digitalmars-d-learn
On Friday, 20 May 2022 at 01:41:59 UTC, Ali Çehreli wrote: On 5/19/22 16:44, Vijay Nayar wrote: > If I remove the call from `static this()`, then the web call works as > normal. Any idea why calling vibe.d's `requestHTTP` function inside of a > module's static construction would cause an infinit