perl: bundle attribute to indicate enabled features
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 20 Jul 2024 20:10:52 +0000 (22:10 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 6 Aug 2024 00:05:55 +0000 (02:05 +0200)
perl.inc.pl
perl.plp

index e010b2656ba43b96f505720e8f931ee64917e540..f6f2b3ff0a546dc1d7942525aac0520130abd2af 100644 (file)
@@ -225,7 +225,7 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
 
        v5.20 => {
                new => [
-                       ['<code>sub ($var)</code>', 'subroutine signatures', {feature => 'signatures', experimental => 'signatures', stable => v5.36}],
+                       ['<code>sub ($var)</code>', 'subroutine signatures', {feature => 'signatures', experimental => 'signatures', stable => v5.36, bundle => 0}],
                        ['<code>%hash{…}</code>', 'hash slices return key+value pairs'],
                        ['<code>[]->@*</code>', 'postfix dereferencing (also e.g. <code>$scalar->$*</code> for <code>$$scalar</code>)', {feature => 'postderef, postderef_qq', experimental => 'postderef', stable => v5.23.1}],
                        [q"<code>use warnings 'once'; $a</code>", 'variables $a and $b are exempt from <em>used once</em> warnings'],
@@ -336,11 +336,11 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
 
        v5.32 => {
                new => [
-                       ['<code>isa</code>', 'infix operator to check class instance', {feature => 'isa', experimental => 'isa', stable => v5.36}],
+                       ['<code>isa</code>', 'infix operator to check class instance', {feature => 'isa', experimental => 'isa', stable => v5.36, bundle => 0}],
                        ['<code>$min &lt; $_ &lt;= $max</code>', 'chained comparison repeats inner part as <code>$min &lt; $_ and $_ &lt;= $max</code>'],
                        ['<code>/\p{Name=$var}/</code>', 'match Unicode Name property like <code>\N{}</code> but with interpolation and subpatterns'],
                        [q"<code>open F, '+&gt;&gt;', undef</code>", 'respect append mode on temporary files with mixed access'],
-                       ["<code>no feature 'indirect'</code>", 'disable indirect object notation such as <code>new Class</code> instead of <code>Class-&gt;new</code>, enforced since use <a href="#v5036">5.36</a>', {name => 'indirect'}],
+                       ["<code>no feature 'indirect'</code>", 'disable indirect object notation such as <code>new Class</code> instead of <code>Class-&gt;new</code>', {name => 'indirect', bundle => v5.36}],
                        ['streamzip', 'program distributed with core IO::Compress::Base to compress stdin into a zip container'],
                ],
                unicode => '13.0',
@@ -358,12 +358,12 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
 
        v5.34 => {
                new => [
-                       ['<code>try {} catch</code>', 'exception handling similar to eval blocks', {feature => 'try', experimental => 'try', stable => v5.40}],
+                       ['<code>try {} catch</code>', 'exception handling similar to eval blocks', {feature => 'try', experimental => 'try', stable => v5.40, bundle => 0}],
                        ['<code>/{,<i>n</i>}/</code>', 'empty lower bound quantifier is accepted as shorthand for 0'],
                        ['<code>\x{ … }</code>', 'insignificant space within curly braces, also for <code>\b{}</code>, <code>\g{}</code>, <code>\k{}</code>, <code>\N{}</code>, <code>\o{}</code> as well as <code>/{m,n}/</code> quantifiers'],
                        ['<code>0o0</code>', 'octal prefix <code>0o</code> alternative to <code>0…</code> and <code>oct</code>'],
                        ["<code>re::optimization(${wbr}qr//)</code>", 'debug regular expression optimization information discovered at compile time'],
-                       ['<code>no feature …</code>', 'disable discouraged practices of <code>multidimensional</code> and <code>bareword_filehandles</code> array emulation, applied in <a href="#v5036">5.36</a> and <a href="#v5038">5.38</a>', {name => 'feature_534'}],
+                       ['<code>no feature …</code>', 'disable discouraged practices of <code>multidimensional</code> and <code>bareword_filehandles</code> array emulation', {name => 'feature_534', bundle => [v5.36, v5.38]}],
                ],
                release => '2021-05-20',
                distro => {
@@ -375,7 +375,7 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
        v5.36 => {
                new => [
                        ['<code>use v5.36</code>', q{use <code><a href="#warnings">warnings</a></code>; use feature qw'<code><a href="#signature">signatures</a> <a href="#isa">isa</a></code>'; no feature qw'<code><a href="#indirect">indirect</a> <a href="#feature_534">multidimensional</a> <a href="#switch">switch</a></code>'}],
-                       ['<code>use builtin</code>', 'namespace for interpreter functions, such as <code>weaken</code> and <code>blessed</code> from <code>Scalar::Util</code>, <code>ceil</code>/<code>floor</code> from <code>POSIX</code>, and <code>trim</code> like <code>String::Util</code>', {experimental => 'builtin', stable => v5.40}],
+                       ['<code>use builtin</code>', 'namespace for interpreter functions, such as <code>weaken</code> and <code>blessed</code> from <code>Scalar::Util</code>, <code>ceil</code>/<code>floor</code> from <code>POSIX</code>, and <code>trim</code> like <code>String::Util</code>', {experimental => 'builtin', stable => v5.40, bundle => 0}],
                        ['<code>is_bool(!0)</code>', 'distinguish scalar variable types (by <code>builtin</code> functions) for data interoperability', {name => 'is_bool'}],
                        ['<code>for my ($k, $v) (%hash)</code>', 'iterate over multiple values at a time (including <code>builtin::indexed</code> for arrays)', {experimental => 'for_list', feature => 'for_list', stable => v5.40}],
                        ['<code>defer {}</code>', 'queue code to be executed when going out of scope', {feature => 'defer', experimental => 'defer'}],
@@ -395,7 +395,7 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
 
        v5.38 => {
                new => [
-                       ['<code>use feature "module_true"</code>', 'default in use 5.37 and up, also <code>no feature "<a href="#feature_534">bareword_filehandles</a>"</code>'],
+                       ['<code>use feature "module_true"</code>', 'packages implicitly return true, enabled along with <code>no feature "<a href="#feature_534">bareword_filehandles</a>"</code>', {name => 'module_true', bundle => 0}],
                        ['<code>sub ($var ||=</code> default<code>)</code>', 'assign values when false (or undefined on <code>//=</code>) instead of omitted'],
                        ['<code>/(*{ … })/</code>', 'optimistic eval: <code>(?{ … })</code> with regex optimisations enabled'],
                        ['<code>class</code>', "define object classes: packages with <code>field</code> variables and <code>method</code> subroutines", {feature => 'class', experimental => 'class'}],
@@ -412,7 +412,7 @@ my $wbr = "\N{ZERO WIDTH SPACE}";
        v5.40 => {
                new => [
                        ['<code>use v5.40</code>', 'import <a href="#builtin">builtin</a> functions and enable the <a href="#try">try</a> feature'],
-                       ['<code>__CLASS__</code>', 'keyword to reference to the current class name, similar to <code>__PACKAGE__</code>', {feature => 'class'}],
+                       ['<code>__CLASS__</code>', 'keyword to reference to the current class name, similar to <code>__PACKAGE__</code>', {feature => 'class', name => 'class_ref'}],
                        ['<code>:reader</code>', 'attribute for <a href="#class">field</a> variables to create corresponding accessor methods', {feature => 'class'}],
                        ['<code>^^</code>', 'higher precedence logical <code>xor</code> operator, as <code>||</code> is to <code>or</code>'],
                        ['perl<code> -M&nbsp;…</code>', 'whitespace allowed after <code>-M</code> options', {dropped => 0}],
index 590cefa227b394355111725c814d77bcc027f22b..cdfe47f333648cdf9c9c6c0261cdc8e8cc0f9df4 100644 (file)
--- a/perl.plp
+++ b/perl.plp
@@ -2,7 +2,7 @@
 
 Html({
        title => 'perl version cheat sheet',
-       version => '1.8',
+       version => '1.9',
        keywords => [qw'
                perl version feature features comparison
                sheet cheat overview summary
@@ -132,6 +132,20 @@ sub featattrs ($attr) {
                $title = join ', ', $prefix, $title // ();
                $attr->{name} //= $attr->{feature};
        }
+       if (defined $attr->{bundle}) {
+               if ($attr->{stable} and !$attr->{bundle}) {
+                       $title .= ' then bundled';
+               }
+               else {
+                       my $v = 'bundled';
+                       $v .= ' in ' . join(' and ',
+                               # specific version(s) distinct from stable or current
+                               map { sprintf '%vd', $_ }
+                               map { ref eq 'ARRAY' ? @{$_} : $_ } $_
+                       ) for $attr->{bundle} || ();
+                       $title = join ', ', $title // (), $v;
+               }
+       }
        $title = $title ? sprintf ' <em class="ex">(%s)</em>', $title : '';
 
        if (my $eg = $attr->{eg}) {