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

[FR] Bool data type? #1328

Open
andrjohns opened this issue May 11, 2023 · 1 comment
Open

[FR] Bool data type? #1328

andrjohns opened this issue May 11, 2023 · 1 comment
Labels
feature New feature or request

Comments

@andrjohns
Copy link
Contributor

andrjohns commented May 11, 2023

Would it be tricky/breaking to add support for a bool/boolean data type? All of the conditional/comparison operators require a boolean value, so users currently have to re-evaluate the condition at each call or rely on the implicit conversion from an int type.

It could make for cleaner syntax to be able to do something like:

data {
  real y_mean;
  bool use_log;
}
parameters {
  real y;
}
model {
  if (use_log) {
    y ~ lognormal(y_mean, 1);
  } else {
    y ~ normal(y_mean, 1);
  }
}
@andrjohns andrjohns added the feature New feature or request label May 11, 2023
@WardBrian
Copy link
Member

WardBrian commented May 11, 2023

bool would essentially be syntactic sugar for int <lower=0, upper=1>, so I don't think this would be a breaking change.

Well, I guess reserving the keyword "bool" would be, but we have a policy for that. true and false are already reserved.

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

No branches or pull requests

2 participants