On Fri, 13 Dec 2019, Brad Gilbert wrote:
> There should probably be a way to require a minimum version of the compiler.
> 
>     use rakudo v2019.07;
> 

As I understand it, this would do something quite different from `use v6`,
which is probably your point(?).  A single Raku compiler would strive to
support `use v6.x` for many x, which Rakudo does by keeping around a setting
for each language version.  The `v6` pragmas can be changed per compunit
under the same compiler, so different parts of the same process can run
under different Raku versions.  (You probably know that more accurately
than me, so please correct me if I'm wrong.)

What Rakudo doesn't do is include a setting for every release, so the effect
of a `use rakudo v2019.07` would be closer to a *dependency* rather than a
pragma: it doesn't change the way your code is executed, it will abort it
altogether if your compiler is not recent enough or not Rakudo.  My under-
standing is that META6.json would be the natural place to declare dependencies,
although I couldn't tell how to properly declare a compiler dependency there,
as the compiler is not a module (right?).

Otherwise such a rakudo pragma is probably as easy to implement as

  --8<-- rakudo.pm6 --------------------------------------------------------
  sub EXPORT (Version:D $ver) {
      given $*PERL.compiler {
          die "This compiler is not Rakudo"    unless .name eq 'rakudo';
          die "Rakudo version ≥ $ver required" unless .version ≥ $ver;
      }
      %( )
  }
  --8<----------------------------------------------------------------------

Regards,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

Reply via email to