From 45a41242594517a044099d34be1868be1ddabe6e Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 15 Apr 2023 15:28:16 +0200 Subject: [PATCH] perl: link between related or revised features --- perl.inc.pl | 32 ++++++++++++++++---------------- perl.plp | 7 +++++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/perl.inc.pl b/perl.inc.pl index 6ab2fdf..faf530e 100644 --- a/perl.inc.pl +++ b/perl.inc.pl @@ -29,13 +29,13 @@ use utf8; v5.6 => { new => [ - ['use warnings', 'pragma to enable warnings in lexical scope'], - ['use utf8', 'experimental unicode semantics (completed in v5.8)', {experimental => 0, stable => v5.8}], + ['use warnings', 'pragma to enable warnings in lexical scope', {name => 'warnings'}], + ['use utf8', 'experimental unicode semantics (completed in v5.8)', {name => 'utf8', experimental => 0, stable => v5.8}], ['use charnames', 'string escape \N{} to insert named character'], ['our', 'declare global variables'], ['v1.2.3', q"represent strings as vector of ordinals, useful in version numbers (printf '%vd' to display)"], ['0b0', q"binary numbers in literals, printf '%b', and oct"], - ['sub :lvalue', 'subroutine attribute to return a modifiable value', {experimental => 0, stable => v5.20}], + ['sub :lvalue', 'subroutine attribute to return a modifiable value', {name => 'sub_lvalue', experimental => 0, stable => v5.20}], # ['sub :locked :method', 'syntax to declare subroutine attributes'], # can be inferred from :lvalue support ['open my $fh, $mode, $expr', 'file handles in scoped scalars, third argument for unambiguous file name'], [q"pack 'q'", '64-bit integer support (also large files >2GiB)', {experimental => 0, stable => v5.8.1}], @@ -58,8 +58,8 @@ use utf8; v5.8 => { new => [ - [q"no utf8", 'full unicode support, utf8 pragma only for script encoding'], - [q"binmode $fh, ':perlio'", 'file handle behaviour altered by PerlIO layers'], + [q"no utf8", 'full unicode support, utf8 pragma only for script encoding', {name => 'utf8_data'}], + [q"binmode $fh, ':perlio'", 'file handle behaviour altered by PerlIO layers', {name => 'perlio'}], [q"open $fh, '-|', @cmd", 'open list to fork a command without spawning a shell'], [q"open $fh, '>', \$var", 'perl scalars as virtual files'], [q"printf '%1$s', @args", 'syntax to use parameters out of order'], @@ -88,7 +88,7 @@ use utf8; ['//', 'defined-or operator'], ['~~', 'smart-match operator to compare different data types (updated in v5.10.1)', {experimental => 'smartmatch'}], ['say', 'print with newline, equivalent to print @_, "\n"', {feature => 'say'}], - ['given', 'switch statement to smart-match with when/default', {feature => 'switch', experimental => 'smartmatch'}], + ['given', 'switch statement to smart-match with when/default', {name => 'switch', feature => 'switch', experimental => 'smartmatch'}], ['/(?<name>)/', 'named capture buffers into %+'], ['/(?1)/', 'recursive regular expression patterns'], ['/(?|)/', 'resets capture numbering for each contained branch'], @@ -97,7 +97,7 @@ use utf8; ['/p', 'optionally preserve ${^MATCH} variables (avoiding $& penalty until COW in v5.20)'], ['/\v/, /\h/', 'vertical and horizontal whitespace escapes (\V \H to invert); also /\R/ for newlines'], ['my $_', 'lexically scoped version of the default variable', {experimental => 'lexical_topic', dropped => v5.23.4}], - ['state', 'persistent my variables', {feature => 'state'}], + ['state', 'persistent my variables (scalars only until 5.28)', {feature => 'state'}], ], release => '2007-12-18', distro => { @@ -122,6 +122,7 @@ use utf8; ['… when', 'when is now allowed to be used as a statement modifier'], [q"use overload 'qr'", 'customisable conversion to regular expressions'], ['/\N/', 'inverse \n to match any character except newline regardless of /s', {experimental => 0, stable => v5.18}], + ['each $ref e.a.', 'array and hash container functions accept references', {experimental => 'autoderef', dropped => v5.23.1}], ], release => '2010-04-12', unicode => '5.2', @@ -141,7 +142,6 @@ use utf8; ['/dalu', 'regexp modifiers to restrict character classes: either default, ascii, locale, or unicode semantics.'], [q"use re '/flags'", 'customise default modifiers'], ['/(?^)/', 'construct to reset to default modifiers'], - ['each $ref e.a.', 'array and hash container functions accept references', {experimental => 'postderef', dropped => v5.23.1}], ['FH->method', 'filehandle method calls load IO::File on demand (eg. STDOUT->flush)'], ['\o{}', 'escape sequence for octal values beyond \777'], ], @@ -263,7 +263,7 @@ use utf8; ['delete %hash{…}', 'hash slices can be deleted with key+value pairs'], ['/(*…)/', 'alphabetic synonyms for assertions, e.g. (*atomic:…) for (?>…) and (*nlb:…) for (?<!…)', {experimental => 'alpha_assertions', stable => v5.31.6}], ['/(*script_run:)/', 'enforces all characters to be from the same script', {experimental => 'script_run', stable => v5.31.6}], - ['state @a', 'persistent lexical array or hash variables'], + ['state @a', 'persistent lexical array or hash variables (in addition to scalars)', {name => 'state_ext'}], ['perl -i -pe die', 'safe in-place editing: files are replaced only after successful completion'], ['${^SAFE_LOCALES}', 'locales are thread-safe on supported systems, indicated by this variable'], ], @@ -281,8 +281,8 @@ use utf8; new => [ ['/(?<=var+)', 'variable length lookbehind assertions', {experimental => 'vlb', stable => v5.36}], ['m(\p{nv=/.*/})', 'match unicode properties by regular expressions', {experimental => 'uniprop_wildcards'}], - ['my $state if 0', 'workaround for state (deprecated since v5.10!) is now prohibited'], - [q"qr'\N'", 'Delimiters must be graphemes; unescaped { illegal; \N in single quotes'], + ['my $state if 0', 'workaround for state (deprecated since v5.10!) is now prohibited'], + [q"qr'\N'", 'Delimiters must be graphemes; unescaped { illegal; \N in single quotes'], ], unicode => '12.1', release => '2019-05-22', @@ -295,7 +295,7 @@ use utf8; new => [ ['isa', 'infix operator to check class instance', {feature => 'isa', experimental => 'isa', stable => v5.36}], ['$min < $_ <= $max', 'chained comparison repeats inner part as $min < $_ and $_ <= $max'], - ['/\p{Name=$var}/', 'match Unicode Name property like \N{} but with interpolation and subpatterns'], + ['/\p{Name=$var}/', 'match Unicode Name property like \N{} but with interpolation and subpatterns'], [q"open F, '+>>', undef", 'respect append mode on temporary files with mixed access'], ["no feature 'indirect'", 'disable indirect object notation such as new Class instead of Class->new'], ['streamzip', 'program distributed with core IO::Compress::Base to compress stdin into a zip container'], @@ -333,13 +333,13 @@ use utf8; new => [ ['use v5.36', "use warnings; use feature qw'signatures isa'; no feature qw'indirect multidimensional switch'"], ['use builtin', 'namespace for interpreter functions, such as weaken and blessed from Scalar::Util, ceil/floor from POSIX, and trim like String::Util', {experimental => 'builtin'}], - ['is_bool(!0)', 'distinguish scalar variable types (by builtin functions) for data interoperability'], + ['is_bool(!0)', 'distinguish scalar variable types (by builtin functions) for data interoperability', {name => 'is_bool'}], ['for my ($k, $v) (%hash)', 'iterate over multiple values at a time (including builtin::indexed for arrays)', {experimental => 'for_list', feature => 'for_list'}], ['defer {}', 'queue code to be executed when going out of scope', {feature => 'defer', experimental => 'defer'}], - ['try {} finally {}', 'run code at the end of a try construct regardless of failure', {feature => 'try', experimental => 'try'}], + ['try {} finally {}', 'run code at the end of a try construct regardless of failure', {name => 'finally', feature => 'try', experimental => 'try'}], ['q«…»', 'unicode delimiters for quoting operators', {experimental => 'extra_paired_delimiters'}], - ['sub ($var) {!pop}', 'signatured subs are stable, but mixing with the arguments array @_ remains experimental', {feature => 'signatures', experimental => 'args_array_with_signatures'}], - ['$SIG{FPE}', 'floating-point exceptions no longer deferred but delivered immediately like other signals'], + ['sub ($var) {!pop}', 'signatured subs are stable, but mixing with the arguments array @_ remains experimental', {feature => 'signatures', experimental => 'args_array_with_signatures'}], + ['$SIG{FPE}', 'floating-point exceptions no longer deferred but delivered immediately like other signals', {name => 'sig_fpe'}], ['perl -g', 'disable input record separator (slurp mode), alias for -0777'], ], unicode => '14.0', diff --git a/perl.plp b/perl.plp index c36f5e8..02d0348 100644 --- a/perl.plp +++ b/perl.plp @@ -100,15 +100,18 @@ for my $vernum (reverse sort keys %{$info}) { if ($attr->{experimental}) { $title = sprintf '%s', $attr->{experimental}, $title; + $attr->{name} //= $attr->{experimental}; } if ($attr->{feature}) { my $prefix = sprintf 'feature', $attr->{feature}; $title = join ', ', $prefix, $title // (); + $attr->{name} //= $attr->{feature}; } - $desc .= sprintf ' (%s)', $title; + $desc .= sprintf ' (%s)', $title if $title; } - say sprintf '
%s
%s', $topic, $desc || '
'; + my $ref = defined $attr->{name} && sprintf ' id="%s"', $attr->{name}; + say sprintf '%s
%s', $ref, $topic, $desc || '
'; } say sprintf '
Unicode
v%s', $_ for $verrow->{unicode} || (); say ''; -- 2.30.0