use lazy_static::lazy_static;
use parking_lot::Mutex;

lazy_static! {
  static ref CTR: Mutex<usize> = Mutex::new(0);
}

pub fn gensym() -> String {
  gensym_prefix("var")
}

pub fn gensym_prefix(prefix: impl AsRef<str>) -> String {
  let mut g = CTR.lock();
  let ctr = *g;
  *g += 1;
  drop(g);
  format!("{}{}", prefix.as_ref(), ctr)
}