From d34366c38b2828bbeb0a417850a22bd0e2bf18e5 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 26 Feb 2016 08:30:57 +0000 Subject: [PATCH] Implement when and unless from r7rs. --- src/runtime/mit-macros.scm | 14 +++++++++++++- src/runtime/runtime.pkg | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/runtime/mit-macros.scm b/src/runtime/mit-macros.scm index 43e17efcf..76df49bf0 100644 --- a/src/runtime/mit-macros.scm +++ b/src/runtime/mit-macros.scm @@ -736,4 +736,16 @@ USA. (syntax-rules () ((ASSERT condition . extra) (IF (NOT condition) - (ERROR "Assertion failed:" 'condition . extra))))) \ No newline at end of file + (ERROR "Assertion failed:" 'condition . extra))))) + +(define-syntax :when + (syntax-rules () + ((when condition form ...) + (if condition + (begin form ...))))) + +(define-syntax :unless + (syntax-rules () + ((unless condition form ...) + (if (not condition) + (begin form ...))))) \ No newline at end of file diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index ac828021a..f59e2fcfd 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -4907,7 +4907,9 @@ USA. (local-declare :local-declare) (parameterize :parameterize) (quasiquote :quasiquote) - (receive :receive)) + (receive :receive) + (unless :unless) + (when :when)) (export (runtime) parse-define-form)) -- 2.25.1