Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Where is the exit?

Where is the exit?

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
13 Posts 9 Posters 0 Views 1 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.
  • D DaveAuld

    Is this a modern Where's Wally?

    red_moon wrote:

    Where is the exit?

    Private Function xxx(ByVal name As String) As Boolean
    Dim xxxResult As Boolean = False
    If name = "A" Then
    ' Lots of code here
    Return xxxResult
    Else
    ' Lots of code here
    Return xxxResult
    End If
    ' Lots of code again
    Return xxxResult
    Exit Function <------Its there just before the word function; Whats the prize?
    End Function

    Ok, so he's using multiple return points, and there is no requirement here for the Exit Function statement as it is at the end.

    Dave Don't forget to rate messages!
    Find Me On: Web|Facebook|Twitter|LinkedIn

    R Offline
    R Offline
    red_moon
    wrote on last edited by
    #4

    And all statements after End If is never executed too ... :doh:

    25160506848319

    1 Reply Last reply
    0
    • P PIEBALDconsult

      Yeah, that needs some GOTOs. :-D

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #5

      Yeah - starting with "GOTO AProgrammingLanguageThanSpotsUnreachableCode"

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      L 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Yeah - starting with "GOTO AProgrammingLanguageThanSpotsUnreachableCode"

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #6

        I haven't met many compilers that do a good job at detecting unreachable statements, try this C# snippet:

        public int unreachable(int a) {
        if (a==1) return 2;
        if (a!=1) return 3;
        return 4;
        }

        :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        OriginalGriffO 1 Reply Last reply
        0
        • L Luc Pattyn

          I haven't met many compilers that do a good job at detecting unreachable statements, try this C# snippet:

          public int unreachable(int a) {
          if (a==1) return 2;
          if (a!=1) return 3;
          return 4;
          }

          :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #7

          That's just a if..else..maybe construct: we used to use them all the time in FORTRAN (because the compiler was such rubbish "maybe" would get executed sometimes). At least C# would spot

          public int unreachable(int a)
          {
          if (a==1)
          return 2;
          else
          return 3;
          return 4;
          }

          Unlike some of the "coderzz" we have asking questions at the moment... :laugh:

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • D DaveAuld

            Is this a modern Where's Wally?

            red_moon wrote:

            Where is the exit?

            Private Function xxx(ByVal name As String) As Boolean
            Dim xxxResult As Boolean = False
            If name = "A" Then
            ' Lots of code here
            Return xxxResult
            Else
            ' Lots of code here
            Return xxxResult
            End If
            ' Lots of code again
            Return xxxResult
            Exit Function <------Its there just before the word function; Whats the prize?
            End Function

            Ok, so he's using multiple return points, and there is no requirement here for the Exit Function statement as it is at the end.

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn

            K Offline
            K Offline
            Kunal Chowdhury IN
            wrote on last edited by
            #8

            daveauld wrote:

            Its there just before the word function; Whats the prize?

            Check the code again. Will it come there to execute? How? ;P

            Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


            Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

            D 1 Reply Last reply
            0
            • D DaveAuld

              Is this a modern Where's Wally?

              red_moon wrote:

              Where is the exit?

              Private Function xxx(ByVal name As String) As Boolean
              Dim xxxResult As Boolean = False
              If name = "A" Then
              ' Lots of code here
              Return xxxResult
              Else
              ' Lots of code here
              Return xxxResult
              End If
              ' Lots of code again
              Return xxxResult
              Exit Function <------Its there just before the word function; Whats the prize?
              End Function

              Ok, so he's using multiple return points, and there is no requirement here for the Exit Function statement as it is at the end.

              Dave Don't forget to rate messages!
              Find Me On: Web|Facebook|Twitter|LinkedIn

              P Offline
              P Offline
              phil o
              wrote on last edited by
              #9

              Maybe this function is so comfortable that the thread spends a lot more time than needed in it ? Therefore the Exit Function to kick its ass and make it return to work... ^^

              1 Reply Last reply
              0
              • R red_moon

                I just take a look into my friend's code, then I found something confusing to me :confused: I have made some modifications here :

                Private Function xxx(ByVal name As String) As Boolean
                Dim xxxResult As Boolean = False
                If name = "A" Then
                ' Lots of code here
                Return xxxResult
                Else
                ' Lots of code here
                Return xxxResult
                End If
                ' Lots of code again
                Return xxxResult
                Exit Function
                End Function

                Finally, when I want to go back to my home, I still confused, the world is spinning in my head, there are so much doors. ;P

                25160506848319

                R Offline
                R Offline
                RugbyLeague
                wrote on last edited by
                #10

                He codes for both Aristotlean and Bhuddist logic. In the vast majority of cases the black and white of Aristotle will hold true but never underestimate the differing shades of Bhuddist logic. Maybe.

                1 Reply Last reply
                0
                • R red_moon

                  I just take a look into my friend's code, then I found something confusing to me :confused: I have made some modifications here :

                  Private Function xxx(ByVal name As String) As Boolean
                  Dim xxxResult As Boolean = False
                  If name = "A" Then
                  ' Lots of code here
                  Return xxxResult
                  Else
                  ' Lots of code here
                  Return xxxResult
                  End If
                  ' Lots of code again
                  Return xxxResult
                  Exit Function
                  End Function

                  Finally, when I want to go back to my home, I still confused, the world is spinning in my head, there are so much doors. ;P

                  25160506848319

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #11

                  Most girls I've asked seem to think there is a very specific area that is an exit (making sure to note that it is not an entrance). In order to pass on this knowledge, I thought I'd let you know that "Return xxx..." is not an entrance.

                  [Forum Guidelines]

                  1 Reply Last reply
                  0
                  • K Kunal Chowdhury IN

                    daveauld wrote:

                    Its there just before the word function; Whats the prize?

                    Check the code again. Will it come there to execute? How? ;P

                    Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


                    Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

                    D Offline
                    D Offline
                    DaveAuld
                    wrote on last edited by
                    #12

                    There are chunks of code removed, so we cannot assume that there are no Exit If's anywhere. Also, if its VB6 there may also be some On Error Resume Next statements. (Or On Error Goto xyz), Ah, those 'handy' statements! :doh: :)

                    Dave Don't forget to rate messages!
                    Find Me On: Web|Facebook|Twitter|LinkedIn

                    K 1 Reply Last reply
                    0
                    • D DaveAuld

                      There are chunks of code removed, so we cannot assume that there are no Exit If's anywhere. Also, if its VB6 there may also be some On Error Resume Next statements. (Or On Error Goto xyz), Ah, those 'handy' statements! :doh: :)

                      Dave Don't forget to rate messages!
                      Find Me On: Web|Facebook|Twitter|LinkedIn

                      K Offline
                      K Offline
                      Kunal Chowdhury IN
                      wrote on last edited by
                      #13

                      So, it's depends on the whole code implementation... Without seeing the original code, it's not feasible to reply... :laugh:

                      Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


                      Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups