Is there any language that native-compiles faster than D?
MrSmith
mrsmith33 at yandex.ru
Thu Aug 27 10:29:41 UTC 2020
On Thursday, 27 August 2020 at 09:47:38 UTC, Per Nordlöw wrote:
> Is Vox so fast because it doesn't (yet) support implicit
> function template instantiation (IFTI)?
IFTI is supported, but only in simple cases. Relevant tests:
https://github.com/MrSmith33/tiny_jit/blob/master/source/tests/passing.d#L3342-L3434
Macros are not yet implemented. But I have variadic templates.
(See tests below IFTI tests).
Here is a fun one. Combining #foreach, variadic template function
and type functions to get writeln functionality. selectPrintFunc
gets run via CTFE and returns alias to relevant function. $
functions work like traits. $type is $alias restricted to types
only.
void printStr(u8[]);
void printInt(i64 i);
$alias selectPrintFunc($type T) {
if ($isInteger(T))
return printInt;
if ($isSlice(T))
return printStr;
$compileError("Invalid type");
}
void write[Args...](Args... args) {
#foreach(i, arg; args) {
alias func = selectPrintFunc(Args[i]);
func(arg);
}
}
void run() {
write("Hello", 42);
}
More information about the Digitalmars-d
mailing list