elisp fixes for nil, and, or
authorAndy Wingo <wingo@pobox.com>
Fri, 9 Apr 2010 19:04:52 +0000 (21:04 +0200)
committerAndy Wingo <wingo@pobox.com>
Fri, 9 Apr 2010 19:06:29 +0000 (21:06 +0200)
* module/language/elisp/runtime/macro-slot.scm (or, and): Fix one-arg
  case to return the arg as-is.

* module/language/elisp/runtime.scm (nil-value): Fix to be #nil.

module/language/elisp/runtime.scm
module/language/elisp/runtime/macro-slot.scm

index cb562c3..0d783b6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; Guile Emacs Lisp
 
-;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;;
 ;;; This library is free software; you can redistribute it and/or
 ;;; modify it under the terms of the GNU Lesser General Public
 (define void (list 42))
 
 
-; Values for t and nil.
+; Values for t and nil. (FIXME remove this abstraction)
 
-; FIXME: Use real nil.
-(define nil-value #f)
+(define nil-value #nil)
 (define t-value #t)
 
 
index 11ab59b..e28fa31 100644 (file)
@@ -1,6 +1,6 @@
 ;;; Guile Emacs Lisp
 
-;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;;
 ;;; This library is free software; you can redistribute it and/or
 ;;; modify it under the terms of the GNU Lesser General Public
 ; The and and or forms can also be easily defined with macros.
 
 (built-in-macro and
-  (lambda (. args)
-    (if (null? args)
-      't
-      (let iterate ((tail args))
-        (if (null? (cdr tail))
-          (car tail)
-          `(if ,(car tail)
-             ,(iterate (cdr tail))
-             nil))))))
+  (case-lambda
+    (() 't)
+    ((x) x)
+    ((x . args)
+     (let iterate ((x x) (tail args))
+       (if (null? tail)
+           x
+           `(if ,x
+                ,(iterate (car tail) (cdr tail))
+                nil))))))
 
 (built-in-macro or
-  (lambda (. args)
-    (let iterate ((tail args))
-      (if (null? tail)
-        'nil
-        (let ((var (gensym)))
-          `(without-void-checks (,var)
-             (lexical-let ((,var ,(car tail)))
-               (if ,var
-                 ,var
-                 ,(iterate (cdr tail))))))))))
+  (case-lambda
+    (() 'nil)
+    ((x) x)
+    ((x . args)
+     (let iterate ((x x) (tail args))
+       (if (null? tail)
+           x
+           (let ((var (gensym)))
+             `(without-void-checks
+               (,var)
+               (lexical-let ((,var ,x))
+                            (if ,var
+                                ,var
+                                ,(iterate (car tail) (cdr tail)))))))))))
 
 
 ; Define the dotimes and dolist iteration macros.