size of pointers

R

Random832

2006-12-20 said:
Richard Bos a écrit :

Yes, there could be computers where addresses are complex numbers
Or floating point numbers.

Or where they are not numbers of any kind.
 
R

Random832

2006-12-20 said:
Richard Heathfield a écrit :

How can you subtract two non integers and obtain an integer?

Can you explain that with all your rubbish???

Pointer subtraction:

pointer - pointer --> integer

pointer + integer --> pointer

pointer - integer --> pointer

If pointer would NOT be of integer type this could
never work.

False. hint: pointer arithmetic may not be implemented with simple
ADD/SUB instructions.
 
R

Random832

2006-12-20 said:
How can you subtract two non integers and obtain an integer?

Can you explain that with all your rubbish???

Pointer subtraction:

pointer - pointer --> integer

pointer + integer --> pointer

pointer - integer --> pointer

If pointer would NOT be of integer type this could
never work.

Sorry for posting twice, but...

You know all about operator overloading, right? Think of this as
operator overloading. It's not _really_ addition, it just looks like it
- just like in c++, cout << x isn't _really_ a left shift.
 
R

Random832

2006-12-20 said:
Richard Heathfield a écrit :

This is the whole disagreement. Ok, it has costed us a certain time but
now we are at the heart of it.

No. The segment is not part of the integer that I am referring to.

Now we're getting somewhere - you see, the segment, where such things
are used, _IS_ part of a pointer. Therefore a pointer is not the same
thing as an integer.
 
J

jacob navia

Random832 said:
Now we're getting somewhere - you see, the segment, where such things
are used, _IS_ part of a pointer. Therefore a pointer is not the same
thing as an integer.

My argument is that it is variable what the "segment" part is.
As I explained in my previous message it depends on which context
you are interested in.

which segment, which process, which machine, etc etc.

Address would become a "variable length" stuff.

I use the address as the integer that numbers the consecutive
memory locations, and the rest is a "prefix", that is dependent
on your interests/context/whatever.
 
K

Keith Thompson

jacob navia said:
Richard Bos a écrit :

Yes, there could be computers where addresses are complex numbers
Or floating point numbers.

Unlikely, but possible. We've been talking about more realistic
possibilities.
So you would access to the address 4677655.2 ...

Addresses are consecutive integers starting with some base offset or
segment. The segment can be implicit, or ignored, etc. There are
many variations, but in ALL cases they are integers numbering
consecutive memory locations.

Or the segment is an *explicit* part of the address.

An address can be a combination of segment (perhaps a number, perhaps
some other indication) *and* an offset within that segment. That
combination is not an integer; it's not even a number. The offset by
itself is not an address.

In the example from upthread, DS:0400 is an address, and is not a
number; 0400 is a number, but is not an address. You seem to be
determined to ignore the distinction.

And that's just one simple possibility.
 
K

Keith Thompson

jacob navia said:
Richard Heathfield a écrit :

How can you subtract two non integers and obtain an integer?

By using pointer subtraction.
Can you explain that with all your rubbish???

Pointer subtraction:

pointer - pointer --> integer

pointer + integer --> pointer

pointer - integer --> pointer

If pointer would NOT be of integer type this could
never work.

If a pointer *were* of integer type, you could add two pointers, or
multiply two pointers.

The language provides a limited set of arithmetic operators that
operate on pointer values. That doesn't make them numbers.
 
K

Keith Thompson

jacob navia said:
Richard Heathfield a écrit :

This is the whole disagreement. Ok, it has costed us a certain time but
now we are at the heart of it.

No. The segment is not part of the integer that I am referring to.

In the case of my address, Maurice Ravel would not suffice since
there is ALSO a Maurice Ravel street in Montmagny, the next town
after Villetaneuse, where I live. And then, you have to take the
country in consideration etc.

In machine addresses, we have

segment:address, but... which segment?

Code segment, say.

Ok, but that is meaningful only within a certain process. And that is
meaningful only within a certain machine... etc etc.

Using the notation popularized with the web, we could also say
that

address://www.hearthfield.com/home/utilities/backup:CODE_SEGMENT:447766555

is an address. The meaning is to name a particular machine
in a particular configuration that runs the "backup" executable.

But WHICH part is necessary?
It depends on the context. You can say that within the context of a
process, the whole part until the second
':' is not necessary, because all that is implicit.

Within the context of a network, an address could be given a different
prefix.

If you take the prefix within the address, there is no end to the
prefixes you would need, and they change from context to context.

For this reason, I leave the "prefix" OUT of the integer, and retain
just the offset within the segment (obejct).

A complex number is just a real number, if you leave out the imaginary
part. Therefore, complex numbers are just real numbers.

Explain how this line of reasoning for complex numbers differs from
yours for pointers.
 
M

Mark McIntyre

Addresses are consecutive integers starting with some base offset or
segment.

Translation for the confused:

Jacob has only encountered machines whose addressing scheme is as
stated above, and he mistakes this for fact. This despite being given
real-world counterexamples.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

How can you subtract two non integers and obtain an integer?

Newsflash: its possible to subtract lots of non-integer types from
each other, eg floats from other floats, and get an integer result.

If pointer would NOT be of integer type this could
never work.

*sigh*
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Chris Dollin a écrit :

This are boundary conditions,

You asked how one could subtract two non integers to obtain an
integer. You were answered.
since float - float doesn't always
yield an integer. Pointer - pointer yields ALWAYS an integer,

This merely tells you that all pointers are members of a set of values
which meets this condition.
See above. CAN BE, but it is not ALWAYS.

So we agree that pointers CAN be represented as polynomials, provided
they meet this condition, which we agree is perfectly possible.
Excuse me but when I come to the railway station I am assigned
an integer by the machine. That integer is my turn. The
employees call the integers aloud, then when I hear my integer
I go to the employee selling the tickets and do my transaction.

When I go to the hospital, I'm assigned a colour and a number by the
receptionist. When a nurse calls out my colour/number combination, I
go to her window.

Does this mean colours are integers?

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Similarly, if you remove all the parts of a floating point value that are
not an integer value, what remains (if anything) is an integer value.

And if you remove all the parts of a coffee mug that are not an integer
value, what remains (if anything) is an integer value.

That does not mean that pointers, floating point values, and coffee mugs are
integers.

ROFL!! I'm jolly glad /my/ coffee mug was empty when I read that,
otherwise I'd be phoning Santa to ask for a new, less
coffee-splattered, screen...

:)
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard Bos

jacob navia said:
Richard Bos a écrit :

My address is the integer 41.

So if I send a letter to "41, France" it will arrive at your place?
Offset from the start of the Maurice Ravel segment.

If I need that information to identify your house, it is part of the
address.
Consecutive memory locations are assigned consecutive integers
within the same segment (or "object", as you wish) of memory.

And how do the addresses of these separate objects (no "as I wish", by
the way; time for you to read the Standard for a change) map to
integers?
Obviously you think that if you do not call them integers but
"pointers" and hide some cloack of "mystery" around those
integers things will improve.

Obviously I have more experience than you, yes.
Be it. Your opinion is different than mine.

Your opinion is worth less than what's stuck on the sole of my shoe. So
is mine. The Standard defines the C language, not your arrogance.

Richard
 
A

av

jacob navia said:
Richard Heathfield a écrit :
Yes they are
Here's a counter-example:

#include <stdio.h>

int main(void)
{
int i = 42;
void *p = &i;
printf("[%p]\n", p);
return 0;
}

Output:

[DS:0400]

Are you arguing that DS:0400 is an integer?

no but pointers are numbers, they are coordinates that
find a memory location

because i don't imagine why i have the need of more than 1 coordinate
for identify a memory location, yes pointers are integers

i can say above printf is bugged because not print:
[12:3456]
Marry Christmas
 
R

Richard Heathfield

av said:
On Tue, 19 Dec 2006 10:46:29 +0000, Richard Heathfield wrote:
Output:

[DS:0400]

Are you arguing that DS:0400 is an integer?

no but pointers are numbers,

Wrong. It is true that, if you take away all the parts of a pointer that are
not a number, then what remains (if anything) is a number. But that does
not mean pointers are numbers.
they are coordinates that find a memory location

You might describe them thus if you like, but that doesn't make them numbers
either.
because i don't imagine why i have the need of more than 1 coordinate
for identify a memory location, yes pointers are integers

Computer hardware designers are not limited by your imagination.
i can say above printf is bugged because not print:
[12:3456]

You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for printf("[%p]\n",
p).
Marry Christmas

No, thank you - I am already happily married.
 
A

av

av said:
Output:
[DS:0400]

Are you arguing that DS:0400 is an integer?

no but pointers are numbers,

Wrong. It is true that, if you take away all the parts of a pointer that are
not a number, then what remains (if anything) is a number. But that does
not mean pointers are numbers.

for the above example
it should be a 16 bits x86 cpu
"DS" should be a 16bits register. pointer i speak should be the 20
bits integer (int20bits)((ds<<4)|0400)
printf has to write it in the output
You might describe them thus if you like, but that doesn't make them numbers
either.

you "describe"

i don't "describe" i write "the definition"

you and other appear confuse about the definition of pointers
it seems all you not have one... :))))))
Computer hardware designers are not limited by your imagination.

one integer of appriopriate dimension can find every momery location

why you all want more dimension for find the momory location?
Do you like to do hard what it is easy?
i can say above printf is bugged because not print:
[12:3456]

You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for printf("[%p]\n",
p).

could be legal don't know
No, thank you - I am already happily married.

excuse me, is it better
"Merry Christmas"
?
 
R

Richard Heathfield

av said:
av said:
Output:
[DS:0400]

Are you arguing that DS:0400 is an integer?

no but pointers are numbers,

Wrong. It is true that, if you take away all the parts of a pointer that
are not a number, then what remains (if anything) is a number. But that
does not mean pointers are numbers.

for the above example
it should be a 16 bits x86 cpu
"DS" should be a 16bits register. pointer i speak should be the 20
bits integer (int20bits)((ds<<4)|0400)
printf has to write it in the output

No, it doesn't have to do any such thing. It is up to each implementor to
choose the way he or she considers best for representing a pointer value.
you "describe"

i don't "describe" i write "the definition"

It is the C Standard which defines pointers, not anything you or I might
write.
you and other appear confuse about the definition of pointers

Not in the slightest.

one integer of appriopriate dimension can find every momery location

Maybe on your platform that is true, but this does not make it true for
every platform.

why you all want more dimension for find the momory location?
Do you like to do hard what it is easy?

Reality isn't always as simple as we'd like it to be. Real machines do exist
on which a simple integer is insufficient to represent a pointer value.

i can say above printf is bugged because not print:
[12:3456]

You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for
printf("[%p]\n", p).

could be legal don't know

It is, and that is sufficient to defeat your claim.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top