develooper Front page | perl.perl5.porters | Postings from March 2021

Perl::FeatureList and feature-list

Thread Next
From:
neilb
Date:
March 13, 2021 15:47
Subject:
Perl::FeatureList and feature-list
Message ID:
4c7af49a-f0ae-4dec-8322-89bf3b60d7b8@Spark
While talking about what new[*] features are in Perl, and which are being used, what version they were introduced in, and whether they’re guarded, I wondered if there’s a single place where that information can be found. There’s perldoc feature, perldoc experimental, and perldeltas. And various online talks, and, …

So I wondered if something analogous to Module::CoreList and corelist would be useful.

I’ve hacked up a module Perl::FeatureList and a feature-list script. By default the script will display a concise summary of the new features in your perl. For example, if you’re running Perl 5.16.3, you’ll see this:

  % feature-list

  ---- new features available in perl 5.016003 ----
  F  say               just like print, but adds a newline
     defined-or        // is like || but on definedness rather than truthiness
  F  state             lexically scoped variables with persistent values
  X  switch            perlish switch statement
  F  unicode_strings   tells compiler to use Unicode rules for all string ops
  F  current_sub       enables __SUB__ token that refers to current subroutine
  F  unicode_eval      makes string eval work more consistently with Unicode
  F  evalbytes         adds an evalbytes keyword that operates on a byte stream
  F  fc                enables fc(), which implements Unicode casefolding

The first column says whether it’s built in, has a Feature guard, or is eXperimental.
The -w switch gives a wide display, which for now just includes the version of Perl.
By default it lists the more notable changes, but -a will display all changes.
The —future switch will follow the first table with a table of features that
have been introduced after your perl.

If you give it a feature name, it will display a brief description of the feature.

You can also ask for the changes in a specific release:

  % feature-list 5.10.0

  F  say             just like print, but adds a newline
     defined-or      // is like || but on definedness rather than truthiness
  F  state           lexically scoped variables with persistent values
     named-capture   ability to name capture parens in a regex
     UNITCHECK       code block run after enclosing unit has been compiled

I’ve only just started going through the perldeltas, so a lot of changes are missing:

    https://github.com/neilb/Perl-FeatureList

Neil

[*] In our discussions, we decided "new" means post-5.8

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