fixed ystream newline handling, thanks to Ivan Shvedunov
[closure-common.git] / definline.lisp
blob696cc154d56df3bfb4216bf2871868e62e731a9a
1 ;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
2 ;;; ---------------------------------------------------------------------------
3 ;;; Title: definline
4 ;;; Created: 1999-05-25 22:32
5 ;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
6 ;;; License: Lisp-LGPL (See file COPYING for details).
7 ;;; ---------------------------------------------------------------------------
8 ;;; (c) copyright 1999 by Gilbert Baumann
10 ;;; This code is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the version 2.1 of the GNU Lesser General Public
12 ;;; License as published by the Free Software Foundation, as clarified
13 ;;; by the "Preamble to the Gnu Lesser General Public License" found in
14 ;;; the file COPYING.
15 ;;;
16 ;;; This code is distributed in the hope that it will be useful,
17 ;;; but without any warranty; without even the implied warranty of
18 ;;; merchantability or fitness for a particular purpose. See the GNU
19 ;;; Lesser General Public License for more details.
20 ;;;
21 ;;; Version 2.1 of the GNU Lesser General Public License is in the file
22 ;;; COPYING that was distributed with this file. If it is not present,
23 ;;; you can access it from http://www.gnu.org/copyleft/lesser.txt (until
24 ;;; superseded by a newer version) or write to the Free Software
25 ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 (in-package :runes)
29 #-(or allegro openmcl)
30 (defmacro definline (name args &body body)
31 `(progn
32 (declaim (inline ,name))
33 (defun ,name ,args .,body)))
35 #+openmcl
36 (defmacro runes::definline (fun args &body body)
37 (if (consp fun)
38 `(defun ,fun ,args
39 ,@body)
40 `(progn
41 (defun ,fun ,args .,body)
42 (define-compiler-macro ,fun (&rest .args.)
43 (cons '(lambda ,args .,body)
44 .args.)))))
46 #+allegro
47 (defmacro definline (fun args &body body)
48 (if (and (consp fun) (eq (car fun) 'setf))
49 (let ((fnam (intern (concatenate 'string "(SETF " (symbol-name (cadr fun)) ")")
50 (symbol-package (cadr fun)))))
51 `(progn
52 (defsetf ,(cadr fun) (&rest ap) (new-value) (list* ',fnam new-value ap))
53 (definline ,fnam ,args .,body)))
54 (labels ((declp (x)
55 (and (consp x) (eq (car x) 'declare))))
56 `(progn
57 (defun ,fun ,args .,body)
58 (define-compiler-macro ,fun (&rest .args.)
59 (cons '(lambda ,args
60 ,@(remove-if-not #'declp body)
61 (block ,fun
62 ,@(remove-if #'declp body)))
63 .args.))))))