Is semicolon really needed after declarations in x++?Why is volatile needed in C?Declaring Multiple Variables in JavaScriptMeaning of 'const' last in a function declaration of a class?Semicolon after class declaration bracesWhat’s the difference between “Array()” and “[]” while declaring a JavaScript array?What is the difference between a definition and a declaration?What are forward declarations in C++?Meaning of = delete after function declarationWhat does “default” mean after a class' function declaration?Isn't a semicolon (';') needed after a function declaration in C++?

How can I search for all contacts without email?

Teaching a class likely meant to inflate the GPA of student athletes

Meaning of 'lose their grip on the groins of their followers'

What is inside of the 200 star chest?

Cascading Switches. Will it affect performance?

Fermat's statement about the ancients: How serious was he?

Russian word for a male zebra

Who won a Game of Bar Dice?

Why not invest in precious metals?

How to hide rifle during medieval town entrance inspection?

Is White controlling this game?

Why didn't Voldemort recognize that Dumbledore was affected by his curse?

Why was this person allowed to become Grand Maester?

Fixing obscure 8080 emulator bug?

Is using 'echo' to display attacker-controlled data on the terminal dangerous?

Is it possible to have a wealthy country without a middle class?

Why are trash cans referred to as "zafacón" in Puerto Rico?

How to hide an urban landmark?

Getting UPS Power from One Room to Another

Is it legal for a bar bouncer to confiscate a fake ID

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

Why can my keyboard only digest 6 keypresses at a time?

A map of non-pathological topology?

How is the excise border managed in Ireland?



Is semicolon really needed after declarations in x++?


Why is volatile needed in C?Declaring Multiple Variables in JavaScriptMeaning of 'const' last in a function declaration of a class?Semicolon after class declaration bracesWhat’s the difference between “Array()” and “[]” while declaring a JavaScript array?What is the difference between a definition and a declaration?What are forward declarations in C++?Meaning of = delete after function declarationWhat does “default” mean after a class' function declaration?Isn't a semicolon (';') needed after a function declaration in C++?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








10















As said in the book Microsoft Dynamics AX 2009 Programming: Getting Started it´s needed to put semicolons after declarations in x++:




The extra semicolon after the variable
declaration is mandatory as long as
the first line of code is not a
keyword. The semicolon tells the
compiler that variable declarations
have come to an end. You cannot
declare new variables after this
semicolon.




