| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This attribute adds an additional way of declaring a prototype for a
sub, making sub foo($$) and sub foo : prototype($$) equivalent. The
intent is to keep the functionality of prototypes while allowing other
modules to use the syntactic space it currently occupies for other
purposes.
The attribute is supported in attributes.xs to allow
attributes::->import to work, but if its defined inline via something
like sub foo : prototype($$) {}, it will not call out to the
attributes module.
For: RT #119251
|
| |
|
|
|
|
| |
Tony Cook: convert from a diff to a commit
|
|
|
|
|
|
|
|
|
|
| |
In the case of a sub definition with a prototype, the prototype
is not attached to the sub until after the body is completely
defined. This means that any sub which calls itself will
not honor its prototype unless the prototype was declared prior to
the sub's definition. Whether or not this behavior is desirable is
debatable, but its far too late to do anything about it other than
document it and test to make sure it doesn't change.
|
|
|
|
|
|
| |
This was brought up in ticket #109744. I cannot change the header of
the section, as it will break links. But at least we can avoid
stressing the constancy as much.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(See RT #113928)
Formerly, __SUB__ within a code block within a qr// returned
a pointer to the "hidden" anon CV that implements the qr// closure. Since
this was never designed to be called directly, it would SEGV if you tried.
The easiest way to make this safe is to skip any CXt_SUB frames that
are marked as CXp_SUB_RE: i.e. skip any subs that are there just to
execute code blocks. For a qr//, this means that we return the sub which
the pattern match is embedded in.
Also, document the behaviour of __SUB__ within code blocks as being
subject to change. It could be argued for example that in these cases it
should return undef. But with the 5.18.0 release a month or two away, just
make it safe for now, and revisit the semantics later if necessary.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Since the typo was added during code freeze, I hope I’m not going too
far in fixing it during code freeze. :-)
|
| |
|
|
|
|
|
|
| |
Those will be equivalent to (_;@) and (_;%) ; since perlsub already
states that the semicolon is redundant before @ and % this is in
line with the existing documentation.
|
|
|
|
|
|
|
| |
It seemed to imply that CORE:: syntax was introduced in 5.16. What it
was supposed to say was that CORE:: breaking through the feature.pm
barrier was introduced in 5.16. (Which sounds a little odd, as 5.16
is still in the future, but whatever.)
|
| |
|
| |
|
|
|
|
|
| |
This mentions the UTF8 flag and moves the discussion to perlapi, where
it belongs, IMHO.
|
| |
|
|
|
|
|
|
| |
where appropriate
Used buildtoc to regenerate pod-related files
|
|
|
|
|
| |
This has worked this way for yonks. It is actually useful, so it might
as well be documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit allows this to work:
BEGIN { *entangle = \&CORE::tie };
entangle $foo, $package;
And the entangle call gets inlined as a tie op, the resulting op tree
being indistinguishable.
These subs are not yet callable via &foo syntax or through a refer-
ence. That will come later, except for some functions, like sort(),
which will probably never support it.
Almost all overridable functions are supported. These few are not:
- infix operators
- not and getprotobynumber (can’t get the precedence right yet;
prototype problem)
- dump
Subsequent commits (hopefully!) will deal with those.
How this works:
gv_fetchpvn_flags is extended with hooks to create subs inside the
CORE package. Those subs are XSUBs (whose C function dies with an
error, for now at least) with a call checker that blows away the
entersub op and replaces it with whatever op the sub represents.
This is slightly inefficient right now, as gv_fetchpvn_flags calls
keyword(), only to have core_prototype call it again. That will
be fixed in a future refactoring.
|
| |
|
| |
|
|
|
|
| |
Signed-off-by: David Golden <dagolden@cpan.org>
|
|
|
|
|
| |
This reverts commit c72c0c0bdd3dbc2b529b28a4f324a1cc149a6453
at Jesse’s request.
|
|
|
|
|
| |
This reverts commit 6b8305409e650748b2e6fb75634200370b69238b
at Jesse’s request.
|
|
|
|
| |
Lvalue subs *can* return lists
|
|
|
|
|
|
|
|
|
| |
Support for lvalue subroutines has been stable and reliable for more
than 10 years. Despite this, they are still marked as being
experimental.
This patch removes the 'experimental' warnings from the docs, and
adjusts the description accordingly.
|
| |
|
| |
|
|
|
|
|
|
| |
local($_) will now strip all magic from $_, so that it is always safe
to localize $_, regardless what kind of special (or tied) variable it
may have been aliased to.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All built-in functions that operate directly on array or hash
containers now also accept hard references to arrays or hashes:
|----------------------------+---------------------------|
| Traditional syntax | Terse syntax |
|----------------------------+---------------------------|
| push @$arrayref, @stuff | push $arrayref, @stuff |
| unshift @$arrayref, @stuff | unshift $arrayref, @stuff |
| pop @$arrayref | pop $arrayref |
| shift @$arrayref | shift $arrayref |
| splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 |
| keys %$hashref | keys $hashref |
| keys @$arrayref | keys $arrayref |
| values %$hashref | values $hashref |
| values @$arrayref | values $arrayref |
| ($k,$v) = each %$hashref | ($k,$v) = each $hashref |
| ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref |
|----------------------------+---------------------------|
This allows these built-in functions to act on long dereferencing
chains or on the return value of subroutines without needing to wrap
them in C<@{}> or C<%{}>:
push @{$obj->tags}, $new_tag; # old way
push $obj->tags, $new_tag; # new way
for ( keys %{$hoh->{genres}{artists}} ) {...} # old way
for ( keys $hoh->{genres}{artists} ) {...} # new way
For C<push>, C<unshift> and C<splice>, the reference will auto-vivify
if it is not defined, just as if it were wrapped with C<@{}>.
Calling C<keys> or C<values> directly on a reference gives a
substantial performance improvement over explicit dereferencing.
For C<keys>, C<values>, C<each>, when overloaded dereferencing is
present, the overloaded dereference is used instead of dereferencing
the underlying reftype. Warnings are issued about assumptions made in
the following three ambiguous cases:
(a) If both %{} and @{} overloading exists, %{} is used
(b) If %{} overloading exists on a blessed arrayref, %{} is used
(c) If @{} overloading exists on a blessed hashref, @{} is used
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The C<+> prototype is a special alternative to C<$> that will act like
C<\[@%]> when given a literal array or hash variable, but will otherwise
force scalar context on the argument. This is useful for functions which
should accept either a literal array or an array reference as the argument:
sub smartpush (+@) {
my $aref = shift;
die "Not an array or arrayref" unless ref $aref eq 'ARRAY';
push @$aref, @_;
}
When using the C<+> prototype, your function must check that the argument
is of an acceptable type.
|
| |
|
|
|
|
|
| |
\$ allows any hash/array element, even if it does not start with a
dollar sign.
|
|
|
|
|
| |
AUTOLOAD documentation didn't mention that if AUTOLOAD is implemented
as an XSUB, $AUTOLOAD is not populated.
|
| |
|
|
|
|
|
| |
Message-Id: <1162EDA1-C865-4CBB-8DA0-3C83F89E826E@hexten.net>
p4raw-id: //depot/perl@34057
|
|
|
|
|
| |
Message-ID: <20071114203430.GA7191@zodiac.codesimply.com>
p4raw-id: //depot/perl@32325
|
|
|
| |
p4raw-id: //depot/perl@31576
|
|
|
| |
p4raw-id: //depot/perl@31049
|
|
|
| |
p4raw-id: //depot/perl@29168
|
|
|
|
|
| |
Message-ID: <20061019120412.GA12290@the.earth.li>
p4raw-id: //depot/perl@29053
|
|
|
| |
p4raw-id: //depot/perl@29049
|
|
|
| |
p4raw-id: //depot/perl@29038
|
|
|
| |
p4raw-id: //depot/perl@29037
|