oftlisp 0.1.3

A compiler and interpreter for OftLisp, in Rust.
Documentation
//! A module that generates symbols, which are guaranteed to be unique.

use std::sync::atomic::{AtomicUsize, Ordering};

use symbol::Symbol;

lazy_static! {
    static ref N: AtomicUsize = AtomicUsize::new(0);
}

/// Returns the next internal counter, incrementing it.
pub fn gensym_counter() -> usize {
    N.fetch_add(1, Ordering::Relaxed)
}

/// Returns a new, unique symbol with the given prefix.
pub fn gensym_prefix<S: AsRef<str>>(s: S) -> Symbol {
    Symbol::from(format!("{}@{}", s.as_ref(), gensym_counter()))
}

/// Returns a new, unique symbol.
pub fn gensym() -> Symbol {
    gensym_prefix("gensym")
}