Home > Raku > Planned obsolescence

Planned obsolescence

Twelve years¹ ago Larry planned the obsolescence of one of my modules. His cunning plan was executed by lizmat a fortnight ago. If you are building Rakudo from source you take another shortcut now.

use v6.e.PREVIEW;

my %detectives;

my @a = <UK London Bakerstreet>;
%detectives{||@a} = "Holms";

say %detectives{||<UK London Bakerstreet>};
dd %detectives;
# OUTPUT: Holms
          Hash %detectives = {:UK(${:London(${:Bakerstreet("Holms")})})}

Slippy semi lists can be quite useful while working with parsed JSON. There are plenty of hashes of hashes of hashes.

Now I got a peculiar problem. One of my modules becomes redundant if — and only if — a Raku version is requested that is younger then v6.d. The module itself can demand v6.d even when used by a program or module that itself demands v6.e. At least it is easy to test for that condition.

use v6.e.PREVIEW;
say $*RAKU.version ~~ v6.e+;
# OUTPUT: True

We can use that to trigger a warning in a module as soon as v6.e becomes the default.

use v6;

CHECK if $*RAKU.version ~~ v6.e+ { warn "Unattended items will be destroy without warning! (This is a warning.)" };

This warning will be displayed once per precompilation so it is easy to miss. Also it will show even thought the program running the use statement might demand an older version of Raku. If only there where a subroutine that is called every time we import a module in the context of the caller!

use v6.d;

sub EXPORT {
    if $*RAKU.version ~~ v6.e+ { warn "Unattended items will be destroy without warning! (This is a warning.)" };
    %()
}

Now use can detect time travel by means of looking up the dynamic variable $*RAKU.

use v6.e.PREVIEW;
use warner;

# OUTPUT: Unattended items will be destroy without warning! (This is a warning.)
          in sub EXPORT at /home/dex/projects/raku/obsolescence/lib/warner.rakumod (warner) line 6

The ability of Raku to fix past mistakes was planned right from the beginning.² I feel ready for the next 100 years.

¹) That’s a lie. The truth was hidden by the move from SVN to git. Please forgive my urge to tell a good story.
²) That’s not a lie.

Categories: Raku
  1. No comments yet.
  1. November 2, 2020 at 17:49

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: