XP is just a number | |
PerlMonks |
Re: POD for use feature 'declared_refs' wrongby kcott (Archbishop) |
on Oct 17, 2021 at 07:28 UTC ( [id://11137648]=note: print w/replies, xml ) | Need Help?? |
G'day Rolf, "this POD is either confusing or plain wrong" I'd say a bit of both. In the context of the first paragraph of "Declaring a Reference to a Variable", experimental::refaliasing should definitely be replaced with experimental::declared_refs. That section goes on to say, "It is intended mainly for use in assignments to references ...". It would be appropriate to mention experimental::refaliasing at this point. "NB: that use feature qw(declared_refs) doesn't seem to make sense without the other feature." There are instances where you want a declaration without assignment (not in "void" context). I've certainly used "\my VAR" in this context often enough. This doesn't require any special feature or warnings code.
Off the top of my head, I couldn't think of an application for "my \VAR" in this context; however, just for completeness, here's a contrived example showing that "declared_refs" is required but "refaliasing" is not.
While these features remain experimental, they're rather unwieldy [see Update below] and probably easy to get wrong:
[Note: Perl 5.34 used for all examples.] Update: Regarding my comment about experimental features being unwieldy; they are, in fact, not as unwieldy as I presented. I had forgotten about the experimental pragma (thanks to ++ikegami for the reminder). The two lines:
can be reduced to the much simpler one line:
— Ken
In Section
Seekers of Perl Wisdom
|
|