mutable data structures

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Markus.Elfring@web.de

    #1

    mutable data structures

    The C++ language specification provides the key word "mutable" that is
    not available in the C99 standard.
    Will it be imported to reduce any incompatibiliti es?



    Regards,
    Markus

  • Chris Hills

    #2
    Re: mutable data structures

    In article <1120995713.141 836.310600@g49g 2000cwa.googleg roups.com>,
    Markus.Elfring@ web.de writes[color=blue]
    >The C++ language specification provides the key word "mutable" that is
    >not available in the C99 standard.
    >Will it be imported to reduce any incompatibiliti es?[/color]

    I doubt it. why would C want to change simply to reduce incompatibility s
    with C++?

    As it is most compilers do not support C99 (OK one claims to support it)
    but the vast majority of C compilers are still at C90+ a few bits. SO
    even if mutable and other C++ things are put into the C0* standard there
    is no guarantee that it will be implemented.

    You will get the companies who produce C/C++ compilers who will do it
    but those that produce just C compilers will probably not unless their
    customers start clamouring for it in a way they have not be asking for
    C99.

    --
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
    /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



    Comment

    • Chris Croughton

      #3
      Re: mutable data structures

      On 10 Jul 2005 04:41:53 -0700, Markus.Elfring@ web.de
      <Markus.Elfring @web.de> wrote:
      [color=blue]
      > The C++ language specification provides the key word "mutable" that is
      > not available in the C99 standard.
      > Will it be imported to reduce any incompatibiliti es?
      > http://david.tribble.com/text/cdiffs...99-cpp-keyword
      > http://www.inf.uni-konstanz.de/~kueh...html#faq-18.13[/color]

      Why should C provide it? It makes sense in C++ because you can have
      member functions which operate on a 'const' object but which need to
      alter data private to that object (so to external view nothing has
      changed, but some internal data has been altered), but in C all fields
      are public anyway so I don't see how it would be useful.

      For instance, having a 'mutable' member would preclude the structure
      being put into read-only memory (when delared as const), which would be
      a definite disadvantage for many embedded systems.

      It isn't a goal of C to remain compatible with C++ or of C++ to remain
      compatible with C (for instance it would be useful to have long long and
      the sized arithmetic types in C++) except via the extern "C" linkage.

      Chris C

      Comment

      • Joe Wright

        #4
        Re: mutable data structures

        Markus.Elfring@ web.de wrote:[color=blue]
        > The C++ language specification provides the key word "mutable" that is
        > not available in the C99 standard.
        > Will it be imported to reduce any incompatibiliti es?
        > http://david.tribble.com/text/cdiffs...99-cpp-keyword
        > http://www.inf.uni-konstanz.de/~kueh...html#faq-18.13
        >
        > Regards,
        > Markus
        >[/color]

        There is no effort that I know of by either the C community nor the C++
        community to make the two languages more compatible. In designing C++ BS
        started with familiar C and built his own new language. As time goes on
        and the two languages evolve, new features of one might find their way
        into the other. This is not about compatibility.

        --
        Joe Wright
        "Everything should be made as simple as possible, but not simpler."
        --- Albert Einstein ---

        Comment

        • Markus.Elfring@web.de

          #5
          Re: mutable data structures



          Chris Croughton schrieb:[color=blue]
          > On 10 Jul 2005 04:41:53 -0700, Markus.Elfring@ web.de
          > <Markus.Elfring @web.de> wrote:
          >[color=green]
          > > The C++ language specification provides the key word "mutable" that is
          > > not available in the C99 standard.
          > > Will it be imported to reduce any incompatibiliti es?
          > > http://david.tribble.com/text/cdiffs...99-cpp-keyword
          > > http://www.inf.uni-konstanz.de/~kueh...html#faq-18.13[/color]
          >
          > Why should C provide it? It makes sense in C++ because you can have
          > member functions which operate on a 'const' object but which need to
          > alter data private to that object (so to external view nothing has
          > changed, but some internal data has been altered), but in C all fields
          > are public anyway so I don't see how it would be useful.[/color]

          Public accessibility and visibility does not affect the constant state
          of an attribute.
          Would you like to be able to specify that a data field can never be
          const and must always be writeable?

          [color=blue]
          > For instance, having a 'mutable' member would preclude the structure
          > being put into read-only memory (when delared as const), which would be
          > a definite disadvantage for many embedded systems.[/color]

          Can you imagine that any data like cached values must not be stored
          into write-protected memory?
          Do you try to cast the constness away in such environments?

          Regards,
          Markus

          Comment

          • Markus.Elfring@web.de

            #6
            Re: mutable data structures

            > There is no effort that I know of by either the C community nor the C++[color=blue]
            > community to make the two languages more compatible. In designing C++ BS
            > started with familiar C and built his own new language. As time goes on
            > and the two languages evolve, new features of one might find their way
            > into the other. This is not about compatibility.[/color]

            I would like to see more cooperation in feature addition.

            Regards,
            Markus

            Comment

            • Richard Bos

              #7
              Re: mutable data structures

              Markus.Elfring@ web.de wrote:
              [color=blue][color=green]
              > > There is no effort that I know of by either the C community nor the C++
              > > community to make the two languages more compatible. In designing C++ BS
              > > started with familiar C and built his own new language. As time goes on
              > > and the two languages evolve, new features of one might find their way
              > > into the other. This is not about compatibility.[/color]
              >
              > I would like to see more cooperation in feature addition.[/color]

              I would like not to see unnecessary keywords added to C. Being 79%
              incompatible with C++ rather than 80% is not a goal that makes sense.

              Richard

              Comment

              • Chris Croughton

                #8
                Re: mutable data structures

                On 11 Jul 2005 05:59:02 -0700, Markus.Elfring@ web.de
                <Markus.Elfring @web.de> wrote:
                [color=blue]
                > Chris Croughton schrieb:[color=green]
                >> On 10 Jul 2005 04:41:53 -0700, Markus.Elfring@ web.de
                >> <Markus.Elfring @web.de> wrote:
                >>[color=darkred]
                >> > The C++ language specification provides the key word "mutable" that is
                >> > not available in the C99 standard.
                >> > Will it be imported to reduce any incompatibiliti es?
                >> > http://david.tribble.com/text/cdiffs...99-cpp-keyword
                >> > http://www.inf.uni-konstanz.de/~kueh...html#faq-18.13[/color]
                >>
                >> Why should C provide it? It makes sense in C++ because you can have
                >> member functions which operate on a 'const' object but which need to
                >> alter data private to that object (so to external view nothing has
                >> changed, but some internal data has been altered), but in C all fields
                >> are public anyway so I don't see how it would be useful.[/color]
                >
                > Public accessibility and visibility does not affect the constant state
                > of an attribute.
                > Would you like to be able to specify that a data field can never be
                > const and must always be writeable?[/color]

                No, I see no need for it in C. As I said, in C++ there is more need for
                it, and it is normally kept protected from user visibility.
                [color=blue][color=green]
                >> For instance, having a 'mutable' member would preclude the structure
                >> being put into read-only memory (when delared as const), which would be
                >> a definite disadvantage for many embedded systems.[/color]
                >
                > Can you imagine that any data like cached values must not be stored
                > into write-protected memory?[/color]

                Huh? If it's modifiable it can't be in write-protected memory,
                obviously.
                [color=blue]
                > Do you try to cast the constness away in such environments?[/color]

                I don't cast constness away in any environments (except for certain
                broken interfaces, and that's been so long ago that I've forgotten why
                we had to do that, something to do with a callback which was specified
                as const incorrectly).

                Chris C

                Comment

                • Chris Croughton

                  #9
                  Re: mutable data structures

                  On 11 Jul 2005 05:59:02 -0700, Markus.Elfring@ web.de
                  <Markus.Elfring @web.de> wrote:
                  [color=blue][color=green]
                  >> There is no effort that I know of by either the C community nor the C++
                  >> community to make the two languages more compatible. In designing C++ BS
                  >> started with familiar C and built his own new language. As time goes on
                  >> and the two languages evolve, new features of one might find their way
                  >> into the other. This is not about compatibility.[/color]
                  >
                  > I would like to see more cooperation in feature addition.[/color]

                  Indeed, I would like to see several things in C propagated into C++. In
                  particular long long and the named-width types in stdint.h. However,
                  propagating features just because they are there is not a good plan.

                  Chris C

                  Comment

                  • Chris Hills

                    #10
                    Re: mutable data structures

                    In article <42d27104.25517 2541@news.xs4al l.nl>, Richard Bos
                    <rlb@hoekstra-uitgeverij.nl> writes[color=blue]
                    >Markus.Elfring @web.de wrote:
                    >[color=green][color=darkred]
                    >> > There is no effort that I know of by either the C community nor the C++
                    >> > community to make the two languages more compatible. In designing C++ BS
                    >> > started with familiar C and built his own new language. As time goes on
                    >> > and the two languages evolve, new features of one might find their way
                    >> > into the other. This is not about compatibility.[/color]
                    >>
                    >> I would like to see more cooperation in feature addition.[/color]
                    >
                    >I would like not to see unnecessary keywords added to C. Being 79%
                    >incompatible with C++ rather than 80% is not a goal that makes sense.
                    >
                    >Richard[/color]

                    I agree the C and C++ are separate languages that share a common
                    ancestor.

                    C and C++ are likely to develop on separate directions for differing
                    reasons. For those people who need to interface to C or use C libraries
                    I suggest that they port the C code to a C subset of C++ that their C++
                    compiler supports.

                    Then write and maintain all the "c" with the C++ compiler.

                    Eventually that hybrid language c/C++ will die out.



                    --
                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                    /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                    Comment

                    • Chris Hills

                      #11
                      Re: mutable data structures

                      In article <slrndd4tv8.qbm .chris@ccserver .keris.net>, Chris Croughton
                      <chris@keristor .net> writes[color=blue]
                      >On 11 Jul 2005 05:59:02 -0700, Markus.Elfring@ web.de
                      > <Markus.Elfring @web.de> wrote:
                      >[color=green][color=darkred]
                      >>> There is no effort that I know of by either the C community nor the C++
                      >>> community to make the two languages more compatible. In designing C++ BS
                      >>> started with familiar C and built his own new language. As time goes on
                      >>> and the two languages evolve, new features of one might find their way
                      >>> into the other. This is not about compatibility.[/color]
                      >>
                      >> I would like to see more cooperation in feature addition.[/color]
                      >
                      >Indeed, I would like to see several things in C propagated into C++. In
                      >particular long long and the named-width types in stdint.h. However,
                      >propagating features just because they are there is not a good plan.
                      >
                      >Chris C[/color]

                      We agree for once ( I won't let it happen again :-)
                      --
                      \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                      \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                      /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                      \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                      Comment

                      • Markus.Elfring@web.de

                        #12
                        Re: mutable data structures

                        > Huh? If it's modifiable it can't be in write-protected memory,[color=blue]
                        > obviously.[/color]

                        What do you do if a few mutable elements are embedded into a larger
                        constant data structure?

                        Regards,
                        Markus

                        Comment

                        • Keith Thompson

                          #13
                          Re: mutable data structures

                          Markus.Elfring@ web.de writes:[color=blue][color=green]
                          >> Huh? If it's modifiable it can't be in write-protected memory,
                          >> obviously.[/color]
                          >
                          > What do you do if a few mutable elements are embedded into a larger
                          > constant data structure?[/color]

                          If a data structure has mutable elements, it's not constant, and you
                          can't put it in write-protected memory -- unless the mutable elements
                          are disjoint.

                          --
                          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

                          • Chris Croughton

                            #14
                            Re: mutable data structures

                            On 12 Jul 2005 05:00:45 -0700, Markus.Elfring@ web.de
                            <Markus.Elfring @web.de> wrote:
                            [color=blue][color=green]
                            >> Huh? If it's modifiable it can't be in write-protected memory,
                            >> obviously.[/color]
                            >
                            > What do you do if a few mutable elements are embedded into a larger
                            > constant data structure?[/color]

                            If an element can be changed then the structure isn't constant. Simple,
                            really.

                            Chris C

                            Comment

                            • Markus.Elfring@web.de

                              #15
                              Re: mutable data structures

                              > If a data structure has mutable elements, it's not constant, and you[color=blue]
                              > can't put it in write-protected memory -- unless the mutable elements
                              > are disjoint.[/color]

                              Do you distinguish between logical and physical constness?

                              Regards,
                              Markus

                              Comment

                              Working...