@@ -629,7 +629,7 @@ AVs that meet the following criteria:
629629
630630=item * are not readonly
631631
632- =item * are "real" (refcounted) AVs
632+ =item * are "real" AVs (see next section)
633633
634634=item * have an av_top_index value > -2
635635
@@ -645,6 +645,42 @@ of normal operations. It is therefore safest, unless you are sure of the
645645lifecycle of an AV, to only use these new functions close to the point
646646of AV creation.
647647
648+ =head3 Real AVs - and those that are not
649+
650+ The standard or typical AV is sometime referred to as being a "real" AV,
651+ a state that can be checked for with the C<AvREAL> macro. What this state
652+ basically signifies is that:
653+
654+ =over
655+
656+ =item * Every accessible element in the array is either initialized but
657+ empty or contains a pointer to a live SV.
658+
659+ =item * When a SV* is assigned to an array element, the reference count on
660+ the SV is incremented. Conversely, when the element is unset, or assigned
661+ a different SV*, the reference count of the expelled SV is decremented.
662+
663+ =back
664+
665+ "Fake" AVs are intended for specific, limited use cases only. Use outside
666+ of core perl is strongly discouraged.
667+
668+ For example, the interpreter's argument stack is implemented as an AV,
669+ but it is not C<AvREAL>. Its elements were historically not reference
670+ counted, which gives rise to the "stack-not-refcounted" class of bugs
671+ when SVs are freed during the execution of a statement but still needed
672+ later in that statement. Efforts are currently underway to move to a
673+ refcounted stack to fix this class of bugs: see the L</"Reference-counted argument stack">
674+ section in this document.
675+
676+ A "fake" AV can be converted into a "real" AV by C<av_reify>. Conversion
677+ must occur if the AV has the C<SVpav_REIFY> flag set, which can be checked
678+ for using the C<AvREIFY()> macro. Trying to store a SV* into, or delete
679+ from, an AV usually involves an C<AvREIFY()> check and conversion if needed.
680+
681+ See comments in F<av.h> and the functions in F<av.c> if you really
682+ want to know more.
683+
648684=head2 Working with HVs
649685
650686To create an HV, you use the following routine:
0 commit comments