Why pointers can only be subtracted ?

C

Chris Croughton

Chris Croughton said:
Consider the addresses 1562 Ram Street and 1838 Ram Street.

[...]

But if we subtract one from the other, we get 276 - the number
of houses you'd have to walk past to get from one to the other
(including one of the end points). This turns out to be a
useful number.

You must live in a place with a different approach to addresses.
By the e-address, infobahn is in Britain, where adresses di often work
like that (although more of them are word addresses, incrementing by two
with odd bytes -- er, houses -- on one side and even ones on the other).

You mean it doesn't work like that everywhere?

Nope. Even in the UK some streets are numbered with consecutive numbers
up one side and back down the other:

1 2 3 4 5 6 7 8 9 10
20 19 18 17 16 15 14 13 12 11

There are also some with big gaps in addresses, or where two houses are
now where there was once one (21a, 21b). In some roads number 13 is
missing.

In some US cities they are numbered by 'blocks', with each block
starting on a multiple of 100 (or a multiple of 100 plus 1) or so, but
not going all of the way to x99.

There are also some places (like the village in Wales where my mother
lives) where some streets have no numbers for the houses, they are
addressed by a string (the house name).

I have noticed that they say that they compile telephone directories,
however, but it must be a cross-compiler. At least, I'd be cross --
maybe furious -- if I had to compile it <g>...

Chris C
 
C

CBFalconer

Michael said:
.... snip ...

No, you can for example have real fun in Ireland... The addresses
sometimes start with 1 .. n on one side of the street and continue
from the "n" end with n+k .. max back to the house opposite no 1.
Even better though _very_ seldom, here in Germany: Some old
villages where the houses are numbered in the order they have been
built in :) Dunno what is happening on the left side on the pond...

We have some areas here in Connecticut that do just that - order of
building, etc. Drives you nuts when you are trying to find an
address. Of course, the houses aren't labelled.
 
M

Michael Wojcik

You mean it doesn't work like that everywhere?

In Japan, there's typically no obvious relationship between building
numbers and their relative spacial arrangement. I have a map of
Fuji-shi somewhere; it shows street numbers for many of the buildings,
because otherwise you'd have to search the whole street to find the
one you're looking for.

I suspect that numbers are just assigned as buildings are built (or
registered for postal delivery or something), but I've never looked
into it. Just part of the fun of modern Japanese life.

Actually, the "incrementing by two" certainly isn't true even in a
lot of places that use the "even on one side, odd on the other"
rule. In the Massachusetts towns I lived in numbers were generally
consecutive-odd on one side and consecutive-even on the other, but
here in Michigan (and in Ohio) they generally seem to use larger
and irregular increments. It's probably based on distances in some
fashion (house N+M is M somethings from house N).

--
Michael Wojcik (e-mail address removed)

[After the lynching of George "Big Nose" Parrot, Dr. John] Osborne
had the skin tanned and made into a pair of shoes and a medical bag.
Osborne, who became governor, frequently wore the shoes.
-- _Lincoln [Nebraska] Journal Star_
 
E

Eric Sosman

Michael said:
[...]
Actually, the "incrementing by two" certainly isn't true even in a
lot of places that use the "even on one side, odd on the other"
rule. In the Massachusetts towns I lived in numbers were generally
consecutive-odd on one side and consecutive-even on the other, but
here in Michigan (and in Ohio) they generally seem to use larger
and irregular increments. It's probably based on distances in some
fashion (house N+M is M somethings from house N).

Even here in Massachusetts the numbering isn't always
consecutive. In many urban areas each block starts a new
batch of numbers -- typically a new batch of a hundred --
so a sequence of numbers along the even side of a street
might be 1750, 1752, 1756, look both ways before crossing,
1800, 1802, ...

In less heavily settled areas, the numbers may be based
on distance from a reference point. The houses on the street
where I grew up bear numbers that give their distances in
ten-foot increments (10 feet ~= 3 meters) from the fire
station that protects that section of town. Now, *there's*
a pointer subtraction with direct practical application!
 
