Re: What is the Result from Invoking this Halt Function?

From: Joe Hendrix (jhendrix_at_uiuc.edu)
Date: 08/18/04


Date: Tue, 17 Aug 2004 18:34:49 -0500

Marc Goodman wrote:
> Joe Hendrix wrote:
>> Marc Goodman wrote:
>>>Please explain again why the below working code does not refute your
>>>statement that "[for standardized C] there is no way for a program
                   ^^^^^
>>>to inspect its own code."
>>>
>>> return(((int *)func)[19]);
>>
>> ^
>> In standard C (C90, C99), you can't typecast a function pointer into a
>> value pointer much less dereference the result, the behavior is
>> undefined in the standard and compiler/architecture specific.
>
> It's merely an example of a single instance of a program
> that conditionalizes its behavior based on whether it returns
> a result or not.
>
> As an example, it works on my dual-processor Athlon box running
> RedHat Linux. It proves such a think is _possible_.
>
> It doesn't have to be standard C to be possible.

You are redefining your claim. You claimed that code proved that
reflection was possible in standard C (by reflection I mean the ability
of a program to inspect it's own code at runtime). I merely pointed out
that your example was not Standard C, so it is not a counterexample.

Obviously, there are languages that support reflection (Java, Lisp,
Prolog, plus many more), but I suspect that Standard C is not one of
them and in fact was intentionally designed not to support reflection.

Since any programming language I know supporting reflection is provably
Turing complete (ignoring resource limits), I don't think this affects
the halting problem, but that's not really a subject I'm going to post
anything (else) about.



Relevant Pages

  • Re: What is the Result from Invoking this Halt Function?
    ... >> value pointer much less dereference the result, ... > It doesn't have to be standard C to be possible. ... them and in fact was intentionally designed not to support reflection. ... Since any programming language I know supporting reflection is provably ...
    (sci.logic)
  • Re: What is the Result from Invoking this Halt Function?
    ... > reflection was possible in standard C (by reflection I mean the ability ... > that your example was not Standard C, so it is not a counterexample. ... in "Standard C" to cast a function pointer to an int pointer and ... > Since any programming language I know supporting reflection is provably ...
    (comp.theory)
  • Re: What is the Result from Invoking this Halt Function?
    ... > reflection was possible in standard C (by reflection I mean the ability ... > that your example was not Standard C, so it is not a counterexample. ... in "Standard C" to cast a function pointer to an int pointer and ... > Since any programming language I know supporting reflection is provably ...
    (sci.logic)
  • Re: A C++ Whishlist
    ... In the vast majority of member functions the first thing you will do ... If I feel it needs an extra check because it won't crash cleanly I may ... >> unless you also check the this pointer you aren't checking every ... The standard does not say "the this pointer cannot be NULL". ...
    (comp.lang.cpp)
  • Re: lvalues and rvalues
    ... pointer type) have both a value and a type. ... is not defined in the C standard. ... in the C abstract machine, we expect to have the same ... and width of the bitfield. ...
    (comp.lang.c)