- The variables are only valid till the function execution.
- Storage of LeadLang variable data (except the moved ones) requires cloning.
- You shouldn't store the mutable or immutable reference of a variable.
Got to define function
Simple LeadLang Package
use interpreter::{generate, module, pkg_name};
use lead_lang_macros::{define, methods};
use interpreter::BufValue;
module! {
Module1,
pkg_name! { "Module" },
methods! {
foo
}
}
generate! {
Module1
}
#[define((
desc: "Prints a variable",
notes: Some("Optional Note"),
params: [
// "my-custom-regex, see example below",
r"\$[a-z0-9_]*" // This is a regex of a lead variable
],
returns: Some("%null"), // %null means that it returns nothing
usage: [
(
desc: "Prints $hello",
code: "print $hello"
)
]
root: Some("MyNewRT"), ))]
fn foo(var: &BufValue) {
println!("{}", var.display());
}