mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 22:40:34 +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:
parent
cd038da546
commit
474060a23c
2 changed files with 28 additions and 24 deletions
|
@ -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
|
||||
|
@ -39,10 +39,9 @@
|
|||
(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)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -84,27 +84,32 @@
|
|||
; 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue