<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## 概述 goto并非完全有害的,程序最終不存在goto,是正確處理的結果,而非避免goto的目標 ## 合適的使用場景 ### 錯誤處理和goto ``` sub PurgeFiles (ByRef ErrorState As Error_code) //code ... errorState = FIleStatus_Success fileIindex=0 While(fileIndex <numFileToPurge) fileIndex = fileIndex +1 if Not (FindFile(fileList(fileIndex),fileToPurge)) Then ErrorState = FileStatus_FileFindError GoTo End_PROC End If if Not OpenFile(fileToPurge) Then errorState = FileStatus_FileOpenError GoTo End_PROC End If if Not OverwriteFIle(fileToPurge) Then errorState = FileStatus_FileOvereriteError GoTo End_PROC End If End While END_PROC: DeletePurgeFIleList(fileList,numFIlesToPurge) End Sub ``` 消除goto方式一:使用 if (但不不合適) bad 示例 ``` sub PurgeFiles (ByRef ErrorState As Error_code) // code errorState = FIleStatus_Success fileIindex=0 While(fileIndex <numFileToPurge And errorState = FileStatus_Success) fileIndex = fileIndex +1 If (FindFile(fileList(fileIndex),fileToPurge)) Then If OpenFile(fileToPurge) Then If Not Erase (fileToPurge) Then errorState = FileStatus_FileEraseError Else errorState = FileStatus_FileOverwriteError Else errorState = FileStatus_FileFindError Else If E,但也算代替goto比較好的方法nd While DeletePurgeFIleList(fileList,numFIlesToPurge) End Sub ``` 消除goto方式二:使用 try-findally 的局限性(比上一方法好) 如果早期代碼既使用了錯誤碼,又使用了異常,那么負責異常處理的代碼就要為每一種可能的錯誤設置一個錯誤碼 ### goto 和在 else 子句中共享代碼 ``` if (statusOK){ if(dataAvaiable){ importantVariable = x; goto MIN_LOOP; } }else{ importantVariable = GetValue(): // lots of code } ``` 消除方式一: 使用子程序 ``` if (statusOK){ if(dataAvaiable){ importantVariable = x; DolotsOfCode(importantVariable) } }else{ importantVariable = GetValue(): DolotsOfCode(importantVariable) } ``` 消除方式二: 重新組織條件 ``` if ( (statusOK & dataAvaiable) || statusOK){ if( (statusOK & dataAvaiable) ){ importantVariable = x; goto MIN_LOOP; }else{ importantVariable = GetValue(): } // lots of code } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看