Perl named operators and builtin subs introduced since 5.6
by ikegami (Patriarch) on Sep 27, 2023 at 06:18 UTC
|
Perl named operators and builtin subs introduced since 5.6
| Name | Availability | Experimental | In CORE:: | Enabling pragma | Enabling feature set
|
|---|
| __CLASS__ | Since 5.40 | — | Since 5.40 | use feature qw( class ); | —
| | __SUB__ | Since 5.16 | — | Since 5.16 | use feature qw( current_sub ); | 5.16 and up
| | ADJUST | Since 5.38 | Since 5.40 | Since 5.38 | use feature qw( class ); | —
| | all | Since 5.42 | Since 5.42 | Since 5.42 | use feature qw( keyword_all ); | —
| | any | Since 5.42 | Since 5.42 | Since 5.42 | use feature qw( keyword_any ); | —
| | blessed | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( blessed ); | 5.40 and up
| | break | From 5.10 | Since 5.16[1] until 5.38 Deprecated from 5.38 until 5.42 | Since 5.16 | use feature qw( switch ); | From 5.10 up to 5.36
| | catch | Since 5.34 | From 5.34 until 5.40 | Since 5.34 | use feature qw( try ); | 5.40 and up
| | ceil | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( ceil ); | 5.40 and up
| | class | Since 5.38 | Since 5.38 | Since 5.38 | use feature qw( class ); | —
| | continue | From 5.10 | Since 5.16[1] until 5.38 Deprecated from 5.38 until 5.42 | Since 5.16 | use feature qw( switch ); | From 5.10 up to 5.36
| | created_as_number | Since 5.36 | Since 5.36 | — | use builtin qw( created_as_number ); | —
| | created_as_string | Since 5.36 | Since 5.36 | — | use builtin qw( created_as_string ); | —
| | default | From 5.10 | Since 5.16[1] until 5.38 Deprecated from 5.38 until 5.42 | Since 5.16 | use feature qw( switch ); | From 5.10 up to 5.36
| | defer | Since 5.36 | Since 5.36 | Since 5.36 | use feature qw( defer ); | 5.40 and up
| | export_lexically | Since 5.38 | Since 5.38 | — | use builtin qw( export_lexically ); | —
| | false | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( false ); | —
| | fc | Since 5.16 | — | Since 5.16 | use feature qw( fc ); | 5.16 and up
| | field | Since 5.38 | Since 5.38 | Since 5.38 | use feature qw( class ); | —
| | floor | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( floor ); | 5.40 and up
| | finally | Since 5.36 | Since 5.36 | Since 5.36 | use feature qw( try ); | 5.40 and up
| | given | From 5.10 | Since 5.16[1] until 5.38 Deprecated from 5.38 until 5.42 | Since 5.16 | use feature qw( switch ); | From 5.10 up to 5.36
| | indexed | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( indexed ); | 5.40 and up
| | inf | Since 5.40 | Since 5.40 | — | use builtin qw( inf ); | —
| | is_bool | Since 5.36 | Since 5.36 | — | use builtin qw( is_bool ); | —
| | is_tainted | Since 5.38 | From 5.38 until 5.40 | — | use builtin qw( is_tainted ); | 5.40 and up
| | is_weak | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( is_weak ); | 5.40 and up
| | isa | Since 5.32 | From 5.32 until 5.34 | Since 5.32 | use feature qw( isa ); | 5.36 and up
| | load_module | Since 5.40 | Since 5.40 | — | use builtin qw( load_module ); | —
| | method | Since 5.38 | Since 5.38 | Since 5.38 | use feature qw( class ); | —
| | nan | Since 5.40 | Since 5.40 | — | use builtin qw( nan ); | —
| | refaddr | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( refaddr ); | 5.40 and up
| | reftype | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( reftype ); | 5.40 and up
| | say | Since 5.10 | — | Since 5.16 | use feature qw( say ); | 5.10 and up
| | state | Since 5.10 | — | Since 5.16 | use feature qw( state ); | 5.10 and up
| | stringify | Since 5.40 | Since 5.40 | — | use builtin qw( stringify ); | —
| | trim | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( trim ); | 5.40 and up
| | true | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( true ); | 5.40 and up
| | try | Since 5.34 | From 5.34 until 5.40 | Since 5.34 | use feature qw( try ); | 5.40 and up
| | unweaken | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( unweaken ); | 5.40 and up
| | weaken | Since 5.36 | From 5.36 until 5.40 | — | use builtin qw( weaken ); | 5.40 and up
| | when | From 5.10 | Since 5.16[1] until 5.38 Deprecated from 5.38 until 5.42 | Since 5.16 | use feature qw( switch ); | From 5.10 up to 5.36
| |
| | builtin::blessed | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::ceil | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::created_as_number | Since 5.36 | Since 5.36 | — | Always available
| | builtin::created_as_string | Since 5.36 | Since 5.36 | — | Always available
| | builtin::export_lexically | Since 5.38 | Since 5.38 | — | Always available
| | builtin::false | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::floor | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::indexed | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::inf | Since 5.40 | Since 5.40 | — | Always available
| | builtin::is_bool | Since 5.36 | Since 5.36 | — | Always available
| | builtin::is_tainted | Since 5.38 | From 5.38 until 5.40 | — | Always available
| | builtin::is_weak | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::load_module | Since 5.40 | Since 5.40 | — | Always available
| | builtin::nan | Since 5.40 | Since 5.40 | — | Always available
| | builtin::refaddr | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::reftype | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::stringify | Since 5.40 | Since 5.40 | — | Always available
| | builtin::trim | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::true | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::unweaken | Since 5.36 | From 5.36 until 5.40 | — | Always available
| | builtin::weaken | Since 5.36 | From 5.36 until 5.40 | — | Always available
| |
| | utf8::decode | Since 5.8 | — | — | Always available
| | utf8::downgrade | Since 5.8 | — | — | Always available
| | utf8::encode | Since 5.8 | — | — | Always available
| | utf8::is_utf8 | Since 5.8.1 | — | — | Always available
| | utf8::native_to_unicode | Since 5.8[2] | — | — | Always available
| | utf8::unicode_to_native | Since 5.8[2] | — | — | Always available
| | utf8::upgrade | Since 5.8 | — | — | Always available
| | utf8::valid | Since 5.8 | — | — | Always available
|
Notes
- Current as of 5.42.
- Perl provides other builtin subs which are meant to be used as methods, which aren't documented to be available at all times, or which aren't documented at all. (These are found in in constant::, Internals::, PerlIO::, re::, Tie::Hash::NamedCapture, UNIVERSAL:: and version::). These are deliberately omitted.
- The existence of dev versions is ignored.
- "Until 5.xx" and "up to 5.xx" are exclusive, meaning they don't include 5.xx.
Footnotes
- Experimental warnings were only added in 5.18, but the switch feature was documented to be experimental since 5.16.
- While utf8::native_to_unicode and utf8::unicode_to_native have only been documented since 5.22, they've been available since 5.8.
Updates
- Added the keywords from the class feature.
- Fixed versions for defer.
- Fixed versions for finally.
- Added availability in CORE::.
- is_tainted, export_lexically, builtin::is_tainted and builtin::export_lexically were missing.
- Updated for 5.40.
- Updated for 5.42.
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] |
|
|
| [reply] [d/l] [select] |
|
|
I've mistakenly said the feature became experimental in 5.18 in the past too. But while the experimental warnings were added in 5.18, it was flagged as experimental in 5.16.
Quote 5.16's perlsyn,
you can say use feature "switch"; to enable an experimental switch feature.
Also,
Under the "switch" feature, Perl gains the experimental keywords given, when, default, continue, and break.
Added break, default and continue to the table.
| [reply] [d/l] [select] |
|
|
|
|
| [reply] [d/l] |
|
|
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
Great table, thanks! Is there any way to find out when features other than keywords were added? I'm currently trying to find (1) when ref() began returning 'Regexp' and (2) when class 'Regexp' was added, if that was more recent than (1). Both ref() and Scalar::Util::blessed() return 'Regexp' as of v5.20.2. The referenced 5.38 delta page contains a link to select earlier versions, but it doesn't seem to work; a "raptor not found" error is displayed.
| [reply] |
|
|
I collect some non-features in Syntax::Construct, but Regexp is not one of them (I might add it, though).
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] |
|
|
| [reply] |
|
|
$ for v in 5.8.9 5.10t 5.12t 5.14t 5.16t 5.18t 5.20t; do
echo $v
$v/bin/perl -le'print ref( qr/x/ )'
done
5.8.9
Regexp
5.10t
Regexp
5.12t
Regexp
5.14t
Regexp
5.16t
Regexp
5.18t
Regexp
5.20t
Regexp
| [reply] [d/l] |
|
|
| [reply] |
Re: Finding when a feature or keyword was introduced
by SankoR (Prior) on Sep 26, 2023 at 17:57 UTC
|
| [reply] [d/l] |
Re: Finding when a feature or keyword was introduced
by choroba (Cardinal) on Sep 26, 2023 at 18:00 UTC
|
Regarding features, the documentation of feature lists the minimal Perl version for each feature.
Regarding keywords, the ones not covered by features (i.e. everything but fc and say) are as old as I remember, so probably pre-5.6. There's no need to bother with so ancient versions.
There are some things that were introduced over the years that weren't mentioned in the deltas or they were but the required version isn't mentioned in their documentation. That's why I created Syntax::Construct.
Update: Reformulated. fc and say are examples of keywords covered by features.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] [select] |
|
|
| [reply] |
Re: Finding when a feature or keyword was introduced (perlver)
by Anonymous Monk on Sep 27, 2023 at 09:41 UTC
|
| [reply] |
|
|
Perl::MinimumVersion Find a minimum required version of perl for Perl code
WoW!!!
Good find - thanks for sharing...
Frok the documentation - Future plans are to also add support for tracing module dependencies
It will be an essential tool as and when that comes to pass. I always struggle to know which version of modules to declare as necessary.
| [reply] |
|
|
| [reply] |
|
|
Re: Finding when a feature or keyword was introduced
by ikegami (Patriarch) on Sep 27, 2023 at 05:35 UTC
|
I don't believe any named operators ("functions") have been added since 5.6, except 1) those that need a pragma to enable, and 2) those that are in a namespace other than main::.
| [reply] |