Plaster
New
List
Login
text
default
anonymous
2024.06.28 13:03:25
Results: clasp is not tested because it doesn't provide an implementation of macroexpand-all (AFAIK) Allegro, LW, CormanCL and MKCL support passing lexical environment, but TRIVIAL-MACROEXPAND-ALL doesn't support it. no-env -- implementation doesn't support passing lexical environment | impl | version | all macro types | declarations bug | doesn't expand LAMBDA | |---------+-------------+-----------------+------------------+-----------------------| | sbcl | 2.4.5 | + | - | YES | | cmucl | 21E Unicode | NO | - | YES | | ccl | 1.12 | + | - | YES | | allegro | 11.0 | + | - | YES | | ecl | 23.9.9 | NO | YES (runtime) | YES | | abcl | 1.9.1 | + | - | YES | | clisp | 2.49.93+ | ±, no-env | YES (logic) | - | | LW | 8.0.1 | + | - | - | | corman | 3.1 (wine) | + | YES (logic) | - | | mkcl | 1.1.11.188 | NO | YES (warning) | YES | M -- macro SM -- symbol macro global -- macro defined in the global environment local-form -- macro defined in the form being macroexpanded local-env -- macro defined in the lexical environment being passed | impl | global M | local-form M | local-env M | global SM | local-form SM | local-env SM | |---------+----------+--------------+-------------+-----------+---------------+--------------| | sbcl | + | + | + | + | + | + | | cmucl | + | + | + | NO | + | NO | | ccl | + | + | + | + | + | + | | allegro | + | + | + | + | + | + | | ecl | + | NO | + | NO | + | NO | | abcl | + | + | + | + | + | + | | clisp | + | + | no-env | + | + | no-env | | LW | + | + | + | + | + | + | | corman | + | + | + | + | + | + | | mkcl | + | NO | + | NO | + | NO | M -- MACROLET SM -- SYMBOL-MACROLET | impl | behaviour | |---------+-------------------------------------------------------------------| | sbcl | Keeps M / SM | | cmucl | Keeps M / SM | | ccl | Converts M / SM to PROGN; or to LOCALLY if there are declarations | | allegro | Keeps M / SM; if EXCL::*KEEP-MACROLET* is NIL converts to LOCALLY | | ecl | Keeps M / SM; errors on declarations in SM | | abcl | Converts M / SM to LOCALLY | | clisp | Converts M to PROGN, unless body is 0--1 form; Keeps SM | | LW | Keeps M / SM; merges declarations, removes them if empty | | corman | Converts M to LET (); converts SM to PROGN () | | mkcl | Keeps M / SM |
Raw
Annotate
Repaste
Edit
Annotations
common-lisp
default
anonymous
2024.06.28 13:03:57
(defpackage #:test-macroexpand-all (:use #:cl) (:export #:macroexpand-all)) (in-package #:test-macroexpand-all) ;; NIH: trivial-macroexpand-all #+mkcl (require :walker) (defun macroexpand-all (form &optional env) (declare (ignorable env)) (values (#+sbcl sb-walker:macroexpand-all #+cmucl walker:macroexpand-all #+ccl ccl:macroexpand-all #+allegro excl::walk-form #+ecl walker:macroexpand-all #+abcl ext:macroexpand-all #+clisp ext:expand-form #+lispworks walker:walk-form #+cormanlisp ccl:macroexpand-all #+mkcl walker:macroexpand-all form #-clisp env) t (or #-clisp t))) ;; utility macro (defmacro at-compile-time ((&optional env) &body body) (let ((capture (gensym))) `(macrolet ((,capture (,@(when env `(&environment ,env))) ,@body)) (,capture)))) ;; Test 0 ;; Identify lisp implementation (values (lisp-implementation-type) (lisp-implementation-version)) ;; Test 1 ;; Here we test if MACROEXPAND-ALL expands all macro types. (defmacro NO-1 () ''YES-1) (define-symbol-macro NO-4 'YES-4) (macrolet ((NO-3 () ''YES-3)) (symbol-macrolet ((NO-6 'YES-6)) (at-compile-time (env) `',(macroexpand-all '(macrolet ((NO-2 () ''YES-2)) (symbol-macrolet ((NO-5 'YES-5)) (values (NO-1) (NO-2) (NO-3) NO-4 NO-5 NO-6))) env)))) ;; Expected result (with or without MACROLET and SYMBOL-MACROLET forms) #+nil (MACROLET ((NO-2 () ''YES-2)) (SYMBOL-MACROLET ((NO-5 'YES-5)) (VALUES 'YES-1 'YES-2 'YES-3 'YES-4 'YES-5 'YES-6))) ;; Test 2 ;; Here we throw a bunch of configurations of [symbol-]macrolet, ;; bodies of different lengths and declarations. (let ((*print-pretty* nil)) (format t "~{~s~%~}" (mapcan (lambda (header) (mapcar (lambda (form) (handler-case (macroexpand-all form) (error () 'ERROR))) `((,@header ) (,@header atom) (,@header (form)) (,@header two forms) (,@header (declare)) (,@header (declare) and-a-form) (,@header (declare) and two-forms) (,@header (declare (optimize)) and-a-form) (,@header (declare (optimize)) (declare (type t)) and-a-form)))) `((macrolet ()) (macrolet ((def ()))) (symbol-macrolet ()) (symbol-macrolet ((def nil))))))) ;; Test 3 ;; Here we test if the LAMBDA macro is expanded. (format t "~&Expands LAMBDA: ~A~%" (not (equal (macroexpand-all '(lambda ())) '(lambda ()))))
Raw
Repaste
Edit
text
default
Grolter
2024.10.31 19:15:13
Updated version: https://plaster.tymoon.eu/view/4637
Raw
Repaste