adr said sometin about db trasactions not thinking it was possible
I thought this was the goal:
with(db.transaction){
foo(1);//transaction.foo(1) but doesnt do it yet
bar(3);//transaction.bar(3) but does it cause spooky
}this is possible:
import std;
enum counter=cast(immutable(void)*)[0].ptr;
auto getcount()=>(*(cast(int*)counter));
auto count()=>(*(cast(int*)counter))++;
int rtcount()=>getcount;
struct transaction_{
template opDispatch(string s) {
auto opDispatch(int line = __LINE__,T...)(T t) {
enum C=count;
writeln(s, line, " ", t," ",rtcount," ",C," ",rtcount==C+1);
}}}
auto maketransaction()=>transaction_();
void main(){
with(maketransaction()){
foo(1);
bar(3);
foobar("hello world");
}
}I dont know if anyone cares but in thoery you could make something like a template maketranactionalapi(alias F,int line) where the user calls alias foo(int line=__LINE__)=maketranactionalapi!(F,line); where F is a template that accepts the call of F!(["foo","bar","foobar"],line/*,T...*/)(1,void,3,void,"hello world")
rough steps:
- abstract counter to be owned by trasaction
- store ct strings, accessed by counter
- appendable ct type list
innatebut redesigned for the appendable type list, indexed by int and grabbing a count
I dont really care about db's tho and the dependence on bugs probaly makes this a nonestarter for poeple