Prev: FAQ 6.21 Are Perl regexes DFAs or NFAs? Are they POSIX compliant?
Next: FAQ 4.51 How do I permute N elements of a list?
From: Ben Morrow on 28 Apr 2010 14:49 Quoth "Uri Guttman" <uri(a)StemSystems.com>: > >>>>> "c" == ccc31807 <cartercc(a)gmail.com> writes: > > c> On Apr 27, 5:35�pm, "Uri Guttman" <u...(a)StemSystems.com> wrote: > >> perl constants are really subs with a prototype of no arguments. they > >> are converted at compile to their value (and constant folded if > >> possible). > > c> Uri, thanks for your explanation. > > c> I would then assume that > c> - use constant DIR => 'log_files'; > c> would be more or less equivalent to > c> - sub DIR { return 'log_files'; } > > sub DIR() { 'log_files' } > > the important difference is the prototype of () so it can be compile > time converted to a constant. the return isn't needed (i dunno if it > affects it becoming a proper constant but i doubt it). ~/src/perl/perl% perl -MO=Concise -e'sub FOO(){"bar"} FOO' 3 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 - <0> ex-const v ->3 -e syntax OK ~/src/perl/perl% perl -MO=Concise -e'sub FOO(){return "bar"} FOO' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 5 <1> entersub[t1] vKS/TARG,1 ->6 - <1> ex-list K ->5 3 <0> pushmark s ->4 - <1> ex-rv2cv sK/128 ->- 4 <$> gv(*FOO) s ->5 -e syntax OK So, yes, it does affect it, at least in 5.10. Ben
From: ccc31807 on 29 Apr 2010 08:54 On Apr 28, 2:49 pm, Ben Morrow <b...(a)morrow.me.uk> wrote: > ~/src/perl/perl% perl -MO=Concise -e'sub FOO(){"bar"} FOO' Ben, I assume that -MO means to use the O module that provides a generic interface to Perl Compiler backends, and that =Concise avoids verbose output. Where would I find the documentation on the options for O and a description of the output? Thanks, CC.
From: Tad McClellan on 29 Apr 2010 09:13
ccc31807 <cartercc(a)gmail.com> wrote: > On Apr 28, 2:49 pm, Ben Morrow <b...(a)morrow.me.uk> wrote: >> ~/src/perl/perl% perl -MO=Concise -e'sub FOO(){"bar"} FOO' > > Ben, > > I assume that -MO means to use the O module that provides a generic > interface to Perl Compiler backends, and that =Concise avoids verbose > output. Where would I find the documentation on the options for O and > a description of the output? You find the docs for the O module the same way you find the docs for the constant pragma. In short, you find the docs for any properly installed module with "perldoc". perldoc constant perldoc O The docs for O tell how to get the docs for backends too: perldoc B::Concise -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/" The above message is a Usenet post. I don't recall having given anyone permission to use it on a Web site. |