61 Commits

Author SHA1 Message Date
Paul "LeoNerd" Evans
bf81de7afe Rename the 'any' and 'all' features and experimental warnings to 'keyword_any' and 'keyword_all'
This avoids confusion with the `use feature ':all'` ability

(As requested by https://github.com/Perl/perl5/issues/23104)
2025-03-14 15:54:13 +00:00
Tony Cook
ed1ae14707 add the smartmatch feature 2025-02-16 14:51:17 +01:00
Tony Cook
9a10079617 Revert "switch removal: remove the feature from feature.pm"
This reverts commit 149bea6edf8c49a1faf4fac124567101172d96bd.
2025-02-16 14:51:16 +01:00
Tony Cook
ff560a7165 feature.h: use the correct format for U32 for cop_feature_bits 2025-01-20 09:45:28 +11:00
Tony Cook
87e1d1722c feature.*: allow cop_feature to expand
The initial implementation of feature bits for faster access to
feature flags used a single U32 member in COP to store the bits, but
we're now up to 24 features, so rather than leaving this to the last
minute I've re-worked regen/feature.pl to allow multiple U32 fields.
2025-01-09 11:06:14 +11:00
Paul "LeoNerd" Evans
6f04944602 Implement PPC0027: Create all and any operators
As these only permit `any BLOCK LIST` and not the deferred-expression
form like `grep EXPR, LIST`, we create a whole new token type, BLKLSTOP,
to represent these. The parser then only accepts the block form and not
the expression form when parsing these.
2024-12-04 16:28:06 +00:00
Tony Cook
37ca2c313a Add the apostrophe_as_package_separator feature to feature.pm 2024-11-11 10:39:40 +11:00
Tony Cook
149bea6edf switch removal: remove the feature from feature.pm 2024-08-15 10:56:18 +10:00
Karl Williamson
850214088a Revert extra_paired_delimiter feature to experimental
This is due to GH #22228
2024-05-23 14:32:01 +02:00
Paul "LeoNerd" Evans
49358d7204 Add the newly-stablised features (try, extra_paired_delimiters) to the :5.40 feature bundle 2024-04-16 11:42:27 +01:00
Tony Cook
b5cbb3ced7 features: populate cop_features from a hints hash the hard way
I originally optimised populating cop_features for eval by storing
the hints mask in "feature/bits" and then fetching that when
re-populating the hints for eval.

But that has turned out to be too fragile, so iterate over the
possible feature keys and populate cop_features from that.

I could perhaps have avoided this cost by ensuring "feature/bits" was
set where else it was needed, but this code already iterates to build
the hints hash, iterating again doesn't increase the scale of the work
we're doing.
2023-08-31 10:07:20 +10:00
Lukas Mai
b7eedb0895 fix incorrect vi filetype declarations in generated files
Vim's filetype declarations are case sensitive. The correct types for
Perl, C, and Pod are perl, c, and pod, respectively.
2023-03-24 06:10:05 +08:00
Elvin Aslanov
6a3688ca38 generated files - update mode lines to specify file type
This updates the mode-line for most of our generated files so that
they include file type information so they will be properly syntax
highlighted on github.

This does not make any other functional changes to the files.

[Note: Commit message rewritten by Yves]
2023-02-19 09:44:05 +08:00
Paul "LeoNerd" Evans
99b497aa90 Initial attack at basic 'class' feature
Adds a new experimental warning, feature, keywords and enough parsing to
implement basic classes with an empty `new` constructor method.

Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted
Creates a new OP_METHSTART opcode to perform method setup
Define an aux flag to remark which stashes are classes

Basic implementation of fields.

Basic anonymous methods.
2023-02-10 12:07:02 +00:00
chromatic
1102a6f006 Enable use feature 'module_true'
Per RFC 18, whenever `use feature 'module_true';` is enabled in a scope,
any file required with `require` has an implicit return value of true
and will not trigger the "did not return a true value" error condition.

This includes logic to use the OPf_SPECIAL flag for OP_RETURN listops to
indicate that the module_true feature is in effect when it executes.
This flag plays no role unless the OP_RETURN tail calls the pp_leaveeval
logic, so it doesn't affect normal sub returns.
2022-11-01 09:46:16 +01:00
Yves Orton
7b038bdfcf feature.h - simplify expression CURRENT_HINTS expression
PL_hints expands to PL_compiling.cop_hints. So there is no
point in doing

    PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints

as it resolves to doing:

    PL_curcop->cop_hints

but with a comparison, which likely kills any speed advantage
the direct access might provide.

The old define is left around to validate that the two are the same
if needed.
2022-10-26 11:11:08 +02:00
Dagfinn Ilmari Mannsåker
31c1155d19 Remove bareword_filehandles from the :5.38 feature bundle
Commit c5327cb77526e4e4c7bb83e24be20ac48e85b1fa fixed the bug that
caused it to be put back in the :5.36 feature bundle, so let's pull it
out again.
2022-07-06 12:29:06 +01:00
Paul "LeoNerd" Evans
eca9683b6b Put 'bareword_filehandles' feature back into the v5.35 bundle 2022-05-13 22:12:47 +01:00
Karl Williamson
9c9853e81d Add 'extra paired delimiters' feature
When this feature is enabled, one can use many more string delimiters
that have an opening version and a mirrored closing one.
2022-03-19 23:17:51 -06:00
Paul "LeoNerd" Evans
3d1a4f0672 Add 'signatures' to :5.36 feature bundle 2022-02-20 00:07:03 +00:00
Paul "LeoNerd" Evans
02547a384a Add 'isa' to 'use feature :5.35' 2022-02-15 13:31:15 +00:00
Ricardo Signes
d5c835da0b feature.pm: remove bareword_filehandles from :5.36 2021-11-02 14:19:43 -04:00
Ricardo Signes
cdba169fcf feature: remove indirect and multidimensional in v5.36 2021-11-02 14:19:43 -04:00
Paul "LeoNerd" Evans
f79e2ff95f Create defer syntax and OP_PUSHDEFER opcode
Adds syntax `defer { BLOCK }` to create a deferred block; code that is
deferred until the scope exits. This syntax is guarded by

  use feature 'defer';

Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field
gives the start of an optree to be deferred until scope exit. That op
pointer will be stored on the save stack and invoked as part of scope
unwind.

Included is support for `B::Deparse` to deparse the optree back into
syntax.
2021-08-25 13:52:09 +01:00
Ricardo Signes
915e574d30 feature.pm: drop "switch" from latest version bundle 2021-07-25 15:37:14 -04:00
Paul "LeoNerd" Evans
a1325b902d Initial attempt at feature 'try'
* Add feature, experimental warning, keyword
 * Basic parsing
 * Basic implementation as optree fragment

See also
  https://github.com/Perl/perl5/issues/18504
2021-02-04 14:20:53 +00:00
Tony Cook
0f2beabb08 add a bareword_filehandles feature, which is enabled by default
This disables use of bareword filehandles except for the built-in handles
2021-01-04 11:28:58 +11:00
Tony Cook
1ad5a39cca add a default enabled feature "multidimensional"
Like "indirect" this feature is enabled by default and enables the
perl4 hash-based multidimensional array emulation documented under
$; in perlvar.
2020-08-10 22:33:10 -06:00
Dagfinn Ilmari Mannsåker
0b657b1955 Add 'indirect' feature that can be turned off to disable indirect object syntax
Co-authored-by: Tony Cook <tony@develop-help.com>
2020-02-16 16:00:00 +00:00
Paul "LeoNerd" Evans
813e85a03d Add the isa operator
Adds a new infix operator named `isa`, with the semantics that

  $x isa SomeClass

is true if and only if `$x` is a blessed object reference that is either
`SomeClass` directly, or includes the class somewhere in its @ISA
hierarchy. It is false without warning or error for non-references or
non-blessed references.

This operator respects `->isa` method overloading, and is intended to
replace boilerplate code such as

  use Scalar::Util 'blessed';

  blessed($x) and $x->isa("SomeClass")
2019-12-09 23:19:05 +00:00
Tony Cook
b34c1a7ee2 updates to $^H{feature_validname} now update cop_features
This removes $^{FEATURE_BITS}, since it's no longer needed.
2019-12-05 10:35:00 +11:00
Tony Cook
7599b8a978 remove now unneeded FEATURE_IS_ENABLED() 2019-10-30 20:09:37 +01:00
Tony Cook
9f601cf3bb Faster feature checks
Perform only a bit check instead of a much more expensive hash
lookup to test features.

For now I've just added a U32 to the cop structure to store the bits,
if we need more we could either add more bits directly, or make it a
pointer.

We don't have the immediate need for a pointer that warning do since
we don't dynamically add new features during compilation/runtime.

The changes to %^H are retained so that caller() can be used from perl
code to check the features enabled at a given caller's scope.
2019-10-30 20:09:37 +01:00
James E Keenan
3dd7db2969 Provide header guards to prevent re-inclusion
Per LGTM analysis: https://lgtm.com/projects/g/Perl/perl5/alerts/?mode=tree&ruleFocus=2163210746

and LGTM recommendation: https://lgtm.com/rules/2163210746/

For: RT 133699
2018-12-04 21:39:19 -05:00
Dagfinn Ilmari Mannsåker
c22e17d0af Remove support for setting $[ to a non-zero value
This removes arybase and all its surrounding machinery.
2018-09-26 13:00:19 +01:00
Father Chrysostomos
401d2aaa50 Enable bitwise feature with ‘use v5.28’ 2017-12-31 12:24:01 -08:00
Father Chrysostomos
82d83da3ce Add declared_refs feature feature 2016-07-17 11:24:07 -07:00
Father Chrysostomos
db629560b6 Give feature.pm the concept of no-op features 2016-05-20 15:59:58 -07:00
Aaron Crane
1c2511e0ac Make postfix dereferencing work without the postderef feature
The feature still exists, for compatibility with code that tries to enable
it, but it has no effect. The postderef_qq feature still exists, however.
2015-07-13 13:42:01 +01:00
Aaron Crane
2ad792cd4e The postderef feature is no longer experimental
As proposed by RJBS.

The "5.24" feature bundle (and therefore C<< use v5.24 >>) now enable
postderef and postderef_qq.

I can't find any precedent for what to do with the relevant experimental::*
warnings category when an experimental feature graduates to acceptance. I
have elected to leave the category in place, so that code doing C<< no
warnings "experimental::postderef" >> will continue to work. This means that
C<< use warnings "experimental::postderef" >> is also accepted, but has no
effect.
2015-06-27 20:39:54 +01:00
Father Chrysostomos
cec892e70e Add bitwise feature feature 2015-01-31 22:03:50 -08:00
Father Chrysostomos
baabe3fb41 Rename lvalue references
Also correct the description of lvref magic.  When it was first added,
it was for list assignments only, but that soon changed.
2014-10-17 20:28:37 -07:00
Father Chrysostomos
7b1dc818da Add lvalue_refs feature feature 2014-10-10 21:53:47 -07:00
Zefram
30d9c59b5f subroutine signatures
Declarative syntax to unwrap argument list into lexical variables.
"sub foo ($a,$b) {...}" checks number of arguments and puts the
arguments into lexical variables.  Signatures are not equivalent to the
existing idiom of "sub foo { my($a,$b) = @_; ... }".  Signatures are only
available by enabling a non-default feature, and generate warnings about
being experimental.  The syntactic clash with prototypes is managed by
disabling the short prototype syntax when signatures are enabled.
2014-02-01 01:27:15 +00:00
Father Chrysostomos
158beccad2 Add postderef_qq feature feature 2013-10-05 14:20:09 -04:00
Father Chrysostomos
b9a36c95eb Add postderef feature feature 2013-10-05 14:20:09 -04:00
Father Chrysostomos
ebd2568602 Add experimental lexical_subs feature 2012-09-15 22:45:11 -07:00
Nicholas Clark
fc4b5f7283 Tweak the FEATURE_IS_ENABLED() macro to avoid a bug in the HP-UX compiler. 2012-04-12 00:35:06 +02:00
Brian Fraser
2a4315f8fb Add the fc keyword in regen/feature.pl
It doesn't do anything yet.
2012-01-29 10:07:40 -07:00
Father Chrysostomos
035b6821e6 feature.h: Mask hints in CURRENT_FEATURE_BUNDLE
Otherwise CURRENT_FEATURE_BUNDLE will end up including any hints added
later that happen to use higher bits.

This was causing autobox to turn off all features, causing failures
for Dist::Zilla::PluginBundle::AVAR.

I’m not adding tests for this, as such tests would need constant
tweaking in future perl developement.  What autobox is doing is
naughty and unsupported anyway.
2012-01-28 23:35:14 -08:00