On Friday, 19 April 2024 at 22:24:17 UTC, Liam McGillivray wrote:
```
template enumMixin(alias Enum) {
static foreach(m; __traits(allMembers, Enum)) static if
(!__traits(isDeprecated, __traits(getMember, Enum, m)))
{
mixin("alias "~m~" = __traits(get
Well, someone on the Discord server has been helping me attempt
this, but while I managed to get a solution that compiles without
errors, I still get the deprecation warning.
Here is what I ended up with:
```
template enumMixin(alias Enum) {
static foreach(m; __traits(allMembers, Enum
template:
```
template enumMixin(Enum) {
private import std.traits;
static foreach(member; EnumMembers!Enum) static if
(__traits(isDeprecated, member))
{
private alias m = __traits(identifier, member);
alias m = member;
}
};
```
It hasn't worked so far.
On Thursday, 20 January 2022 at 01:14:51 UTC, Adam Ruppe wrote:
On Thursday, 20 January 2022 at 00:55:33 UTC, Jack Stouffer
wrote:
static foreach(member; __traits(allMembers,
Manager))
member here is a string, not the member. I prefer to call it
memberName.
Then you __traits
On Thursday, 20 January 2022 at 00:55:33 UTC, Jack Stouffer wrote:
static foreach(member; __traits(allMembers,
Manager))
member here is a string, not the member. I prefer to call it
memberName.
Then you __traits(getMember, Manager, memberName) to actually get
the alias you can
his prints nothing:
```d
import std.traits;
import std.stdio;
enum Runnable;
struct SubSystem
{
void run()
{
writeln("SubSystem ran");
}
}
struct Manager
{
@Runnable SubSystem subsystem;
void run()
{
static fore
On Wednesday, 19 January 2022 at 21:44:57 UTC, Jack Stouffer
wrote:
The error is actually coming from trying to use the result of
getSymbolsByUDA in the right part of the `static foreach`
huh..
I never use most of std.traits, they just complicate things. Bleh
idk, I wouldn't bother
`static foreach`, not
the call to the `run` function. Which was odd to me because I
thought it just returned a `AliasSeq`.
Here's a link to the erroring code with your traits change:
https://run.dlang.io/is/gO84ox
On Wednesday, 19 January 2022 at 20:46:17 UTC, Jack Stouffer
wrote:
static foreach(system; getSymbolsByUDA!(Manager,
Runnable))
{
system.run();
onlineapp.d(16): Error: value of `this` is not known at compile
time
The getSymbols returns aliases, meaning you hit
d the
documentation of getSymbolsByUDA is unhelpful, as there are no
practical use-case examples.
Here's a very simplified version of my code
```d
import std.traits;
enum Runnable;
struct SubSystem
{
void run();
}
struct Manager
{
@Runnable SubSystem subsystem;
void run()
{
On Wednesday, 22 December 2021 at 16:30:06 UTC, data pulverizer
wrote:
On Wednesday, 22 December 2021 at 16:10:42 UTC, Adam D Ruppe
wrote:
So OUTSIDE a function, static foreach() {{ }} is illegal
because a plain {} is illegal outside a function.
But INSIDE a function, static foreach
On Wednesday, 22 December 2021 at 16:10:42 UTC, Adam D Ruppe
wrote:
So OUTSIDE a function, static foreach() {{ }} is illegal
because a plain {} is illegal outside a function.
But INSIDE a function, static foreach() {{ }} is legal, but it
isn't magic about static foreach - it is just a
On Wednesday, 22 December 2021 at 16:01:49 UTC, rikki cattermole
wrote:
Seems to be working just fine as of 2.098.
```d
import std;
void main()
{
static foreach(Foo; ["Abc", "def"]) {{
string str = Foo;
writeln("Hello D ", str, __VERSION__);
On 22.12.21 17:01, rikki cattermole wrote:
Anyway, AliasAssign has nothing to do with this. This "trick" creates a
closure aka ``() { ... }``. Thats all its doing.
From the AST dump:
```
import object;
import std;
void main()
{
{
string str = "Abc";
writeln("Hello D ",
On Wednesday, 22 December 2021 at 15:57:29 UTC, data pulverizer
wrote:
I noticed that the double bracket `{{` for scoping `static
foreach` is no longer part of D and it looks like it has been
replaced with
https://dlang.org/changelog/2.098.0.html#AliasAssign
None of these things have
Seems to be working just fine as of 2.098.
```d
import std;
void main()
{
static foreach(Foo; ["Abc", "def"]) {{
string str = Foo;
writeln("Hello D ", str, __VERSION__);
}}
}
```
```
Hello D Abc2098
Hello D def2098
```
Anyway, AliasAssi
Hi All,
I noticed that the double bracket `{{` for scoping `static
foreach` is no longer part of D and it looks like it has been
replaced with
https://dlang.org/changelog/2.098.0.html#AliasAssign. Could
someone confirm this with a link to the DIP and any other tools
that we should be using
iated
templates and unrolled static foreach loops.
On Thursday, 16 September 2021 at 04:54:21 UTC, james.p.leblanc
wrote:
Thank you for your kind response. Wow, at first the large
output file
from a small test program was a bit surprising .., but actually
it is
manageable to dig through to find the interesting bits.
So, this is quite useful!
On Thursday, 16 September 2021 at 03:26:46 UTC, Tejas wrote:
On Wednesday, 15 September 2021 at 19:59:43 UTC,
james.p.leblanc wrote:
s
Use the `mixin` compiler flag
`dmd -mixin= file.d`
Beware, this will also include **all** the mixin code from
standard library and runtime.
But it's manag
On Wednesday, 15 September 2021 at 19:59:43 UTC, james.p.leblanc
wrote:
Dear All,
In attempting to learn and use code generation, it
would be useful to be able to view the source code
that gets generated.
However, with various combinations of templates, UDAs, and
mixins it has not been easy.
I
Dear All,
In attempting to learn and use code generation, it
would be useful to be able to view the source code
that gets generated.
However, with various combinations of templates, UDAs, and
mixins it has not been easy.
Is there some standard way this is done?
Optimal would be to print out th
On Thursday, 22 July 2021 at 18:16:54 UTC, Tejas wrote:
On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote:
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote:
Why does this work?
```d
import std;
void main()
{
mixin("int") a;
writeln(a);
}
```
You can mix in a type:
h
On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote:
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote:
Why does this work?
```d
import std;
void main()
{
mixin("int") a;
writeln(a);
}
```
You can mix in a type:
https://dlang.org/spec/type.html#mixin_types
Looks like
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote:
Why does this work?
```d
import std;
void main()
{
mixin("int") a;
writeln(a);
}
```
You can mix in a type:
https://dlang.org/spec/type.html#mixin_types
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
... it compiles no-more: Error: found `End of File` when
expecting `}` following compound statement
... what I am doing wrong ?
You'll get the same error from this code:
```d
On Thursday, 22 July 2021 at 08:16:43 UTC, Patrick Schluter wrote:
What an unreadable mess. Sorry.
Indeed LoL !!!
I would have done something like that:
```d
mixin(format!
`case r"%1$s"d :
classTickerCustom%1$s lobjTicker%1$s = new
classTickerCustom%1$s (lstrSymbolID);
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote:
Each individual string has to compile on its own. You'll have
to concatenate strings and then mixin them.
I forgot about that !
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
... it compiles no-more: Error: found `End of File` when
expecting `}` following compound statement
... what I am doing wrong ?
You'll get the same error from this code:
```d
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
```
Now, if uncomment those two innocuous commented lines for the
if (true == true) block:
```d
labelSwitch: switch (lstrExchangeID) {
static foreach (sstrExchangeID; gstrExchangeIDs) {
mixin(r"case r"d, `"`,
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
... it compiles no-more: Error: found `End of File` when
expecting `}` following compound statement
... what I am doing wrong ?
You'll get the same error from this code:
```d
unittest {
mixin("{");
mixin("}");
}
```
https://d
The following code chunk compiles perfectly:
```d
labelSwitch: switch (lstrExchangeID) {
static foreach (sstrExchangeID; gstrExchangeIDs) {
mixin(r"case r"d, `"`, sstrExchangeID, `"`, r"d : "d);
mixin(r"classTickerCustom"d, sstrExchangeID, r&
am not Timon Gehr, the person who originally replied to
you, but I was able to find the bug report by searching
Bugzilla for "static foreach nogc".
Sorry about getting your name wrong, I got a little overzealous
when snipping off the quoted part of my post! If I find anything
el
On Saturday, 3 October 2020 at 14:12:21 UTC, Paul Backus wrote:
https://issues.dlang.org/show_bug.cgi?id=18439
Perfect! Thanks for getting back to me so quickly.
, but I was able to find the bug report by searching Bugzilla
for "static foreach nogc".
On Saturday, 3 October 2020 at 14:02:08 UTC, tspike wrote:
On Saturday, 3 October 2020 at 12:43:01 UTC, Timon Gehr wrote:
It's a compiler bug, the same as this one:
@nogc:
void main(){
static immutable x = { int[] a; a~=1; return a; }();
}
Ah, thank you for the quick reply! Do you know i
On Saturday, 3 October 2020 at 12:43:01 UTC, Timon Gehr wrote:
It's a compiler bug, the same as this one:
@nogc:
void main(){
static immutable x = { int[] a; a~=1; return a; }();
}
Ah, thank you for the quick reply! Do you know if this bug has
already been reported?
On 03.10.20 13:18, tspike wrote:
I came across an issue recently that I’m a little confused by. The
following program fails to compile under LDC and DMD, though it compiles
fine under GDC:
@nogc:
void main()
{
static foreach(i; 0 .. 4)
{
pragma
I came across an issue recently that I’m a little confused by.
The following program fails to compile under LDC and DMD, though
it compiles fine under GDC:
@nogc:
void main()
{
static foreach(i; 0 .. 4)
{
pragma(msg, i);
}
}
Both DMD and
https://run.dlang.io/is/xiqi4P
not pretty :)) but ...
On Wednesday, 9 September 2020 at 17:02:26 UTC, visitor wrote:
On Friday, 14 February 2020 at 06:41:02 UTC, cc wrote:
import std.meta;
enum A = AliasSeq!(1, 2, 3, 4);
static foreach (idx, field; A) {
static if (__traits(compiles, THREELOOP)) {} else {
static if (field == 3
On Friday, 14 February 2020 at 06:41:02 UTC, cc wrote:
import std.meta;
enum A = AliasSeq!(1, 2, 3, 4);
static foreach (idx, field; A) {
static if (__traits(compiles, THREELOOP)) {} else {
static if (field == 3) {
pragma(msg, "Got a 3!");
On 7/8/20 9:38 AM, ag0aep6g wrote:
On 08.07.20 14:24, Steven Schveighoffer wrote:
I solved it for now by extrapolating the inner code into a local
template function. But this is definitely an awkward situation for
static foreach.
FWIW, you can write the extra function like this:
static
On 08.07.20 14:24, Steven Schveighoffer wrote:
I solved it for now by extrapolating the inner code into a local
template function. But this is definitely an awkward situation for
static foreach.
FWIW, you can write the extra function like this:
static foreach (T; Types
code somewhere else. However it still won't work,
because static foreach requires a label for break. So if I fix the loop
problem, I will still have a label problem, because I need to label the
switch and use labeled breaks on that.
This is really an issue with:
a) static foreach-ing cas
On 7/8/20 5:10 AM, cc wrote:
I think I ran into similar problems due to the requirement to use a
labeled break inside static foreach. I got around it by defining enums
when my target was found and checking if it existed via
__traits(compiles) to "ignore" the rest of the loop.
On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer
wrote:
Seems simple enough, except that this inner portion is
unrolled, and if I have more than one type to run this on, I
already have an "innerloop" label defined.
Is there a way to define a label using a mixin or something? o
labels like:
innerloop:
while(haveMoreData)
switchstmt:
switch(nextDataElement) {
static foreach(name; __traits(allMembers, T)) {
case name:
... // handle it
break switchstmt;
}
case "STOP":
break innerloop;
}
Seems simple e
labels like:
innerloop:
while(haveMoreData)
switchstmt:
switch(nextDataElement) {
static foreach(name; __traits(allMembers, T)) {
case name:
... // handle it
break switchstmt;
}
case "STOP":
break innerloop;
}
Seems simple e
struct a switch
that can handle member names (this is for serialization).
If I encounter a certain name, then I want to break out of the inner
loop (it's a while loop)
So naturally, I have to use break statements with labels like:
innerloop:
while(haveMoreData)
switchstmt:
switch(n
static and it will work too.
Yesh, I forgot about the old implicit static foreach loop.
On 07.03.20 17:41, MoonlightSentinel wrote:
On Saturday, 7 March 2020 at 16:30:59 UTC, Robert M. Münch wrote:
Is this possible at all?
You can use an anonymous lambda to build the string in CTFE:
It turns out that if you do use this standard idiom, you might end up
getting blamed for an unr
On 2020-03-07 16:41:47 +, MoonlightSentinel said:
You can use an anonymous lambda to build the string in CTFE:
--
struct S {
int a;
bool b;
}
import std;
enum string sql = {
string s = "CREATE TABLE data(";
static
;
}
import std;
enum string sql = {
string s = "CREATE TABLE data(";
static foreach(f; FieldNameTuple!S) {
s ~= f ~ ",";
}
s ~= ");";
return s;
} ();
pragma(msg, sql);
--
This prints "CRE
On 2020-03-07 16:40:15 +, Adam D. Ruppe said:
Use regular foreach with a regular string. Put that inside a function.
Then simply use that function to initialize your other thing and enjoy
the magic of CTFE!
Perfect! This implicit CTFE is a tricky thing to see/remember/...
Feeling a bit
On Saturday, 7 March 2020 at 16:30:59 UTC, Robert M. Münch wrote:
Which of course doesn't work... I didn't find any reference how
to build-up strings in a statif foreach loop.
Is this possible at all?
Use regular foreach with a regular string. Put that inside a
function.
Then simply use th
REATE TABLE data(";
static foreach(f; FieldNameTuple!S) {
s ~= f ~ ",";
}
s ~= ");";
return s;
} ();
pragma(msg, sql);
--
This prints "CREATE TABLE data(a, b);"
I want to create a "CREATE TABLE data (...)" where the columns are
derived from struct member names. Something like:
string s = "CREATE TABLE data(";
static foreach(f; FieldNameTuple!myStruct) {
s ~= f ~ ",";
}
s ~= ");";
Which of course doesn'
On Friday, 14 February 2020 at 22:24:14 UTC, Ben Jones wrote:
Hi all,
I'm getting unexpected results while trying to process symbols
from a module, some of which are enums.
Depending on whether or not I comment out the first static
foreach loop below, fullyQualifiedName gives me diff
On Friday, 14 February 2020 at 22:24:14 UTC, Ben Jones wrote:
Hi all,
I'm getting unexpected results while trying to process symbols
from a module, some of which are enums.
Depending on whether or not I comment out the first static
foreach loop below, fullyQualifiedName gives me diff
Hi all,
I'm getting unexpected results while trying to process symbols
from a module, some of which are enums.
Depending on whether or not I comment out the first static
foreach loop below, fullyQualifiedName gives me different results
in the second loop.
In either case, I'm s
On 2/14/20 1:41 AM, cc wrote:
import std.meta;
enum A = AliasSeq!(1, 2, 3, 4);
THREELOOP: static foreach (idx, field; A) {
static if (field == 3) {
pragma(msg, "Got a 3!");
break THREELOOP;
}
static if (idx == A.length - 1) {
static assert(0,
this kind of thing doesn't work super well due to the nature of
compile time. My suggestion is to put the checks and the
implementation in separate things.
void foo(T...)() {
static bool checkHelper() {
bool passed;
static foreach(t; T) {
static if
6, 7]);
static foreach (ai, af; ARRS) {
static if (!__traits(compiles, FOUND)) {
static foreach (idx, field; af.x) {
// Have to declare a different MISMATCH enum for each inner
loop iteration
// unless we enclose it in its own {} scope, but if we do
import std.meta;
enum A = AliasSeq!(1, 2, 3, 4);
THREELOOP: static foreach (idx, field; A) {
static if (field == 3) {
pragma(msg, "Got a 3!");
break THREELOOP;
}
static if (idx == A.length - 1) {
static assert(0,
On Sunday, 7 July 2019 at 18:45:14 UTC, 0xEAB wrote:
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote:
Why does this `static foreach` lead to hidden usage of operator
Further notes by Dan (aka "Wild"):
I added some small printfs to the compiler, http://ix.io/1NWM
It seems like
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote:
Why does this `static foreach` lead to hidden usage of operator
Further notes by Dan (aka "Wild"):
I added some small printfs to the compiler, http://ix.io/1NWM
It seems like it lowers it into something weird
On Sunday, 7 July 2019 at 17:07:59 UTC, a11e99z wrote:
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote:
Why does this `static foreach` lead to hidden usage of
operator `~=` calls in some cases?
probably same
oops! this one
https://forum.dlang.org/post/eidpgqohllwmuumxw
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote:
Why does this `static foreach` lead to hidden usage of operator
`~=` calls in some cases?
probably same
https://forum.dlang.org/post/qd9ee0$2eud$1...@digitalmars.com
Why does this `static foreach` lead to hidden usage of operator
`~=` calls in some cases?
static foreach(i; 0 .. cnt)
onlineapp.d(9): Error: cannot use operator ~= in @nogc delegate
onlineapp.xv!(myUDA("/")).__funcliteral2.__lambda1
import std.traits;
private @safe pure not
Ok, thanks for explaining. Nice idea.
On Tuesday, 28 May 2019 at 13:43:45 UTC, Nick Treleaven wrote:
Hi,
Last week's TWiD had a tip that didn't make sense:
http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_20.html#tip-of-the-week
template Locals(int i) {
alias Whatever = int;
}
static foreach(i; [1, 2, 3]) {
Hi,
Last week's TWiD had a tip that didn't make sense:
http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_20.html#tip-of-the-week
template Locals(int i) {
alias Whatever = int;
}
static foreach(i; [1, 2, 3]) {
Locals!i.Whatever;
}
The body is just `int;`. Not sure how to
On Monday, 11 February 2019 at 01:05:05 UTC, kdevel wrote:
On Monday, 11 February 2019 at 00:54:27 UTC, Seb wrote:
On Monday, 11 February 2019 at 00:19:02 UTC, kdevel wrote:
[...]
You can't read or list files at compile-time.
dmd can read files at compile time using the import function [1]
files = mixin(LS);
static foreach (f; template_files) {
pragma (msg, `reading template <` ~ f ~ ">");
template_map[f] = import (f);
}
}
```
[1]
https://forum.dlang.org/thread/njnwacxnvxlwlpjcu...@forum.dlang.org
mplate_map;
>
> static this ()
> {
> static foreach (f; dirEntries (``, `*.html`,
> SpanMode.shallow)) {
>pragma (msg, `reading template <` ~ f ~ ">");
>template_map[f] = import (f);
> }
> }
> ```
>
> dmd v2.082.0 says
>
> ...li
On Monday, 11 February 2019 at 00:19:02 UTC, kdevel wrote:
I am trying to get this code compiled:
```TemplateStore.d
module TemplateStore;
import std.path;
import std.conv;
import std.file;
[...]
You can't read or list files at compile-time. What are you trying
to do?
I am trying to get this code compiled:
```TemplateStore.d
module TemplateStore;
import std.path;
import std.conv;
import std.file;
immutable string[string] template_map;
static this ()
{
static foreach (f; dirEntries (``, `*.html`,
SpanMode.shallow)) {
pragma (msg, `reading template
On Monday, 7 January 2019 at 16:31:49 UTC, Steven Schveighoffer
wrote:
On 1/7/19 11:16 AM, Michelle Long wrote:
On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote:
[...]
static foreach(k, p; AliasSeq!(Alias!this, s))
{{
p.foo(); // Fails even if this line is removed
}}
To
On Monday, 7 January 2019 at 16:29:25 UTC, Alex wrote:
On Monday, 7 January 2019 at 16:16:57 UTC, Michelle Long wrote:
On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote:
static foreach(k, p; AliasSeq!(this, s))
{{
p.foo(); // Fails even if this line is removed
On 1/7/19 11:16 AM, Michelle Long wrote:
On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote:
static foreach(k, p; AliasSeq!(this, s))
{{
p.foo(); // Fails even if this line is removed
}}
this not known at compile time. replace s with this and it works! s is
an argument which
On Monday, 7 January 2019 at 16:16:57 UTC, Michelle Long wrote:
On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote:
static foreach(k, p; AliasSeq!(this, s))
{{
p.foo(); // Fails even if this line is removed
}}
this not known at compile time. replace s with this
On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote:
static foreach(k, p; AliasSeq!(this, s))
{{
p.foo(); // Fails even if this line is removed
}}
this not known at compile time. replace s with this and it
works! s is an argument which is also not known at
static foreach(k, p; AliasSeq!(this, s))
{{
p.foo(); // Fails even if this line is removed
}}
this not known at compile time. replace s with this and it works!
s is an argument which is also not known at compile
time(generally).
Should work with this.
Just "simpli
On Tuesday, 1 January 2019 at 21:34:08 UTC, Paul Backus wrote:
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote:
auto foo(S s)
{
static foreach(k, p; [s, this])
for(int i = 0; i < p.length; i++)
...
}
The idea is to provide sin
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote:
auto foo(S s)
{
static foreach(k, p; [s, this])
for(int i = 0; i < p.length; i++)
...
}
The idea is to provide single for loop structure for each of
the variables(in this case s
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote:
auto foo(S s)
{
static foreach(k, p; [s, this])
for(int i = 0; i < p.length; i++)
...
}
try
static foreach(...) {{
stuff
}}
The double {{ and double }} are intentional.
auto foo(S s)
{
static foreach(k, p; [s, this])
for(int i = 0; i < p.length; i++)
...
}
The idea is to provide single for loop structure for each of the
variables(in this case s and this).
The is to avoid string mixins which are pathetic
On 10/10/2018 04:03 PM, James Japherson wrote:> Says that it cannot
interpret X(the class that contains the static> opApply).
It's a bit hard to diagnose the problem you're getting using that
function when we don't have the code that uses it. Or the context that's
referenced with the foreach loo
X."~m~");");
}
}
return 0;
}
This is not a problem using foreach.
But when I use static foreach it fails!!!
Says that it cannot interpret X(the class that contains the
static opApply).
the opApply is static, it does everything at compile time, so why
On Thursday, 30 August 2018 at 09:49:15 UTC, drug wrote:
30.08.2018 11:19, Andrey пишет:
Thanks everybody. Works!
30.08.2018 11:19, Andrey пишет:
Hello,
is it possible to declare an internal variable in "static foreach" and
on each iteration assign something to it?
Example:
static foreach(arg; SomeAliasSeq)
{
internal = arg[0].converted; // a shortcut for expression
"arg[0].convert
On Thursday, 30 August 2018 at 08:19:47 UTC, Andrey wrote:
Hello,
is it possible to declare an internal variable in "static
foreach" and on each iteration assign something to it?
Example:
static foreach(arg; SomeAliasSeq)
{
internal = arg[0].converted;// a shortcut for
expre
Hello,
is it possible to declare an internal variable in "static
foreach" and on each iteration assign something to it?
Example:
static foreach(arg; SomeAliasSeq)
{
internal = arg[0].converted;// a shortcut for expression
"arg[0].converted"
static if(
On Tuesday, 3 April 2018 at 19:41:54 UTC, Alex wrote:
On Tuesday, 3 April 2018 at 19:31:50 UTC, Vladimirs Nordholm
wrote:
[...]
Would labelling help?
https://run.dlang.io/is/vE1KyD
Ah! Okay, now I see.
Thanks Alex and Adam!
On Tuesday, 3 April 2018 at 19:31:50 UTC, Vladimirs Nordholm
wrote:
switch(foo)
Put the label on the switch
whatever: switch(foo)
mixin(format("
case Foo.%s:bar = Bar.%s;break;
", f, f));
then use the label here
break whatever;
On Tuesday, 3 April 2018 at 19:31:50 UTC, Vladimirs Nordholm
wrote:
My base problem is that I want to mixin `break` into a switch
statement, but the mixin is within a static foreach. Take a
look at the following code:
switch(foo)
{
static foreach(f; EnumMembers!Foo
My base problem is that I want to mixin `break` into a switch
statement, but the mixin is within a static foreach. Take a look
at the following code:
switch(foo)
{
static foreach(f; EnumMembers!Foo)
{
mixin(format("
case Foo.%s:bar
On Wednesday, 28 March 2018 at 23:42:26 UTC, Simen Kjærås wrote:
On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote:
There's many things that can be done to make the code easier to
follow. These lines:
[...]
[...]
WOW. Thank you. That's the kind of tricks for (or more properly:
On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote:
There's many things that can be done to make the code easier to
follow. These lines:
static if (!hasPosition)
{
assert(0, "Need to pass a position!");
}
Can be replaced with thi
1 - 100 of 138 matches
Mail list logo