Commit | Line | Data |
---|---|---|
71d540f7 MD |
1 | ;;; installed-scm-file |
2 | ||
3 | ;;;; Copyright (C) 2001 Free Software Foundation, Inc. | |
4 | ;;;; | |
5 | ;;;; This program is free software; you can redistribute it and/or modify | |
6 | ;;;; it under the terms of the GNU General Public License as published by | |
7 | ;;;; the Free Software Foundation; either version 2, or (at your option) | |
8 | ;;;; any later version. | |
9 | ;;;; | |
10 | ;;;; This program is distributed in the hope that it will be useful, | |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;;;; GNU General Public License for more details. | |
14 | ;;;; | |
15 | ;;;; You should have received a copy of the GNU General Public License | |
16 | ;;;; along with this software; see the file COPYING. If not, write to | |
17 | ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
18 | ;;;; Boston, MA 02111-1307 USA | |
19 | ;;;; | |
20 | \f | |
21 | ||
22 | (define-module (oop goops old-define-method) | |
23 | :use-module (oop goops) | |
24 | :no-backtrace | |
25 | ) | |
26 | ||
27 | (export define-method) | |
28 | ||
29 | (define define-method | |
30 | (procedure->memoizing-macro | |
31 | (lambda (exp env) | |
32 | (let ((name (cadr exp))) | |
33 | (if (and (pair? name) | |
34 | (eq? (car name) 'setter) | |
35 | (pair? (cdr name)) | |
36 | (symbol? (cadr name)) | |
37 | (null? (cddr name))) | |
38 | (let ((name (cadr name))) | |
39 | (cond ((not (symbol? name)) | |
40 | (goops-error "bad method name: ~S" name)) | |
41 | ((defined? name env) | |
42 | `(begin | |
43 | ;; *fixme* Temporary hack for the current module system | |
44 | (if (not ,name) | |
45 | (define-accessor ,name)) | |
46 | (add-method! (setter ,name) (method ,@(cddr exp))))) | |
47 | (else | |
48 | `(begin | |
49 | (define-accessor ,name) | |
50 | (add-method! (setter ,name) (method ,@(cddr exp))))))) | |
51 | (cond ((not (symbol? name)) | |
52 | (goops-error "bad method name: ~S" name)) | |
53 | ((defined? name env) | |
54 | `(begin | |
55 | ;; *fixme* Temporary hack for the current module system | |
56 | (if (not ,name) | |
57 | (define-generic ,name)) | |
58 | (add-method! ,name (method ,@(cddr exp))))) | |
59 | (else | |
60 | `(begin | |
61 | (define-generic ,name) | |
62 | (add-method! ,name (method ,@(cddr exp))))))))))) |