; .EnTete "Le←Lisp version 15.2" " " "Version 16 to 15 Facility"

; .Titre "Version 16 to 15 Facility"
; .Auteur "Je'ro↑me Chailloux"
; .Centre "$Header: v16tov15.ll,v 1.2 88/12/16 11:27:55 gallou Exp $"

;;; This library permits to compile and to run programs written
;;; with the Version 16 of Le-Lisp, in the version 15.2.


(synonym 'dynamic-let 'let)

(df dynamic (name)
    (symeval name))

(defmacro-open dynamic (name)
    `(progn ,name))


  ;; Lists manipulations
  (defmacro push (x l) `(newl ,l ,x)) ; Peux mieux faire !!!
  (defmacro pop (l) `(nextl ,l))

  ;; Multiples values simulation
  ; ca ne tient qu'a un 1/2 cheveux mais ca marche dans les cas non vicieux!?!
  (defvar *values-list-results* ())
  (defvar *print-values* t)

  (defmacro values l
    `(progn (setq *values-list-results* ())
	    ,@(mapcar #'(lambda (i) `(push ,i *values-list-results*))
			l)
	    (setq *values-list-results*
		  (nreverse *values-list-results*))
	    (when *print-values* (print *values-list-results*))
	    (car *values-list-results*)))

  (defmacro multiple-value-bind (lvars lvalues . body)
    `(let ((*print-values* ()))
       (let ((*values-list-results* ()))
	 ,lvalues
	 (letv ',lvars (prog1 *values-list-results*
			 (setq *values-list-results* ()))
	       ,@body))))

  (defmacro multiple-value-setq (lvars lvalues . body)
    `(let ((*print-values* ()))
       (let ((*values-list-results* ()))
	 ,lvalues
	 ,@(mapcar (lambda (x) `(setq ,x (nextl *values-list-results*))) lvars)
	 (setq *values-list-results* ())
	 ,@body)))