使用从文件加载的定义启动 REPL [英] Start REPL with definitions loaded from file

查看:30
本文介绍了使用从文件加载的定义启动 REPL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用从文件加载的定义来启动 Perl 6 REPL?

Is there a way to start the Perl 6 REPL with definitions loaded from a file?

即假设我在 test.p6 中有这个:

I.e. let's say I have this in test.p6:

sub abc() { say 123; }

我希望能够启动 perl6 REPL 并加载该文件,以便我可以交互地使用 abc.

I'd like to be able to start the perl6 REPL and load that file so that I can use abc interactively.

推荐答案

我想最简单的方法是将您的代码放在 .pm6 文件中,例如./Foo.pm6,用is export标记有问题的子程序,然后像这样启动Rakudo Perl 6:

I guess the easiest way would be to put your code in a .pm6 file, e.g. ./Foo.pm6, mark the subroutines in question with is export and then start Rakudo Perl 6 like this:

$ perl6 -I. -MFoo
To exit type 'exit' or '^D'
> abc
123

这篇关于使用从文件加载的定义启动 REPL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