pub enum Expr {
Show 33 variants
Never,
None,
Comment(String, CommentKind),
TextSeparator,
Annotation(String),
Bool(bool),
U8(u8),
Int(i64),
Float(f64),
Dec(Decimal),
Symbol(String),
KeySymbol(String),
Char(char),
String(String),
Type(String),
List(Vec<Expr>),
Array(Arc<RwLock<Vec<Expr>>>),
Buffer(usize, Arc<RwLock<Vec<u8>>>),
Map(Arc<RwLock<HashMap<String, Expr>>>),
Set(Arc<RwLock<HashSet<Expr>>>),
IntRange(i64, i64, i64),
FloatRange(f64, f64, f64),
Func(Vec<Expr>, Vec<Expr>, Arc<Scope>, String),
Macro(Vec<Expr>, Vec<Expr>),
ForeignFunc(ForeignFnRef),
Foreign(Arc<dyn Any + Send + Sync>),
ForeignMut(Arc<RwLock<dyn Any + Send + Sync>>),
Error(String),
Do,
Let,
If(Box<Expr>, Box<Expr>, Option<Box<Expr>>),
Annotated(Box<Expr>, HashMap<String, Expr>),
Module(Arc<Module>),
}
Expand description
A symbolic expression. This is the ‘universal’ data type in the language, all values are expressions (and expressions are values). Evaluation is expression rewriting to a fixed point.
Variants§
Never
None
Comment(String, CommentKind)
TextSeparator
Annotation(String)
Bool(bool)
U8(u8)
Int(i64)
Float(f64)
Dec(Decimal)
Symbol(String)
KeySymbol(String)
Char(char)
String(String)
Type(String)
List(Vec<Expr>)
Array(Arc<RwLock<Vec<Expr>>>)
Buffer(usize, Arc<RwLock<Vec<u8>>>)
Map(Arc<RwLock<HashMap<String, Expr>>>)
Set(Arc<RwLock<HashSet<Expr>>>)
IntRange(i64, i64, i64)
FloatRange(f64, f64, f64)
Func(Vec<Expr>, Vec<Expr>, Arc<Scope>, String)
Func(params, body, func_scope, filename)
Macro(Vec<Expr>, Vec<Expr>)
Macro(params, body)
ForeignFunc(ForeignFnRef)
Foreign(Arc<dyn Any + Send + Sync>)
ForeignMut(Arc<RwLock<dyn Any + Send + Sync>>)
Error(String)
Do
Let
If(Box<Expr>, Box<Expr>, Option<Box<Expr>>)
Annotated(Box<Expr>, HashMap<String, Expr>)
Module(Arc<Module>)
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn transform<F>(self, f: &F) -> Selfwhere
F: Fn(Self) -> Self,
pub fn transform<F>(self, f: &F) -> Selfwhere
F: Fn(Self) -> Self,
Transforms the expression by recursively applying the f
mapping
function.
pub fn try_transform<F>(self, f: &F) -> Result<Self, Error>
pub fn transform_mut<F>(self, f: &mut F) -> Selfwhere
F: FnMut(Self) -> Self,
Sourcepub fn transform_bfs<F>(self, _f: &F) -> Selfwhere
F: Fn(Self) -> Self,
pub fn transform_bfs<F>(self, _f: &F) -> Selfwhere
F: Fn(Self) -> Self,
Transforms the expression by recursively applying the f
mapping
function, breadth-first-search
pub fn quot(self, context: &mut Context) -> Self
Source§impl Expr
impl Expr
pub fn symbol(s: impl Into<String>) -> Self
pub fn key_symbol(s: impl Into<String>) -> Self
pub fn string(s: impl Into<String>) -> Self
pub fn error(s: impl Into<String>) -> Self
pub fn typ(s: impl Into<String>) -> Self
pub fn array(a: impl Into<Vec<Expr>>) -> Self
pub fn map(m: impl Into<HashMap<String, Expr>>) -> Self
pub fn set(s: impl Into<HashSet<Expr>>) -> Self
pub fn foreign_func(f: &'static FnNoContext) -> Self
pub fn foreign_func_mut_context(f: &'static FnMutContext) -> Self
pub fn annotated(expr: Expr, annotations: &HashMap<String, Expr>) -> Self
pub fn maybe_annotated( expr: Expr, annotations: Option<&HashMap<String, Expr>>, ) -> Self
Source§impl Expr
impl Expr
pub fn annotations(&self) -> Option<&HashMap<String, Expr>>
pub fn annotations_mut(&mut self) -> Option<&mut HashMap<String, Expr>>
pub fn extract(&self) -> (&Expr, Option<&HashMap<String, Expr>>)
pub fn unpack_consuming(self) -> Self
pub fn annotation(&self, name: impl Into<String>) -> Option<&Expr>
pub fn is_none(&self) -> bool
pub fn is_func(&self) -> bool
pub fn is_invocable(&self) -> bool
pub fn is_transient(&self) -> bool
pub fn is_false(&self) -> bool
pub fn as_int(&self) -> Option<i64>
pub fn as_u8(&self) -> Option<u8>
pub fn as_float(&self) -> Option<f64>
pub fn as_float_range(&self) -> Option<Range<f64>>
pub fn as_decimal(&self) -> Option<Decimal>
pub fn as_bool(&self) -> Option<bool>
pub fn as_string(&self) -> Option<&str>
pub fn as_stringable(&self) -> Option<&str>
pub fn as_stringable_consuming(self) -> Option<String>
pub fn is_symbol(&self) -> bool
pub fn as_symbol(&self) -> Option<&str>
pub fn as_key_symbol(&self) -> Option<&str>
Sourcepub fn as_symbolic(&self) -> Option<&str>
pub fn as_symbolic(&self) -> Option<&str>
Tries to extract Symbol or KeySymbol.
pub fn as_type(&self) -> Option<&str>
pub fn as_char(&self) -> Option<char>
pub fn as_list(&self) -> Option<&Vec<Expr>>
pub fn as_array(&self) -> Option<RwLockReadGuard<'_, Vec<Expr>>>
pub fn as_array_consuming(self) -> Option<Arc<RwLock<Vec<Expr>>>>
pub fn as_array_mut(&self) -> Option<RwLockWriteGuard<'_, Vec<Expr>>>
pub fn as_buffer(&self) -> Option<RwLockReadGuard<'_, Vec<u8>>>
pub fn as_buffer_mut(&self) -> Option<(usize, RwLockWriteGuard<'_, Vec<u8>>)>
pub fn as_map(&self) -> Option<RwLockReadGuard<'_, HashMap<String, Expr>>>
pub fn as_map_mut(&self) -> Option<RwLockWriteGuard<'_, HashMap<String, Expr>>>
pub fn as_set(&self) -> Option<RwLockReadGuard<'_, HashSet<Expr>>>
pub fn as_set_mut(&self) -> Option<RwLockWriteGuard<'_, HashSet<Expr>>>
pub fn static_type(&self) -> &Expr
pub fn dyn_type(&self, context: &Context) -> Expr
pub fn range(&self) -> Option<Range>
Trait Implementations§
impl Eq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl !RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl !UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more