apjanke / octave-packajoozle

A just-for-fun reworking of GNU Octave's `pkg` tool
GNU General Public License v3.0
4 stars 1 forks source link

You can call `continue` from within a function, for the caller's loop? #35

Closed apjanke closed 5 years ago

apjanke commented 5 years ago

You can call continue from within a function, and it works on the loop in the calling function?


    function out = get_status (this)
      %RAII.cd = packajoozle.internal.Util.local_cd_change (this.repo_path);
      cmd = sprintf ("git -C '%s' status --porcelain", this.repo_path);
      [exit_code, txt] = system (cmd); % Non-zero exit status does not mean error!
      lines = regexp (txt, "\r?\n", "split");
      out.file = {};
      out.status = {};
      if isempty (txt)
        continue
      endif
      for i = 1:numel (lines)
        line = lines{i};
        if isempty (line)
          continue
        endif
        out.file{i} = line(4:end);
        out.status{i} = line(1:2);
      endfor
    endfunction

Called that from a loop, and it skipped passes!

apjanke commented 5 years ago

Reported upstream: https://savannah.gnu.org/bugs/?55995

apjanke commented 5 years ago

This has been changed upstream: in Octave default, continue is now lexically scoped.