From 59610c58a1edf11807a085906fd3ee0ccca43095 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Fri, 2 Apr 2021 02:46:14 +0200 Subject: [PATCH] Implement recursion --- lib/Minilisp.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index 7ac8b65..d12d968 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -362,7 +362,12 @@ sub macro_defun { return sub { my $ctx = shift; - my $fn = $body->($ctx); + my $fn; + my $self = sub { + return $fn->(@_); + }; + $ctx->{$ident->{value}} = $self; + $fn = $body->($ctx); $ctx->{$ident->{value}} = $fn; return $fn; }