summaryrefslogtreecommitdiff
path: root/pod/perlsub.pod
Commit message (Collapse)AuthorAgeFilesLines
* Adding a prototype attribute.Peter Martini2013-10-161-1/+3
| | | | | | | | | | | | | | | 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
* [perl #77680] add pointers to a few other perl called subsTony Cook2013-09-161-0/+13
|
* [perl #77680] perlsub pointers to sub names used by perl itselfZsbán Ambrus2013-09-161-2/+38
| | | | Tony Cook: convert from a diff to a commit
* [perl #2726] Prototype is not applied until BLOCK is definedPeter Martini2013-08-061-0/+10
| | | | | | | | | | 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.
* perlsub: constant -> inlinableFather Chrysostomos2013-07-301-1/+1
| | | | | | 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.
* Fixed verbatim lines in POD over 79 charactersBrian Gottreu2013-06-221-32/+32
|
* Update perlsub.pod for lvalue subroutines.Johan Vromans2013-06-211-30/+6
|
* make qr/(?{ __SUB__ })/ safeDavid Mitchell2013-04-241-0/+3
| | | | | | | | | | | | | | | | | | (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.
* Use two colons for lexsub warningFather Chrysostomos2012-09-301-5/+5
|
* pod/perlsub.pod: Warn about possible lexsub removalFather Chrysostomos2012-09-171-2/+2
|
* Document lexical subsFather Chrysostomos2012-09-151-0/+101
|
* perlsub: Document state variables betterFather Chrysostomos2012-09-151-0/+15
|
* perlsub: #109408Brian Fraser2012-06-271-4/+3
|
* perlsub: Fix new typoFather Chrysostomos2012-04-241-2/+2
| | | | | Since the typo was added during code freeze, I hope I’m not going too far in fixing it during code freeze. :-)
* point out __SUB__ in perlsub.podRicardo Signes2012-04-241-0/+12
|
* Allow prototypes (_@) and (_%)Rafael Garcia-Suarez2012-01-271-3/+3
| | | | | | 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.
* Correct bad wording in perlsubFather Chrysostomos2012-01-091-1/+1
| | | | | | | 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.)
* perlsub: constant redef warning is default, not mandatoryFather Chrysostomos2011-11-211-2/+3
|
* Improve documentation of XS autoloadingFather Chrysostomos2011-10-111-2/+2
|
* Update docs for XS AUTOLOADFather Chrysostomos2011-10-091-2/+1
| | | | | This mentions the UTF8 flag and moves the discussion to perlapi, where it belongs, IMHO.
* Removing modules should include updating referencesFather Chrysostomos2011-10-071-1/+1
|
* Remove all references to old OO tutorial docs, and add refs to perlootut ↵Dave Rolsky2011-09-081-1/+1
| | | | | | where appropriate Used buildtoc to regenerate pod-related files
* Document and test $; prototype syntaxFather Chrysostomos2011-08-151-1/+5
| | | | | This has worked this way for yonks. It is actually useful, so it might as well be documented.
* Add inlinable &CORE::functionsFather Chrysostomos2011-08-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Update proto docs after prev commitFather Chrysostomos2011-06-241-2/+2
|
* Doc update for changes in 5.15.0 + tweaksFather Chrysostomos2011-06-171-11/+7
|
* Typo fix in When to Still Use local()Ian Goodacre2011-06-161-1/+1
| | | | Signed-off-by: David Golden <dagolden@cpan.org>
* Revert "Accept lvalue subroutines as a useful feature."Father Chrysostomos2011-05-311-10/+34
| | | | | This reverts commit c72c0c0bdd3dbc2b529b28a4f324a1cc149a6453 at Jesse’s request.
* Revert "Remove a line added by the prev commit"Father Chrysostomos2011-05-311-0/+2
| | | | | This reverts commit 6b8305409e650748b2e6fb75634200370b69238b at Jesse’s request.
* Remove a line added by the prev commitFather Chrysostomos2011-05-311-2/+0
| | | | Lvalue subs *can* return lists
* Accept lvalue subroutines as a useful feature.Johan Vromans2011-05-311-34/+10
| | | | | | | | | 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.
* [perl #91518] Fix minor typo in pod/perlsub.pod.Johan Vromans2011-05-241-1/+1
|
* perlsub.pod: Fix broken linkKarl Williamson2011-05-181-1/+1
|
* #84774: local $_ calls STORE when $_ is aliased to a tied hash elementJan Dubois2011-03-201-16/+3
| | | | | | 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.
* Fix bad pod links found by Test::Pod::LinkCheckApocalypse2011-02-151-1/+1
|
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add single-term prototypeDavid Golden2010-10-211-2/+16
| | | | | | | | | | | | | | | | 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.
* Fix pod syntax in perlsubFather Chrysostomos2010-09-201-1/+1
|
* [perl #47365] Docs for \$ prototypesFather Chrysostomos2010-09-201-3/+6
| | | | | \$ allows any hash/array element, even if it does not start with a dollar sign.
* Update AUTOLOAD section in perlsubRob Hoelz2010-09-151-1/+5
| | | | | AUTOLOAD documentation didn't mention that if AUTOLOAD is implemented as an XSUB, $AUTOLOAD is not populated.
* Document "delete local" in perlsubVincent Pit2009-07-271-0/+50
|
* Re: Patches / gitAndy Armstrong2008-06-161-1/+1
| | | | | Message-Id: <1162EDA1-C865-4CBB-8DA0-3C83F89E826E@hexten.net> p4raw-id: //depot/perl@34057
* perlsub's docs on state assignment are bustedRicardo SIGNES2007-11-151-5/+4
| | | | | Message-ID: <20071114203430.GA7191@zodiac.codesimply.com> p4raw-id: //depot/perl@32325
* Modernize opendir() syntaxRafael Garcia-Suarez2007-07-101-4/+3
| | | p4raw-id: //depot/perl@31576
* Remove the code that handles assignment to state variablesRafael Garcia-Suarez2007-04-241-19/+4
| | | p4raw-id: //depot/perl@31049
* Make readpipe() overridable (and also `` and qx//)Rafael Garcia-Suarez2006-10-311-1/+2
| | | p4raw-id: //depot/perl@29168
* stab at UNITCHECK blocksAlexander Gough2006-10-191-6/+7
| | | | | Message-ID: <20061019120412.GA12290@the.earth.li> p4raw-id: //depot/perl@29053
* Adjust documentation for previous changeRafael Garcia-Suarez2006-10-191-2/+3
| | | p4raw-id: //depot/perl@29049
* Document _ prototype in perlsubRafael Garcia-Suarez2006-10-181-1/+4
| | | p4raw-id: //depot/perl@29038
* Fix prototype to mimic built-in in perlsub examplesRafael Garcia-Suarez2006-10-181-1/+1
| | | p4raw-id: //depot/perl@29037