1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-01 01:40:21 +02:00

remove unnecessary elisp macros

* module/language/elisp/runtime/macros.scm (when, unless, dotimes)
  (dolist, pop, push): Remove. (They are not special forms in Emacs.)

* module/language/elisp/runtime/function-slot.scm: Update import and
  export lists.

* test-suite/tests/elisp-compiler.test ("Conditionals")["failing when"]
  ["succeeding when", "failing unless", "succeeding unless"]: Remove.
  ("Iteration")["dotimes", "dolist"]: Remove.
  ("List Built-Ins")["pop", "push"]: Remove.
This commit is contained in:
BT Templeton 2011-06-17 02:10:55 -04:00
parent 59e46065ce
commit a338fa3d87
3 changed files with 3 additions and 120 deletions

View file

@ -45,16 +45,6 @@
(lambda (form1 form2 . rest)
`(progn ,form1 (prog1 ,form2 ,@rest))))
;;; Define the conditionals when and unless as macros.
(built-in-macro when
(lambda (condition . thens)
`(if ,condition (progn ,@thens) nil)))
(built-in-macro unless
(lambda (condition . elses)
`(if ,condition nil (progn ,@elses))))
;;; Impement the cond form as nested if's. A special case is a
;;; (condition) subform, in which case we need to return the condition
;;; itself if it is true and thus save it in a local variable before
@ -109,50 +99,6 @@
,var
,(iterate (car tail) (cdr tail))))))))))
;;; Define the dotimes and dolist iteration macros.
(built-in-macro dotimes
(lambda (args . body)
(if (prim or
(not (list? args))
(< (length args) 2)
(> (length args) 3))
(macro-error "invalid dotimes arguments" args)
(let ((var (car args))
(count (cadr args)))
(if (not (symbol? var))
(macro-error "expected symbol as dotimes variable"))
`(let ((,var 0))
(while ((guile-primitive <) ,var ,count)
,@body
(setq ,var ((guile-primitive 1+) ,var)))
,@(if (= (length args) 3)
(list (caddr args))
'()))))))
(built-in-macro dolist
(lambda (args . body)
(if (prim or
(not (list? args))
(< (length args) 2)
(> (length args) 3))
(macro-error "invalid dolist arguments" args)
(let ((var (car args))
(iter-list (cadr args))
(tailvar (gensym)))
(if (not (symbol? var))
(macro-error "expected symbol as dolist variable")
`(let (,var)
(lexical-let ((,tailvar ,iter-list))
(while ((guile-primitive not)
((guile-primitive null?) ,tailvar))
(setq ,var ((guile-primitive car) ,tailvar))
,@body
(setq ,tailvar ((guile-primitive cdr) ,tailvar)))
,@(if (= (length args) 3)
(list (caddr args))
'()))))))))
;;; Exception handling. unwind-protect and catch are implemented as
;;; macros (throw is a built-in function).
@ -196,13 +142,3 @@
(lambda () ,body)
(lambda () ,@clean-ups))))
;;; Pop off the first element from a list or push one to it.
(built-in-macro pop
(lambda (list-name)
`(prog1 (car ,list-name)
(setq ,list-name (cdr ,list-name)))))
(built-in-macro push
(lambda (new-el list-name)
`(setq ,list-name (cons ,new-el ,list-name))))