What does the expression "sizeof(int)*p" mean?

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

    #16
    Re: What does the expression "sizeof(in t)*p" mean?

    jeffc wrote:[color=blue]
    > "Ron Natalie" <ron@sensor.com > wrote in message
    > news:3f6b57c0$0 $198$9a6e19ea@n ews.newshosting .com...[color=green]
    >>
    >> "jeffc" <nobody@nowhere .com> wrote in message
    >> news:3f6b50aa_3 @news1.prserv.n et...
    >>[color=darkred]
    >>> sizeof is a function,[/color]
    >>
    >> sizeof is not a function. It's an operator.[/color]
    >
    > Same thing.[/color]

    No, it is not. See the standard. See any language book. Please explain if
    operator is same as function, that how the heck can a *function call
    operator* exist?

    --
    WW aka Attila


    Comment

    • WW

      #17
      Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

      jeffc wrote:[color=blue]
      > "WW" <wolof@freemail .hu> wrote in message
      > news:bkfrfp$4pd $1@phys-news1.kolumbus. fi...[color=green]
      >> jeffc wrote:[color=darkred]
      >>> "Xenos" <dont.spam.me@s pamhate.com> wrote in message
      >>> news:bkfkti$ke3 3@cui1.lmms.lmc o.com...
      >>>>
      >>>> No, sizeof is an operator. The paranteses are only required for
      >>>> uses with a type expression.
      >>>
      >>> Makes no difference.[/color]
      >>
      >> You stated that sizeof is a function. It is not. It is an
      >> operator. Makes all the difference possible. It is an operator,
      >> same way as the + sign ot the () function call operator.[/color]
      >
      > Operators are functions. It's just that the syntax is sometimes a
      > little different. It sure does not make "all the difference
      > possible". Why do you think the term "Operator Functions" exists?[/color]

      Jeff it is not a shame to be a beginner, but it is a shameful to see years
      later your incorrect statements still in the newsgroup archives. Been
      there. So making the mistake of calling operators as functions is one
      thing. Insisting on it when you have been told it is not true is another
      thing.

      In 13.5 Oveerloaded operators Paragraph one Simon says:

      "A function declaration having one of the following /operator-function-ids/
      as its name declares an operator function. An operator function is said to
      implement the operator named in its /operator-function-ids/."

      Read it carefully. It does not say operators are functions. It says:
      overloaded operators (overloaded ones!) are *implemented as* functions.

      --
      WW aka Attila


      Comment

      • jeffc

        #18
        Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


        "WW" <wolof@freemail .hu> wrote in message
        news:bkfsms$740 $1@phys-news1.kolumbus. fi...[color=blue]
        > jeffc wrote:[color=green]
        > > "Ron Natalie" <ron@sensor.com > wrote in message
        > > news:3f6b57c0$0 $198$9a6e19ea@n ews.newshosting .com...[color=darkred]
        > >>
        > >> "jeffc" <nobody@nowhere .com> wrote in message
        > >> news:3f6b50aa_3 @news1.prserv.n et...
        > >>
        > >>> sizeof is a function,
        > >>
        > >> sizeof is not a function. It's an operator.[/color]
        > >
        > > Same thing.[/color]
        >
        > No, it is not. See the standard. See any language book.[/color]

        I obviously don't mean an operator is EXACTLY the same thing as a function.
        I mean for the purposes of what I was saying, and in context, it amounts to
        the same thing. int and long are 2 different things, but in some contexts
        they are the same thing. On some machines they take the same amount
        storage, on others they might not. In some operations they yield the same
        results, in others they do not.

        This is the same silly argument as when Ron tried to argue that calls to
        base class constructors from initializer lists are not function calls merely
        because the physical order they appear in don't mean that's the order
        they'll necessarily be called in.

        It doesn't matter if you write
        sizeof 'a'
        sizeof('a')
        The results are the same.


        Comment

        • jeffc

          #19
          Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


          "WW" <wolof@freemail .hu> wrote in message
          news:bkft4g$7sg $1@phys-news1.kolumbus. fi...[color=blue]
          >
          > "A function declaration having one of the following[/color]
          /operator-function-ids/[color=blue]
          > as its name declares an operator function. An operator function is said to
          > implement the operator named in its /operator-function-ids/."
          >
          > Read it carefully. It does not say operators are functions. It says:
          > overloaded operators (overloaded ones!) are *implemented as* functions.[/color]

          It also says "a function declaration". What does that mean? And does that
          prove anything? You're being silly. Operators take arguments. They act
          like functions. If the context of this discussion were different, you'd be
          arguing the opposite side just as vehemently. You know exactly what I'm
          talking about, so you're just being arbitrary.


          Comment

          • WW

            #20
            Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

            jeffc wrote:[color=blue][color=green]
            >> No, it is not. See the standard. See any language book.[/color]
            >
            > I obviously don't mean an operator is EXACTLY the same thing as a
            > function. I mean for the purposes of what I was saying, and in
            > context, it amounts to the same thing.[/color]

            You have said for the sizeof operator to be a function. It is not. It can
            be compared to one (knowing the differences) but it is not a function from
            *any* valid viewpoint.
            [color=blue]
            > int and long are 2 different
            > things, but in some contexts they are the same thing.[/color]

            In no context they are the same thing. They both belong to types if that is
            what you mean but functions and the sizeof operators only meet at the
            expression level. Functions are called or inlined while the implementation
            for operators is not defined etc. They are not the same in any repspect.
            Especially when talking about sizeof.
            [color=blue]
            > On some
            > machines they take the same amount storage, on others they might not.[/color]

            Which has no significance in the matter of operators are not functions.
            They are both integral types, their coherence is much much higher than the
            one between operators and functions.
            [color=blue]
            > In some operations they yield the same results, in others they do not.[/color]

            Irrelevant to the topic.
            [color=blue]
            > This is the same silly argument as when Ron tried to argue that calls
            > to base class constructors from initializer lists are not function
            > calls merely because the physical order they appear in don't mean
            > that's the order they'll necessarily be called in.[/color]

            Sure. They are not function calls. There are several reasons to it. One
            of ehich Ron told. Another (which leads to the same) is that contsructors
            are not functions. They are *special* member functions, which special
            semantics.
            [color=blue]
            > It doesn't matter if you write
            > sizeof 'a'
            > sizeof('a')
            > The results are the same.[/color]

            Yes. How does that support your theory of sizeof being a function from the
            C++ language point of view?

            --
            WW aka Attila


            Comment

            • jeffc

              #21
              Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


              "WW" <wolof@freemail .hu> wrote in message
              news:bkfuje$aae $1@phys-news1.kolumbus. fi...[color=blue][color=green]
              > > This is the same silly argument as when Ron tried to argue that calls
              > > to base class constructors from initializer lists are not function
              > > calls merely because the physical order they appear in don't mean
              > > that's the order they'll necessarily be called in.[/color]
              >
              > Sure. They are not function calls. There are several reasons to it. One
              > of ehich Ron told.[/color]

              Really? They're not function calls because the order in which they appear
              does not necessarily match the order in which they're called? Is that what
              you're saying the "proof" is that they're not functions?
              [color=blue]
              > Another (which leads to the same) is that contsructors
              > are not functions. They are *special* member functions, which special
              > semantics.[/color]

              Ah, I see. They're not functions. They're *special* functions. Thanks for
              clearing that up.
              [color=blue][color=green]
              > > It doesn't matter if you write
              > > sizeof 'a'
              > > sizeof('a')
              > > The results are the same.[/color]
              >
              > Yes. How does that support your theory of sizeof being a function from[/color]
              the[color=blue]
              > C++ language point of view?[/color]

              It supports my view that my comments are relevant to the context of the OP's
              original question. He wrote sizeof((int)*p) . Now if context makes no
              difference, then how about if you come up and explain to the class the
              difference between these 4 expressions.
              short s;
              sizeof s*(double)s
              sizeof (double)s*s
              sizeof (s*(double)s)
              sizeof ((double)s*s)
              And please don't tell me they're the same.


              Comment

              • WW

                #22
                Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                jeffc wrote:[color=blue]
                > "WW" <wolof@freemail .hu> wrote in message
                > news:bkft4g$7sg $1@phys-news1.kolumbus. fi...[color=green]
                >>
                >> "A function declaration having one of the following
                >> /operator-function-ids/ as its name declares an operator function.
                >> An operator function is said to implement the operator named in its
                >> /operator-function-ids/."
                >>
                >> Read it carefully. It does not say operators are functions. It
                >> says: overloaded operators (overloaded ones!) are *implemented as*
                >> functions.[/color]
                >
                > It also says "a function declaration". What does that mean?[/color]

                I am sorry? You do not know what a function declaration means? Oh boy.
                [color=blue]
                > And does that prove anything?[/color]

                It only proves that operators are not functions.
                [color=blue]
                > You're being silly.[/color]

                Really? Since when are you a mental health expert?
                [color=blue]
                > Operators take arguments.[/color]

                Yeah. That makes them more functional than you are. Try to read the
                exceprt from the standard again.
                [color=blue]
                > They act like functions.[/color]

                No, they don't. One reason is because they are not functions. Take the
                member access operator for example (the . operator). Does that act as a
                function? Nope. Some (actually very very few) operators may *look* like a
                function call in code in some of their allowed form(s). But just the same
                way as yellow snow is not from tee with lemon, operators in C++ are not
                functions. Overloaded operators are *implemented* as functions.
                [color=blue]
                > If the context of this discussion were different,
                > you'd be arguing the opposite side just as
                > vehemently.[/color]

                Now you are a mind reader, too. Boy are you talented! How come I have
                never heard about your achivements before?
                [color=blue]
                > You know exactly what I'm talking about, so you're just
                > being arbitrary.[/color]

                Yes, I am being arbitrary. By the "absolute" meaning of the word
                "arbitrary" . How come? There is only one absolute which decides what is
                what in C++. And that is the standard. And that clearly makes a
                fundamental distinction between operators and functions. Therefore they are
                not the same.

                --
                WW aka Attila


                Comment

                • WW

                  #23
                  Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                  jeffc wrote:[color=blue]
                  > "WW" <wolof@freemail .hu> wrote in message
                  > news:bkfuje$aae $1@phys-news1.kolumbus. fi...[color=green][color=darkred]
                  >>> This is the same silly argument as when Ron tried to argue that
                  >>> calls to base class constructors from initializer lists are not
                  >>> function calls merely because the physical order they appear in
                  >>> don't mean that's the order they'll necessarily be called in.[/color]
                  >>
                  >> Sure. They are not function calls. There are several reasons to
                  >> it. One of ehich Ron told.[/color]
                  >
                  > Really? They're not function calls because the order in which they
                  > appear does not necessarily match the order in which they're called?[/color]

                  Amongst other things, yes.
                  [color=blue]
                  > Is that what you're saying the "proof" is that they're not functions?[/color]

                  What are they? The proof that constructors are not functions is in the
                  standard. Read it. They are special member functions. For one example how
                  special they are: they have no names. But again: read the standard.
                  [color=blue][color=green]
                  >> Another (which leads to the same) is that contsructors
                  >> are not functions. They are *special* member functions, which
                  >> special semantics.[/color]
                  >
                  > Ah, I see. They're not functions. They're *special* functions.
                  > Thanks for clearing that up.[/color]

                  No. They are *special* member functions. One of their specialty is that
                  they do not have a name. The have special semantics.
                  [color=blue][color=green][color=darkred]
                  >>> It doesn't matter if you write
                  >>> sizeof 'a'
                  >>> sizeof('a')
                  >>> The results are the same.[/color]
                  >>
                  >> Yes. How does that support your theory of sizeof being a function
                  >> from the C++ language point of view?[/color]
                  >
                  > It supports my view that my comments are relevant to the context of
                  > the OP's original question. He wrote sizeof((int)*p) . Now if
                  > context makes no difference, then how about if you come up and
                  > explain to the class the difference between these 4 expressions.
                  > short s;
                  > sizeof s*(double)s
                  > sizeof (double)s*s
                  > sizeof (s*(double)s)
                  > sizeof ((double)s*s)
                  > And please don't tell me they're the same.[/color]

                  By meaning they are the same. All are takig the size of the type of the
                  expression (double)s*(doub le(s), which is sizeof(double).

                  I still see the above as an example against your idea of operators being
                  functions.

                  --
                  WW aka Attila


                  Comment

                  • Kevin Goodsell

                    #24
                    Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                    jeffc wrote:[color=blue]
                    > "Ron Natalie" <ron@sensor.com > wrote in message
                    > news:3f6b57c0$0 $198$9a6e19ea@n ews.newshosting .com...[color=green]
                    >>
                    >>sizeof is not a function. It's an operator.[/color]
                    >
                    >
                    > Same thing.[/color]

                    Absolutely not. A few differences are that sizeof is never 'called' (it
                    is evaluated at compile time), and sizeof does not have an address. A
                    consequence of the first point is that the operand of 'sizeof' is not
                    evaluated:

                    int i = 0;
                    sizeof(++i);
                    assert(i == 0); // OK, i has not changed.
                    [color=blue][color=green]
                    >>Parens have no bearing on order of evaulation in C++.[/color]
                    >
                    >
                    > Of course they do.[/color]

                    No, they don't.
                    [color=blue]
                    > Compare:
                    > 1 + (2 * 3)
                    > (1 + 2) * 3[/color]

                    This is an example of parens being used to change precedence. Precedence
                    and order of evaluation are not the same. Given

                    exp1 + exp2

                    the order that exp1 and exp2 are evaluated is not specified. Adding
                    parens does not change this:

                    (exp1 + exp2)
                    (exp1) + exp2
                    exp1 + (exp2)

                    None of these make the order of evaluation specified. Similarly, given a
                    statement that modifies a variable twice without an intervening sequence
                    point:

                    i = i++;

                    You cannot make the result of this well-defined by adding any number of
                    parens, because the order of evaluation of the assignment and the
                    increment is not specified and parens don't change it:

                    i = (i++); // still undefined

                    -Kevin
                    --
                    My email address is valid, but changes periodically.
                    To contact me please use the address from a recent posting.

                    Comment

                    • Kevin Goodsell

                      #25
                      Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                      jeffc wrote:
                      [color=blue]
                      >
                      > It also says "a function declaration". What does that mean? And does that
                      > prove anything? You're being silly. Operators take arguments. They act
                      > like functions.[/color]

                      Please show me how to take the address of the sizeof function. I know
                      all functions have addresses, and thanks to you I now know that sizeof
                      is a function, therefore must have an address. Can you please show me
                      how to determine this address? Thank you.

                      -Kevin
                      --
                      My email address is valid, but changes periodically.
                      To contact me please use the address from a recent posting.

                      Comment

                      • WW

                        #26
                        Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                        Kevin Goodsell wrote:[color=blue]
                        > jeffc wrote:
                        >[color=green]
                        >>
                        >> It also says "a function declaration". What does that mean? And
                        >> does that prove anything? You're being silly. Operators take
                        >> arguments. They act like functions.[/color]
                        >
                        > Please show me how to take the address of the sizeof function. I know
                        > all functions have addresses, and thanks to you I now know that sizeof
                        > is a function, therefore must have an address. Can you please show me
                        > how to determine this address? Thank you.[/color]

                        It is:

                        Dwight Look College of Engineering | Texas A&M University
                        301 Harvey R. Bright Bldg, College Station, TX 77843-3112

                        Do you also want a phone number? ;-)

                        --
                        WW aka Attila


                        Comment

                        • Kevin Goodsell

                          #27
                          Re: What does the expression &quot;sizeof(in t)*p&quot; mean?

                          Kevin Goodsell wrote:
                          [color=blue]
                          > jeffc wrote:
                          >[color=green]
                          >>
                          >> It also says "a function declaration". What does that mean? And does
                          >> that
                          >> prove anything? You're being silly. Operators take arguments. They act
                          >> like functions.[/color]
                          >
                          >
                          > Please show me how to take the address of the sizeof function. I know
                          > all functions have addresses, and thanks to you I now know that sizeof
                          > is a function, therefore must have an address. Can you please show me
                          > how to determine this address? Thank you.
                          >[/color]

                          Here's another revelation thanks to this new "operators are functions"
                          rule. The following is no longer undefined:

                          int i = 0;
                          i = i++;
                          assert(i == 0);
                          i = ++i;
                          assert(i == 1);

                          Since '=' is a function, there is a sequence point before it is called,
                          and the increment operation is finalized. Unfortunately, some compilers
                          still seem to give incorrect results for this. I guess they haven't
                          implemented "operators are functions" yet.

                          -Kevin
                          --
                          My email address is valid, but changes periodically.
                          To contact me please use the address from a recent posting.

                          Comment

                          • Xenos

                            #28
                            Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


                            "jeffc" <nobody@nowhere .com> wrote in message
                            news:3f6b70f2_4 @news1.prserv.n et...[color=blue]
                            >
                            > "Xenos" <dont.spam.me@s pamhate.com> wrote in message
                            > news:bkfkti$ke3 3@cui1.lmms.lmc o.com...[color=green]
                            > >
                            > > No, sizeof is an operator. The paranteses are only required for uses[/color][/color]
                            with[color=blue]
                            > a[color=green]
                            > > type expression.[/color]
                            >
                            > Makes no difference.
                            >
                            >[/color]

                            Makes all the difference in the world. The argument to sizeof is not
                            evaluated as would be for a function. saying "sizeof(++i )" does not change
                            the value of i. Futhermore, I don't know any function that can take a type
                            as an argument, as in sizeof(int). sizeof is a compiler constructor, it is
                            never executed by the runtime.

                            DrX.


                            Comment

                            • jeffc

                              #29
                              Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


                              "WW" <wolof@freemail .hu> wrote in message
                              news:bkfvkd$eqg $1@phys-news1.kolumbus. fi...[color=blue]
                              > jeffc wrote:[color=green]
                              > > "WW" <wolof@freemail .hu> wrote in message
                              > > news:bkft4g$7sg $1@phys-news1.kolumbus. fi...[color=darkred]
                              > >>
                              > >> "A function declaration having one of the following
                              > >> /operator-function-ids/ as its name declares an operator function.
                              > >> An operator function is said to implement the operator named in its
                              > >> /operator-function-ids/."
                              > >>
                              > >> Read it carefully. It does not say operators are functions. It
                              > >> says: overloaded operators (overloaded ones!) are *implemented as*
                              > >> functions.[/color]
                              > >
                              > > It also says "a function declaration". What does that mean?[/color]
                              >
                              > I am sorry? You do not know what a function declaration means? Oh boy.[/color]

                              You do not know how to draw logical conclusions? Oh boy. Obviously I meant
                              "what does that mean with regard to your argument?" It called it a
                              "function declaration". That implies a "function". What you wrote supports
                              my argument, not yours.
                              [color=blue][color=green]
                              > > And does that prove anything?[/color]
                              >
                              > It only proves that operators are not functions.[/color]

                              Try again.



                              Comment

                              • jeffc

                                #30
                                Re: What does the expression &quot;sizeof(in t)*p&quot; mean?


                                "Kevin Goodsell" <usenet1.spamfr ee.fusion@never box.com> wrote in message
                                news:qPLab.9474 $UN4.1633@newsr ead3.news.pas.e arthlink.net...[color=blue]
                                > jeffc wrote:
                                >[color=green]
                                > >
                                > > It also says "a function declaration". What does that mean? And does[/color][/color]
                                that[color=blue][color=green]
                                > > prove anything? You're being silly. Operators take arguments. They[/color][/color]
                                act[color=blue][color=green]
                                > > like functions.[/color]
                                >
                                > Please show me how to take the address of the sizeof function. I know
                                > all functions have addresses, and thanks to you I now know that sizeof
                                > is a function, therefore must have an address. Can you please show me
                                > how to determine this address? Thank you.[/color]

                                Can't be done Kevin. As I've already said, my comments are to be taken in
                                context. You're just another pedant with too much time on your hands. Why
                                don't *you* explain why WW quoted text referring to "function declarations"
                                in the context of operators? I'm sure that will occupy you for quite
                                awhile.


                                Comment

                                Working...