M

Mark McIntyre

Actually, the "incrementing by two" certainly isn't true even in a
lot of places that use the "even on one side, odd on the other"
rule. In the Massachusetts towns I lived in numbers were generally
consecutive-odd on one side and consecutive-even on the other, but
here in Michigan (and in Ohio) they generally seem to use larger
and irregular increments. It's probably based on distances in some
fashion (house N+M is M somethings from house N).

In the UK, the rule used to be "a house is 5 yards wide, so every 5 yards
you have a house number". If a house was built wider, or stole the plot
next door for gardens, the number of the "wider" bit got missed out. Also
its common nowadays to run up one side of a street and down teh other. Or
to start odds at the end of the street, and evens in the middle (if eg
there used to be a park on the rest of it). Gah. I'm in 93, my neighbours
either side are 91 and 99 (with a gap between us, no prizes for working out
how wide...), but the nearest houses opposite are 6 and 10, with 2 and 4
being about a quarter of a mile away, past the sports ground....
 
J

Joe Wright

CBFalconer said:
Michael Mair wrote:

... snip ...



We have some areas here in Connecticut that do just that - order of
building, etc. Drives you nuts when you are trying to find an
address. Of course, the houses aren't labelled.
If they were labelled you could just goto them. :)
 
R

Richard Tobin

Michael Mair said:
No, you can for example have real fun in Ireland... The addresses
sometimes start with 1 .. n on one side of the street and continue
from the "n" end with n+k .. max back to the house opposite no 1.

That's common here as well.

There's a big street, built probably at the end of the 19th century,
near where I used to live in Birmingham that has houses with names in
alphabetical order. Or at least the first letter of the names.

Numbers were added to them later.

-- Richard
 
A

Albert van der Horst

Pointers are like numbers that denote positions on a
scale of some kind. It makes sense to subtract two such
positions to find the interval between them, and it makes
sense to add two intervals, or to add a position and an
interval. But it doesn't make sense to add two positions;
one can only do so by agreeing on a zero reference and then
converting one or both positions to intervals.

Actually mathematicians can make sense of anything.
They define and use a Cartesian product of (in this case) group.
It is a bit like cheating.
What is the sum of 2 apple and 3 oranges. Well, it is ...
2 apples and 3 oranges. You can add 1 orange in the obvious
way, but actually the apples and oranges never get mixed up.

The C equivalent would be
struct {
int apple;
int orange;
}

These structs can be added in a meaningful way, which is
left as an exercise to the reader. (Hint, don't mix apples
and oranges.). For the advanced reader, how would the
mathematician go about multiplying these structs?


--
 
M

Mabden

Richard Tobin said:
That's common here as well.

There's a big street, built probably at the end of the 19th century,
near where I used to live in Birmingham that has houses with names in
alphabetical order. Or at least the first letter of the names.

Numbers were added to them later.

In the quaint city of Carmel, California there are no numbers or names.
Well, some people name their houses, of course, but nothing official. To
describe an "address" you refer to the nearest cross street. So it's
like, "Second house from the North West corner of Carmelo and 7th."

They don't get mail at the house, however, they all have to use post
office boxes.

Side note: I forget the name of Clint Eastwood's house, but I have had
it pointed out to me. The high walls have broken glass shards embedded
in the concrete along the top of the wall. Nice touch.
 
R

Richard Bos

Mabden said:
In the quaint city of Carmel, California there are no numbers or names.
Well, some people name their houses, of course, but nothing official. To
describe an "address" you refer to the nearest cross street. So it's
like, "Second house from the North West corner of Carmelo and 7th."

And the fun bit is, the analogous computer architecture address would
probably still be encodable as a C pointer.
Side note: I forget the name of Clint Eastwood's house, but I have had
it pointed out to me. The high walls have broken glass shards embedded
in the concrete along the top of the wall. Nice touch.

Standard practice in some parts. It's less obviously plebeian than
barbed wire.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top