Re: The X Macro using D

2017-07-22 Thread Martin Nowak via Digitalmars-d
On Saturday, 22 July 2017 at 11:50:40 UTC, Stefan Koch wrote: tuple map and array are all pretty expensive. please profile. Well a bit more compile time isn't the end of the world, and by far not the only metric (e.g. readability and maintainability also rank high). You're slightly obsessed

Re: The X Macro using D

2017-07-22 Thread Stefan Koch via Digitalmars-d
On Friday, 21 July 2017 at 20:44:13 UTC, Enamex wrote: On Thursday, 20 July 2017 at 22:02:32 UTC, Walter Bright wrote: [...] How about this (if I'm not mistaken, this's only one template instantiation per tuple-type): [...] tuple map and array are all pretty expensive. please profile.

Re: The X Macro using D

2017-07-21 Thread Nicholas Wilson via Digitalmars-d
On Friday, 21 July 2017 at 19:26:05 UTC, Johan Engelen wrote: On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote: Some time ago, I wrote about the X Macro in C: https://digitalmars.com/articles/b51.html I used it from time to time in C code. It's one of the things I actually

Re: The X Macro using D

2017-07-21 Thread Enamex via Digitalmars-d
On Thursday, 20 July 2017 at 22:02:32 UTC, Walter Bright wrote: On 7/20/2017 2:21 PM, Stefan Koch wrote: Please tell me this is not going to get into dmd :) templates are so much more expensive then macros. (Well, for now :) ) Those templates can and should be replaced by CTFE. If you like,

Re: The X Macro using D

2017-07-21 Thread Johan Engelen via Digitalmars-d
On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote: Some time ago, I wrote about the X Macro in C: https://digitalmars.com/articles/b51.html I used it from time to time in C code. It's one of the things I actually like about the C preprocessor. But in translating the aged C

Re: The X Macro using D

2017-07-21 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-21 14:27, Olivier FAURE wrote: Quick questions: isn't it possible to do private __gshared const(char)*[24] pseudotab = Y.map!(x => x.id); instead? That seems like the most obvious and easy to read option; and in contrast to the other solutions proposed, it's closer to the Rule

Re: The X Macro using D

2017-07-21 Thread Olivier FAURE via Digitalmars-d
On Friday, 21 July 2017 at 12:27:35 UTC, Olivier FAURE wrote: private __gshared const(char)*[24] pseudotab = Y.map!(x => x.id); I meant private __gshared static immutable string[Y.length] pseudotab = Y.map!(x => x.id); but you get my point. Also, upon trying it, it doesn't

Re: The X Macro using D

2017-07-21 Thread Olivier FAURE via Digitalmars-d
On Friday, 21 July 2017 at 08:06:09 UTC, Stefan Koch wrote: My pleasure :) // ... mixin((){ // ... enum Y = [ // id reg mask ty X("AH", 4, mAX, TYuchar), X("AL", 0, mAX, TYuchar), X("AX", 8, mAX, TYushort), X("BH", 7, mBX,

Re: The X Macro using D

2017-07-21 Thread Nick Treleaven via Digitalmars-d
On Friday, 21 July 2017 at 11:19:47 UTC, Patrick Schluter wrote: In C there's no point in the X macro anymore since C99. Designated initializer allow to do it properly[1] now. enum COLORS { red, blue, green, max }; char *cstring[max] = {[red]="red", [blue]="blue", [green]="green" };

Re: The X Macro using D

2017-07-21 Thread Nicholas Wilson via Digitalmars-d
On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote: Some time ago, I wrote about the X Macro in C: https://digitalmars.com/articles/b51.html I used it from time to time in C code. It's one of the things I actually like about the C preprocessor. But in translating the aged C

Re: The X Macro using D

2017-07-21 Thread Patrick Schluter via Digitalmars-d
On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote: Some time ago, I wrote about the X Macro in C: https://digitalmars.com/articles/b51.html I used it from time to time in C code. It's one of the things I actually like about the C preprocessor. But in translating the aged C

Re: The X Macro using D

2017-07-21 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-21 10:25, Stefan Koch wrote: and leaves bloat in the binary. Perhaps that should be fixed in the compiler ;) -- /Jacob Carlborg

Re: The X Macro using D

2017-07-21 Thread Stefan Koch via Digitalmars-d
On Friday, 21 July 2017 at 08:12:55 UTC, Jacob Carlborg wrote: On 2017-07-21 00:02, Walter Bright wrote: On 7/20/2017 2:21 PM, Stefan Koch wrote: Please tell me this is not going to get into dmd :) templates are so much more expensive then macros. (Well, for now :) ) Those templates can and

Re: The X Macro using D

2017-07-21 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-21 10:06, Stefan Koch wrote: My pleasure :) My approach, without string mixin: http://forum.dlang.org/post/oksd27$1li9$1...@digitalmars.com :) -- /Jacob Carlborg

Re: The X Macro using D

2017-07-21 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-21 00:02, Walter Bright wrote: On 7/20/2017 2:21 PM, Stefan Koch wrote: Please tell me this is not going to get into dmd :) templates are so much more expensive then macros. (Well, for now :) ) Those templates can and should be replaced by CTFE. If you like, present the CTFE

Re: The X Macro using D

2017-07-21 Thread Stefan Koch via Digitalmars-d
On Thursday, 20 July 2017 at 22:02:32 UTC, Walter Bright wrote: On 7/20/2017 2:21 PM, Stefan Koch wrote: Please tell me this is not going to get into dmd :) templates are so much more expensive then macros. (Well, for now :) ) Those templates can and should be replaced by CTFE. If you like,

Re: The X Macro using D

2017-07-20 Thread Walter Bright via Digitalmars-d
On 7/20/2017 2:21 PM, Stefan Koch wrote: Please tell me this is not going to get into dmd :) templates are so much more expensive then macros. (Well, for now :) ) Those templates can and should be replaced by CTFE. If you like, present the CTFE solution. Should be fun!

Re: The X Macro using D

2017-07-20 Thread Stefan Koch via Digitalmars-d
On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote: template Y(alias X) { enum Y = [ // id reg mask ty X!("AH", 4, mAX, TYuchar), X!("AL", 0, mAX, TYuchar), X!("AX", 8, mAX, TYushort), X!("BH", 7, mBX, TYuchar),

The X Macro using D

2017-07-20 Thread Walter Bright via Digitalmars-d
Some time ago, I wrote about the X Macro in C: https://digitalmars.com/articles/b51.html I used it from time to time in C code. It's one of the things I actually like about the C preprocessor. But in translating the aged C code to D it was time to make X work in D. Here's the C code,