Dlang code mixin output
JS
js.mdnq at gmail.com
Wed Jul 31 06:25:44 PDT 2013
On Wednesday, 31 July 2013 at 13:19:46 UTC, dennis luehring wrote:
> Am 31.07.2013 14:35, schrieb JS:
>> On Wednesday, 31 July 2013 at 12:23:42 UTC, dennis luehring
>> wrote:
>>> Am 31.07.2013 14:09, schrieb JS:
>>>> It would be nice to be able to have a precompilation step
>>>> that
>>>> produces a d output file that is the "mixed down" version
>>>> with
>>>> all the string mixins computed. This would allow one to look
>>>> at
>>>> the files, allow better code analysis/error messages, and
>>>> intellisense and other things to be useful.
>>>>
>>>> A simple compiler switch would do the trick to enable such a
>>>> feature. *.dc files could be generated, or whatever, for
>>>> each d
>>>> file if it uses string mixins(I suppose template mixins could
>>>> also be reduced).
>>>
>>> what about something that catches mixin results into a static
>>> compiletime strings
>>>
>>> template GenStruct(string Name, string M1)
>>> {
>>> const char[] GenStruct = "struct " ~ Name ~ "{ int " ~ M1 ~
>>> "; }";
>>> }
>>>
>>> which generates:
>>>
>>> struct Foo { int bar; }
>>>
>>> catch_generated_output(my_mixin_output)
>>> {
>>> mixin(GenStruct!("Foo", "bar"));
>>> }
>>>
>>> pragma(msg, my_mixin_output);
>>>
>>> prints:
>>>
>>> struct Foo { int bar; }
>>
>>
>> I already do that...
>
> it was just a proposal to have something between all (on
> commandline) and areas of the source
>
> >When you do that with nested templates it
> > creates a huge mess... also errors are useless... as the
> point to
> > the mixin string.
>
> and what does a complete output help then better?
Because it won't double up on pragmas.
If you nest templates using your method, which I do, then you
will get multiple pragma outputs but you'll always only have one
string mixin.
the processed output will be actual D code, not a bunch of pragma
messages, which could be anything... even invalid D code if they
are formatted that way.
More information about the Digitalmars-d
mailing list