Adam D. Ruppe <destructiona...@gmail.com> wrote:
alias DataObjectFromSqlCreateTable!(import("db.sql"), "users") User;
// sql source code , table to fetch
void main() {
auto obj = new User(null); // that null should actually be a db
handle if
you want to be able to commit changes
// read/write access to the user table, with compile time
// type and name checks
obj.first = "Changing my name!";
obj.date_last_edited = getUTCtime();
obj.commitChanges(); // save your writes back to the database,
(reasonably) efficiently
}
D can! It can dynamically make those DataObjects too, with the
same syntax, but you lose compile time checks for obvious reasons.
I just couldn't help but laugh a bit when I ran this thing through
CTFE and found it actually worked, so figured I'd share a positive
message with you guys :-)
This is awesome. I've known that D could do it, and I've occasionally
poked at it myself, but always felt it was too much work for
something that isn't all that hard to do by hand. Now, getting
someone else to do it for me...
--
Simen