Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: The Concept of References

by Anonymous Monk
on Apr 14, 2005 at 11:07 UTC ( #447701=note: print w/ replies, xml ) Need Help??


in reply to The Concept of References

That looks like an explaination of pointers. It strongly suggests that you can do arithmetic on references, to get to the "next" memory location. I like this image:

+--------+ Alias: | $alias | ------------+ +--------+ | | \|/ +--------+ +----------+ +---------+ Variable: | $var | ----> | Variable | ----> | Content | +--------+ +----------+ +---------+ /|\ +--------+ +--------+ +----------+ | Reference: | $ref | ----> | Variable | --+ +--------+ +----------+
But that might be too much internals for some.


Comment on Re: The Concept of References
Download Code
Re^2: The Concept of References
by Juerd (Abbot) on Apr 14, 2005 at 12:25 UTC

    These things are often called name, container and value. Your diagram has them neatly put in columns:

    Name Container Value +--------+ Alias: | $alias | ------------+ +--------+ | | \|/ +--------+ +----------+ +---------+ Variable: | $var | ----> | Variable | ----> | Content | +--------+ +----------+ +---------+ /|\ +--------+ +--------+ +----------+ | Reference: | $ref | ----> | Variable | --+ +--------+ +----------+
    The "variable" label isn't accurate, though, if you also call one of the blocks "variable". And, to more clearly illustrate that an alias is absolutely not a reference, you could consider making the original name and the second name more visually equal:
    +--------+ __ | $name | \ +--------+ \ +-----------+ +-------+ ====> | container | ----> | value | +--------+ / +-----------+ +-------+ | $alias | __/ +--------+
    And I think the content/value part of Reference is missing in your diagram. It does have one, and that is the actual reference! Hard to draw, though.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      I know how references work internally, but those are details not really needed to understand references and aliases. As for visually equalizing $name and $alias, I usually do the diagram interactively, in front of a blackboard, starting with the middle line of my diagram. And then I won't wipe out the $name box to draw it a bit lower (or higher).
Re^2: The Concept of References
by leriksen (Curate) on Apr 15, 2005 at 02:27 UTC
    Nice diagram - I deliberately didnt do it this way, even though yours is more accurate. And I hope to add The Concept of Alias' today.

    ...it is better to be approximately right than precisely wrong. - Warren Buffet

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-07-25 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls