1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; b i g l o o . s t k -- Bigloo compatibility file
|
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Copyright <20> 1997-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Permission to use, copy, modify, distribute,and license this
|
|
|
|
|
;;;; software and its documentation for any purpose is hereby granted,
|
|
|
|
|
;;;; provided that existing copyright notices are retained in all
|
|
|
|
|
;;;; copies and that this notice is included verbatim in any
|
|
|
|
|
;;;; distributions. No written agreement, license, or royalty fee is
|
|
|
|
|
;;;; required for any of the authorized uses.
|
|
|
|
|
;;;; This software is provided ``AS IS'' without express or implied
|
|
|
|
|
;;;; warranty.
|
1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; Author: Erick Gallesio [eg@unice.fr]
|
|
|
|
|
;;;; Creation date: 28-Oct-1997 11:09
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Last file update: 3-Sep-1999 19:49 (eg)
|
1998-04-10 06:59:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; define-inline
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
#|
|
|
|
|
|
(define-macro (define-inline args . body)
|
|
|
|
|
`(define-macro ,args
|
|
|
|
|
(list (lambda ,(copy-tree (cdr args)) ,@body) ,@(cdr args))))
|
|
|
|
|
|
|
|
|
|
This definition works but is not more efficient than not inlining the function
|
|
|
|
|
(since it calls in fact an internal lambda)
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
|
|
(define define-inline define)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; labels
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-macro (labels bindings . body)
|
|
|
|
|
(define (expand binding)
|
|
|
|
|
(when (< (length binding) 3)
|
|
|
|
|
(error "labels: bad binding ~S" binding))
|
|
|
|
|
`(,(car binding) (lambda ,(cadr binding) ,@(cddr binding))))
|
|
|
|
|
|
|
|
|
|
`(letrec ,(map expand bindings)
|
|
|
|
|
,@body))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; A macro for parsing the Bigloo MODULE directive
|
|
|
|
|
;;; This macro has been written for the MATCH-CASE and MATCH-LAMBDA
|
|
|
|
|
;;; primitives.
|
|
|
|
|
;;; Alas, the problem is that we don't have match-case here :-)
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-macro (module name . clauses)
|
|
|
|
|
(define (import-directive x)
|
|
|
|
|
`(import ,@(map (lambda (x) (if (pair? x) (car x) x)) x)))
|
|
|
|
|
|
|
|
|
|
(define (export-directive x)
|
|
|
|
|
`(export ,@(map (lambda (x)
|
|
|
|
|
(if (pair? x)
|
|
|
|
|
( (if (eq? (car x) 'inline) cadr car) x)
|
|
|
|
|
x))
|
|
|
|
|
x)))
|
|
|
|
|
|
1998-04-30 07:04:33 -04:00
|
|
|
|
`(begin
|
|
|
|
|
(define-module ,name
|
|
|
|
|
,@(map (lambda (clause)
|
|
|
|
|
(case (car clause)
|
|
|
|
|
((export) (export-directive (cdr clause)))
|
|
|
|
|
((import) (import-directive (cdr clause)))
|
|
|
|
|
((use) '())
|
|
|
|
|
(else (error "module" "Unknown clause" (cons name clause)))))
|
|
|
|
|
clauses)
|
|
|
|
|
(define error bigloo:error))
|
1998-04-10 06:59:06 -04:00
|
|
|
|
(select-module ,name)))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Error
|
|
|
|
|
;;;
|
|
|
|
|
(define (bigloo:error proc msg obj)
|
|
|
|
|
(error "~A: ~A ~S" proc msg obj))
|
|
|
|
|
|
|
|
|
|
(define-module __error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide "bigloo")
|