Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Created May 30, 2025 20:07
Show Gist options
  • Save crazymonkyyy/639c5284045c65c74457fdc0d182c3c4 to your computer and use it in GitHub Desktop.
Save crazymonkyyy/639c5284045c65c74457fdc0d182c3c4 to your computer and use it in GitHub Desktop.
--- bar.d
enum hotload; @hotload:
void foo(){}
float bar(){return 3.14;}
enum hotloadstop; @hotloadstop:
void foobar(){}
--- foo.d
import std;
import bar;
template takeudalist(alias where, alias start,alias end){
static foreach(I,A;getSymbolsByUDA!(where,start)){
static if(is(A==end)){
alias takeudalist=getSymbolsByUDA!(where,start)[0..I];
}}
//todo assert end exists or it was written
}
struct foobar{
int i;
int j()=>i;
enum start;@start:
float f;
float g()=>f;
bool b;
enum end;@end:
bool c()=>b;
ubyte u;
}
enum modstart;@modstart:
int a;
bool b;
char c;
enum modend;@modend:
dchar d;
unittest{
takeudalist!(bar,hotload,hotloadstop).stringof.writeln;
takeudalist!(foobar,foobar.start,foobar.end).stringof.writeln;
takeudalist!(mixin(__MODULE__),modstart,modend).stringof.writeln;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment