Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #27648

Re: Compatibility question

From Steve Thompson <stevet810@gmail.com>
Newsgroups comp.lang.c
Subject Re: Compatibility question
Date 2012-10-24 20:20 +0000
Organization Friends of the Galactic Collective
Message-ID <LAWkIU.3db.huHtX@gmail.com> (permalink)
References (5 earlier) <0.5ef6d4d4944842791bc8.20121022210639BST.87pq4a9sq8.fsf@bsb.me.uk> <ap54B1.hSk.bor8X@gmail.com> <lnr4opdm7m.fsf@nuthaus.mib.org> <VTQKnL.Au1.NMBnf@gmail.com> <lnzk3cvlzy.fsf@nuthaus.mib.org>

Show all headers | View raw


On Tue, Oct 23, 2012 at 03:53:21PM -0700, Keith Thompson wrote:
> Steve Thompson <stevet810@gmail.com> writes:
> > On Tue, Oct 23, 2012 at 12:26:05PM -0700, Keith Thompson wrote:
> >> Steve Thompson <stevet810@gmail.com> writes:
> >> > On Mon, Oct 22, 2012 at 09:06:39PM +0100, Ben Bacarisse wrote:
> >> [...]
> >> >> Whatever goes on under the hood (and I'd dispute that 'a' is "really a
> >> >> pointer") it's much easier to learn a language in its own terms, at
> >> >> least as far as that's possible.
> >> >
> >> > Well, no.  'a' is never a pointer as such in the terms of the language
> >> > syntax, but its treatment by the compiler internally is nominally
> >> > equivalent to they way it handles a pointer, with the exception that
> >> > the language grammar forbids its use in the program text as a pointer.
> >> 
> >> I don't believe that's true.  Do you have some evidence that it is?
> >
> > The distinction is largely moot.  In a practical sense, all variables
> > have a value which is stored somewhere.  The compiler is making an
> > explicit use of a pointer when it does something with the value.  The
> > problem is that "use" in this context may as well be referring to ether
> > or memory and there's no easy way of knowing which it is.
> 
> When you say "explicit use of a pointer", do you mean that there's
> a pointer *object* somewhere, or are you talking about a pointer
> *value*, also known as an "address"?

I suppose address is the better term, but that does not work for
registers.
 
> How much do you know about the internal workings of compilers?

Precious little.  My brain is only starting to think about
interpreters; I plan to hold off polluting my brain with compiler
internals until I find a pressing need to write one.

> >> > In a simplistic sense, all variables are pointers to a segment of
> >> > program data, modifiable or otherwise.
> 
> No, a variable is not a pointer to a chunk of memory, it *is* a chunk of
> memory (which can contain a value at execution time).
> 
> More precisely, the C standard doesn't define the word "variable", but I
> presume that a "variable" is a kind of "object", which is defined as a
> "region of data storage in the execution environment, the contents of
> which can represent values".  Not a pointer in sight.

My bad, I have assumed that a variable must be distinguished from
other variables by an address, which implies a pointer of some sort,
but you might choose to call that an identifier instead.

More generally, a value must be distinguished from other values with a
unique identifier.  In a program, we call this identifier a 'named
variable', which in a sense may be thought of as is its 'address' by
virtue of its entry in the program's 'dictionary' of identifiers.
Anything else implies magic of some unspecified/unknowable nature, and
I'm not all that keen on the idea of magic.

This 'address' has distinct qualities in the compiler's representation
of the program and in the assembled object code, which I suppose are
representative of distinct, but related ontologies.  The standard, of
course, is not concerned with the philosophy of computer software,
only its behavior in the execution environment.

> >> > values may move around in and from RAM to CPU registers and back while
> >> > being identified as a single consistent entity.  This helps to
> >> > illustrate the difference between a language and its implementation.
> >> 
> >> So a char object is really a pointer to char, an int object is
> >> really a pointer to int, and a char** object is really a char**?
> 
> Sorry, what I meant to write is that a char** object is really (in your
> model) a char***, i.e., a pointer to a char**.
> 
> > No, a char ** object is a pointer to a char ** object.
> 
> Was that really what you meant to type?  I messed up the number of *s,
> so I can hardly criticize you for doing the same thing, but I'd like to
> know what you meant.

I must suggest that the fundamental nature of objects is that they
have an identifier and existence.  Existence implies location,
especially in a computer program.  Proving the proposition that
identifiers have existence independent of their object I leave as an
exercise for the student.
 
> In your model, as I understand it, an int object is really a pointer to
> int, or an int*.  It would follow that a char** object is really a
> pointer to a char**, or a char***.  Or am I misunderstanding you?

Perhaps you can revisit that question after considering the
philosophical statements above.
 
> In fact, an int object is an int object.  I find that so obvious
> that it seems odd to have to state it.  For an operation on such
> an object, a compiler might have to generate code that determines
> that object's address.  That does not in any sense imply that an
> int object is "really" a pointer.  You can construct a pointer to
> an int object, but the pointer and the object it points to are two
> different things.

We're using pointer in two different senses:  in the sense defined by
the C standard, and in the sense that an identifier points to
an object, by definition.  The concept of 'pointer' is implicit to the
idea of 'object'.  You seem to be confused by the use of pointer to
refer to anything other than a C pointer object.

Religions seem to rely on that same kind of confusion to obscure the
origins and nature of some kinds of religious 'knowledge'.  Moreover,
thinking about philosophy and ontology is all but outlawed today.

> >> I think you're simply adding an extra -- and unnecessary -- level
> >> of indirection, and of confusion.
> >> 
> >> There may also be some confusion between pointer *objects* and
> >> pointer *values* (i.e., addresses).
> >
> > Let me say again that I am not talking about addresses as might be
> > referenced in object code.  Perhaps it will clarify that I am thinking
> > of something like the phase space of the compiler as it is building
> > the tree representing the source code of the program.
> 
> And we're getting even farther afield from the actual semantics of a C
> program.

Maybe.
 
> An object doesn't even exist during compilation.  Memory for it
> is allocated as the program is executed.  Pointers (either pointer
> objects or pointer values) do not exist until the program executes.
> The "phase space" of the compiler is irrelevant.

Of course it exists, or rather the object's identifier implies its
existence in the execution environment.  If it did not, you could not
write programs and compilers could not compile programs.  Furthermore,
the existence of the execution environment is in some sense guaranteed
by the existence of the compiler, is it not?
 
> When you claim that a struct object is "really" a pointer, are you
> referring to something that exists internally to a compiler during
> compilation?  If so, of what possible use is it to understanding
> what a struct object is?
>
> >> If I define an object of struct type and perform some operation
> >> on it (say, a simple assignment), the generated code might very
> >> well refer to the address of the object.  There is no *object*
> >> of pointer type, either explicitly or implicitly.
> >
> > That could depend on the way the compiler is designed.
> 
> Perhaps.  But an object of pointer-to-struct type is a region
> of memory holding the address of the struct object.  Why would a
> compiler allocate and initialize such a pointer object, or generate
> code to do so, in the absence of C code to take the addrss of the
> struct object?

Because it is natural to do so.  The fact that your compiler copies
such structures in assignment contexts (seemingly) one field at a time
is an artifact of its design.  Another compiler might use a form of
memcpy(), in which case there would have to be a pointer -- just not
one that you defined explicitly in your source code.

> >> Struct objects are very often manipulated via pointers (simulating
> >> by-reference argument passing, for example), but that's a coding
> >> convention, not anything inherent to the language.
> >
> > Agreed.
> 
> So where do these "pointers" you keep talking about come from?
> In what sense do they exist?
> 
> [big snip]
> 
> > See my comment above regarding the compiler's phase space, although
> > I'm not quite sure that is the best term to use in describing what I
> > am thinking.
> 
> I'm pretty sure it isn't.

I think the philosophical perspective better illustrates what I was
thinking.  The phase space is referential to a program's execution
environment, which we generally assume to exist, and hence any object
in that phase space has an address which is, by definition, a pointer.

I hope this makes things clearer.



Regards,

Steve Thompson

-- 
GOTO's are like guns.  Safety is entirely contingent on the user.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-20 03:08 +0000
  Re: Compatibility question Ian Collins <ian-news@hotmail.com> - 2012-10-20 16:20 +1300
    Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-20 11:50 +0100
      Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-20 11:41 -0700
        Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-21 23:04 +0000
          Re: Compatibility question Barry Schwarz <schwarzb@dqel.com> - 2012-10-21 20:27 -0700
    Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-20 04:01 +0000
      Re: Compatibility question Ian Collins <ian-news@hotmail.com> - 2012-10-21 09:26 +1300
        Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-21 22:54 +0000
          Re: Compatibility question Ian Collins <ian-news@hotmail.com> - 2012-10-22 12:29 +1300
            Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-21 23:50 +0000
              Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 02:27 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 02:28 +0000
                Re: Compatibility question Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-22 11:18 -0400
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 16:19 +0000
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 17:37 +0100
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 17:40 +0100
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 17:30 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 17:23 +0000
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-22 10:52 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 18:42 +0000
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 21:06 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 22:52 +0000
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-23 03:33 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-23 12:28 +0000
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 16:45 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-23 17:53 +0000
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-23 12:41 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 21:28 +0100
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-23 20:57 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-23 12:26 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-23 20:39 +0000
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-23 15:53 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-24 00:57 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-23 20:06 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-24 11:18 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 12:04 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-24 23:10 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 16:58 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-25 01:46 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 19:40 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-24 20:20 +0000
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 14:38 -0700
                Re: Compatibility question James Kuyper <jameskuyper@verizon.net> - 2012-10-24 17:55 -0400
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 16:29 -0700
                Re: Compatibility question Greg Martin <greg@softsprocket.com> - 2012-10-24 15:21 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-26 03:30 +0000
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-26 13:02 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-27 00:04 +0000
                Re: Compatibility question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-27 20:15 +0100
                Re: Compatibility question Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-10-27 16:36 -0600
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-28 17:36 +0000
                Re: Compatibility question Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-10-27 22:42 +0300
                Re: Compatibility question Greg Martin <greg@softsprocket.com> - 2012-10-27 14:30 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-27 22:57 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-27 17:04 -0700
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-27 17:14 -0700
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-27 18:04 -0700
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-24 16:46 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-25 01:18 +0000
                Re: Compatibility question Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-10-27 21:08 +0300
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-28 17:38 +0000
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 00:38 +0100
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-22 16:50 -0700
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-23 12:33 +0000
                Re: Compatibility question Öö Tiib <ootiib@hot.ee> - 2012-10-22 14:23 -0700
                Re: Compatibility question James Kuyper <jameskuyper@verizon.net> - 2012-10-22 17:26 -0400
                Re: Compatibility question Ian Collins <ian-news@hotmail.com> - 2012-10-23 10:55 +1300
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 23:27 +0000
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-22 22:44 +0100
                Re: Compatibility question Les Cargill <lcargill99@comcast.com> - 2012-10-22 17:15 -0500
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 00:13 +0100
                Re: Compatibility question James Kuyper <jameskuyper@verizon.net> - 2012-10-22 18:35 -0400
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 00:14 +0100
                Re: Compatibility question Steve Thompson <stevet810@gmail.com> - 2012-10-22 23:42 +0000
                Re: Compatibility question Ian Collins <ian-news@hotmail.com> - 2012-10-23 13:35 +1300
                Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-22 17:01 -0700
                Re: Compatibility question "BartC" <bc@freeuk.com> - 2012-10-23 01:47 +0100
              Re: Compatibility question Keith Thompson <kst-u@mib.org> - 2012-10-21 19:27 -0700

csiph-web