@@ -91,14 +91,6 @@ macro_rules! expr {
9191 ( $( $x: tt) * ) => { $crate:: Atom :: expr( [ $( expr!( $x) , ) * ] ) } ;
9292}
9393
94- #[ macro_export]
95- macro_rules! constexpr {
96- ( ) => { $crate:: Atom :: Expression ( $crate:: ExpressionAtom :: new( hyperon_common:: collections:: CowArray :: Literal ( & [ ] ) ) ) } ;
97- ( $x: literal) => { $crate:: Atom :: Symbol ( $crate:: SymbolAtom :: new( hyperon_common:: unique_string:: UniqueString :: Const ( $x) ) ) } ;
98- ( ( $( $x: tt) * ) ) => { $crate:: Atom :: Expression ( $crate:: ExpressionAtom :: new( hyperon_common:: collections:: CowArray :: Literal ( const { & [ $( constexpr!( $x) , ) * ] } ) ) ) } ;
99- ( $( $x: tt) * ) => { $crate:: Atom :: Expression ( $crate:: ExpressionAtom :: new( hyperon_common:: collections:: CowArray :: Literal ( const { & [ $( constexpr!( $x) , ) * ] } ) ) ) } ;
100- }
101-
10294/// Constructs new symbol atom. Can be used to construct `const` instances.
10395///
10496/// # Examples
@@ -171,7 +163,7 @@ pub struct ExpressionAtom {
171163
172164impl ExpressionAtom {
173165 /// Constructs new expression from vector of sub-atoms. Not intended to be
174- /// used directly, use [expr!], [constexpr !] or [Atom::expr] instead.
166+ /// used directly, use [expr!], [metta!], [metta_const !] or [Atom::expr] instead.
175167 pub const fn new ( children : CowArray < Atom > ) -> Self {
176168 Self { children, evaluated : false }
177169 }
@@ -242,16 +234,24 @@ pub struct VariableAtom {
242234}
243235
244236impl VariableAtom {
245- /// Constructs new variable using `name` provided. Name should not contain
246- /// `#` characted which is reserved for internal name formatting (see
247- /// [VariableAtom::parse_name]). Usually [Atom::var] method should be used
248- /// to create new variable atom instance. But sometimes [VariableAtom]
249- /// instance is required. For example for using as a key in variable bindings
250- /// (see [matcher::Bindings ]).
237+ /// Constructs new variable using `name` provided. Usually [Atom::var]
238+ /// method should be used to create new variable atom instance. But
239+ /// sometimes [VariableAtom] instance is required. For example for using
240+ /// as a key in variable bindings (see [matcher::Bindings]).
241+ /// Name should not contain `#` characted which is reserved for internal
242+ /// name formatting (see [VariableAtom::parse_name ]).
251243 pub fn new < T : Into < UniqueString > > ( name : T ) -> Self {
252244 Self { name : Self :: check_name ( name) , id : 0 }
253245 }
254246
247+ /// Constructs new constant variable instance using `name` provided. Method
248+ /// is introduced to support creating constant expressions.
249+ /// Name should not contain `#` characted which is reserved for internal
250+ /// name formatting (see [VariableAtom::parse_name]).
251+ pub const fn new_const ( name : UniqueString ) -> Self {
252+ Self { name, id : 0 }
253+ }
254+
255255 /// Constructs new variable using `name` and 'id' provided. This method is
256256 /// used to construct proper variable for testing purposes only.
257257 pub fn new_id < T : Into < UniqueString > > ( name : T , id : usize ) -> Self {
0 commit comments