Re: ptr conversions and values
- From: kuyper@xxxxxxxxxx
- Date: 20 Dec 2005 07:11:42 -0800
S.Tobias wrote:
> > S.Tobias wrote:
> > > kuyper@xxxxxxxxxx wrote:
....
> My view of correspondence (which I used to call "equivalence") is as
> in two parallel Universes: suppose in each one there is one copy of me
> and you. There's no way to move things between the two Universes (so
> talking about replacing things is nonsensical), yet in some circumstances
> we might be able to connect Me_1 with Me_2, and You_1 with You_2.
OK, then I would have to say that there is no such thing as a
correspondence, in the sense that you talk about, between integers and
memory locations. There is only a mapping, in the strict mathematical
sense: there's two different sets, and a relationship that connects
members of one set with members of the other set. The members of each
set that are connected to each other do not become, in any sense,
copies of each other just as result of defining that mapping. It is
quite possible to define a map that has one or more fixed points:
members of set 1 that happen to be the same as the corresponding
members of set 2. However, since there are no members of the set of
integers that are also members of the set of memory locations, the
concept of a fixed-point of the mapping is meaningless in this context.
You're essentially saying that every element in the first set is the
same as the corresponding element of the second set: every element is a
fixed point. That would require that both sets be the same set, which
isn't the case here. A mapping that makes such a correspondance is
called an identity mapping. Even between identical sets, there's only
one identity mapping, and a very large number of non-identity mappings.
> > I think you'll continue to have a very difficult time understanding
> > what my objection is, until you gain a clearer understanding of the
> > distinction between a symbol and it's referent.
> >
> Indeed, I still can't understand it.
Consider the difference between "James Kuyper" and the person who is
represented by the name "James Kuyper". In conventional English, I
might say "I am James Kuyper", but mathematically it's more accurate to
say that I'm the person referred to by the name "James Kuyper". Me and
my name are not interchangeable, one represents the other, and the
characteristics of the representation are in many ways quite different
from the characteristics of the thing represented.The name "James
Kuyper" doesn't have a wife; I do. I don't have a specified position
in alphabetical order, my name does.
....
> You can't put me into the database, because I live in a different world.
> If the database is to reflect our world, then we might define number 4
> to represent me (number 4 in the Database World corresponds to me in a
> Real World; it does not refer to me, it is an object in itself).
>
> Integers and pointers are like objects living in different worlds.
Yes, and the integer that represents a given memory location is not the
same as that memory location, any more than I am the same as the number
4 that represents me in your database.
....
> > > So you indeed do think that types must have the same nature to have the
> > > same representation. It's even stronger, you think they have to have
> > > a set of overlapping values (whatever this means).
> >
> > Your phrase "the same nature" is very vague - do complex numbers have
> > the same nature as integers?
> Did you mean `reals' here?
No. I was quite specific - I'm asking you if integers have the same
nature as complex numbers. I'm not sure what exactly you mean by "same
nature", so I'm testing your concept by giving you the most extremely
different pair of things I could think of that, in my opinion, could
meaningfully be required to have the same representation. The standard
could state that every complex object that represents a integer real
value from LONG_MIN to LONG_MAX must have the same representation as a
long integer representing the same value. The current C standard has no
such requirement. I think it would be a bad idea to impose such a
requirement. However, I do think you could meaningfully express that
very bad idea.
I don't think it's possible for a requirement that integers and memory
locations have the same representation to be meaningful.
> I think you tried to convince me that complex can have the same
> representation as an array of two reals, because complex values may be
> represented (consist of?) two reals, thus they have parts that have the
> same nature; integer and pointer can't as they are incongruous.
The real and imaginary parts of a complex number ARE real numbers, and
a pair of real numbers can uniquely identify any given complex number.
The representation of a complex number can therefore consist of the
representation of two real numbers. If you want to specify that those
two numbers must be stored contiguously with no gap between them, it's
meaningful to express that requirement by stating that the
representation is that same as that of an array of exactly two reals,
because such an array has those exact same requirements.
However, the complex number itself does not "consist" of two real
numbers. There is a conceptual structure on top of the simple pairing
that makes the pair a complex number. There's other conceptual
structures that could be added onto the pairing that would make them
something quite different from a complex number. For instance, the
product of two pairs could be (and in some computer languages, is)
defined as [pair1[0]*pair2[0], [pair1[1]*pair2[1]], which is quite
different from the definition of the product of two complex numbers.
> > A requirement that two types have the same representation for a set of
> > values is meaningful only if that set of values is a subset of each of
> > the two sets of values represented by those types.
> >
> I don't see this in the Standard. ...
It's a matter of mathematical definitions, which means it's outside the
scope of the C standard.
> ... Do pointers to different structs
> have a common subset of values (except the value null)? Or pointers to
> void and char? ...
Pointers represent memory locations. Any memory location that could be
the starting point of an object of type A, and could also be the
starting point of an object of type B, can indeed meaningly have the
same representation in the corresponding pointer types.
> ... I don't consider complex types and arrays of two reals,
> or imaginary and real, to have much in common (in terms of values).
> (Besides, imaginary values are basically a subset of complex type,
> thus how could they have the same representation as a single real and
> array of two reals at the same time?
It can't. However, you can require that the imaginary part of a
imaginary double object have the same representation as a real double,
with the real part being implied as 0. Alternatively, you could require
that imaginary types have the same representation as the corresponding
complex type, with the real part explicitly set to 0, which would take
up exactly twice as much space. But you can't use two different
representations for the same type simultaneously; you have to chose one
or the other.
> ... Shouldn't it be more logical for
> complex and imaginary to have the same representation?)
You could require imaginary and complex to have the same
representation. However, the whole point of having a distinct imaginary
type is that you can represent all pure imaginary values with a single
real value, rather than with a pair of real values. It saves a lot of
space, for those rare occasions when you're working with quantities
that are guaranteed to be pure imaginary. If you're going to require
same representation, there's no point in having a distinct type for it.
> [ BTW: from 6.2.5p20: "A pointer type describes an object whose value
> provides a reference to an entity of the referenced type." What entity
> does a pointer to void provide a reference to? ]
Pointers to void, like null pointers, are a special case. Ideally,
every statement in the standard would be written so it remains
meaningful and true when applied to such special cases. This is an
example of a case where that ideal hasn't been met. I don't believe you
can derive any meangful conclusion from that fact.
.
- References:
- Re: ptr conversions and values
- From: S.Tobias
- Re: ptr conversions and values
- Prev by Date: Re: structure component overwrite
- Next by Date: Re: structure component overwrite
- Previous by thread: Re: ptr conversions and values
- Next by thread: void* conversion paragraph redundant?
- Index(es):
Relevant Pages
|
Loading