Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re (tilly) 6: NEWBIE Brain Teaser

by tilly (Archbishop)
on Apr 16, 2001 at 06:27 UTC ( #72747=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Re: NEWBIE Brain Teaser
in thread NEWBIE Brain Teaser

Yes, that is what aliasing is supposed to do.

For instance consider this:

# No aliasing... foreach my $thing (@array) { # $thing is now an *alias* for something in @array # In reality there is a layer of indirection here # from the concept of $thing to the array, but you # do not have to write the dereferencing since Perl # hid it for you in $thing # ... } # Alias over
See? There is indirection needed to do what happens in that loop, but you don't have to think about it, and it does not appear as explicit dereferences in your code. It just works.

That is the difference between an alias and a reference. With a reference the indirection shows up as your having to tell Perl to dereference things. With an alias it is hidden inside the definition of the variable.

That is an amusing difference between Perl and, say, C. The same code written in C is in reality more direct than in Perl. But the Perl code *looks* more direct because you don't see the indirections...


Comment on Re (tilly) 6: NEWBIE Brain Teaser
Download Code
Re: Re (tilly) 6: NEWBIE Brain Teaser
by Ri-Del (Friar) on Apr 16, 2001 at 08:53 UTC
    That is really cool! Thanks for explaining it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-08-22 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (153 votes), past polls