Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Creator: Completion no longer adds closing semicolon
Forum Updated to NodeBB v4.3 + New Features

Creator: Completion no longer adds closing semicolon

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
29 Posts 9 Posters 6.9k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #3

    Can't tell if it was previously the case, I usually make a new file for each class, but I noticed this for enumerations as well.
    I Could swear that before 4.5 the autocompleter made the semicolon there too.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    sierdzioS 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      Can't tell if it was previously the case, I usually make a new file for each class, but I noticed this for enumerations as well.
      I Could swear that before 4.5 the autocompleter made the semicolon there too.

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #4

      @J.Hilk said in Creator: Completion no longer adds closing semicolon:

      I Could swear that before 4.5 the autocompleter made the semicolon there too.

      Yep, it did.

      So, @Asperamanca will you create a bug report for this? If yes please post the link here, I'll upvote it.

      (Z(:^

      aha_1980A 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @J.Hilk said in Creator: Completion no longer adds closing semicolon:

        I Could swear that before 4.5 the autocompleter made the semicolon there too.

        Yep, it did.

        So, @Asperamanca will you create a bug report for this? If yes please post the link here, I'll upvote it.

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @sierdzio @Asperamanca @J-Hilk:

        Looks like this one is related to https://bugreports.qt.io/browse/QTCREATORBUG-18872

        The reason to change the brace insertion was: https://bugreports.qt.io/browse/QTCREATORBUG-15073

        So please, someone create a report for this regression too. Thanks.

        Qt has to stay free or it will die.

        1 Reply Last reply
        3
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by Asperamanca
          #6

          I can do that via support.

          EDIT: Thanks for confirming this. Have now raised via support.

          1 Reply Last reply
          1
          • JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #7

            Please don't shoot me for asking this here --- technically I guess it's OT --- but I have wondered (I'm not a C++-er): why does a C++ class X { ... } statement/construct actually need a terminating semi-colon? Is it that you can optionally write something at the end, like

            { ... } variable, *pointer;
            , like you can with struct { ... } ??

            sierdzioS 1 Reply Last reply
            0
            • JonBJ JonB

              Please don't shoot me for asking this here --- technically I guess it's OT --- but I have wondered (I'm not a C++-er): why does a C++ class X { ... } statement/construct actually need a terminating semi-colon? Is it that you can optionally write something at the end, like

              { ... } variable, *pointer;
              , like you can with struct { ... } ??

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #8

              @JonB said in Creator: Completion no longer adds closing semicolon:

              Please don't shoot me for asking this here --- technically I guess it's OT --- but I have wondered (I'm not a C++-er): why does a C++ class X { ... } statement/construct actually need a terminating semi-colon?

              There is no real reason. Somebody, somewhere, a long time ago, decided that this will be the syntax, and it stayed to this day ;-)

              (Z(:^

              kshegunovK 1 Reply Last reply
              2
              • sierdzioS sierdzio

                @JonB said in Creator: Completion no longer adds closing semicolon:

                Please don't shoot me for asking this here --- technically I guess it's OT --- but I have wondered (I'm not a C++-er): why does a C++ class X { ... } statement/construct actually need a terminating semi-colon?

                There is no real reason. Somebody, somewhere, a long time ago, decided that this will be the syntax, and it stayed to this day ;-)

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #9

                @sierdzio said in Creator: Completion no longer adds closing semicolon:

                There is no real reason. Somebody, somewhere, a long time ago, decided that this will be the syntax, and it stayed to this day ;-)

                I beg to disagree, @JonB's supposition is perfectly correct.

                class {
                } variable, *pointer;
                

                is a valid and expected (in some cases) construct, albeit somewhat rare. So the semicolon has a well defined meaning and usage.

                Read and abide by the Qt Code of Conduct

                JonBJ sierdzioS 2 Replies Last reply
                4
                • kshegunovK kshegunov

                  @sierdzio said in Creator: Completion no longer adds closing semicolon:

                  There is no real reason. Somebody, somewhere, a long time ago, decided that this will be the syntax, and it stayed to this day ;-)

                  I beg to disagree, @JonB's supposition is perfectly correct.

                  class {
                  } variable, *pointer;
                  

                  is a valid and expected (in some cases) construct, albeit somewhat rare. So the semicolon has a well defined meaning and usage.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #10

                  @kshegunov

                  Yes, I wondered whether C++ might allow just that, exactly as struct does! As you say, I have never seen that used with class! So, since we omitted even a class name after the word class, here we have an anonymous class. Interesting :)

                  kshegunovK 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @kshegunov

                    Yes, I wondered whether C++ might allow just that, exactly as struct does! As you say, I have never seen that used with class! So, since we omitted even a class name after the word class, here we have an anonymous class. Interesting :)

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #11

                    There's no difference between struct and class in C++ with the exception of the default access specifier - being public and private respectively (also extending to default-access inheritance).

                    Read and abide by the Qt Code of Conduct

                    JonBJ 1 Reply Last reply
                    0
                    • kshegunovK kshegunov

                      There's no difference between struct and class in C++ with the exception of the default access specifier - being public and private respectively (also extending to default-access inheritance).

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #12

                      @kshegunov

                      There's no difference between struct and class in C++ with the exception of the default access specifier

                      Hmm, can I try to challenge this (without lazily just Googling!)?

                      One problem is that I'm used to C# not C++, C# has struct as well as class, but does have different semantics, so what I'm thinking of might be C# not C++...

                      IIRC (though I could be shaky!), in C# struct must have a constructor with no parameters, even if there is another overload which does take parameters. Not so for class. How's that in C++ ? :) In C++, class can do multiple inheritance, right? But structs can't multiple inherit, can they?

                      kshegunovK 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @kshegunov

                        There's no difference between struct and class in C++ with the exception of the default access specifier

                        Hmm, can I try to challenge this (without lazily just Googling!)?

                        One problem is that I'm used to C# not C++, C# has struct as well as class, but does have different semantics, so what I'm thinking of might be C# not C++...

                        IIRC (though I could be shaky!), in C# struct must have a constructor with no parameters, even if there is another overload which does take parameters. Not so for class. How's that in C++ ? :) In C++, class can do multiple inheritance, right? But structs can't multiple inherit, can they?

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by kshegunov
                        #13

                        @JonB said in Creator: Completion no longer adds closing semicolon:

                        How's that in C++ ? :)

                        They're absolutely equivalent:

                        struct X
                        {
                            X(int, int);
                        };
                        

                        is the same as:

                        class X
                        {
                        public:
                            X(int, int);
                        };
                        

                        And then:

                        class X : Y
                        {
                        };
                        

                        is the same as:

                        class X : private Y
                        {
                        };
                        

                        as for struct:

                        struct X : Y
                        {
                        }:
                        

                        is equivalent to:

                        struct X : public Y
                        {
                        };
                        

                        Additionally inheritance can mix class and struct all the same, it doesn't care about the exact keyword you used, only cares about the access of each member.

                        But structs can't multiple inherit, can they?

                        Sure they can.

                        struct A { };
                        struct B { };
                        struct C : A, B  {};
                        

                        Is absolutely valid.

                        Read and abide by the Qt Code of Conduct

                        JonBJ 1 Reply Last reply
                        2
                        • kshegunovK kshegunov

                          @JonB said in Creator: Completion no longer adds closing semicolon:

                          How's that in C++ ? :)

                          They're absolutely equivalent:

                          struct X
                          {
                              X(int, int);
                          };
                          

                          is the same as:

                          class X
                          {
                          public:
                              X(int, int);
                          };
                          

                          And then:

                          class X : Y
                          {
                          };
                          

                          is the same as:

                          class X : private Y
                          {
                          };
                          

                          as for struct:

                          struct X : Y
                          {
                          }:
                          

                          is equivalent to:

                          struct X : public Y
                          {
                          };
                          

                          Additionally inheritance can mix class and struct all the same, it doesn't care about the exact keyword you used, only cares about the access of each member.

                          But structs can't multiple inherit, can they?

                          Sure they can.

                          struct A { };
                          struct B { };
                          struct C : A, B  {};
                          

                          Is absolutely valid.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #14

                          @kshegunov

                          OK, this is why I like C & C# but not C++ ! I'll stop trying to think of where C++ struct might differ from class, since you're pretty clear & adamant that they don't :) Thanks.

                          A 1 Reply Last reply
                          0
                          • kshegunovK kshegunov

                            @sierdzio said in Creator: Completion no longer adds closing semicolon:

                            There is no real reason. Somebody, somewhere, a long time ago, decided that this will be the syntax, and it stayed to this day ;-)

                            I beg to disagree, @JonB's supposition is perfectly correct.

                            class {
                            } variable, *pointer;
                            

                            is a valid and expected (in some cases) construct, albeit somewhat rare. So the semicolon has a well defined meaning and usage.

                            sierdzioS Offline
                            sierdzioS Offline
                            sierdzio
                            Moderators
                            wrote on last edited by
                            #15

                            @kshegunov said in Creator: Completion no longer adds closing semicolon:

                            class {
                            } variable, *pointer;

                            is a valid and expected (in some cases) construct, albeit somewhat rare

                            Indeed, point taken :-) You are right.

                            (Z(:^

                            1 Reply Last reply
                            1
                            • JonBJ JonB

                              @kshegunov

                              OK, this is why I like C & C# but not C++ ! I'll stop trying to think of where C++ struct might differ from class, since you're pretty clear & adamant that they don't :) Thanks.

                              A Offline
                              A Offline
                              Asperamanca
                              wrote on last edited by
                              #16

                              @JonB said in Creator: Completion no longer adds closing semicolon:

                              @kshegunov

                              OK, this is why I like C & C# but not C++ ! I'll stop trying to think of where C++ struct might differ from class, since you're pretty clear & adamant that they don't :) Thanks.

                              C++ makes perfect sense, if you know it's history. Off the top of my head, I would say that struct came from pure C. When they designed C++, they needed a new construct for 'class', but decided to model it as closely as possible to an already existing construct, 'struct'. They decided that making everything public by default was too dangerous for 'class', but for compatibility reasons, they could not change that behavior for 'struct'.

                              Today, you can use 'struct' and 'class' to convey different intentions. See http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-struct

                              jsulmJ 1 Reply Last reply
                              0
                              • A Asperamanca

                                @JonB said in Creator: Completion no longer adds closing semicolon:

                                @kshegunov

                                OK, this is why I like C & C# but not C++ ! I'll stop trying to think of where C++ struct might differ from class, since you're pretty clear & adamant that they don't :) Thanks.

                                C++ makes perfect sense, if you know it's history. Off the top of my head, I would say that struct came from pure C. When they designed C++, they needed a new construct for 'class', but decided to model it as closely as possible to an already existing construct, 'struct'. They decided that making everything public by default was too dangerous for 'class', but for compatibility reasons, they could not change that behavior for 'struct'.

                                Today, you can use 'struct' and 'class' to convey different intentions. See http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-struct

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                @Asperamanca I think struct is still part of C++ because C should be a subset of C++ (more or less)

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                A 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @Asperamanca I think struct is still part of C++ because C should be a subset of C++ (more or less)

                                  A Offline
                                  A Offline
                                  Asperamanca
                                  wrote on last edited by
                                  #18

                                  @jsulm said in Creator: Completion no longer adds closing semicolon:

                                  @Asperamanca I think struct is still part of C++ because C should be a subset of C++ (more or less)

                                  I had no intention of saying "struct is not part of C++", because of course it is.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • A Asperamanca

                                    @jsulm said in Creator: Completion no longer adds closing semicolon:

                                    @Asperamanca I think struct is still part of C++ because C should be a subset of C++ (more or less)

                                    I had no intention of saying "struct is not part of C++", because of course it is.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #19

                                    @Asperamanca You misunderstood me: I think struct could be removed from C++ as it is redundant (class is same thing), but then C wouldn't be subset of C++ anymore.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    A 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @Asperamanca You misunderstood me: I think struct could be removed from C++ as it is redundant (class is same thing), but then C wouldn't be subset of C++ anymore.

                                      A Offline
                                      A Offline
                                      Asperamanca
                                      wrote on last edited by
                                      #20

                                      @jsulm
                                      Compatibility to legacy code is one of the strengths of C++. I for one would not want to go digging in old but reliably working code, just because a new version of the language stopped supporting certain constructs.

                                      When MS did that moving from VB6 to VB.NET, we dropped VB and since use C++ instead.

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • A Asperamanca

                                        @jsulm
                                        Compatibility to legacy code is one of the strengths of C++. I for one would not want to go digging in old but reliably working code, just because a new version of the language stopped supporting certain constructs.

                                        When MS did that moving from VB6 to VB.NET, we dropped VB and since use C++ instead.

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        @Asperamanca I didn't suggest to do it, just mentioned why (probably) C++ still has struct even if it has class.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        JonBJ 1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @Asperamanca I didn't suggest to do it, just mentioned why (probably) C++ still has struct even if it has class.

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by JonB
                                          #22

                                          @jsulm
                                          C# has struct as well as class, even though it has no pretence of backward C compatibility!

                                          And since we can't get C compilers any more, only C++ ones, thank goodness we can still get old-fashioned C code through them, without C++ bloatware ;-)

                                          sierdzioS 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved