[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: identity
From: |
Keisuke Nishida |
Subject: |
Re: identity |
Date: |
Sat, 14 Apr 2001 08:16:48 -0400 |
User-agent: |
Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.102 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) |
At 14 Apr 2001 11:03:38 +0200,
Marius Vollmer wrote:
>
> > (define (identity x) x)
> >
> > (define (id x)
> > (display ";;; `id' is deprecated. Use `identity' instead.\n")
> > x)
>
> Isn't that a bit much? You'll get the warning on every use of `id',
> which might be an enourmous number of times. In any case, the message
> should go to (current-error-port).
Right. What about this?
(define id
(let ((warned #f))
(lambda args
(cond ((not warned)
(display ";;; `id' is deprecated. Use `identity' instead.\n"
(current-error-port))
(set! warned #t)))
(apply identity args))))
> Maybe this is a good opportunity to intriduce explicit support for
> deprecating into the module system? We could for example have a way
> to emit a warning once when a deprecated binding is looked up.
We could write a macro `define-duplicate' or something that
produces the above code. Should we do that?
(define-macro (define-duplicate old new)
`(define ,old
(let ((warned #f))
(lambda args
(cond ((not warned)
(format (current-error-port)
";;; `~A' is deprecated. Use `~A' instead.\n"
',old ',new)
(set! warned #t)))
(apply ,new args)))))
guile> (define-duplicate id identity)
guile> (id 1)
;;; `id' is deprecated. Use `identity' instead.
1
guile> (id 1)
1
- identity, Keisuke Nishida, 2001/04/12
- Re: identity, Marius Vollmer, 2001/04/13
- Re: identity, Keisuke Nishida, 2001/04/13
- Re: identity, Marius Vollmer, 2001/04/13
- Re: identity, Keisuke Nishida, 2001/04/13
- Re: identity, Marius Vollmer, 2001/04/14
- Re: identity,
Keisuke Nishida <=
- Re: identity, Keisuke Nishida, 2001/04/14
- Re: identity, Marius Vollmer, 2001/04/15
- Re: identity, Keisuke Nishida, 2001/04/15
- Re: identity, Marius Vollmer, 2001/04/15