over engineered

This commit is contained in:
J. Nick Koston
2025-10-26 09:32:43 -07:00
parent 97346e5644
commit 5e4a551a77
3 changed files with 12 additions and 15 deletions

View File

@@ -198,10 +198,9 @@ class LambdaExpression(Expression):
self.return_type = safe_exp(return_type) if return_type is not None else None
def __str__(self):
# Unary + converts stateless lambda to function pointer
# This allows implicit conversion to void (*)() or bool (*)()
prefix = "+" if self.capture == "" else ""
cpp = f"{prefix}[{self.capture}]({self.parameters})"
# Stateless lambdas (empty capture) implicitly convert to function pointers
# when assigned to function pointer types - no unary + needed
cpp = f"[{self.capture}]({self.parameters})"
if self.return_type is not None:
cpp += f" -> {self.return_type}"
cpp += " {\n"