Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Re: NEWBIE Brain Teaser

by merlyn (Sage)
on Apr 15, 2001 at 04:29 UTC ( [id://72640]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

Explicit referencing requires an explicit dereference. Aliasing is intended to mean something much more transparent.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: NEWBIE Brain Teaser
by Ri-Del (Friar) on Apr 15, 2001 at 05:45 UTC
    Alright, then in learning from this brain teaser not only have I learned the original point, but also stumbled upon another concept that I need to read up on. Thank you!

    I take it then that aliasing was meant to make our lives easier both in how we code as well as in how we think about the whole process?

      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...

        That is really cool! Thanks for explaining it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://72640]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.