小编Sno*_*Sno的帖子

perl6:无法将65536位宽的bigint解包为本机整数

我尝试了Rosettacode的一些例子并遇到了提供的Ackermann示例的问题:当运行它"未修改"时(我用latin-1替换了utf-8变量名),我得到(类似,但现在可复制):

$ perl6 t/ackermann.p6
65533
19729 digits starting with 20035299304068464649790723515602557504478254755697...
Cannot unbox 65536 bit wide bigint into native integer
  in sub A at t/ackermann.p6 line 3
  in sub A at t/ackermann.p6 line 11
  in sub A at t/ackermann.p6 line 3
  in block <unit> at t/ackermann.p6 line 17
Run Code Online (Sandbox Code Playgroud)

删除第3行中的proto声明(通过注释掉):

$ perl6 t/ackermann.p6
65533
19729 digits starting with 20035299304068464649790723515602557504478254755697...
Numeric overflow
  in sub A at t/ackermann.p6 line 8
  in sub A at t/ackermann.p6 line 11
  in block <unit> at t/ackermann.p6 …
Run Code Online (Sandbox Code Playgroud)

biginteger perl6

7
推荐指数
2
解决办法
160
查看次数

perl6 NativeCall在达尔文上找不到库

我正在玩NativeCall以熟悉Perl6的那一面.当然,我首先尝试加载libstatgrab(还有什么?).

所以我从最简单的部分开始 - 主机信息.由于还没有集群支持,它只是一个结果 - 不用担心复杂化.

代码:

#!/usr/bin/env perl6 

use v6;
use NativeCall;

enum sg_error (
        SG_ERROR_NONE                   => 0,
        SG_ERROR_INVALID_ARGUMENT       => 1,
        ...
);

class sg_error_details is repr('CStruct') {
        has int32 $.error;
        has int32 $.errno_value;
        has Str $.error_arg;
};

sub sg_init(int32 $ignore_errors) returns int32 is native('statgrab') { * };

enum sg_host_state (
        sg_unknown_configuration        => 0,
        sg_physical_host                => 1,
        sg_virtual_machine              => 2,
        sg_paravirtual_machine          => 3,
        sg_hardware_virtualized         => 4
);

class sg_host_info is repr('CStruct') {
        has Str $.os_name;
        has Str $.os_release;
        has …
Run Code Online (Sandbox Code Playgroud)

shared-libraries dlopen perl6 nativecall

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

标签 统计

perl6 ×2

biginteger ×1

dlopen ×1

nativecall ×1

shared-libraries ×1