develooper Front page | perl.perl5.porters | Postings from June 2022

Pre-{Pre-RFC} - match/case syntax

Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 24, 2022 22:18
Subject:
Pre-{Pre-RFC} - match/case syntax
Message ID:
20220624231753.2c39a049@shy.leonerd.org.uk
I'm nowhere near ready yet to consider writing even a Pre-RFC on
match/case syntax, because far too much is still open for design. But I
thought I'd remind people here who enjoy a good language design debate,
that the thing exists and is being experimented on as a CPAN module:

  https://metacpan.org/pod/Syntax::Keyword::Match

E.g. from the SYNOPSIS:

  use v5.14;
  use Syntax::Keyword::Match;

  my $n = ...;

  match($n : ==) {
     case(1) { say "It's one" }
     case(2) { say "It's two" }
     case(3) { say "It's three" }
     case(4), case(5)
             { say "It's four or five" }
     default { say "It's something else" }
  }

There's a lot of design work still to be done on this; several of the
big questions are sat as "Wishlist" RT tickets on the queue:

  https://rt.cpan.org/Dist/Display.html?Name=Syntax-Keyword-Match


I'd encourage anyone who would express an interest in commenting on any
future (Pre-)RFC on the design of such syntax, should probably begin by
taking at least a quick look at the module and some of those issues
now, and ideally help me work them out on CPAN before we even get it
to the RFC stage.

Ideally we'd proceed with the in-core implementation much like the
(very successful, if I may say so) try/catch migration which went from
stable CPAN module to proper in-core implementation very quickly. That
was possible precisely because it had all that time as a CPAN module to
work out all the exciting design questions first. It'd be nice to do
the same process here.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About