1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

elisp fixes for nil, and, or

* 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.
This commit is contained in:
Andy Wingo 2010-04-09 21:04:52 +02:00
parent cd038da546
commit 474060a23c
2 changed files with 28 additions and 24 deletions

View file

@ -1,6 +1,6 @@
;;; Guile Emacs Lisp ;;; 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 ;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public ;;; modify it under the terms of the GNU Lesser General Public
@ -39,10 +39,9 @@
(define void (list 42)) (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 #nil)
(define nil-value #f)
(define t-value #t) (define t-value #t)

View file

@ -1,6 +1,6 @@
;;; Guile Emacs Lisp ;;; 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 ;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public ;;; modify it under the terms of the GNU Lesser General Public
@ -84,27 +84,32 @@
; The and and or forms can also be easily defined with macros. ; The and and or forms can also be easily defined with macros.
(built-in-macro and (built-in-macro and
(lambda (. args) (case-lambda
(if (null? args) (() 't)
't ((x) x)
(let iterate ((tail args)) ((x . args)
(if (null? (cdr tail)) (let iterate ((x x) (tail args))
(car tail) (if (null? tail)
`(if ,(car tail) x
,(iterate (cdr tail)) `(if ,x
nil)))))) ,(iterate (car tail) (cdr tail))
nil))))))
(built-in-macro or (built-in-macro or
(lambda (. args) (case-lambda
(let iterate ((tail args)) (() 'nil)
(if (null? tail) ((x) x)
'nil ((x . args)
(let ((var (gensym))) (let iterate ((x x) (tail args))
`(without-void-checks (,var) (if (null? tail)
(lexical-let ((,var ,(car tail))) x
(if ,var (let ((var (gensym)))
,var `(without-void-checks
,(iterate (cdr tail)))))))))) (,var)
(lexical-let ((,var ,x))
(if ,var
,var
,(iterate (car tail) (cdr tail)))))))))))
; Define the dotimes and dolist iteration macros. ; Define the dotimes and dolist iteration macros.