Re: How do I create classes dynamically?

2021-04-15 Thread Ali Çehreli via Digitalmars-d-learn
On 4/15/21 1:56 PM, mw wrote: >>> I wanted to find out if it is possible to create classes dynamically. >> >> out of curiosity: Why you would like to do this? I cannot think of a >> use case for this - this is why i ask. > > In response to user input? That's a different question because

Re: How do I create classes dynamically?

2021-04-15 Thread Jack via Digitalmars-d-learn
On Thursday, 15 April 2021 at 17:48:02 UTC, Imperatorn wrote: On Thursday, 15 April 2021 at 16:39:30 UTC, Kagamin wrote: On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: [...] String mixins is D replacement of macros for code generation. Works like this: ```d mixin("class

Re: How do I create classes dynamically?

2021-04-15 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Apr 15, 2021 at 08:56:18PM +, mw via Digitalmars-d-learn wrote: [...] > of course, one can manually dispatch: > > if (userInputString == "cat") createCat(); > else if (userInputString == "dog") createDog(); > ... > > but this this tedious. --- // Disclaimer:

Re: How do I create classes dynamically?

2021-04-15 Thread mw via Digitalmars-d-learn
On Thursday, 15 April 2021 at 18:21:16 UTC, Martin wrote: On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: I wanted to find out if it is possible to create classes dynamically. out of curiosity: Why you would like to do this? I cannot think of a use case for this - this is why i

Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 15 April 2021 at 19:38:04 UTC, z wrote: I understand that it won't be possible to pinpoint the cause without a reduced test case, but : ```D int[] a,b,c,d,e; void templatef(args...){/*...*/} //... auto seq = AliasSeq!(b,c,d); templatef!(a,seq,e); templatef!(a,b,c,d,e); //am i

Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn
On Thursday, 15 April 2021 at 19:38:04 UTC, z wrote: ```D int[] a,b,c,d,e; void templatef(args...){/*...*/} //... auto seq = AliasSeq!(b,c,d); templatef!(a,seq,e); templatef!(a,b,c,d,e); //am i being mistaken for thinking these two template calls should be equivalent in behavior? ``` woops,

Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn
On Thursday, 15 April 2021 at 18:58:40 UTC, Paul Backus wrote: Without an example that shows the actual problem you encountered, it will be almost impossible for anyone to help you figure out what is causing it. Since you were not able to trigger it, it seems likely that the problem is

Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 15 April 2021 at 18:43:29 UTC, z wrote: To see what i mean : https://run.dlang.io/is/VXDRL4 (i could not manage to trigger it here however.) Without an example that shows the actual problem you encountered, it will be almost impossible for anyone to help you figure out what is

AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn
I've tried to group together a bundle of alias template parameters with AliasSeq, but while without it works just fine, when the verbose parameters are grouped with multiple AliasSeqs, the lengths of the array parameters passed through AliasSeq are 0(inside the templated function, before the

Re: How do I create classes dynamically?

2021-04-15 Thread Martin via Digitalmars-d-learn
On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: I wanted to find out if it is possible to create classes dynamically. out of curiosity: Why you would like to do this? I cannot think of a use case for this - this is why i ask.

Re: How do I create classes dynamically?

2021-04-15 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 15 April 2021 at 16:39:30 UTC, Kagamin wrote: On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: Maybe I am just too short in D, but I wanted to find out if it is possible to create classes dynamically. My problem is, I just don't know where to start reading. Maybe at mixin

Re: How do I create classes dynamically?

2021-04-15 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: Maybe I am just too short in D, but I wanted to find out if it is possible to create classes dynamically. My problem is, I just don't know where to start reading. Maybe at mixin templates? CreateClassWithName!("MyDynamicClassName");

Re: How do I create classes dynamically?

2021-04-15 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: Maybe I am just too short in D, but I wanted to find out if it is possible to create classes dynamically. My problem is, I just don't know where to start reading. Maybe at mixin templates? CreateClassWithName!("MyDynamicClassName");

Re: How do I create classes dynamically?

2021-04-15 Thread Ali Çehreli via Digitalmars-d-learn
On 4/14/21 1:38 PM, Mario wrote: > Maybe I am just too short in D, but I wanted to find out if it is > possible to create classes dynamically. In D world, "dynamically" means "at run time". > Maybe at mixin templates? Both mixins and templates are compile time features. > Normally I would

Re: Range Error

2021-04-15 Thread martinm via Digitalmars-d-learn
On Sunday, 11 April 2021 at 19:48:42 UTC, Ruby The Roobster wrote: On Sunday, 11 April 2021 at 19:45:30 UTC, Ruby The Roobster wrote: What am I doing wrong here? Is it the 'for' loop? Nevermind. I messed up what line it was. It was actually this line: ```d square[i][j] = new

Re: How to build a specific library version with dub?

2021-04-15 Thread martinm via Digitalmars-d-learn
On Sunday, 11 April 2021 at 15:01:04 UTC, Mike Parker wrote: On Sunday, 11 April 2021 at 13:43:47 UTC, martinm wrote: I'm trying to use wayland-d which depends on derelict-util-2.0.6. DUB can't download the zip and fails. I download the zip to ~/.dub/packages/derelict-util folder, unzip and