openzl icon indicating copy to clipboard operation
openzl copied to clipboard

ECLAIR Compiler Procedural Macro

Open bhgomes opened this issue 3 years ago • 0 comments

To build circuits in an abstract setting we need to pass around the compiler argument. In many cases, when we want to just compose existing primitives, we don't want to have to specify it and it would be nice to just infer it at every call site. This is where the procedural macro simplifies the work of the developer. They would go from this:

fn circuit<X, Y, Z, COM>(x: X, y: Y, z: Z, compiler: &mut COM) 
where
    X: Add<Y, COM, Output = Z>,
    Z: PartialEq<Z, COM>,
{
    compiler.assert_eq(&x.add(y, compiler), &z)
}

to this:

#[eclair]
fn circuit<X, Y, Z>(x: X, y: Y, z: Z) 
where
    X: Add<Y, Output = Z>,
    Z: PartialEq,
{
    assert_eq!(x + y, z)
}

bhgomes avatar Nov 01 '22 20:11 bhgomes