New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[patch] wrong examples in perlsub/"Constant Functions" #7183
Comments
From padre@elte.huCreated by padre@elte.huBy testing whether some functions are treated as constants by perl or not, I believe that the difference (for example between FOO_SET and foo_set in I checked the functions being inlined or not by redefining them later in The patch follows. HAND, Inline Patch--- /usr/share/perl/5.8.3/pod/perlsub.pod 2004-02-15 07:55:04.000000000 +0100
+++ perlsub.pod 2004-03-18 17:05:04.000000000 +0100
@@ -1131,7 +1131,16 @@
sub FLAG_MASK () { FLAG_FOO | FLAG_BAR }
sub OPT_BAZ () { not (0x1B58 & FLAG_MASK) }
- sub BAZ_VAL () {
+
+ sub N () { int(OPT_BAZ) / 3 }
+
+ sub FOO_SET () { 1 if FLAG_MASK & FLAG_FOO }
+
+Be aware that these will not be inlined:
+
+ sub foo_set () { if (FLAG_MASK & FLAG_FOO) { 1 } }
+
+ sub baz_val () {
if (OPT_BAZ) {
return 23;
}
@@ -1140,11 +1149,10 @@
}
}
- sub N () { int(BAZ_VAL) / 3 }
BEGIN {
my $prod = 1;
for (1..N) { $prod *= $_ }
- sub N_FACTORIAL () { $prod }
+ sub n_factorial () { $prod }
}
If you redefine a subroutine that was eligible for inlining, you'll get Perl Info
|
From @rgspadre@elte.hu (via RT) wrote:
That's correct (and I added the note.)
...although I think this last example *should* be inlined, so I'm |
The RT System itself - Status changed from 'new' to 'open' |
@rgs - Status changed from 'open' to 'resolved' |
From perl5-porters@ton.iguana.beIn article <20040322220927.1247aa9b.rgarciasuarez@_ree._r>,
Though it might be nice to update the docs with a way to actually get #! /usr/bin/perl -wl |
From @rgsTon Hospel wrote in perl.perl5.porters :
Doesn't this belong to the constant manpage instead ? |
Migrated from rt.perl.org#27768 (status was 'resolved')
Searchable as RT27768$
The text was updated successfully, but these errors were encountered: