http://qs321.pair.com?node_id=869400


in reply to Re^2: typeglob/symbolic reference question
in thread typeglob/symbolic reference question

hi ikegami. dereferencing is literally accessing something at the address pointed by variable value. perl jargon is sigil...however perl does borrow many concepts (like referencing=~pointers nuts and bolts) from C. Maybe it's not the most useful concept (in my mindset) to bring across from C to perl with me...anyhow you can dereference a code reference in perl without the ampersand, so any argument about what ampersand actually does in perl is debatable, unless you actually see some requirement for it in compiled/assembled/running perl code. and it's not in current fashion for perl code afaik. maybe i should re-read the black book..but that's quite dated now.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re^3: typeglob/symbolic reference question

Replies are listed 'Best First'.
Re^4: typeglob/symbolic reference question
by ikegami (Patriarch) on Nov 04, 2010 at 06:16 UTC

    Maybe it's not the most useful concept (in my mindset) to bring across from C to perl with me...

    Definitely, cause Perl's "&" never does anything similar to C's "&". Perl's "\" would be the closest to C's "&".

    anyhow you can dereference a code reference in perl without the ampersand

    $ref->(), although I don't see how the question relevant.

    so any argument about what ampersand actually does in perl is debatable

    Not really. It can be used to bypass prototypes (&func(...)), to call a func with parent's args (&func;), to dereference a code ref (&$ref) and surely more. None of them return an address (like C's "&") or anything similar (like Perl's "\").

Re^4: typeglob/symbolic reference question
by chromatic (Archbishop) on Nov 04, 2010 at 19:12 UTC
    dereferencing is literally accessing something at the address pointed by variable value

    Not in any version of Perl. C pointers may be a fact of the implementation of Perl 5, but there is no language requirement for anything of the sort.

      I don't understand your disagreement. The quoted statement seems obvious to me. If your language can dereference, you have references, and if you have references, you have some form of addressing. Dereferencing is the act of finding what's referenced (pointed to) by that reference (address).

        I suppose the use of the word "addressing" sounds awfully much like raw pointers in C to me. I see what you mean; perhaps I'm drawing too fine a distinction.