* featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v)
[not found] <E1JI3n9-0003Yy-Mx@cvs.savannah.gnu.org>
@ 2008-01-24 21:44 ` Reiner Steib
2008-01-24 21:55 ` Dan Nicolaescu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Reiner Steib @ 2008-01-24 21:44 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
On Thu, Jan 24 2008, Dan Nicolaescu on emacs-diffs:
> --- gnus/ChangeLog 24 Jan 2008 07:47:37 -0000 1.633
> +++ gnus/ChangeLog 24 Jan 2008 15:14:50 -0000 1.634
> @@ -1,3 +1,9 @@
> +2008-01-24 Dan Nicolaescu <dann@ics.uci.edu>
> +
> + * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
> + * message.el (message-beginning-of-line): Use featurep instead of bound
> + tests in order to resolve conditionals at compile time.
In the past, I've been told that it's preferable to use fbound tests
instead of Emacs flavor or version tests. So I'm surprised by changes
like these...
> --- gnus/sieve.el 8 Jan 2008 20:45:19 -0000 1.12
> +++ gnus/sieve.el 24 Jan 2008 15:14:49 -0000 1.13
> @@ -290,15 +290,15 @@
> (get-char-property (or pos (point)) 'script-name))
>
> (eval-and-compile
> - (defalias 'sieve-make-overlay (if (fboundp 'make-overlay)
> - 'make-overlay
> - 'make-extent))
> - (defalias 'sieve-overlay-put (if (fboundp 'overlay-put)
> - 'overlay-put
> - 'set-extent-property))
> - (defalias 'sieve-overlays-at (if (fboundp 'overlays-at)
> - 'overlays-at
> - 'extents-at)))
> + (defalias 'sieve-make-overlay (if (featurep 'xemacs)
> + 'make-extent
> + 'make-overlay))
> + (defalias 'sieve-overlay-put (if (featurep 'xemacs)
> + 'set-extent-property
> + 'overlay-put))
> + (defalias 'sieve-overlays-at (if (featurep 'xemacs)
> + 'extents-at
> + 'overlays-at)))
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v)
2008-01-24 21:44 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Reiner Steib
@ 2008-01-24 21:55 ` Dan Nicolaescu
2008-01-24 22:48 ` featurep instead of bound tests Stefan Monnier
2008-01-25 22:47 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Richard Stallman
2 siblings, 0 replies; 7+ messages in thread
From: Dan Nicolaescu @ 2008-01-24 21:55 UTC (permalink / raw)
To: emacs-devel
Reiner Steib <reinersteib+gmane@imap.cc> writes:
> On Thu, Jan 24 2008, Dan Nicolaescu on emacs-diffs:
>
> > --- gnus/ChangeLog 24 Jan 2008 07:47:37 -0000 1.633
> > +++ gnus/ChangeLog 24 Jan 2008 15:14:50 -0000 1.634
> > @@ -1,3 +1,9 @@
> > +2008-01-24 Dan Nicolaescu <dann@ics.uci.edu>
> > +
> > + * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
> > + * message.el (message-beginning-of-line): Use featurep instead of bound
> > + tests in order to resolve conditionals at compile time.
>
> In the past, I've been told that it's preferable to use fbound tests
> instead of Emacs flavor or version tests. So I'm surprised by changes
> like these...
In general probably yes, but these particular cases are about functions
that emacs will probably never get because it has similar facilities:
overlays vs extents.
> > --- gnus/sieve.el 8 Jan 2008 20:45:19 -0000 1.12
> > +++ gnus/sieve.el 24 Jan 2008 15:14:49 -0000 1.13
> > @@ -290,15 +290,15 @@
> > (get-char-property (or pos (point)) 'script-name))
> >
> > (eval-and-compile
> > - (defalias 'sieve-make-overlay (if (fboundp 'make-overlay)
> > - 'make-overlay
> > - 'make-extent))
> > - (defalias 'sieve-overlay-put (if (fboundp 'overlay-put)
> > - 'overlay-put
> > - 'set-extent-property))
> > - (defalias 'sieve-overlays-at (if (fboundp 'overlays-at)
> > - 'overlays-at
> > - 'extents-at)))
> > + (defalias 'sieve-make-overlay (if (featurep 'xemacs)
> > + 'make-extent
> > + 'make-overlay))
> > + (defalias 'sieve-overlay-put (if (featurep 'xemacs)
> > + 'set-extent-property
> > + 'overlay-put))
> > + (defalias 'sieve-overlays-at (if (featurep 'xemacs)
> > + 'extents-at
> > + 'overlays-at)))
>
> Bye, Reiner.
> --
> ,,,
> (o o)
> ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests
2008-01-24 21:44 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Reiner Steib
2008-01-24 21:55 ` Dan Nicolaescu
@ 2008-01-24 22:48 ` Stefan Monnier
2008-01-25 5:49 ` Dan Nicolaescu
2008-01-25 22:47 ` Richard Stallman
2008-01-25 22:47 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Richard Stallman
2 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2008-01-24 22:48 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
>> --- gnus/ChangeLog 24 Jan 2008 07:47:37 -0000 1.633
>> +++ gnus/ChangeLog 24 Jan 2008 15:14:50 -0000 1.634
>> @@ -1,3 +1,9 @@
>> +2008-01-24 Dan Nicolaescu <dann@ics.uci.edu>
>> +
>> + * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
>> + * message.el (message-beginning-of-line): Use featurep instead of bound
>> + tests in order to resolve conditionals at compile time.
> In the past, I've been told that it's preferable to use fbound tests
> instead of Emacs flavor or version tests. So I'm surprised by changes
> like these...
Agreed. I see 2 better solutions:
1 - use (require 'outline)
2 - teach the byte-optimizer that (fboundp 'make-overlay) will always be t.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests
2008-01-24 22:48 ` featurep instead of bound tests Stefan Monnier
@ 2008-01-25 5:49 ` Dan Nicolaescu
2008-01-25 9:45 ` Stephen J. Turnbull
2008-01-25 22:47 ` Richard Stallman
1 sibling, 1 reply; 7+ messages in thread
From: Dan Nicolaescu @ 2008-01-25 5:49 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> --- gnus/ChangeLog 24 Jan 2008 07:47:37 -0000 1.633
> >> +++ gnus/ChangeLog 24 Jan 2008 15:14:50 -0000 1.634
> >> @@ -1,3 +1,9 @@
> >> +2008-01-24 Dan Nicolaescu <dann@ics.uci.edu>
> >> +
> >> + * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
> >> + * message.el (message-beginning-of-line): Use featurep instead of bound
> >> + tests in order to resolve conditionals at compile time.
>
> > In the past, I've been told that it's preferable to use fbound tests
> > instead of Emacs flavor or version tests. So I'm surprised by changes
> > like these...
>
> Agreed. I see 2 better solutions:
> 1 - use (require 'outline)
> 2 - teach the byte-optimizer that (fboundp 'make-overlay) will always be t.
That has the problem that XEmacs would have to teach its compiler that
it is always false. Or if the test was (fboundp 'make-extent) emacs will
have to know it's always false.
IMO for extents vs overlays and zmacs-* the featurep test is the best
option.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests
2008-01-25 5:49 ` Dan Nicolaescu
@ 2008-01-25 9:45 ` Stephen J. Turnbull
0 siblings, 0 replies; 7+ messages in thread
From: Stephen J. Turnbull @ 2008-01-25 9:45 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: Stefan Monnier, emacs-devel
Dan Nicolaescu writes:
> Stefan Monnier writes:
> > Agreed. I see 2 better solutions:
> > 1 - use (require 'outline)
I have no opinion on that, but
> > 2 - teach the byte-optimizer that (fboundp 'make-overlay) will
> > always be t.
is not useful.
(fboundp 'make-overlay) is always the wrong thing to do (unless the
code gracefully exits, doing nothing, without it). XEmacs *does* have
`make-overlay' (it's deprecated and not autoloaded or dumped, but it
exists in a compatibility library that can be require'd). I imagine
there are some people who have emulated `make-extent' with
`make-overlay' for Emacs, too.
However, emulations are rarely perfect (XEmacs's `make-overlay' is
explicitly not intended to be), so many developers are going to wish
to use the native facilities. That *requires* a (featurep 'xemacs) or
equivalent to know which is native when both are fboundp.
> [Optimizing (fboundp 'make-overlay)] has the problem that XEmacs
> would have to teach its compiler that it is always false.
No, that's not a problem. The compiler doesn't need to know, it's an
optimization. In any case, it's not always false in XEmacs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v)
2008-01-24 21:44 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Reiner Steib
2008-01-24 21:55 ` Dan Nicolaescu
2008-01-24 22:48 ` featurep instead of bound tests Stefan Monnier
@ 2008-01-25 22:47 ` Richard Stallman
2 siblings, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2008-01-25 22:47 UTC (permalink / raw)
To: Reiner Steib; +Cc: dann, emacs-devel
In the past, I've been told that it's preferable to use fbound tests
instead of Emacs flavor or version tests.
Yes, often the fboundp tests are prefereable.
In general probably yes, but these particular cases are about functions
that emacs will probably never get because it has similar facilities:
overlays vs extents.
Even so, the fboundp tests are sometimes better.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: featurep instead of bound tests
2008-01-24 22:48 ` featurep instead of bound tests Stefan Monnier
2008-01-25 5:49 ` Dan Nicolaescu
@ 2008-01-25 22:47 ` Richard Stallman
1 sibling, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2008-01-25 22:47 UTC (permalink / raw)
To: Stefan Monnier; +Cc: dann, emacs-devel
2 - teach the byte-optimizer that (fboundp 'make-overlay) will always be t.
That is a good idea.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-25 22:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1JI3n9-0003Yy-Mx@cvs.savannah.gnu.org>
2008-01-24 21:44 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Reiner Steib
2008-01-24 21:55 ` Dan Nicolaescu
2008-01-24 22:48 ` featurep instead of bound tests Stefan Monnier
2008-01-25 5:49 ` Dan Nicolaescu
2008-01-25 9:45 ` Stephen J. Turnbull
2008-01-25 22:47 ` Richard Stallman
2008-01-25 22:47 ` featurep instead of bound tests (was: Changes to emacs/lisp/gnus/ChangeLog, v) Richard Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).