Re: Simplify some C-style code

2025-01-06 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 28 December 2024 at 23:23:02 UTC, monkyyy wrote: The spec would need to drastically improve before my opinion changes; Im also uninterested practicing withholding my opinions. The spec may have flaws, as any complex technical spec is prone to. There is no reason why anyone on the

Re: Simplify some C-style code

2025-01-06 Thread sfp via Digitalmars-d-learn
On Sunday, 5 January 2025 at 16:02:47 UTC, Christian Köstlin wrote: On Wednesday, 25 December 2024 at 07:49:28 UTC, sfp wrote: I have some code like this: ``` enum DomainType { Ball, Box, CsgDiff } struct Domain(int Dim) { DomainType type; union { Ball!Dim ball; Box!Dim box;

Re: Simplify some C-style code

2025-01-05 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 07:49:28 UTC, sfp wrote: I have some code like this: ``` enum DomainType { Ball, Box, CsgDiff } struct Domain(int Dim) { DomainType type; union { Ball!Dim ball; Box!Dim box; CsgDiff!Dim csgDiff; } this(Ball!Dim ball) { this.type =

Re: Simplify some C-style code

2024-12-29 Thread monkyyy via Digitalmars-d-learn
On Sunday, 29 December 2024 at 15:15:28 UTC, Andy Valencia wrote: On Saturday, 28 December 2024 at 23:23:02 UTC, monkyyy wrote: The spec would need to drastically improve before my opinion changes; Im also uninterested practicing withholding my opinions. There are many many ancient bugs, that

Re: Simplify some C-style code

2024-12-29 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 28 December 2024 at 23:23:02 UTC, monkyyy wrote: The spec would need to drastically improve before my opinion changes; Im also uninterested practicing withholding my opinions. There are many many ancient bugs, that you need to inherent implicit knowledge to navigate, either those

Re: Simplify some C-style code

2024-12-28 Thread monkyyy via Digitalmars-d-learn
On Friday, 27 December 2024 at 11:31:05 UTC, Nick Treleaven wrote: On Wednesday, 25 December 2024 at 21:34:00 UTC, monkyyy wrote: The spec is full of lies and slander, noun: lie; plural noun: lies an intentionally false statement. Can you please stop saying that the spec is intentionally

Re: Simplify some C-style code

2024-12-27 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 21:34:00 UTC, monkyyy wrote: The spec is full of lies and slander, noun: lie; plural noun: lies an intentionally false statement. Can you please stop saying that the spec is intentionally false?

Re: Simplify some C-style code

2024-12-26 Thread sfp via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 07:49:28 UTC, sfp wrote: I have some code like this: ... Thanks again for all the helpful feedback. This is where I landed: ``` import std.algorithm : map; import std.algorithm.iteration : joiner; import std.array : array; string uncap(string s) { import st

Re: Simplify some C-style code

2024-12-25 Thread bauss via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 07:49:28 UTC, sfp wrote: I have some code like this: ``` enum DomainType { Ball, Box, CsgDiff } struct Domain(int Dim) { DomainType type; union { Ball!Dim ball; Box!Dim box; CsgDiff!Dim csgDiff; } this(Ball!Dim ball) { this.type =

Re: Simplify some C-style code

2024-12-25 Thread sfp via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 21:23:00 UTC, Jim Balter wrote: On Wednesday, 25 December 2024 at 16:41:05 UTC, sfp wrote: On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the gr

Re: Simplify some C-style code

2024-12-25 Thread Jim Balter via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 18:25:57 UTC, sfp wrote: kind of weird that it doesn't work inside `enum`. Seems like an obvious application... It's not weird at all when you understand that it's an AST that is being mixed in, not just a string as if it were an C preprocessor macro. The in

Re: Simplify some C-style code

2024-12-25 Thread Jim Balter via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 21:34:00 UTC, monkyyy wrote: On Wednesday, 25 December 2024 at 21:23:00 UTC, Jim Balter wrote: I suggest reading the spec rather than just trying random things. I suggest trying random things instead of reading the spec. The spec is full of lies and slander,

Re: Simplify some C-style code

2024-12-25 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 21:23:00 UTC, Jim Balter wrote: I suggest reading the spec rather than just trying random things. I suggest trying random things instead of reading the spec. The spec is full of lies and slander, and when your in template hell, defensively syntax test to find

Re: Simplify some C-style code

2024-12-25 Thread Jim Balter via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 16:41:05 UTC, sfp wrote: On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the ground... This doesn't compile: ``` enum Test { mixin("A, B, C") }

Re: Simplify some C-style code

2024-12-25 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 18:25:57 UTC, sfp wrote: What is a template map? I'd be interested in seeing this pattern and whether it's worth it to try to salvage std.sumtype. ```d import std; struct Ball(int i){} struct Box(int i){} struct CsgDiff(int i){} alias dimlist(int dim)=Alias

Re: Simplify some C-style code

2024-12-25 Thread sfp via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 17:46:01 UTC, monkyyy wrote: On Wednesday, 25 December 2024 at 17:20:01 UTC, user1234 wrote: What you can do however is to use https://dlang.org/phobos/std_sumtype.html. instead of a the manually defined tagged union. If he's struggling to define a enum with

Re: Simplify some C-style code

2024-12-25 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 17:20:01 UTC, user1234 wrote: What you can do however is to use https://dlang.org/phobos/std_sumtype.html. instead of a the manually defined tagged union. If he's struggling to define a enum with a mixin I assume he's very new and to get this code to work wit

Re: Simplify some C-style code

2024-12-25 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 16:41:05 UTC, sfp wrote: On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the ground... This doesn't compile: ``` enum Test { mixin("A, B, C") }

Re: Simplify some C-style code

2024-12-25 Thread sfp via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 17:20:01 UTC, user1234 wrote: On Wednesday, 25 December 2024 at 16:41:05 UTC, sfp wrote: On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the grou

Re: Simplify some C-style code

2024-12-25 Thread user1234 via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 16:41:05 UTC, sfp wrote: On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the ground... This doesn't compile: ``` enum Test { mixin("A, B, C") }

Re: Simplify some C-style code

2024-12-25 Thread sfp via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 07:57:04 UTC, monkyyy wrote: static foreach, traits and mixin I was looking into this but I think I need some help getting off the ground... This doesn't compile: ``` enum Test { mixin("A, B, C") } ```

Re: Simplify some C-style code

2024-12-25 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 25 December 2024 at 07:49:28 UTC, sfp wrote: I have some code like this: ``` enum DomainType { Ball, Box, CsgDiff } struct Domain(int Dim) { DomainType type; union { Ball!Dim ball; Box!Dim box; CsgDiff!Dim csgDiff; } this(Ball!Dim ball) { this.type =

Simplify some C-style code

2024-12-24 Thread sfp via Digitalmars-d-learn
I have some code like this: ``` enum DomainType { Ball, Box, CsgDiff } struct Domain(int Dim) { DomainType type; union { Ball!Dim ball; Box!Dim box; CsgDiff!Dim csgDiff; } this(Ball!Dim ball) { this.type = DomainType.Ball; this.ball = ball; } this(Box!Dim b