2020.46 Coercion Renewed

Months of work by Vadim Belman, implementing the new type coercion protocol, was finally merged in time for the 2020.11 Rakudo compiler release. This makes coercion types such as Str() first class citizens. And allows custom classes to define their behaviour when used in coercions. For example, a user writes

    sub foo(Frobnicator() $f) {
        ...
    }

in their code (which specifies that the first positional parameter should be coerced to the Frobnicator class). The developer of the Frobnicator class can now actually provide code to handle that case:

    class Frobnicator {
        has $.value;
        method COERCE($value) {  # <-- new special method name
            my $coerced = # something, depending on $value
            Frobnicator.new(value => $coerced);
        }
    }

Previously, this kind of coercion was only possible for the core classes, in something like:

    sub foo(Int() $f) {
        ...
    }

So this is a big step forward in the malleability of, and the use of typing in, the Raku Programming Language!

Advent closing around the corner

It’s almost that time of the year again: Raku Advent Blog Post Time! Be sure to submit your ideas for an Advent post and make sure there’s a slot available for you.

From the Raku Steering Council

Patrick Spek has joined the Raku Steering Council.

Two flowers

Looks like many people are hedging their blogging tuits for the Raku Advent Calendar. This week saw only two blog posts, one by Wenzel P.P. Peppmeyer (Parallel errors) and one by Alexey Melezhik (Ubiquitous Asynchronous Task Runner with Nice Frontend).

Weekly Challenge

Weekly Challenge #87 is available for your perusal.

Core Developments

  • Will Coleda clarified the nqp build instructions a bit.
  • Peter du Marchie van Voorthuysen made sure that the Windows build instructions mention that building with MinGW should be possible.
  • Elizabeth Mattijsen made 42 does role a runtime error, as it would “taint” the value 42 for any use of the value 42. And they also made it possible to easily typecheck on typed arrays and hashes, as well as on object hashes and shaped arrays.
  • And many smaller fixes and improvements.

This week’s new Pull Requests:

Please check them out and leave any comments that you may have!

Questions about Raku

Meanwhile on Twitter

Meanwhile on the mailing-list

Comments about Raku

Updated Raku Modules

Winding down

Again a week with many module updates, although the numbers have been skewed a bit by some module maintenance work by yours truly. Please check in again next week with more news about the Raku Programming Language!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s