Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return statements in void methods. #238

Open
ggutierrez opened this issue Oct 2, 2014 · 1 comment
Open

Return statements in void methods. #238

ggutierrez opened this issue Oct 2, 2014 · 1 comment
Labels

Comments

@ggutierrez
Copy link
Member

I have a very naive question that is much related to C++ than anything else. As it occurs in several points of the mozart2 implementation I decided to ask it here :).

The following is just a method I happened to step in while debugging some behavior.

 template <class ... Args> 
  void callBuiltin(VM vm, Args &&... args) {
    if (_self.is<BuiltinProcedure>()) {
      return _self.as<BuiltinProcedure>().callBuiltin(vm, std::forward<Args>(args)...);
    } else if (_self.isTransient()) {
      waitFor(vm, _self);
      throw std::exception(); // not reachable
    } else {
      return Interface<BuiltinCallable>().callBuiltin(_self, vm, std::forward<Args>(args)...);
    }
  }

My question is simple: why method that is supposed to return nothing (i.e. void) does actually contain return statements of "values" returned by others?. Is there some purpose behind this?

@sjrd
Copy link
Member

sjrd commented Oct 2, 2014

IIRC, these are remnants of a big refactoring that turned error codes in return values into longjmp-based exceptions. They can typically be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants