3 ;;; Mes --- Maxwell Equations of Software
4 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; loop.mes: This file is part of Mes.
8 ;;; Mes is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; Mes is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
21 ;; The Maxwell Equations of Software -- John McCarthy page 13
22 ;; http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
24 (define (scm-define x a)
25 (cond ((atom? (cadr x)) (cons (cadr x) (eval (caddr x) a)))
26 (#t (cons (caadr x) (cons 'lambda (cons (cdadr x) (cddr x)))))))
28 (define (scm-define-macro x a)
30 (cons (cons (caadr e) (cons 'lambda (cons (cdadr e) (cddr e))))
31 (cdr (assq '*macro* a)))))
34 ;; (display '____loop2)
41 (display 'loop2-exiting...)
44 (loop2 (eval e a) (readenv a) a))
45 ((eq? (car e) 'define)
46 (loop2 *unspecified* (readenv a) (cons (scm-define e a) a)))
47 ((eq? (car e) 'define-macro)
48 (loop2 *unspecified* (readenv a) (cons (scm-define-macro e a) a)))
50 (loop2 (set-cdr! (assq (cadr e) a) (eval (caddr e) a)) (readenv a) a))
51 (#t (loop2 (eval e a) (readenv a) a))))