小编Mik*_*kke的帖子

构建Go项目时"nosplit堆栈溢出"?

我在我的代码中进行了一次Spring清理,将其拆分为更多的Go包,主要是为了帮助重用(每个"building block"都在自己的包中).

修复导入错误后,我发现我的程序突然无法构建.运行"go build"会返回nosplit堆栈溢出错误.

机器人main.init:nosplit堆栈溢出

    120     guaranteed after split check in main.init
    112     on entry to robot/web.init
    104     on entry to robot/controller.init
    96      on entry to robot/slam.init
    88      on entry to robot/slam/hector.init
    80      on entry to hectormapping/map/mapimages.init
    72      on entry to hectormapping/map/maprep.init
    64      on entry to hectormapping/map/mapproccontainer.init
    56      on entry to hectormapping/scanmatcher.init
    48      on entry to hectormapping/map/gridmap/occbase.init
    40      on entry to hectormapping/map/gridmap/base.init
    32      on entry to hectormapping/map/gridmap.init
    24      on entry to github.com/skelterjohn/go%2ematrix.init
    16      on entry to math.init
    8 …
Run Code Online (Sandbox Code Playgroud)

go

9
推荐指数
1
解决办法
1281
查看次数

如何确保泛型中的类型在 Dart 中实现某些运算符?

我想构建一个包含类型对象的泛型类T。包含类必须在这些对象上执行一些运营商,具体地说操作者喜欢+-*/。如何确保对象的类型实现这些运算符?

具体来说,我正在实现一个矩阵类,就像在数学矩阵中一样。我本可以只允许double元素,但我也希望能够制作自定义数字类的矩阵,如有理数或复数(这是一个更大项目的一部分)。

我当前的实现有签名

class Matrix<T extends MatrixElement> {
  final int _rows;          // The number of rows
  final int _cols;          // The number of columns
  ...
  final List<T> _elements;  // Matrix data, [i*step+j] is row i, col j.
Run Code Online (Sandbox Code Playgroud)

MatrixElement带有运算符的抽象类在哪里

dynamic operator + (dynamic other);
Run Code Online (Sandbox Code Playgroud)

我本可以将 Matrix 类更改为简单的class Matrix<T> { ... },但是在运行时可能会出现错误,并且 Dart 编辑器充满了有关未为该类定义运算符的警告Object

我的直觉是这样说的class Matrix<T implements MatrixElement> { ... },但 Dart 似乎不支持这一点。

generics dart

5
推荐指数
1
解决办法
1899
查看次数

标签 统计

dart ×1

generics ×1

go ×1