Re: Need help passing arrays by reference pls.
From: ko (kuujinbo_at_hotmail.com)
Date: 02/08/04
- Previous message: Sam Holden: "Re: Time with Epoch earlier than 1970 question"
- In reply to: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Next in thread: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Reply: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 08 Feb 2004 15:51:30 +0900
Ben Morrow wrote:
[snip]
> A tool I like for answering this sort of question is B::Graph, which
> produces a graph of the optree. It seems that
>
> print "a", "b";
>
> becomes
>
> nextstate -> pushmark -> const -> const -> print
>
> (nextstate starts a new statement. pushmark makes a mark in the Perl
> stack to show where the arguments for the print begin. The consts push
> items onto the stack, the print takes them off down to the mark and
> prints them) whereas
>
> print "a" . "b";
>
> becomes
>
> nextstate -> pushmark -> const -> print
>
> ie. perl will perform the concatenation at compile time, and thus it
> must be more efficient. However,
>
> print "a", $x;
>
> becomes
>
> nextstate -> pushmark -> const -> padsv -> print
>
> as before (padsv gets the value of the variable and pushes it onto the
> stack) whereas
>
> print "a" . $x;
>
> becomes
>
> nextstate -> pushmark -> const -> padsv -> concat -> print
>
> ie. the concatenation is done as a separate step before the print, so
> it may well be slower (this depends on whether printing several items
> as opposed to one is slower or faster than concatenating them).
>
> Certainly it is not true that they are the same
[snip]
Perl's internals are over my head, but thank you for providing a simple,
concise explanation that makes sense. Have never used any of the B
modules and tried to play around with B::Graph, but couldn't figure out
how to get output like yours :( . But there's a link at the bottom of
the documentation, so I'll look at that and at perlguts.
keith
- Previous message: Sam Holden: "Re: Time with Epoch earlier than 1970 question"
- In reply to: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Next in thread: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Reply: Ben Morrow: "Re: Need help passing arrays by reference pls."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|