【发布时间】:2019-09-28 20:23:49
【问题描述】:
我正在学习 D 并使用run.dlang.io 进行调试。下面的代码在run.dlang.io 上运行没有问题:
import std.stdio;
import std.algorithm;
import std.range;
import std.typecons;
static bool even(Tuple!(ulong, double) a) {
return (a[0] & 1) == 0;
}
void main() {
double[] arr = [31, 22, -3, 44, 51, 26, 47, 58, 19, 10];
auto res1 = arr.enumerate.filter!(even).map!(a => a[1]);
writeln(res1);
}
但是,DMD32 v2.088 在 Windows 10 上编译完全相同的代码 dmd temp.d 时会引发异常。
Error: function temp.even(Tuple!(ulong, double) a) is not callable using argument types (Tuple!(uint, "index", double, "value"))
而 LDC 编译器 (1.18.0-beta1):(基于 DMD v2.088.0 和 LLVM 8.0.1)编译相同的文件没有问题。
run.dlang.io 使用 2.087 dmd 编译器,不知何故它神奇地工作,为什么它不能在 Windows 上工作?
【问题讨论】:
标签: d