Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-06-04 Thread mw via Digitalmars-d-learn
On Thursday, 4 June 2020 at 19:42:57 UTC, mw wrote: On Thursday, 4 June 2020 at 18:42:05 UTC, H. S. Teoh wrote: TBH, whenever I run into a diamond inheritance problem or similar, my first reaction is, I'm using the wrong tool for ^^ Haha, it's also because most of th

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-06-04 Thread mw via Digitalmars-d-learn
On Thursday, 4 June 2020 at 18:42:05 UTC, H. S. Teoh wrote: TBH, whenever I run into a diamond inheritance problem or similar, my first reaction is, I'm using the wrong tool for modelling my data; I should be using some kind of component-based system instead of OO inheritance. I have no probl

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-06-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 04, 2020 at 06:09:35PM +, mw via Digitalmars-d-learn wrote: [...] > -- > class Person : NameI, AddrI { > mixin NameT!Person rename equals as name_equals; > mixin AddrT!Person rename equals as addr_equals; > >

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-06-04 Thread mw via Digitalmars-d-learn
On Sunday, 31 May 2020 at 06:28:11 UTC, mw wrote: This is better, ... but it breaks std.traits: void main() { auto fields = FieldNameTuple!(Point); writeln(fields); } $ ./b varvarvar And normally, we cannot define 2 fields with different types: class P { int x; double x; // b.d(45):

Re: Fastest way to check using if identifier has already been defined, using static if or similar?

2020-06-04 Thread drathier via Digitalmars-d-learn
On Wednesday, 3 June 2020 at 09:03:22 UTC, drathier wrote: I'm generating some code. Some of the generated types need to be overridden, so I define them manually at the top of the generated file. Then I need to guard against redefining the identifier (type/value/function) later on, in the gener

Re: Is there a list of things which are slow to compile?

2020-06-04 Thread drathier via Digitalmars-d-learn
On Wednesday, 3 June 2020 at 17:02:35 UTC, H. S. Teoh wrote: On Wed, Jun 03, 2020 at 09:36:52AM +, drathier via Digitalmars-d-learn wrote: I'm wondering if there's a place that lists things which are slower/faster to compile? DMD is pretty famed for compiling quickly, but I'm not seeing par

Re: Fastest way to check using if identifier has already been defined, using static if or similar?

2020-06-04 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 4 June 2020 at 14:20:45 UTC, Q. Schroll wrote: Little nitpicking, but D has many forms of string literals. Escaping is hard to read especially without syntax highlighting. Escaping to me is an old hack C did we shouldn't really use. string exists(string s) { return

Re: Fastest way to check using if identifier has already been defined, using static if or similar?

2020-06-04 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 4 June 2020 at 14:20:45 UTC, Q. Schroll wrote: On Thursday, 4 June 2020 at 09:03:40 UTC, Simen Kjærås wrote: string exists(string s) { return "__traits(compiles, { mixin(\"alias _ = "~s~";\"); })"; } Little nitpicking, but D has many forms of string literals. Escaping is ha

Re: Fastest way to check using if identifier has already been defined, using static if or similar?

2020-06-04 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 4 June 2020 at 09:03:40 UTC, Simen Kjærås wrote: string exists(string s) { return "__traits(compiles, { mixin(\"alias _ = "~s~";\"); })"; } Little nitpicking, but D has many forms of string literals. Escaping is hard to read especially without syntax highlighting. Escaping

Re: Fastest way to check using if identifier has already been defined, using static if or similar?

2020-06-04 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 3 June 2020 at 15:25:51 UTC, Paul Backus wrote: On Wednesday, 3 June 2020 at 13:24:17 UTC, Basile B. wrote: This is because the template parameter must be resolved to a valid symbol or type. This version other version bypass the problem: --- enum Exists(string s) = is(typeof(mixi