Skip to content

[FR] Bool data type? #1328

Open
Open

Description

@andrjohns

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);
  }
}

Activity

  1. WardBrian commented on May 11, 2023

    @WardBrian
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions