问题标签 [phobos]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
64 浏览

arrays - 使用 Array!T 和 opSlice() 时,std.algorithm.sorting 失败并出现模糊错误

我确定我在这里遗漏了一些明显的东西——D 的其余部分(甚至是编译器错误)非常明智且易于理解。我有一个std.containers.Array可比较的结构,我想对其进行排序。文档指出,std.containers为了使用其中的内容,std.algorithm您需要使用array[]或对其进行切片array.opSlice()。好的没问题。

但是,如果我Array选择两种非常琐碎的类型,它不会排序 - 相反,它告诉我 Phobos 深处的例程不是 nothrow (?)

下面的最小示例。第一个sort(自动生成的两个值的标准数组)排序很好。其他sort调用因上述编译器错误而失败。使用 VS Community 2015 的 DMD2 构建,我找不到编译器版本标识符,但这是昨天才下载的。

0 投票
1 回答
61 浏览

d - 一个可以解析IP域的类(例如192.168.0.0/16)

我正在用 D 语言编写一个简单的脚本,该脚本需要与使用 IP 域地址(例如10.0.14.0/24)的命令行网络程序交互。

在 D 中是否存在任何现成的解析器?

可以验证域并将其分解为元素的东西。

0 投票
1 回答
364 浏览

d - compilation issue with split/splitter

Here's simple code:

Looks like it should work, but it won't compile. DMD 2.068.2 fails with this error:

It compiles if I insert .array before .split.

Am I missing something? Or is it a bug? I've tried to make a brief search in the bug tracker, but didn't found anything.

0 投票
1 回答
123 浏览

d - 为什么 Nullable!(Nullable!int) 拒绝编译?

以下代码拒绝编译:

使用此错误消息:

为什么?

0 投票
1 回答
175 浏览

d - 为什么 GDC 的标准库与 DMD 的 phobos 不同

例如,我无法使用 GDC 5.2.0 (2016-02-05T11:17:49.3234388) 编译导入 std.meta 的程序,因为找不到该文件。

我正在比较 GDC 和 DMD 之间的包含文件夹,我发现版本非常不匹配。

这阻止了我可以放心地使用 GDC。

任何人都知道为什么 GDC 包含的不是同一个 Phobos 库吗?

0 投票
4 回答
289 浏览

d - D Phobos 中是否有 Glob 的等价物?

在 python 中,我可以使用 glob 来搜索路径模式。例如:

会打印这个:

我将如何glob或在 D 中制作一个等价的 glob?

------2017 年 9 月 12 日更新------

我写了一个小 D 模块在 D 中做 Glob:https ://github.com/workhorsy/d-glob

0 投票
2 回答
588 浏览

d - 使用 Dlang 中的反射在运行时获取变量值

是否可以在运行时在 dlang 中获取类/结构/其他变量值以获取/设置其值?如果是,请提供示例。还有可能获得运行时变量值吗?

前任:

输出:

可变变量的值 = 5;
bvariable 的值 = 10;

0 投票
1 回答
119 浏览

d - vibe.d: Try to send a Message to a stopped Task

When sending a Message to a stopped vibe.d Task, the application gets an segmentation fault. I did not expect the message to be delivered, but to get notified about the failed sending attempt (or at least not to crash).

The following example illustrates this Problem.

When running the code above, the output is:

... instead of:

The callstack looks like this.

  • How could the segfault be prevented? Are there checking send functions? How could this be patched in vibe.d or phobos2?
  • Is it a bug of vibe.d or phobos2?
0 投票
1 回答
438 浏览

types - What is the right way to convert Variant to proper type?

I use mysql-native that return Variant data type. I need to convert it to standard types like int, string etc.

D have std.conv, but std.variant also have methods for concretion.

I can't understand what difference between: get, coerce, toString and to (from std.conv).

Also it's sound very strange that convertsTo is return bool. By it's name I expected that it should do convention. IMHO isConvertable is more proper name for it.

0 投票
1 回答
45 浏览

arrays - std.algorithm.remove() 复制数组项?

我有一个数组,我需要按索引从中删除项目。由于某种原因,它复制了数组中的其他项目以取代已删除项目的位置。这是该问题的一个示例。

任何帮助,将不胜感激。