我应该根据使用语句的顺序获得 raku Segfault 吗?

p6s*_*eve 9 raku

我正在寻求帮助以防止我扯掉头发。我有几个相互依赖的模块:

  • 物理::单位
  • Physics::Measure(使用 Physics::Unit)

现在我创建了一个新模块 Physics::UnitAffix,其工作是将 SI 前缀和 SI 单位的组合作为 raku 后缀运算符(cm、mm、nm 等)导出到脚本命名空间中。

这是新模块的高尔夫版本:

unit module Physics::UnitAffixQ:ver<0.0.4>:auth<Steve Roe (p6steve@furnival.net)>;

{
use Physics::Unit;

Unit.new( factor => 0.000000001, offset => 0, defn => 'nanometre', type => '', 
      dims => [1,0,0,0,0,0,0,0], dmix => ("metre"=>1).MixHash, 
      names => ['nm'], stock => True );

}

sub do-postfix( Real $v, Str $n, Str $t ) { 
    my $pmt = "Physics::Measure::$t";
    return ::($pmt).new(value => $v, units => $n);
} 

sub postfix:<nm> (Real:D $x) is export(:DEFAULT) { do-postfix($x,'nm','Length') } 
Run Code Online (Sandbox Code Playgroud)

这是 raku 脚本:

#!/usr/bin/env raku 
use lib '../lib';
use Physics::UnitAffixQ;   #must be 1st 
use Physics::Measure;

my $l = 1nm;                say ~$l;   #1 nm
Run Code Online (Sandbox Code Playgroud)

我希望模块的用户能够以任何顺序编写他们的 use 语句。但是,如果他们首先使用 Physics::Measure,我要么得到 SegFault。或者稍微好一点,我已经能够确定这个错误:

No such symbol 'Physics::Measure::Length'
  in sub do-postfix at /Users/stephenroe/Dropbox/ThreeMeasures/raku-Physics-Measure/bin/../lib/Physics/UnitAffixQ.rakumod (Physics::UnitAffixQ) line 14
  in sub postfix:<nm> at /Users/stephenroe/Dropbox/ThreeMeasures/raku-Physics-Measure/bin/../lib/Physics/UnitAffixQ.rakumod (Physics::UnitAffixQ) line 17
  in block <unit> at synopsis-unitaffixq.raku line 6 
Run Code Online (Sandbox Code Playgroud)

任何人都可以就 (i) 我是否应该指定使用语句的顺序和/或 (ii) 如何修复此错误提出建议?

还要提到这个以前的SO并注意已经尝试在 curls 中使用应用程序来限制范围。

我的工具包:欢迎使用™ v2020.10。实现™ 编程语言 v6.d。基于 MoarVM 版本 2020.10。

我在 GitHub 上创建了 raku-Physics-Measure 的新分支“SO64837072”以帮助重现此设置,请转到:

    zef install Physics::Unit
 or zef install https://github.com/p6steve/raku-Physics-Unit.git
    git clone git clone https://github.com/p6steve/raku-Physics-Measure.git
    git checkout SO64837072
    cd raku-Physics-Measure/bin
    ./synopsis-unitaffixq.raku
Run Code Online (Sandbox Code Playgroud)