3 karma · joined Nov 20, 2018 (8y ago) · 4 submissions
comment 7y ago · link · parent
import std.stdio;
struct Math(string Op) {
static auto eval(T, U)(T l, U r) {
static if (Op == "+")
return l + r;
else static if (Op == "-")
return l - r;
else static if (Op == "*")
return l * r;
else static if (Op == "/")
return l / r;
}
}
static immutable auto result = Math!("+").eval(1, 2) + Math!("*").eval(3.0, 3.0);
void main() {
writeln(result);
}
You'll never be able to do anything like that in Rust until const generics are not only complete on their own, but also fully compatible with "const fn".comment 8y ago · link · parent
Keep in mind it was usually always the case you could set widget sizes (or do anything else you wanted) "in code", also.
It's not as though you were ever forced to always use the visual designer for absolutely everything.
In general, there are no significant differences whatsoever between the way something like React actually works and the way something like WinForms works.