1
1
;;; gfunc.el --- support for generic function
2
;;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
2
;;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
3
3
;;; HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
4
4
;;; $Id: gfunc.el,v 1.16 2011-12-31 15:07:29 hira Exp $
96
96
(gfunc-call (quote ,base-name) ,dispatchers-var args))))
98
(put 'gfunc-def 'lisp-indent-hook 2)
99
98
(defmacro gfunc-def (base-name args-declaration &optional description)
100
99
"Define generic function like `gfunc-define-function'.
101
100
The only difference is omission of dispatchers; it must be specified
102
101
by `gfunc-with' outside."
103
103
`(gfunc-define-function ,base-name ,args-declaration ,*gfunc-dispatchers-var*
106
(put 'gfunc-with 'lisp-indent-hook 1)
107
106
(defmacro gfunc-with (dispatchers-var &rest body)
108
107
"With the defalut DISPATCHERS-VAR, execute BODY.
109
108
BODY is typically a set of `gfunc-def', and DISPATCHERS-VAR is used
110
109
as their dispatchers.
111
110
This macro cannot be nested."
112
;; Be careful to etc/NEWS in Emacs 24.3 or
113
;; http://www.masteringemacs.org/articles/2013/03/11/whats-new-emacs-24-3/
114
;; "Emacs tries to macroexpand interpreted (non-compiled) files during load."
115
(setq *gfunc-dispatchers-var* dispatchers-var)
112
116
`(eval-and-compile
113
;; I want to use let instead of setq.
114
;; But, let doesn't work when this file is byte-compiled.
115
;; I don't understand the problem around macro and byte-compilation.
116
(setq *gfunc-dispatchers-var* (quote ,dispatchers-var))
118
;; (let ((*gfunc-dispatchers-var* (quote ,dispatchers-var)))