Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^7: compiling perl scripts aka why is perl not as fast as C

by moritz (Cardinal)
on Mar 22, 2010 at 17:57 UTC ( [id://830127]=note: print w/replies, xml ) Need Help??


in reply to Re^6: compiling perl scripts aka why is perl not as fast as C
in thread compiling perl scripts aka why is perl not as fast as C

Ok, so you say the coercion that occurs is from list to array. If that's true, then
my @a = @b;
also does coercion (array to list, then list to array), and the topic becomes irrelevant and silly. It may be true, but the concept is completely useless and not worth discussing

I think the main issue is that we're talking about different levels: When I look at Perl code, I don't see that my @a = @b does a coercion to list and back again - so to me it doesn't happen. You seem to know that either by knowing the core or by memorizing some rules that are not obvious from looking at Perl code, or the documentation in perlsyn et al.

So to me the isomorphism of a list of a single scalar and a list containing a single scalar also does not exist - When I see $foo, I think "this is a scalar" and not "this is a scalar, also constituting a list of a single scalar". It's the assignment that turns the RHS of my @a = $b into a list, and that's what I call coercion.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^8: compiling perl scripts aka why is perl not as fast as C
by ikegami (Patriarch) on Mar 22, 2010 at 18:19 UTC

    You seem to know that either by knowing the core

    Quite the contrary. I'm viewing at a high level.

    Let's look at foreach loops for a second. A foreach loop iterates over a list. It's how it's documented. It's how it works conceptually. The list can from a list literal, a range, an array, a function, etc. Internally, foreach treats ranges and arrays specially, but conceptually, it works on a list.

    I don't see the list assignment any differently. As far as I'm concerned, the list assignment is an operator that takes a list and assigns it to a list or an array. That view is independent of the actual implementation. If I were to peak into the core, it wouldn't surprise me that @a=@b is optimised to avoid creating a list. But like you said, the internal specifics aren't being discussed.

    That's how I see it.

    Update: Added foreach example.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://830127]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found