From 390e8b6664a6e5fd58111b8d650d176825a877d3 Mon Sep 17 00:00:00 2001
From: Gabriel Dos Reis <gdr@axiomatics.org>
Date: Wed, 6 Jan 2016 04:59:53 -0800
Subject: macroExpand: Do not expand the definiendum in a definition.

---
 src/ChangeLog          |  5 +++++
 src/interp/define.boot | 10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/ChangeLog b/src/ChangeLog
index f5cd62a3..89e40198 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-06  Gabriel Dos Reis  <gdr@axiomatics.org>
+
+	* interp/define.boot (macroExpand): Do not expand the definiendum,
+	except parameter types, in a definition.
+
 2015-12-31  Gabriel Dos Reis  <gdr@axiomatics.org>
 
 	* interp/compiler.boot (coerceEasy): Allow expansion of current
diff --git a/src/interp/define.boot b/src/interp/define.boot
index 1ec07745..c6cf8942 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -1,6 +1,6 @@
 -- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
 -- All rights reserved.
--- Copyright (C) 2007-2015, Gabriel Dos Reis.
+-- Copyright (C) 2007-2016, Gabriel Dos Reis.
 -- All rights reserved.
 --
 -- Redistribution and use in source and binary forms, with or without
@@ -918,8 +918,8 @@ giveFormalParametersValues(argl,e) ==
   e
 
 
-macroExpandInPlace: (%Form,%Env) -> %Form 
-macroExpandInPlace(x,e) ==
+macroExpand!: (%Form,%Env) -> %Form 
+macroExpand!(x,e) ==
   y:= macroExpand(x,e)
   x isnt [.,:.] or y isnt [.,:.] => y
   x.first := first y
@@ -934,7 +934,7 @@ macroExpand(x,e) ==   --not worked out yet
     u is ['%mlambda,:.] => x
     macroExpand(u,e)
   x is ['DEF,lhs,sig,rhs] =>
-    ['DEF,macroExpand(lhs,e),macroExpandList(sig,e),macroExpand(rhs,e)]
+    ['DEF,lhs,macroExpandList(sig,e),macroExpand(rhs,e)]
   -- macros should override niladic props
   [op,:args] := x
   ident? op and args = nil and niladicConstructor? op and
@@ -2353,7 +2353,7 @@ compCapsuleItems(db,itemlist,$predl,$e) ==
   $e
  
 compSingleCapsuleItem(db,item,$predl,$e) ==
-  doIt(db,macroExpandInPlace(item,$e),$predl)
+  doIt(db,macroExpand!(item,$e),$predl)
   $e
  
 
-- 
cgit v1.2.3