I am making a macro to expand geometric algebra expressions, and in order for the macro to work, it needs to know to know the type of geometric algebra (3D VGA, 2D PGA, etc.) at compile time.
I could do this easily by passing the type (3D PGA) in implicitly at each call of eq!:
let a = eq!((3, 0, 1): e1 + e2);
let b = eq!((3, 0, 1): 3 + e12);
println!("{:?}", eq!((3, 0, 1): a + b))
or
let a = eq!("PGA3d": e1 + e2);
let b = eq!("PGA3d": 3 + e12);
println!("{:?}", eq!("PGA3d": a + b))
or by creating a specific macro for each type:
let a = pga_3d!(e1 + e2);
let b = pga_3d!(3 + e12);
println!("{:?}", pga_3d!(a + b))
but I'd rather not have to write out the type at every single eq! call or create a specific macro for every single type someone could want (there are an infinite amount of types and I want to be able to, at least theoretically, handle them all). Is there a way to define the type as a const or with another procedural macro in order to have all eq! calls to know the specified type? (eq! needs to know what the type actually is in order to expand.) Ideally, I'd like the code to look like this:
const TYPE: (usize, usize, usize) = (3, 0, 1);
// or
set_type!(3, 0, 1);
fn main() {
let a = eq!(e1 + e2); // eq somehow knows to use 3D PGA because of TYPE or set_type!
let b = eq!(3 + e12);
println!("{:?}", eq!(a + b));
}