Add 'again' keyword for recursive calls
The `again` keyword is introduced to facilitate explicit recursive function calls. It is restricted to tail-call positions to prevent dead code and ensure TCO optimization. Type checking is enhanced to validate argument types against function parameters.
This commit is contained in:
@@ -96,6 +96,10 @@ pub enum BoundKind<T = ()> {
|
||||
args: Box<BoundNode<T>>,
|
||||
},
|
||||
|
||||
Again {
|
||||
args: Box<BoundNode<T>>,
|
||||
},
|
||||
|
||||
Block {
|
||||
exprs: Vec<BoundNode<T>>,
|
||||
},
|
||||
@@ -207,6 +211,7 @@ where
|
||||
args: ab,
|
||||
},
|
||||
) => ca == cb && aa == ab,
|
||||
(BoundKind::Again { args: aa }, BoundKind::Again { args: ab }) => aa == ab,
|
||||
(BoundKind::Block { exprs: ea }, BoundKind::Block { exprs: eb }) => ea == eb,
|
||||
(BoundKind::Tuple { elements: ea }, BoundKind::Tuple { elements: eb }) => ea == eb,
|
||||
(BoundKind::Record { fields: fa }, BoundKind::Record { fields: fb }) => fa == fb,
|
||||
@@ -254,6 +259,7 @@ impl<T> BoundKind<T> {
|
||||
format!("LAMBDA({}, Captures:{})", p_str, upvalues.len())
|
||||
}
|
||||
BoundKind::Call { .. } => "CALL".to_string(),
|
||||
BoundKind::Again { .. } => "AGAIN".to_string(),
|
||||
BoundKind::Block { .. } => "BLOCK".to_string(),
|
||||
BoundKind::Tuple { elements } => format!("TUPLE({})", elements.len()),
|
||||
BoundKind::Record { fields } => format!("RECORD({})", fields.len()),
|
||||
|
||||
Reference in New Issue
Block a user