小编ang*_*lus的帖子

有没有办法在Chapel中where子句的函数中使用非标量值?

在过去一年左右的时间里,我一直在尝试Chapel.我过去曾简单地使用过C和C++,但我最近的经验是使用Python,Ruby和Erlang等动态语言.

在接触到Erlang及其功能条款后,我很高兴能够找到Chapel中的子句.但是,我在使用它时遇到了障碍.在Y分钟内学习Chapel包含以下代码,演示如何使用where子句:

proc whereProc(param N : int): void
  where (N > 0) {
    writeln("N is greater than 0");
}

proc whereProc(param N : int): void
  where (N < 0) {
    writeln("N is less than 0");
}

whereProc(10);
whereProc(-1);
Run Code Online (Sandbox Code Playgroud)

这会为两个标量值10和-1中的每一个生成预期输出.但是,我试图编写迭代范围或数组的类似程序.我甚至尝试过递归.在所有情况下,我得到基本相同的错误:

whereproc2.chpl:12: error: unresolved call 'whereProc(int(64))'
whereproc2.chpl:1: note: candidates are: whereProc(param N: int)
whereproc2.chpl:6: note:                 whereProc(param N: int)
Run Code Online (Sandbox Code Playgroud)

产生此特定错误的代码是:

proc whereProc(param N : int): void
  where (N > 0) {
    writeln("N is greater than 0");
}

proc whereProc(param N : int): void …
Run Code Online (Sandbox Code Playgroud)

chapel

6
推荐指数
1
解决办法
64
查看次数

标签 统计

chapel ×1