DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T x

⟦67c4ebfc9⟧ TextFile

    Length: 5957 (0x1745)
    Types: TextFile
    Names: »xconv.scm.11«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/gnu-31mar87/scheme/scm/xconv.scm.11« 

TextFile

;;; -*-Scheme-*-
;;;
;;;	Copyright (c) 1984 Massachusetts Institute of Technology
;;;
;;;	This material was developed by the Scheme project at the
;;;	Massachusetts Institute of Technology, Department of
;;;	Electrical Engineering and Computer Science.  Permission to
;;;	copy this software, to redistribute it, and to use it for any
;;;	purpose is granted, subject to the following restrictions and
;;;	understandings.
;;;
;;;	1. Any copy made of this software must include this copyright
;;;	notice in full.
;;;
;;;	2. Users of this software agree to make their best efforts (a)
;;;	to return to the MIT Scheme project any improvements or
;;;	extensions that they make, so that these may be included in
;;;	future releases; and (b) to inform MIT of noteworthy uses of
;;;	this software.
;;;
;;;	3.  All materials developed as a consequence of the use of
;;;	this software shall duly acknowledge such use, in accordance
;;;	with the usual standards of acknowledging credit in academic
;;;	research.
;;;
;;;	4. MIT has made no warrantee or representation that the
;;;	operation of this software will be error-free, and MIT is
;;;	under no obligation to provide any services, by way of
;;;	maintenance, update, or otherwise.
;;;
;;;	5.  In conjunction with products arising from the use of this
;;;	material, there shall be no use of the name of the
;;;	Massachusetts Institute of Technology nor of any adaptation
;;;	thereof in any advertising, promotional, or sales literature
;;;	without prior written consent from MIT in each case.
;;;

;;;; Convert Declarations to Integrations

(declare (usual-integrations))
\f


(define primitive-integration-type)
(define make-primitive-integration)
(define delete-usual-primitive!)

(let ((primitive-integration-tag (make-named-tag "PRIMITIVE-INTEGRATION"))
      (make-declaration))

(define (convert-declaration text body)
  (define (loop declarations)
    (if (null? declarations)
	body
	(let ((declaration (car declarations))
	      (body (loop (cdr declarations))))
	  (let ((association (assq (car declaration)
				   known-primitive-integrations)))
	    (if association
		((cdr association)
		 (cdr declaration)
		 (lambda (names values)
		   (special-primitive-integration names values body)))
		(special-declaration declaration body))))))
  (loop text))

(define (special-primitive-integration names values body)
  (if (primitive-integration? body)
      (primitive-integration-components body
	(lambda (inner-names inner-values body)
	  (make-primitive-integration
	   (append names inner-names)
	   (append values inner-values)
	   body)))
      (make-primitive-integration names values body)))

(define (special-declaration text body)
  (if (declaration? body)
      (declaration-components body
	(lambda (inner-text body)
	  (make-declaration (cons text inner-text) body)))
      (make-declaration (list text) body)))
\f


(define (integrate-named-primitives specifications receiver)
  (if (null? specifications)
      (receiver '() '())
      (extract-primitive-name (car specifications)
	(lambda (variable primitive)
	  (integrate-named-primitives (cdr specifications)
	    (lambda (variables primitives)
	      (receiver (cons variable variables)
			(cons (make-primitive-procedure primitive)
			      primitives))))))))

(define (extract-primitive-name specification receiver)
  (cond ((conjunction (pair? specification)
		      (symbol? (car specification))
		      (pair? (cdr specification))
		      (symbol? (cadr specification))
		      (null? (cddr specification)))
	 (receiver (first specification) (second specification)))
	((symbol? specification)
	 (receiver specification specification))
	(else
	 (error "Bad primitive specification" specification))))

(define (integrate-usual-primitives deletions receiver)
  (if (null? deletions)
      (receiver global-primitive-operators
		global-primitive-operator-values)
      (error "Deletions no longer supported in COMPILE-USUAL-PRIMITIVES"
	     deletions)))

(define (cache-primitive-operators)
  (mapcar (lambda (name)
	    (lexical-reference system-global-environment name))
	  global-primitive-operators))

(define global-primitive-operator-values
  (cache-primitive-operators))

(set! delete-usual-primitive!
      (named-lambda (delete-usual-primitive! name)
	(set! global-primitive-operators
	      (delq! name global-primitive-operators))
	(set! global-primitive-operator-values
	      (cache-primitive-operators))
	name))

(define known-primitive-integrations
  `((USUAL-INTEGRATIONS . ,integrate-usual-primitives)

    ;; For (sort of) upwards compatibility.
    (COMPILE-USUAL-PRIMITIVE-FUNCTIONS . ,integrate-usual-primitives)
    (COMPILE-USUAL-PRIMITIVE-VARIABLES . ,integrate-usual-primitives)
    (COMPILABLE-PRIMITIVE-FUNCTIONS . ,integrate-named-primitives)
    (COMPILABLE-PRIMITIVE-VARIABLES . ,integrate-named-primitives)))

(set! primitive-integration-type
      (make-sub-type 'PRIMITIVE-INTEGRATION
		     comment-type
		     (lambda (comment)
		       (let ((text (comment-text comment)))
			 (conjunction (vector? text)
				      (not (zero? (vector-size text)))
				      (eq? (vector-first text)
					   primitive-integration-tag))))))

(set! make-primitive-integration
      (lambda (names values body)
	(make-comment (vector primitive-integration-tag names values) body)))

(install-declaration-hook!
 (lambda (old-make)
   (set! make-declaration old-make)
   convert-declaration))

)

(define primitive-integration?
  (type-object-predicate primitive-integration-type))

(define (primitive-integration-components primitive-integration receiver)
  (comment-components primitive-integration
    (lambda (text expression)
      (receiver (vector-second text)
		(vector-third text)
		expression))))
\f


;;; Local Modes:
;;; Scheme PRIMITIVE-INTEGRATION-COMPONENTS Indent: 1
;;; Scheme INTEGRATE-NAMED-PRIMITIVES Indent: 1
;;; Scheme EXTRACT-PRIMITIVE-NAME Indent: 1
;;; Scheme INTEGRATE-USUAL-PRIMITIVES Indent: 1
;;; End: