June 02, 2020
On 6/2/20 10:51 AM, realhet wrote:
> On Tuesday, 2 June 2020 at 13:10:55 UTC, Paul Backus wrote:
>> On Tuesday, 2 June 2020 at 09:28:01 UTC, realhet wrote:
>>     mixin("@property auto ", k, "() const { return ", v, "; }");
> 
> Wow, string mixin can process comma separated list, I gotta remember this, thanks!

Indeed, I too did not know about this!

I generally do a ~ b ~ c, not worrying about performance since it's compile time, but this requires that you do the conversion to string yourself. In some cases, it's a requirement since what the compiler does to convert to a string may not be what you want.

But something like mixin("int a = ", adefault, ";"); is much better than

import std.format;
mixin(format("int a = %s;" adefault));

I will have to remember this. I recently found out that pragma(msg) has the same capability.

-Steve
June 03, 2020
On Tuesday, 2 June 2020 at 20:38:40 UTC, Steven Schveighoffer wrote:
> On 6/2/20 10:51 AM, realhet wrote:
>> On Tuesday, 2 June 2020 at 13:10:55 UTC, Paul Backus wrote:
>>> On Tuesday, 2 June 2020 at 09:28:01 UTC, realhet wrote:

A month ago I discovered that mixinDeclarations can be used for types too:

mixin("int[", 2, "]") a = [5, 6];


June 03, 2020
On Wednesday, 3 June 2020 at 10:11:59 UTC, realhet wrote:
> On Tuesday, 2 June 2020 at 20:38:40 UTC, Steven Schveighoffer wrote:
>> On 6/2/20 10:51 AM, realhet wrote:
>>> On Tuesday, 2 June 2020 at 13:10:55 UTC, Paul Backus wrote:
>>>> On Tuesday, 2 June 2020 at 09:28:01 UTC, realhet wrote:

mixin("int[", 2, "]") a = mixin([5]) ~ 6;

That's insane :D
1 2
Next ›   Last »