alashworth / test-issue-import

0 stars 0 forks source link

Add exit() to the language #108

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by syclik Monday Aug 22, 2016 at 15:12 GMT Originally opened as https://github.com/stan-dev/stan/issues/2022


Summary:

Add an exit() function to the language.

We could also call it error(), fatal(), or fatal_error().

Description:

Currently, we have reject() in the Stan language. Using reject() rejects the current iteration.

We should have matching exit() calls in the Stan language. Using exit() should stop algorithms from continuing. This will indicate that there is something wrong and shouldn't be ignored. As opposed to reject() which will continue onto the next iteration.

Here's an example:

parameters {
  real<lower = 0, upper = 1> theta;
}
model {
  exit();
}

Current Output:

Currently, this will show that the 100 tries for initialization failed.

Expected Output:

Exit the algorithm.

Current Version:

v2.11.0

alashworth commented 5 years ago

Comment by syclik Monday Aug 22, 2016 at 15:14 GMT


I think action is on me to come up with possible exceptions to throw.

alashworth commented 5 years ago

Comment by syclik Tuesday May 09, 2017 at 21:27 GMT


I would suggest using std::system_error (introduced in C++11). http://www.cplusplus.com/reference/system_error/system_error/

It takes a string and an error code. With pull request stan-dev/stan#2307, this should pass through and stop the samplers.