#region pre-processor or not?

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

    #region pre-processor or not?

    I have two books saying different things about the #region directive. One
    says that all code within #region does not affect the compilation process
    in any way, while the other states that the entire region is marked for a
    pre-processor directive which does affect the compilation process.

    I was wondering which is accurate? Is #region/#endregion just a text
    editor visualization tool with not effect otherwise, or is everything
    within the block seen as one big preprocessor command?

    TIA
    -John
  • Alvin Bruney

    #2
    Re: #region pre-processor or not?

    there really isnt a preprocessing phase in the compilation process these
    were c++ days. the 'pre-processing' phase is now part of the lexigraphical
    analyzer portion. code falling within these blocks affect conditional
    compilation which means that the text is re-arranged before the compiler
    proper sees. so in fact, pre-processing does affect the compilation process.

    "John" <Jeric@Sbcgloba lDotNetwork.NoS pam> wrote in message
    news:pan.2003.0 9.28.15.27.55.9 3518@SbcglobalD otNetwork.NoSpa m...[color=blue]
    > I have two books saying different things about the #region directive. One
    > says that all code within #region does not affect the compilation process
    > in any way, while the other states that the entire region is marked for a
    > pre-processor directive which does affect the compilation process.
    >
    > I was wondering which is accurate? Is #region/#endregion just a text
    > editor visualization tool with not effect otherwise, or is everything
    > within the block seen as one big preprocessor command?
    >
    > TIA
    > -John[/color]


    Comment

    • Not Available

      #3
      Re: #region pre-processor or not?

      Interesting, because I recently took a c# skills test and I got the following question wrong. I think I answered D



      4 The #region preprocessor directive:

      a. defines a region of code to be executed before the rest.

      b. Marks an area of text with a comment

      c. Defines a region of code to be compiled with 'debug on'

      d. Marks an area of text to be treated as native call.



      I looked through all the documenatation and the best I could figure was it was B.





      "Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in message news:%23OV7a2dh DHA.1696@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > there really isnt a preprocessing phase in the compilation process these
      > were c++ days. the 'pre-processing' phase is now part of the lexigraphical
      > analyzer portion. code falling within these blocks affect conditional
      > compilation which means that the text is re-arranged before the compiler
      > proper sees. so in fact, pre-processing does affect the compilation process.
      >
      > "John" <Jeric@Sbcgloba lDotNetwork.NoS pam> wrote in message
      > news:pan.2003.0 9.28.15.27.55.9 3518@SbcglobalD otNetwork.NoSpa m...[color=green]
      > > I have two books saying different things about the #region directive. One
      > > says that all code within #region does not affect the compilation process
      > > in any way, while the other states that the entire region is marked for a
      > > pre-processor directive which does affect the compilation process.
      > >
      > > I was wondering which is accurate? Is #region/#endregion just a text
      > > editor visualization tool with not effect otherwise, or is everything
      > > within the block seen as one big preprocessor command?
      > >
      > > TIA
      > > -John[/color]
      >
      >[/color]

      Comment

      • Daniel O'Connell

        #4
        Re: #region pre-processor or not?

        b is probably correct, #region is used to subsection code in the editor, its
        a language feature that exists strictly for nicer IDE's.
        Its actually the only one I can think of that is there for that singular
        purpose.

        blasted OE, looses commenting markers when changing from html to plain text,
        <g>

        -----end post-----

        "Not Available" <notavailable@b .com> wrote in message
        news:FqFdb.2015 9$lZ6.5209723@t wister.nyc.rr.c om...
        Interesting, because I recently took a c# skills test and I got the
        following question wrong. I think I answered D

        4 The #region preprocessor directive:
        a. defines a region of code to be executed before the rest.
        b. Marks an area of text with a comment
        c. Defines a region of code to be compiled with 'debug on'
        d. Marks an area of text to be treated as native call.

        I looked through all the documenatation and the best I could figure was it
        was B.


        "Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
        message news:%23OV7a2dh DHA.1696@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > there really isnt a preprocessing phase in the compilation process these
        > were c++ days. the 'pre-processing' phase is now part of the lexigraphical
        > analyzer portion. code falling within these blocks affect conditional
        > compilation which means that the text is re-arranged before the compiler
        > proper sees. so in fact, pre-processing does affect the compilation[/color]
        process.[color=blue]
        >
        > "John" <Jeric@Sbcgloba lDotNetwork.NoS pam> wrote in message
        > news:pan.2003.0 9.28.15.27.55.9 3518@SbcglobalD otNetwork.NoSpa m...[color=green]
        > > I have two books saying different things about the #region directive.[/color][/color]
        One[color=blue][color=green]
        > > says that all code within #region does not affect the compilation[/color][/color]
        process[color=blue][color=green]
        > > in any way, while the other states that the entire region is marked for[/color][/color]
        a[color=blue][color=green]
        > > pre-processor directive which does affect the compilation process.
        > >
        > > I was wondering which is accurate? Is #region/#endregion just a text
        > > editor visualization tool with not effect otherwise, or is everything
        > > within the block seen as one big preprocessor command?
        > >
        > > TIA
        > > -John[/color]
        >
        >[/color]


        Comment

        • Joe Mayo

          #5
          Re: #region pre-processor or not?

          "John" <Jeric@Sbcgloba lDotNetwork.NoS pam> wrote in message
          news:pan.2003.0 9.28.15.27.55.9 3518@SbcglobalD otNetwork.NoSpa m...[color=blue]
          > I have two books saying different things about the #region directive. One
          > says that all code within #region does not affect the compilation process
          > in any way, while the other states that the entire region is marked for a
          > pre-processor directive which does affect the compilation process.
          >
          > I was wondering which is accurate? Is #region/#endregion just a text
          > editor visualization tool with not effect otherwise, or is everything
          > within the block seen as one big preprocessor command?[/color]

          Hi John,

          The #region/#endregion preprocessing directives have no effect on the
          resulting compiled code. They exist simply for the benefit of IDE's to
          group a block of code during editing.

          Joe
          --
          Welcome to C# Station!  This is a community site for people interested in applying .NET using the C# programming language.  We’ve been around since July 4th 2000 and have continued to grow over the years.  Items of interest include Articles, Books, Links, Documentation,  and Tutorials. More… Source Code If you would like to see an […]



          Comment

          • John S.

            #6
            Re: #region pre-processor or not?

            On Sun, 28 Sep 2003 15:27:53 -0600, Joe Mayo wrote:
            [color=blue]
            > They exist simply for the benefit of IDE's to
            > group a block of code during editing.[/color]

            Thanks for the reply. I don't see why microsoft chose this method as
            opposed to a more normal one such as a derivation of //, /*, or /// for
            regions. Using a preprocessor directive that has nothing to do but make
            comments seems so odd. Is there a reason that they didn't use a normal
            commenting alternative, instead, for this concept?

            TIA
            -John

            Comment

            • Joe Mayo

              #7
              Re: #region pre-processor or not?

              "John S." <Jeric@Sbcgloba lDotNetwork.NoS pam> wrote in message
              news:pan.2003.0 9.28.23.38.52.1 05836@Sbcglobal DotNetwork.NoSp am...[color=blue]
              > On Sun, 28 Sep 2003 15:27:53 -0600, Joe Mayo wrote:
              >[color=green]
              > > They exist simply for the benefit of IDE's to
              > > group a block of code during editing.[/color]
              >
              > Thanks for the reply. I don't see why microsoft chose this method as
              > opposed to a more normal one such as a derivation of //, /*, or /// for
              > regions. Using a preprocessor directive that has nothing to do but make
              > comments seems so odd. Is there a reason that they didn't use a normal
              > commenting alternative, instead, for this concept?[/color]

              Although you can add text to the #region directive, that is not a comment,
              but is really a description of the region. IMO, a comment would be
              additional syntax for expressing what a region does and would not be a good
              substitute because you would have to define a region comment standard that
              has a begin and end. Also, IMO, a comment is not representative for what a
              region accomplishes. The real purpose of a region is to help organize code.

              In the IDE, you can use a region to expand and collapse large blocks of
              code. This makes navigation and reading code a whole lot easier. An
              example of this is when defining a custom collection class in VS.NET. Every
              time you implement an interface and press the tab key, VS.NET adds a new
              region to your type with skeleton stubs for interface members. By the time
              you've completed collection class implementation, you have dozens of
              members. The regions that categorize and classify these methods according
              to interface make the class a whole lot easiser to navigate and use. This
              is just one way that regions can help organize code, which could also be by
              member type (events, methods, properties, etc). If all you have is Notepad,
              they lack benefit because there is no way to expand and collapse them, but
              if you're using an IDE, they are great.

              Joe
              --
              Welcome to C# Station!  This is a community site for people interested in applying .NET using the C# programming language.  We’ve been around since July 4th 2000 and have continued to grow over the years.  Items of interest include Articles, Books, Links, Documentation,  and Tutorials. More… Source Code If you would like to see an […]



              Comment

              Working...