commit 62542ee689f00399ef1b58573134eb23c5cc4cfd
parent 8ea23fc15ec7b3cfc1bb2d1ff968b98fff7071b0
Author: Alexander Burger <abu@software-lab.de>
Date: Tue, 3 Jan 2012 19:44:43 +0100
'var' to use 'put' again, allow explicit class 'cls'
Diffstat:
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/doc/refV.html b/doc/refV.html
@@ -47,10 +47,13 @@ href="refS.html#select/3">select/3</a></code>.
</code></pre>
<dt><a name="var"><code>(var sym . any) -> any</code></a>
+<dt><code>(var (sym . cls) . any) -> any</code>
<dd>Defines a class variable <code>sym</code> with the initial value
-<code>any</code> for the current class (in <code><a
-href="refC.html#*Class">*Class</a></code>). See also <a href="ref.html#oop">OO
-Concepts</a>, <code><a href="refR.html#rel">rel</a></code> and <code><a
+<code>any</code> for the current class, implicitly given by the value of the
+global variable <code><a href="refC.html#*Class">*Class</a></code>, or - in the
+second form - for the explicitly given class cls. See also <a
+href="ref.html#oop">OO Concepts</a>, <code><a
+href="refR.html#rel">rel</a></code> and <code><a
href="refV.html#var:">var:</a></code>.
<pre><code>
diff --git a/ersatz/lib.l b/ersatz/lib.l
@@ -1,4 +1,4 @@
-# 11nov11abu
+# 03jan12abu
# (c) Software Lab. Alexander Burger
(setq *OS (java (java "java.lang.System" "getProperty" "os.name")))
@@ -218,7 +218,9 @@
# Class variables
(de var X
- (put *Class (car X) (cdr X)) )
+ (if (pair (car X))
+ (def (cdar X) (caar X) (cdr X))
+ (def *Class (car X) (cdr X)) ) )
(de var: X
(apply meta X This) )
diff --git a/lib.l b/lib.l
@@ -265,7 +265,9 @@
# Class variables
(de var X
- (def *Class (car X) (cdr X)) )
+ (if (pair (car X))
+ (def (cdar X) (caar X) (cdr X))
+ (def *Class (car X) (cdr X)) ) )
(de var: X
(apply meta X This) )