function to return pointer question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Heathfield

    #16
    Re: function to return pointer question

    Ark said:
    Richard Heathfield wrote:
    >Keith Thompson said:
    >>
    <snip>
    >>That would seem to imply that an expression such as 42, that doesn't
    >>refer to any object, does not yield a "value". I've always thought of
    >>a "value" as being either the interpreted contents of an object *or*
    >>the result of an expression.
    >>
    >Yes, and both the C89 Standard and the C99 Standard refer to "the value
    >of CHAR_MIN" when describing numerical limits, even though it is quite
    >evident that CHAR_MIN is not an object. So, one way or another, the C99
    >Standard is wrong.
    >>
    ><snip>
    >>
    >
    Assuming e.g.
    #define CHAR_MIN (-128)
    isn't it true that CHAR_MIN is a const object of type int and value
    -128?
    No.
    And likewise 42U a const object of type unsigned int and value 42?
    No.
    Oh, it lacks an address but so do register variables.
    So do operators. That doesn't make them objects either.
    Am I wrong?
    Yes.
    What's an object anyway then?
    It is "a region of data storage in the execution environment, the contents
    of which can represent values."
    In any case, 42 and CHAR_MIN are expressions, so they have a type and a
    value.
    Yes, they are expressions, and they have a type and a value. But being an
    expression is not enough to make you an object.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999

    email: rjh at the above domain, - www.

    Comment

    • Keith Thompson

      #17
      Re: function to return pointer question

      Ark <akhasin@macroe xpressions.comw rites:
      Richard Heathfield wrote:
      >Keith Thompson said:
      >>
      <snip>
      >>That would seem to imply that an expression such as 42, that doesn't
      >>refer to any object, does not yield a "value". I've always thought of
      >>a "value" as being either the interpreted contents of an object *or*
      >>the result of an expression.
      >Yes, and both the C89 Standard and the C99 Standard refer to "the
      >value of CHAR_MIN" when describing numerical limits, even though it
      >is quite evident that CHAR_MIN is not an object. So, one way or
      >another, the C99 Standard is wrong.
      ><snip>
      >>
      >
      Assuming e.g.
      #define CHAR_MIN (-128)
      isn't it true that CHAR_MIN is a const object of type int and value
      -128? And likewise 42U a const object of type unsigned int and value
      42?
      No. CHAR_MIN is merely a macro. It exists only in a C source file;
      Objects exist at run time.

      (Well, actually it's in the standard header <limits.h>, which needn't
      be an actual source file, but that's beside the point.)
      Oh, it lacks an address but so do register variables.
      Am I wrong? What's an object anyway then?
      An object is a "region of data storage in the execution environment,
      the contents of which can represent values" (C99 3.14).
      In any case, 42 and CHAR_MIN are expressions, so they have a type and
      a value.
      Am I wrong again?
      Yes, an expression has a type and a value. The only problem is that
      the standard's definition of "value" isn't quite worded correctly.

      --
      Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
      San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
      We must do something. This is something. Therefore, we must do this.

      Comment

      • Sjouke Burry

        #18
        Re: function to return pointer question

        Ark wrote:
        Richard Heathfield wrote:
        >Keith Thompson said:
        >>
        <snip>
        >>That would seem to imply that an expression such as 42, that doesn't
        >>refer to any object, does not yield a "value". I've always thought of
        >>a "value" as being either the interpreted contents of an object *or*
        >>the result of an expression.
        >>
        >Yes, and both the C89 Standard and the C99 Standard refer to "the
        >value of CHAR_MIN" when describing numerical limits, even though it is
        >quite evident that CHAR_MIN is not an object. So, one way or another,
        >the C99 Standard is wrong.
        >>
        ><snip>
        >>
        >
        Assuming e.g.
        #define CHAR_MIN (-128)
        isn't it true that CHAR_MIN is a const object of type int and value
        -128? And likewise 42U a const object of type unsigned int and value 42?
        Oh, it lacks an address but so do register variables.
        Am I wrong? What's an object anyway then?
        In any case, 42 and CHAR_MIN are expressions, so they have a type and a
        value.
        Am I wrong again?
        >
        Yes , 42 is the answer to the reason for the universe :) :) ;)n

        Comment

        • Dietmar Schindler

          #19
          Re: function to return pointer question

          Richard Heathfield wrote:
          >
          Keith Thompson said:
          >
          ...
          Incidentally while writing this I looked up the standard's definition
          of "value" (C99 3.17):

          precise meaning of the contents of an object when interpreted as
          having a specific type

          That would seem to imply that an expression such as 42, that doesn't
          refer to any object, does not yield a "value". I've always thought of
          a "value" as being either the interpreted contents of an object *or*
          the result of an expression.
          >
          Yes, and both the C89 Standard and the C99 Standard refer to "the value of
          CHAR_MIN" when describing numerical limits, even though it is quite evident
          that CHAR_MIN is not an object. So, one way or another, the C99 Standard is
          wrong.
          From the definition of "value" being "precise meaning of the contents
          of an object ...", it does not follow that in the phrase "the value of
          CHAR_MIN" the noun "CHAR_MIN" were to be regarded as "an object".
          We just have to keep in mind that "value" is defined as "precise meaning
          ....", and apply an appropriate one of the many meanings of "of" (found
          at http://www.thefreedictionary.com/of for example); this way, "the
          value of CHAR_MIN" can be restated as

          "the precise meaning ... derived or coming from CHAR_MIN",

          "the precise meaning ... associated with or adhering to CHAR_MIN",

          "the precise meaning ... belonging or connected to CHAR_MIN",

          "the precise meaning ... specified as, named or called CHAR_MIN";

          also, "CHAR_MIN" can be an appositive noun, which is perhaps the best
          way to see it.

          crossposted to alt.usage.engli sh
          --
          Dietmar Schindler

          Comment

          • Peter Moylan

            #20
            Re: function to return pointer question

            Dietmar Schindler wrote:
            Richard Heathfield wrote:
            >Keith Thompson said:
            >>
            >>...
            >>Incidentall y while writing this I looked up the standard's definition
            >>of "value" (C99 3.17):
            >>>
            >> precise meaning of the contents of an object when interpreted as
            >> having a specific type
            >>>
            >>That would seem to imply that an expression such as 42, that doesn't
            >>refer to any object, does not yield a "value". I've always thought of
            >>a "value" as being either the interpreted contents of an object *or*
            >>the result of an expression.
            [...]
            crossposted to alt.usage.engli sh
            The newsgroup alt.usage.engli sh is, for the moment, occupied with a
            discussion about the meaning of dates in C17 and C18, so it'll be a
            while before we get as far as C99.

            I feel your pain, but the C notation has always encouraged sloppiness
            over the value/reference distinction, and things went totally out of
            control when objects came into the picture. Given this, an error in the
            standard is a mere bagatelle.

            You might get AUE more interested in the question if you put it in the
            context of what the name of the song is called.

            --
            Peter Moylan http://www.pmoylan.org

            Please note the changed e-mail and web addresses. The domain
            eepjm.newcastle .edu.au no longer exists, and I can no longer
            receive mail at my newcastle.edu.a u addresses. The optusnet
            address could disappear at any time.

            Comment

            Working...