Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I limit my Perl 6 program to running under a particular implementation?

Tags:

raku

rakudo

The dd routine is a Rakudo-specific feature, but that's incidental to my question. Is there a way inside a program to check the implementation and bail out if it's not the right one? Do I have to do this on my own?

 die "Unsupported VM" unless $*VM ~~ m/^ 'moar' /;

Maybe we need something like Perl 5's Devel::AssertOS.

I'm not at all interested in creating implementation-specific programs, but I can imagine cases where one implementation has particular quirks and bugs that are incompatible with a program. Because, you know, that was Java for several years (remember the MRJ?).

like image 586
brian d foy Avatar asked Jul 20 '17 23:07

brian d foy


People also ask

What is Perl 6 good for?

Perl 6 is multi-paradigm, maybe omni-paradigm; it claims to support object-oriented programming, functional programming, aspect-oriented programming, array programming, and (good old) procedural programming.

When did Perl 6 come out?

Perl 6 First Official Release. Released on December 24, 2015, Perl 6 Version 1.0 is also Perl 6.

What is Perl 6 called?

Raku is a member of the Perl family of programming languages. Formerly known as Perl 6, it was renamed in October 2019.


1 Answers

If you want to run your program only on MoarVM, then:

BEGIN die "Must run on MoarVM, not $*VM.name()" unless $*VM.name eq 'moar';

should be enough.

UPDATE: added BEGIN as suggested by Jonathan Worthington

like image 130
Elizabeth Mattijsen Avatar answered Sep 23 '22 23:09

Elizabeth Mattijsen