You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Native functions are kind of a pain to implement. It would be good to create a proper proc macro for this, and implement type checking and value conversion automatically. It would be really cool if this also somehow made nondeterminism and arbitrary outputs easy:
#[lumber]fnadd(a:Int,b:Int,c:Int){
c = a + b;}
No idea how this will work nicely, as Rust and Lumber are fundamentally very different languages. The above example will not work. Maybe something using structs and impl blocks will be necessary (though very verbose, and I'm making up some generator syntax).
#[lumber("add/3")]structAdd(Int,Int,Int);implAdd{
#[lumber(add(A!, B!, C)]fn add_c(a: Int, b: Int, c: Option<Int>) -> ()
yields () -> Self{match c {Some(c)if(a + b == c) => yield Add(a, b, c),
Some(..) => {},
None => yield Add(a, b, a + b),
}}
#[lumber(add(A!, B, C!)]fn add_b(a: Int, b: Option<Int>, c: Int) -> ()
yields () -> Self{match b {Some(b)if(a + b == c) => yield Add(a, b, c),
Some(..) => {},
None => yield Add(a, c - a, c),
}}
#[lumber(add(A, B!, C!)]fn add_b(a: Option<Int>, b: Int, c: Int) -> ()
yields () -> Self{match a {Some(a)if(a + b == c) => yield Add(a, b, c),
Some(..) => {},
None => yield Add(c - b, b, c),
}}}
The text was updated successfully, but these errors were encountered:
Native functions are kind of a pain to implement. It would be good to create a proper proc macro for this, and implement type checking and value conversion automatically. It would be really cool if this also somehow made nondeterminism and arbitrary outputs easy:
No idea how this will work nicely, as Rust and Lumber are fundamentally very different languages. The above example will not work. Maybe something using structs and impl blocks will be necessary (though very verbose, and I'm making up some generator syntax).
The text was updated successfully, but these errors were encountered: