30

Why is dereferencing called dereferencing?

I'm just learning pointers properly, and I'd like to know why dereferencing is called that. It confused me as it sounds like you are removing a reference, rather than going via the pointer to the destination.

Can anyone explain why it is called this?

To me something like destination or pointed_to_value would make more sense.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
  • 3
    Destination and pointed-to value are nouns... you're asking about the verb in the title. :-) – Platinum Azure May 26 '10 at 18:51
  • I agree - it's never made any sense to me either why it's called that. I would prefer it if it were called 'following' or somesuch. – Robert Tuck May 26 '10 at 19:01
  • I think your refering to the right direciton I was looking for. Is the word dereferencing a purely CS term? Without using that word in my life aside from this, I tried to assume what it ment, which is where I went wrong I think! Is it a word only used for this situation? Are there other examples where you would use this term? – Chris Barry May 26 '10 at 19:03
  • 1
    Just to confuse matters, the Windows kernel uses "dereference" to mean "decrement reference count": http://msdn.microsoft.com/en-us/library/ff557724%28VS.85%29.aspx – bk1e May 26 '10 at 22:03
  • @PlatinumAzure `getting` still feels more appropriate to me – Coder Dec 20 '20 at 03:03

3 Answers3

44

A pointer refers to an object. Ergo, we dereference the pointer (or, get the referent of the pointer) to get the object pointed-to.

The de- prefix most likely comes from the Latin preposition meaning from; I suppose you could think of dereference as meaning "to obtain the referent (or object) from the reference."

James McNellis
  • 348,265
  • 75
  • 913
  • 977
12

Dereferencing means taking away the reference and giving you what it was actually referring to.

A pointer to something really means that your pointer variable holds a memory address of something. But the pointer can also be thought of as a reference to something instead.

Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
  • Is it a purely cs term, or can you think of another situation where you would use the same word? – Chris Barry May 26 '10 at 19:05
  • There's thousands of CS terms that aren't used in "the real world" – Adam May 26 '10 at 19:30
  • It sounded like it did some to do with making a pointer null, rather than finding something at the end of it. I think I thought that because I thought it sounded like a word that could exist in the real world. – Chris Barry May 26 '10 at 19:32
3

Wiktionary only contains definitions related to programming: http://en.wiktionary.org/wiki/dereference

So it looks like it's really just technical jargon.

Francis Gagné
  • 60,274
  • 7
  • 180
  • 155