(copied directly from the book, unchanged, if needed I'll remove it)



However, when I remove the semicolon and run the job, there's absolutely no error or problem:



static void Job1(Args _args)

str string1 = "STACKOVERFLOW";
;
print string1;
pause;



works just as



static void Job2(Args _args)

str string1 = "STACKOVERFLOW";

print string1;
pause;



Is it really needed? Should I get used to using it?










share|improve this question
























  • I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

    – Pascal Paradis
    Feb 18 '10 at 14:29











  • for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

    – Carlos Heuberger
    Feb 25 '13 at 18:31






  • 1





    Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

    – SShaheen
    Feb 25 '13 at 19:06


















10















As said in the book Microsoft Dynamics AX 2009 Programming: Getting Started it´s needed to put semicolons after declarations in x++:




The extra semicolon after the variable
declaration is mandatory as long as
the first line of code is not a
keyword. The semicolon tells the
compiler that variable declarations
have come to an end. You cannot
declare new variables after this
semicolon.




(copied directly from the book, unchanged, if needed I'll remove it)



However, when I remove the semicolon and run the job, there's absolutely no error or problem:



static void Job1(Args _args)

str string1 = "STACKOVERFLOW";
;
print string1;
pause;



works just as



static void Job2(Args _args)

str string1 = "STACKOVERFLOW";

print string1;
pause;



Is it really needed? Should I get used to using it?










share|improve this question
























  • I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

    – Pascal Paradis
    Feb 18 '10 at 14:29











  • for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

    – Carlos Heuberger
    Feb 25 '13 at 18:31






  • 1





    Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

    – SShaheen
    Feb 25 '13 at 19:06














10












10








10


1






As said in the book Microsoft Dynamics AX 2009 Programming: Getting Started it´s needed to put semicolons after declarations in x++:




The extra semicolon after the variable
declaration is mandatory as long as
the first line of code is not a
keyword. The semicolon tells the
compiler that variable declarations
have come to an end. You cannot
declare new variables after this
semicolon.




(copied directly from the book, unchanged, if needed I'll remove it)



However, when I remove the semicolon and run the job, there's absolutely no error or problem:



static void Job1(Args _args)

str string1 = "STACKOVERFLOW";
;
print string1;
pause;



works just as



static void Job2(Args _args)

str string1 = "STACKOVERFLOW";

print string1;
pause;



Is it really needed? Should I get used to using it?










share|improve this question
















As said in the book Microsoft Dynamics AX 2009 Programming: Getting Started it´s needed to put semicolons after declarations in x++:




The extra semicolon after the variable
declaration is mandatory as long as
the first line of code is not a
keyword. The semicolon tells the
compiler that variable declarations
have come to an end. You cannot
declare new variables after this
semicolon.




(copied directly from the book, unchanged, if needed I'll remove it)



However, when I remove the semicolon and run the job, there's absolutely no error or problem:



static void Job1(Args _args)

str string1 = "STACKOVERFLOW";
;
print string1;
pause;



works just as



static void Job2(Args _args)

str string1 = "STACKOVERFLOW";

print string1;
pause;



Is it really needed? Should I get used to using it?







declaration axapta x++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 18:53









Jonathan Leffler

582k966961052




582k966961052










asked Dec 29 '09 at 18:23









MarceloMarcelo

1,921104171




1,921104171












  • I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

    – Pascal Paradis
    Feb 18 '10 at 14:29











  • for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

    – Carlos Heuberger
    Feb 25 '13 at 18:31






  • 1





    Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

    – SShaheen
    Feb 25 '13 at 19:06


















  • I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

    – Pascal Paradis
    Feb 18 '10 at 14:29











  • for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

    – Carlos Heuberger
    Feb 25 '13 at 18:31






  • 1





    Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

    – SShaheen
    Feb 25 '13 at 19:06

















I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

– Pascal Paradis
Feb 18 '10 at 14:29





I was about to ask the same question when I came across msdn.microsoft.com/en-us/library/cc967415.aspx. Good question!

– Pascal Paradis
Feb 18 '10 at 14:29













for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

– Carlos Heuberger
Feb 25 '13 at 18:31





for more information: blogs.msdn.com/b/mfp/archive/2008/04/24/…

– Carlos Heuberger
Feb 25 '13 at 18:31




1




1





Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

– SShaheen
Feb 25 '13 at 19:06






Your answer is right there in the definition. "mandatory as long as the first line of code is not a keyword." print is a keyword.

– SShaheen
Feb 25 '13 at 19:06













4 Answers
4






active

oldest

votes


















14














It's explained rather elegantly here.



A key quote [emphasis mine]:




"The reason you need that extra semicolon is because the compiler can’t always see where the variable declarations end. If you don’t help a little, it will make a guess. And it’s not very good at guessing."



While the compiler is analyzing the code it checks if the first word on a line matches the name of a type (AOT object). If it’s a type name the compiler treats the line as a variable declaration. In this case a variable name should be next.







share|improve this answer
































    8














    With the release of AX 2012 there is no need to put the additional semicolon after variable declaration.



    http://msdn.microsoft.com/en-us/library/aa636895.aspx






    share|improve this answer




















    • 4





      Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

      – 10p
      Sep 6 '12 at 0:10



















    6














    You only need the semicolon if the body of your code doesn't start with a keyword. In your example, your code starts with print, which is a built in keyword. If you had tried to start you code with: string1+=".COM"; you would receive an error.



    Dynamics AX 2009 is the last version of AX that will require the extra semicolon. AX 6.0 should fix this: mfp's two cents: What's up with this semicolon?






    share|improve this answer






























      4














      You really don't need the lovely semicolon (you don't get a compilation error) when the next word after declarations (if any) is not some keyword recognized by compilator like a type (an EDT, table, class, ...)



      For example:



      void method1()

      CustTable custTable;

      custTable = CustTable::find("cust");



      ERROR! as compiler can't separate the class declaration block of the start of the X++ code. When compilator reads the second line it doesn't know if custTable is a new variable or is part of the X++ code. So that, you need the extra semicolon to say the compiler where is the end of declarations (really, where is the start of X++ code).



      void method1()

      CustTable custTable;

      if (custTable)

      // stuff happens




      WORKS! as compiler knows that you can't declare a variable of type if (it's a reserved keyword, obviously) so it's clear that this is the beginning of X++ code and you can't declare variables after this line.



      This works that way even if there is no variable declarations:



      CustTable method1()

      custTable = CustTable::find("cust"); // custTable may exists in the context
      return custTable;



      ERROR! custTable may be a decaration, or X++ code like that example.



      CustTable method1()

      return CustTable::find("cust");



      WORKS! as return can't be a declaration.



      EXTRA:



      void method1()

      info("This should work, ya?");



      This should work (as info is not a type), isn't it? ... but it doesn't! Why? Because info is an special kernel method that will be replaced to its full name: Global::info(), first token will be Global after the precompiler replacement, and Global is a class.






      share|improve this answer

























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1976080%2fis-semicolon-really-needed-after-declarations-in-x%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        14














        It's explained rather elegantly here.



        A key quote [emphasis mine]:




        "The reason you need that extra semicolon is because the compiler can’t always see where the variable declarations end. If you don’t help a little, it will make a guess. And it’s not very good at guessing."



        While the compiler is analyzing the code it checks if the first word on a line matches the name of a type (AOT object). If it’s a type name the compiler treats the line as a variable declaration. In this case a variable name should be next.







        share|improve this answer





























          14














          It's explained rather elegantly here.



          A key quote [emphasis mine]:




          "The reason you need that extra semicolon is because the compiler can’t always see where the variable declarations end. If you don’t help a little, it will make a guess. And it’s not very good at guessing."



          While the compiler is analyzing the code it checks if the first word on a line matches the name of a type (AOT object). If it’s a type name the compiler treats the line as a variable declaration. In this case a variable name should be next.







          share|improve this answer



























            14












            14








            14







            It's explained rather elegantly here.



            A key quote [emphasis mine]:




            "The reason you need that extra semicolon is because the compiler can’t always see where the variable declarations end. If you don’t help a little, it will make a guess. And it’s not very good at guessing."



            While the compiler is analyzing the code it checks if the first word on a line matches the name of a type (AOT object). If it’s a type name the compiler treats the line as a variable declaration. In this case a variable name should be next.







            share|improve this answer















            It's explained rather elegantly here.



            A key quote [emphasis mine]:




            "The reason you need that extra semicolon is because the compiler can’t always see where the variable declarations end. If you don’t help a little, it will make a guess. And it’s not very good at guessing."



            While the compiler is analyzing the code it checks if the first word on a line matches the name of a type (AOT object). If it’s a type name the compiler treats the line as a variable declaration. In this case a variable name should be next.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 24 '18 at 17:50

























            answered Dec 29 '09 at 18:30









            Drew DormannDrew Dormann

            42.4k981144




            42.4k981144























                8














                With the release of AX 2012 there is no need to put the additional semicolon after variable declaration.



                http://msdn.microsoft.com/en-us/library/aa636895.aspx






                share|improve this answer




















                • 4





                  Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                  – 10p
                  Sep 6 '12 at 0:10
















                8














                With the release of AX 2012 there is no need to put the additional semicolon after variable declaration.



                http://msdn.microsoft.com/en-us/library/aa636895.aspx






                share|improve this answer




















                • 4





                  Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                  – 10p
                  Sep 6 '12 at 0:10














                8












                8








                8







                With the release of AX 2012 there is no need to put the additional semicolon after variable declaration.



                http://msdn.microsoft.com/en-us/library/aa636895.aspx






                share|improve this answer















                With the release of AX 2012 there is no need to put the additional semicolon after variable declaration.



                http://msdn.microsoft.com/en-us/library/aa636895.aspx







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 13 '12 at 18:22









                Jan B. Kjeldsen

                16.6k52746




                16.6k52746










                answered Dec 23 '10 at 12:31









                Deepak KalraDeepak Kalra

                9111




                9111







                • 4





                  Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                  – 10p
                  Sep 6 '12 at 0:10













                • 4





                  Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                  – 10p
                  Sep 6 '12 at 0:10








                4




                4





                Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                – 10p
                Sep 6 '12 at 0:10






                Strictly speaking, this isn't true: msdn.microsoft.com/en-us/library/cc641200.aspx "Starting in Microsoft Dynamics AX 2012 you rarely need to include a semicolon before the first statement in your X++ methods. However, you need the semi-colon in X++ methods that call static methods in the .NET Framework." More on it here: erptechnician.net/2012/06/30/… That is there are cases, however seldom they might be, when the semicolon is required even in AX 2012.

                – 10p
                Sep 6 '12 at 0:10












                6














                You only need the semicolon if the body of your code doesn't start with a keyword. In your example, your code starts with print, which is a built in keyword. If you had tried to start you code with: string1+=".COM"; you would receive an error.



                Dynamics AX 2009 is the last version of AX that will require the extra semicolon. AX 6.0 should fix this: mfp's two cents: What's up with this semicolon?






                share|improve this answer



























                  6














                  You only need the semicolon if the body of your code doesn't start with a keyword. In your example, your code starts with print, which is a built in keyword. If you had tried to start you code with: string1+=".COM"; you would receive an error.



                  Dynamics AX 2009 is the last version of AX that will require the extra semicolon. AX 6.0 should fix this: mfp's two cents: What's up with this semicolon?






                  share|improve this answer

























                    6












                    6








                    6







                    You only need the semicolon if the body of your code doesn't start with a keyword. In your example, your code starts with print, which is a built in keyword. If you had tried to start you code with: string1+=".COM"; you would receive an error.



                    Dynamics AX 2009 is the last version of AX that will require the extra semicolon. AX 6.0 should fix this: mfp's two cents: What's up with this semicolon?






                    share|improve this answer













                    You only need the semicolon if the body of your code doesn't start with a keyword. In your example, your code starts with print, which is a built in keyword. If you had tried to start you code with: string1+=".COM"; you would receive an error.



                    Dynamics AX 2009 is the last version of AX that will require the extra semicolon. AX 6.0 should fix this: mfp's two cents: What's up with this semicolon?







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 29 '09 at 19:19









                    Jay HofackerJay Hofacker

                    3,1991514




                    3,1991514





















                        4














                        You really don't need the lovely semicolon (you don't get a compilation error) when the next word after declarations (if any) is not some keyword recognized by compilator like a type (an EDT, table, class, ...)



                        For example:



                        void method1()

                        CustTable custTable;

                        custTable = CustTable::find("cust");



                        ERROR! as compiler can't separate the class declaration block of the start of the X++ code. When compilator reads the second line it doesn't know if custTable is a new variable or is part of the X++ code. So that, you need the extra semicolon to say the compiler where is the end of declarations (really, where is the start of X++ code).



                        void method1()

                        CustTable custTable;

                        if (custTable)

                        // stuff happens




                        WORKS! as compiler knows that you can't declare a variable of type if (it's a reserved keyword, obviously) so it's clear that this is the beginning of X++ code and you can't declare variables after this line.



                        This works that way even if there is no variable declarations:



                        CustTable method1()

                        custTable = CustTable::find("cust"); // custTable may exists in the context
                        return custTable;



                        ERROR! custTable may be a decaration, or X++ code like that example.



                        CustTable method1()

                        return CustTable::find("cust");



                        WORKS! as return can't be a declaration.



                        EXTRA:



                        void method1()

                        info("This should work, ya?");



                        This should work (as info is not a type), isn't it? ... but it doesn't! Why? Because info is an special kernel method that will be replaced to its full name: Global::info(), first token will be Global after the precompiler replacement, and Global is a class.






                        share|improve this answer





























                          4














                          You really don't need the lovely semicolon (you don't get a compilation error) when the next word after declarations (if any) is not some keyword recognized by compilator like a type (an EDT, table, class, ...)



                          For example:



                          void method1()

                          CustTable custTable;

                          custTable = CustTable::find("cust");



                          ERROR! as compiler can't separate the class declaration block of the start of the X++ code. When compilator reads the second line it doesn't know if custTable is a new variable or is part of the X++ code. So that, you need the extra semicolon to say the compiler where is the end of declarations (really, where is the start of X++ code).



                          void method1()

                          CustTable custTable;

                          if (custTable)

                          // stuff happens




                          WORKS! as compiler knows that you can't declare a variable of type if (it's a reserved keyword, obviously) so it's clear that this is the beginning of X++ code and you can't declare variables after this line.



                          This works that way even if there is no variable declarations:



                          CustTable method1()

                          custTable = CustTable::find("cust"); // custTable may exists in the context
                          return custTable;



                          ERROR! custTable may be a decaration, or X++ code like that example.



                          CustTable method1()

                          return CustTable::find("cust");



                          WORKS! as return can't be a declaration.



                          EXTRA:



                          void method1()

                          info("This should work, ya?");



                          This should work (as info is not a type), isn't it? ... but it doesn't! Why? Because info is an special kernel method that will be replaced to its full name: Global::info(), first token will be Global after the precompiler replacement, and Global is a class.






                          share|improve this answer



























                            4












                            4








                            4







                            You really don't need the lovely semicolon (you don't get a compilation error) when the next word after declarations (if any) is not some keyword recognized by compilator like a type (an EDT, table, class, ...)



                            For example:



                            void method1()

                            CustTable custTable;

                            custTable = CustTable::find("cust");



                            ERROR! as compiler can't separate the class declaration block of the start of the X++ code. When compilator reads the second line it doesn't know if custTable is a new variable or is part of the X++ code. So that, you need the extra semicolon to say the compiler where is the end of declarations (really, where is the start of X++ code).



                            void method1()

                            CustTable custTable;

                            if (custTable)

                            // stuff happens




                            WORKS! as compiler knows that you can't declare a variable of type if (it's a reserved keyword, obviously) so it's clear that this is the beginning of X++ code and you can't declare variables after this line.



                            This works that way even if there is no variable declarations:



                            CustTable method1()

                            custTable = CustTable::find("cust"); // custTable may exists in the context
                            return custTable;



                            ERROR! custTable may be a decaration, or X++ code like that example.



                            CustTable method1()

                            return CustTable::find("cust");



                            WORKS! as return can't be a declaration.



                            EXTRA:



                            void method1()

                            info("This should work, ya?");



                            This should work (as info is not a type), isn't it? ... but it doesn't! Why? Because info is an special kernel method that will be replaced to its full name: Global::info(), first token will be Global after the precompiler replacement, and Global is a class.






                            share|improve this answer















                            You really don't need the lovely semicolon (you don't get a compilation error) when the next word after declarations (if any) is not some keyword recognized by compilator like a type (an EDT, table, class, ...)



                            For example:



                            void method1()

                            CustTable custTable;

                            custTable = CustTable::find("cust");



                            ERROR! as compiler can't separate the class declaration block of the start of the X++ code. When compilator reads the second line it doesn't know if custTable is a new variable or is part of the X++ code. So that, you need the extra semicolon to say the compiler where is the end of declarations (really, where is the start of X++ code).



                            void method1()

                            CustTable custTable;

                            if (custTable)

                            // stuff happens




                            WORKS! as compiler knows that you can't declare a variable of type if (it's a reserved keyword, obviously) so it's clear that this is the beginning of X++ code and you can't declare variables after this line.



                            This works that way even if there is no variable declarations:



                            CustTable method1()

                            custTable = CustTable::find("cust"); // custTable may exists in the context
                            return custTable;



                            ERROR! custTable may be a decaration, or X++ code like that example.



                            CustTable method1()

                            return CustTable::find("cust");



                            WORKS! as return can't be a declaration.



                            EXTRA:



                            void method1()

                            info("This should work, ya?");



                            This should work (as info is not a type), isn't it? ... but it doesn't! Why? Because info is an special kernel method that will be replaced to its full name: Global::info(), first token will be Global after the precompiler replacement, and Global is a class.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 25 '13 at 21:00

























                            answered Feb 25 '13 at 17:32









                            j.a.estevanj.a.estevan

                            2,9251430




                            2,9251430



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1976080%2fis-semicolon-really-needed-after-declarations-in-x%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                                Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript