473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Pointer Analogies

After sooo many years, I've just re-read Tracy Kidder's The Soul of a New
Machine - the guy really knows how to explain things to the lay reader [thus
the Pulitzer]! E.g., an abridged extract on addressing/memory:

". the main issue was the computer's storage system. The situation resembles
that of a region's telephone system; telephones are of no use unless they
are distinct one from the other, and an item in a computer's storage system
is of no use unless it can easily be found. The general solution resembles
the phone company's; each compartment in the computer's storage has its own
'phone number,' its own unique symbol, known as an address"

When I read that I started to think if there was some 'real-world' analogy I
could use to initially discuss *pointers* in C.

On the telephone theme, I started thinking about mobile phones and wondered
whether I could use a person's number as a kind of pointer-to-person thing.
I also thought about email addresses. However, my phone number doesn't get
to 'me', it get's to my mobile - same for my email address [of which I have
many - which can 'work' here of course: many pointers to the same object].

Having rejected these though, I thought about things like ISBN, and book
[Dewey Decimal] references, e.g., 127.56.3 in our library points to K&R
[which is always there]. Dewey references - being very similar to IP
addresses, I thought about IP addresses directly, but stuck with DNS
resolved addresses e.g., using something like:

BBC * www.bbc.co.uk //A pointer to the BBC - um?

Ok, it doesn't give me *the* BBC, but a page on the BBC's website - but you
get the idea?

The website/URL thing does have one added bonus, in that pointer to
pointers - if this analogy holds - can also be factored in i.e., say, you go
to a website and find that it's moved, and that the old pages re-direct you
to the new website, e.g., by dereferencing the initial URL the
data/'information' you get is another URL which when dereference gets you to
the website you're looking for.

Anyway, I'd be interested in hearing what others think about these
analogies, and whether they think they're 'close enough' to form an initial
hook into the function of pointers. Of course, better analogies form the
real-world would be very welcome, esp. if they allow different references to
'point' to the same object [like email addresses], and, at the same time,
can be used to get the pointer-to-pointer concept across.
--
==============
Not a pedant
==============
Jul 26 '06 #1
6 2654
On 2006-07-26, pemo <us***********@gmail.comwrote:
After sooo many years, I've just re-read Tracy Kidder's The Soul of a New
Machine - the guy really knows how to explain things to the lay reader [thus
the Pulitzer]! E.g., an abridged extract on addressing/memory:

". the main issue was the computer's storage system. The situation resembles
that of a region's telephone system; telephones are of no use unless they
are distinct one from the other, and an item in a computer's storage system
is of no use unless it can easily be found. The general solution resembles
the phone company's; each compartment in the computer's storage has its own
'phone number,' its own unique symbol, known as an address"

When I read that I started to think if there was some 'real-world' analogy I
could use to initially discuss *pointers* in C.

On the telephone theme, I started thinking about mobile phones and wondered
whether I could use a person's number as a kind of pointer-to-person thing.
I also thought about email addresses. However, my phone number doesn't get
to 'me', it get's to my mobile - same for my email address [of which I have
many - which can 'work' here of course: many pointers to the same object].

Having rejected these though, I thought about things like ISBN, and book
[Dewey Decimal] references, e.g., 127.56.3 in our library points to K&R
[which is always there]. Dewey references - being very similar to IP
addresses, I thought about IP addresses directly, but stuck with DNS
resolved addresses e.g., using something like:

BBC * www.bbc.co.uk //A pointer to the BBC - um?

Ok, it doesn't give me *the* BBC, but a page on the BBC's website - but you
get the idea?

The website/URL thing does have one added bonus, in that pointer to
pointers - if this analogy holds - can also be factored in i.e., say, you go
to a website and find that it's moved, and that the old pages re-direct you
to the new website, e.g., by dereferencing the initial URL the
data/'information' you get is another URL which when dereference gets you to
the website you're looking for.

Anyway, I'd be interested in hearing what others think about these
analogies, and whether they think they're 'close enough' to form an initial
hook into the function of pointers. Of course, better analogies form the
real-world would be very welcome, esp. if they allow different references to
'point' to the same object [like email addresses], and, at the same time,
can be used to get the pointer-to-pointer concept across.
I suppose that if you considered each /phone/ to be a memory location, you
could go back to using phone numbers as an analogy. I liked that one.

However, I learned pointers from an assembler manual, so I'm probably not
a very good layperson. :-)

--
Andrew Poelstra <website down>
My server is down; you can't mail
me, nor can I post convieniently.
Jul 26 '06 #2
pemo wrote:
After sooo many years, I've just re-read Tracy Kidder's The Soul of a New
Machine - the guy really knows how to explain things to the lay reader [thus
the Pulitzer]! E.g., an abridged extract on addressing/memory:

". the main issue was the computer's storage system. The situation resembles
that of a region's telephone system; telephones are of no use unless they
are distinct one from the other, and an item in a computer's storage system
is of no use unless it can easily be found. The general solution resembles
the phone company's; each compartment in the computer's storage has its own
'phone number,' its own unique symbol, known as an address"

When I read that I started to think if there was some 'real-world' analogy I
could use to initially discuss *pointers* in C.
Lewis Carroll gave a very droll illustration of objects, pointers and
variables in C, in terms only *somewhat* real-world. Still, considering the
fact that he wrote it for children, and before C existed, it's quite a good
show.

Lewis Carroll wrote:
'You are sad,' the Knight said in an anxious tone: 'let me sing you a
song to comfort you.'

'Is it very long?' Alice asked, for she had heard a good deal of poetry
that day.

'It's long,' said the Knight, 'but very, VERY beautiful. Everybody that
hears me sing it--either it brings the TEARS into their eyes, or else--'

'Or else what?' said Alice, for the Knight had made a sudden pause.

'Or else it doesn't, you know. The name of the song is called "HADDOCKS'
EYES."'

'Oh, that's the name of the song, is it?' Alice said, trying to feel
interested.

'No, you don't understand,' the Knight said, looking a little vexed.
'That's what the name is CALLED. The name really IS "THE AGED AGED
MAN."'

'Then I ought to have said "That's what the SONG is called"?' Alice
corrected herself.

'No, you oughtn't: that's quite another thing! The SONG is called "WAYS
AND MEANS": but that's only what it's CALLED, you know!'

'Well, what IS the song, then?' said Alice, who was by this time
completely bewildered.

'I was coming to that,' the Knight said. 'The song really IS "A-SITTING
ON A GATE": and the tune's my own invention.'
One way of reading it is to substitute "object" for "song", "pointer" for
"name" and "what the variable holding it is called" for "is called":

The pointer to the object is in a variable called "HADDOCKS' EYES".
The pointer (i.e. its value) really is "THE AGED AGED MAN".
The object is in a variable called "WAYS AND MEANS".
The object really is "A-SITTING ON A GATE".

S.
Jul 26 '06 #3

pemo wrote:

[snip]
>
On the telephone theme, I started thinking about mobile phones and wondered
whether I could use a person's number as a kind of pointer-to-person thing.
I also thought about email addresses. However, my phone number doesn't get
to 'me', it get's to my mobile - same for my email address [of which I have
many - which can 'work' here of course: many pointers to the same object].
[snip]
>
Anyway, I'd be interested in hearing what others think about these
analogies, and whether they think they're 'close enough' to form an initial
hook into the function of pointers. Of course, better analogies form the
real-world would be very welcome, esp. if they allow different references to
'point' to the same object [like email addresses], and, at the same time,
can be used to get the pointer-to-pointer concept across.
Well, there's stuff like call-forwarding; you set it up so that when
people dial number A, the call is actually sent to number B. That's
probably the closest phone-based real-world analogy I can think of.

Jul 26 '06 #4
Skarmander <in*****@dontmailme.comwrites:
[...]
Lewis Carroll gave a very droll illustration of objects, pointers and
variables in C, in terms only *somewhat* real-world. Still, considering the
fact that he wrote it for children, and before C existed, it's quite a good
show.

Lewis Carroll wrote:
>'You are sad,' the Knight said in an anxious tone: 'let me sing you a
song to comfort you.'

'Is it very long?' Alice asked, for she had heard a good deal of poetry
that day.

'It's long,' said the Knight, 'but very, VERY beautiful. Everybody that
hears me sing it--either it brings the TEARS into their eyes, or else--'

'Or else what?' said Alice, for the Knight had made a sudden pause.

'Or else it doesn't, you know. The name of the song is called "HADDOCKS'
EYES."'

'Oh, that's the name of the song, is it?' Alice said, trying to feel
interested.

'No, you don't understand,' the Knight said, looking a little vexed.
'That's what the name is CALLED. The name really IS "THE AGED AGED
MAN."'

'Then I ought to have said "That's what the SONG is called"?' Alice
corrected herself.

'No, you oughtn't: that's quite another thing! The SONG is called "WAYS
AND MEANS": but that's only what it's CALLED, you know!'

'Well, what IS the song, then?' said Alice, who was by this time
completely bewildered.

'I was coming to that,' the Knight said. 'The song really IS "A-SITTING
ON A GATE": and the tune's my own invention.'

One way of reading it is to substitute "object" for "song", "pointer" for
"name" and "what the variable holding it is called" for "is called":

The pointer to the object is in a variable called "HADDOCKS' EYES".
The pointer (i.e. its value) really is "THE AGED AGED MAN".
The object is in a variable called "WAYS AND MEANS".
The object really is "A-SITTING ON A GATE".
I think Lewis Carroll (I haven't seen him posting here lately; what
happened to him?) actually got one detail wrong. The Knight should
have said "The song really IS" and then started singing it. (I think
Martin Gardner pointed this out in _The Annotated Alice_.)

Your last statement:
The object really is "A-SITTING ON A GATE".
would be correct given:
char WAYS_AND_MEANS[] = "A-SITTING ON A GATE";

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 26 '06 #5
Keith Thompson wrote:
Skarmander <in*****@dontmailme.comwrites:
[...]
>Lewis Carroll gave a very droll illustration of objects, pointers and
variables in C, in terms only *somewhat* real-world. Still, considering the
fact that he wrote it for children, and before C existed, it's quite a good
show.

Lewis Carroll wrote:
>>'You are sad,' the Knight said in an anxious tone: 'let me sing you a
song to comfort you.'

'Is it very long?' Alice asked, for she had heard a good deal of poetry
that day.

'It's long,' said the Knight, 'but very, VERY beautiful. Everybody that
hears me sing it--either it brings the TEARS into their eyes, or else--'

'Or else what?' said Alice, for the Knight had made a sudden pause.

'Or else it doesn't, you know. The name of the song is called "HADDOCKS'
EYES."'

'Oh, that's the name of the song, is it?' Alice said, trying to feel
interested.

'No, you don't understand,' the Knight said, looking a little vexed.
'That's what the name is CALLED. The name really IS "THE AGED AGED
MAN."'

'Then I ought to have said "That's what the SONG is called"?' Alice
corrected herself.

'No, you oughtn't: that's quite another thing! The SONG is called "WAYS
AND MEANS": but that's only what it's CALLED, you know!'

'Well, what IS the song, then?' said Alice, who was by this time
completely bewildered.

'I was coming to that,' the Knight said. 'The song really IS "A-SITTING
ON A GATE": and the tune's my own invention.'
One way of reading it is to substitute "object" for "song", "pointer" for
"name" and "what the variable holding it is called" for "is called":

The pointer to the object is in a variable called "HADDOCKS' EYES".
The pointer (i.e. its value) really is "THE AGED AGED MAN".
The object is in a variable called "WAYS AND MEANS".
The object really is "A-SITTING ON A GATE".

I think Lewis Carroll (I haven't seen him posting here lately; what
happened to him?) actually got one detail wrong. The Knight should
have said "The song really IS" and then started singing it. (I think
Martin Gardner pointed this out in _The Annotated Alice_.)
Obviously Carroll is alluding to the possibility of multiple representations
for the same value, which C explicitly allows. I must confess I have a hard
time imagining a real-world system where a few words are equivalent to a
piece of music, but a dearth of imagination is not a proof of nonexistence.

Of course, if multiple representations are the issue here, the "really is"
should be take more liberally as "one possible representation of the value is".

The book would presumably have been cut short if the Knight had generated a
trap representation.

S.
Jul 26 '06 #6
Skarmander <in*****@dontmailme.comwrites:
Keith Thompson wrote:
>Skarmander <in*****@dontmailme.comwrites:
[...]
>>The pointer to the object is in a variable called "HADDOCKS' EYES".
The pointer (i.e. its value) really is "THE AGED AGED MAN".
The object is in a variable called "WAYS AND MEANS".
The object really is "A-SITTING ON A GATE".
I think Lewis Carroll (I haven't seen him posting here lately; what
happened to him?) actually got one detail wrong. The Knight should
have said "The song really IS" and then started singing it. (I think
Martin Gardner pointed this out in _The Annotated Alice_.)
Obviously Carroll is alluding to the possibility of multiple
representations for the same value, which C explicitly allows. I must
confess I have a hard time imagining a real-world system where a few
words are equivalent to a piece of music, but a dearth of imagination
is not a proof of nonexistence.

Of course, if multiple representations are the issue here, the "really
is" should be take more liberally as "one possible representation of
the value is".

The book would presumably have been cut short if the Knight had
generated a trap representation.
Not necessarily. Generating (or using) a trap representation merely
invokes undefined behavior. It's possible that the entire book is a
result of this. (Much more pleasant than the usual nasal demons.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: 3seas | last post by:
If you are not interested, then don't bitch, its a short message. http://www.matrixcommunity.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=8;t=000918 I don't know if that link got broken. -- 3...
4
by: Carsten Spieß | last post by:
Hello all, i have a problem with a template constructor I reduced my code to the following (compiled with gcc 2.7.2) to show my problem: // a base class class Base{}; // two derived...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
35
by: tuko | last post by:
Hello kind people. Can someone explain please the following code? /* Create Storage Space For The Texture */ AUX_RGBImageRec *TextureImage; /* Line 1*/ /* Set The Pointer To NULL...
16
by: junky_fellow | last post by:
According to Section A6.6 Pointers and Integers (k & R) " A pointer to one type may be converted to a pointer to another type. The resulting pointer may cause addressing exceptions if the...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
16
by: aegis | last post by:
Given the following: int a = 10; int *p; void *p1; unsigned char *p2; p = &a;
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.