unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] New convenience macros
@ 2007-08-18 14:30 Steve Youngs
  2007-08-19 15:52 ` Richard Stallman
  2007-08-20  4:09 ` Stefan Monnier
  0 siblings, 2 replies; 17+ messages in thread
From: Steve Youngs @ 2007-08-18 14:30 UTC (permalink / raw)
  To: XEmacs patches; +Cc: Emacs devel


[-- Attachment #1.1: Type: text/plain, Size: 3345 bytes --]

I added these to SXEmacs a little while ago.  They are a couple of
macros that can be used when you need to conditionalise on emacs
flavour.  And at the same time not generate byte-compiler warnings,
regardless of the flavour of emacs you are using to compile the .el.

It is my hope that both XEmacs and GNU/Emacs will include these macros
so that elisp programmers can benefit from them no matter what their
preferred emacsen is.

ChangeLog entry for XEmacs (sorry, I have no clue where these macros
should go in GNU/Emacs)...

2007-08-19  Steve Youngs  <steve@sxemacs.org>

	* subr.el (do-in-sxemacs, do-in-xemacs, do-in-gnu-emacs)
	(with-emacs-type): Convenience macros to use when you need to
	conditionalise on emacs flavour.  They have the added advantage of
	suppressing byte-compiler warnings.

diff -r ad09012c3de7 lisp/subr.el
--- a/lisp/subr.el	Wed Aug 15 23:23:30 2007 +0000
+++ b/lisp/subr.el	Sun Aug 19 00:29:24 2007 +1000
@@ -188,6 +188,69 @@ ELT must be a string.  Upper-case and lo
   (while (and list (not (eq t (compare-strings elt 0 nil (car list) 0 nil t))))
     (setq list (cdr list)))
   list)
+
+;; Convenience macros to let you conditionalise code for different
+;; emacs variants without generating any byte-compiler warnings
+
+(eval-when-compile
+  (if (featurep 'xemacs)
+      (or (featurep 'sxemacs)
+	  (defvar running-sxemacs))
+    (defvar running-sxemacs)
+    (defvar running-xemacs)))
+
+(defmacro do-in-sxemacs (&rest body)
+  "Execute BODY if in SXEmacs."
+  (and running-sxemacs
+       (cons 'progn body)))
+
+(put 'do-in-sxemacs 'lisp-indent-hook 'defun)
+
+(defmacro do-in-xemacs (&rest body)
+  "Execute BODY if in XEmacs."
+  (and running-xemacs
+       (cons 'progn body)))
+
+(put 'do-in-xemacs 'lisp-indent-hook 'defun)
+
+(defmacro do-in-gnu-emacs (&rest body)
+  "Execute BODY if in GNU/Emacs."
+  (unless (or running-sxemacs
+	      running-xemacs)
+    (cons 'progn body)))
+
+(put 'do-in-gnu-emacs 'lisp-indent-hook 'defun)
+
+(defmacro with-emacs-type (type &rest body)
+  "Execute BODY depending on emacs TYPE.
+
+Argument TYPE is a quoted symbol, being one of `sxemacs', `xemacs', or
+`gnu'.  For example...
+
+  \(with-emacs-type 'sxemacs
+    ;; SXEmacs only code goes here.
+    ;; XEmacs and GNU/Emacs won't see it and won't complain about unbound
+    ;; funcs/vars.
+    \)
+  \(with-emacs-type 'xemacs
+    ;; XEmacs code goes here.
+    ;; GNU/Emacs won't see it and won't complain about unbound funcs/vars.
+    \)
+  \(with-emacs-type 'gnu
+    ;; GNU/Emacs code goes here.
+    ;; SXEmacs and XEmacs won't see it and won't complain about unbound
+    ;; funcs/vars.
+    \)"
+  (cond
+   ((equal type '(quote sxemacs))
+    (do-in-sxemacs (cons 'progn body)))
+   ((equal type '(quote xemacs))
+    (do-in-xemacs (cons 'progn body)))
+   ((equal type '(quote gnu))
+    (do-in-gnu-emacs (cons 'progn body)))
+   (t (error 'invalid-argument type))))
+
+(put 'with-emacs-type 'lisp-indent-hook 'defun)
 
 \f
 ;;;; Keymap support.


-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|

[-- Attachment #1.2: Type: application/pgp-signature, Size: 312 bytes --]

[-- Attachment #2: Type: text/plain, Size: 165 bytes --]

_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches@xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-18 14:30 [PATCH] New convenience macros Steve Youngs
@ 2007-08-19 15:52 ` Richard Stallman
  2007-08-20  2:06   ` Steve Youngs
  2007-08-20  4:09 ` Stefan Monnier
  1 sibling, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2007-08-19 15:52 UTC (permalink / raw)
  To: Steve Youngs; +Cc: xemacs-patches, emacs-devel

I don't want to contrast the name "XEmacs" with the name "GNU Emacs",
so I don't want these macros installed in Emacs under the names
proposed.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-19 15:52 ` Richard Stallman
@ 2007-08-20  2:06   ` Steve Youngs
  2007-08-20 10:58     ` Kim F. Storm
  2007-08-20 18:30     ` Richard Stallman
  0 siblings, 2 replies; 17+ messages in thread
From: Steve Youngs @ 2007-08-20  2:06 UTC (permalink / raw)
  To: emacs-devel; +Cc: xemacs-patches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* Richard Stallman <rms@gnu.org> writes:

  > I don't want to contrast the name "XEmacs" with the name "GNU Emacs",
  > so I don't want these macros installed in Emacs under the names
  > proposed.

How about.. `do-in-emacs', `do-in-xemacs', `do-in-sxemacs', and
`with-emacs-type', and change the symbol in `with-emacs-type' from `gnu'
to `emacs'.  Would that be better?

The names aren't that important, providing they are consistent across
the 3 emacs variants.  I have no particular preference so I'm happy to
go with whatever names you decide, Richard.  Just let me know what names
you do use for these macros so I can ensure the same goes into XEmacs
and SXEmacs.

Thanks!

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkbI9ygACgkQHSfbS6lLMAMQrQCdHolngtnBMsWPEgS/q7z9dYSg
kA0AoIKiqyHRAiHEOKFZrefU7BIjOSAn
=Tm0S
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-18 14:30 [PATCH] New convenience macros Steve Youngs
  2007-08-19 15:52 ` Richard Stallman
@ 2007-08-20  4:09 ` Stefan Monnier
  2007-08-23 11:13   ` Steve Youngs
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2007-08-20  4:09 UTC (permalink / raw)
  To: XEmacs patches; +Cc: Emacs devel

> I added these to SXEmacs a little while ago.  They are a couple of
> macros that can be used when you need to conditionalise on emacs
> flavour.  And at the same time not generate byte-compiler warnings,
> regardless of the flavour of emacs you are using to compile the .el.

We've done it differently in Emacs-22 (and maybe even Emacs-21: can't
remember exactly when it was introduced): (featurep 'xemacs) is known by the
source-level optimizer as a constant of value nil, so

  (if (featurep 'xemacs) a b)

will only look at `b' and won't generate any warnings about code in `a'.
The corresponding code is very simple (in byte-opt.el):

   (put 'featurep 'byte-optimizer 'byte-optimize-featurep)
   (defun byte-optimize-featurep (form)
     ;; Emacs-21's byte-code doesn't run under XEmacs anyway, so we can
     ;; safely optimize away this test.
     (if (equal '((quote xemacs)) (cdr-safe form))
         nil
       form))

I haven't come across any (featurep 'sxemacs) yet, so the code hasn't been
updated for that use yet, but it's trivial to do so, obviously.

The advantage over a macro is that the elisp code will work regardless of
whether this optimization is implemented (it only affects byte-compiler
warnings anyway), so it's trivially backward&forward compatible.


        Stefan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-20  2:06   ` Steve Youngs
@ 2007-08-20 10:58     ` Kim F. Storm
  2007-08-20 18:30     ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: Kim F. Storm @ 2007-08-20 10:58 UTC (permalink / raw)
  To: emacs-devel

Steve Youngs <steve@sxemacs.org> writes:

> NotDashEscaped: You need GnuPG to verify this message
>
> * Richard Stallman <rms@gnu.org> writes:
>
>   > I don't want to contrast the name "XEmacs" with the name "GNU Emacs",
>   > so I don't want these macros installed in Emacs under the names
>   > proposed.
>
> How about.. `do-in-emacs', `do-in-xemacs', `do-in-sxemacs', and
> `with-emacs-type', and change the symbol in `with-emacs-type' from `gnu'
> to `emacs'.  Would that be better?
>
> The names aren't that important, providing they are consistent across
> the 3 emacs variants.  I have no particular preference so I'm happy to
> go with whatever names you decide, Richard.  Just let me know what names
> you do use for these macros so I can ensure the same goes into XEmacs
> and SXEmacs.

So far, there is code in Emacs which is XEmacs aware by testing on
(if (featurep 'xemacs) ...) and the byte compiler being aware that
this condition is always false in Emacs, so XEmacs code is ignored.

We could arrange for to byte-compiler to know about (featurep
'sxemacs) as well, but I think that's as far as we should go in terms
of differentiating yet another Emacs derivate.

I suppose that SXEmacs also provides xemacs (or you will have to edit
a lot of existing code!), so it is really only for the differences
between SXEmacs and XEmacs that you may need additional sxemacs tests.

I really don't see why Emacs has to be concerned about that.
Next month somebody else will ask for support for TXEmacs.

I could go as far as creating a new macro "when-emacs" that could
be used as

  (when-emacs emacs ...)
  (when-emacs xemacs ...)
  (when-emacs sxemacs ...)

which simply expands into

  (if (featurep (quote VARIANT)) BODY)

And instead of just a fixed 'xemacs symbol in the byte compiler,
there could be a list of features to ignore:

(defvar byte-compiler-ignored-features '(xemacs sxemacs))


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-20  2:06   ` Steve Youngs
  2007-08-20 10:58     ` Kim F. Storm
@ 2007-08-20 18:30     ` Richard Stallman
  2007-08-23 10:54       ` Steve Youngs
  1 sibling, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2007-08-20 18:30 UTC (permalink / raw)
  To: Steve Youngs; +Cc: emacs-devel

    How about.. `do-in-emacs', `do-in-xemacs', `do-in-sxemacs', and
    `with-emacs-type', and change the symbol in `with-emacs-type' from `gnu'
    to `emacs'.  Would that be better?

Those names are ok.  We could install them with those names.

However, Stefan wrote:

    The advantage over a macro is that the elisp code will work regardless of
    whether this optimization is implemented (it only affects byte-compiler
    warnings anyway), so it's trivially backward&forward compatible.

This is a good argument for _using_ featurep rather than the macros.

That doesn't mean we can't also install the macros.  But maybe you
will agree it is better to use featurep.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-20 18:30     ` Richard Stallman
@ 2007-08-23 10:54       ` Steve Youngs
  2007-08-23 14:12         ` Johan Bockgård
  2007-08-23 14:47         ` Stefan Monnier
  0 siblings, 2 replies; 17+ messages in thread
From: Steve Youngs @ 2007-08-23 10:54 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1216 bytes --]

* Richard Stallman <rms@gnu.org> writes:

  > However, Stefan wrote:

  >     The advantage over a macro is that the elisp code will work regardless of
  >     whether this optimization is implemented (it only affects byte-compiler
  >     warnings anyway), so it's trivially backward&forward compatible.

  > This is a good argument for _using_ featurep rather than the macros.

  > That doesn't mean we can't also install the macros.  But maybe you
  > will agree it is better to use featurep.

Yes, I agree.  I'm even going to add a similar optimisation to SXEmacs
and XEmacs.  However, there are situations where this optimisation won't
work, here's an example...

  (if (and (featurep 'simple) (featurep 'xemacs)) a b)

warns about free variables for both `a' and `b'.  So I think having the
macros as well as the optimisation is a good idea.  Can you please add
them, Richard? (with the updated names of course)

Thanks very much.

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|

[-- Attachment #1.2: Type: application/pgp-signature, Size: 312 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-20  4:09 ` Stefan Monnier
@ 2007-08-23 11:13   ` Steve Youngs
  2007-08-23 15:11     ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Steve Youngs @ 2007-08-23 11:13 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1920 bytes --]

* Stefan Monnier <monnier@iro.umontreal.ca> writes:

  >> I added these to SXEmacs a little while ago.  They are a couple of
  >> macros that can be used when you need to conditionalise on emacs
  >> flavour.  And at the same time not generate byte-compiler warnings,
  >> regardless of the flavour of emacs you are using to compile the
  >> .el.

  > We've done it differently in Emacs-22 (and maybe even Emacs-21:
  > can't remember exactly when it was introduced): (featurep 'xemacs)
  > is known by the source-level optimizer as a constant of value nil,
  > so

  >   (if (featurep 'xemacs) a b)

  > will only look at `b' and won't generate any warnings about code in
  > `a'.  The corresponding code is very simple (in byte-opt.el):

  >    (put 'featurep 'byte-optimizer 'byte-optimize-featurep)
  >    (defun byte-optimize-featurep (form)
  >      ;; Emacs-21's byte-code doesn't run under XEmacs anyway, so we can
  >      ;; safely optimize away this test.
  >      (if (equal '((quote xemacs)) (cdr-safe form))
  >          nil
  >        form))

Oh, that's nice.  Thank you very much for showing me this, Stefan, I'm
going to add something similar to SXEmacs (and XEmacs too I hope).

  > I haven't come across any (featurep 'sxemacs) yet, so the code
  > hasn't been updated for that use yet, but it's trivial to do so,
  > obviously.

And because it would be so trivial, perhaps you wouldn't mind adding it
now, Stefan?  There's currently not much (if anything) out in the wild
that would depend on (featurep 'sxemacs), but we're constantly adding
new stuff so it's only a matter of time. :-)

Thanks very much!

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|

[-- Attachment #1.2: Type: application/pgp-signature, Size: 312 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 10:54       ` Steve Youngs
@ 2007-08-23 14:12         ` Johan Bockgård
  2007-08-23 14:47         ` Stefan Monnier
  1 sibling, 0 replies; 17+ messages in thread
From: Johan Bockgård @ 2007-08-23 14:12 UTC (permalink / raw)
  To: emacs-devel

Steve Youngs <steve@sxemacs.org> writes:

> However, there are situations where this optimisation won't work,
> here's an example...
>
>   (if (and (featurep 'simple) (featurep 'xemacs)) a b)
>
> warns about free variables for both `a' and `b'.  So I think having the
> macros as well as the optimisation is a good idea.

It does the right thing if you reverse the order of the feature tests.

The compiler could do better though.

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 10:54       ` Steve Youngs
  2007-08-23 14:12         ` Johan Bockgård
@ 2007-08-23 14:47         ` Stefan Monnier
  2007-08-23 18:24           ` Steve Youngs
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2007-08-23 14:47 UTC (permalink / raw)
  To: emacs-devel

>   (if (and (featurep 'simple) (featurep 'xemacs)) a b)
> warns about free variables for both `a' and `b'.  So I think having the

That's a valid criticism, but I fail to see how your macros would fare any
better on the above kind of code.  I.e. what code would you write instead of
the above, using your macros?


        Stefan


PS: Of course while Johan's comment that the compiler could do better is
true, the fact is that it currently doesn't and that noone has volunteered
to improve it in this respect.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 11:13   ` Steve Youngs
@ 2007-08-23 15:11     ` Stefan Monnier
  2007-08-23 18:24       ` Steve Youngs
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2007-08-23 15:11 UTC (permalink / raw)
  To: emacs-devel

> And because it would be so trivial, perhaps you wouldn't mind adding it
> now, Stefan?  There's currently not much (if anything) out in the wild
> that would depend on (featurep 'sxemacs), but we're constantly adding
> new stuff so it's only a matter of time. :-)

Done,


        Stefan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 14:47         ` Stefan Monnier
@ 2007-08-23 18:24           ` Steve Youngs
  2007-08-23 19:12             ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Steve Youngs @ 2007-08-23 18:24 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* Stefan Monnier <monnier@iro.umontreal.ca> writes:

  >> (if (and (featurep 'simple) (featurep 'xemacs)) a b)
  >> warns about free variables for both `a' and `b'.  So I think having the

  > That's a valid criticism, but I fail to see how your macros would fare any
  > better on the above kind of code.  I.e. what code would you write instead of
  > the above, using your macros?

  (or (do-in-xemacs (when (featurep 'simple) a)) b)

Or...

  (with-emacs-type 'xemacs (when (featurep 'simple) a))
  (with-emacs-type 'emacs b)

Both only warn about `b' and the resulting bytecode has no mention of
`a'. 

  > PS: Of course while Johan's comment that the compiler could do
  > better is true, the fact is that it currently doesn't and that
  > noone has volunteered to improve it in this respect.

The same thing is happening in SXEmacs, BTW, with a similar optimisation
to Emacs' #'byte-optimize-featurep.  My version looks like...

  (defun byte-optimize-featurep (form)
    (let ((str (prin1-to-string (cdr-safe form))))
      (if (string-match #r"\s-+s?xemacs\(\s-\|)\)" str)
	  (byte-optimize-predicate form)
        form)))

I had to string-match it to cater for (S)XEmacs' advanced featurep
form

  (featurep '(and foo bar (not (or baz biz))))

At first I thought it was #'byte-optimize-predicate, but because you
guys don't use that and you do have the same problem, it can't be that.
I think the real problem lies in lisp's boolean function not being truly
boolean.

(or list_of_stuff) is traversed left-to-right and first non-nil wins.
#'and is the same, left-to-right, first nil wins (lose?), otherwise last
cons-car wins.

Sorry, I don't have a solution, but I'll certainly let you know if and
when I do. :-)

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkbN0MQACgkQHSfbS6lLMAPRPwCg2o8ZRzKBdye0uE6gC8cvrtlV
rc8AoInzF9abCMpo5TovqRdFW2UnMn97
=+Ds3
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 15:11     ` Stefan Monnier
@ 2007-08-23 18:24       ` Steve Youngs
  0 siblings, 0 replies; 17+ messages in thread
From: Steve Youngs @ 2007-08-23 18:24 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* Stefan Monnier <monnier@iro.umontreal.ca> writes:

  >> And because it would be so trivial, perhaps you wouldn't mind adding it
  >> now, Stefan?  There's currently not much (if anything) out in the wild
  >> that would depend on (featurep 'sxemacs), but we're constantly adding
  >> new stuff so it's only a matter of time. :-)

  > Done,

Ah, wonderful.  Thank you very much, Stefan!

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkbN0PAACgkQHSfbS6lLMAMWQACeMGjfIoKzBVYBxiKTVN4lopG9
+okAniRiin/94Mg5DyuC7NPwI7mk+uft
=w//4
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 18:24           ` Steve Youngs
@ 2007-08-23 19:12             ` Stefan Monnier
  2007-08-26 14:52               ` Steve Youngs
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2007-08-23 19:12 UTC (permalink / raw)
  To: emacs-devel

>>> (if (and (featurep 'simple) (featurep 'xemacs)) a b)
>>> warns about free variables for both `a' and `b'.  So I think having the

>> That's a valid criticism, but I fail to see how your macros would fare any
>> better on the above kind of code.  I.e. what code would you write instead of
>> the above, using your macros?

>   (or (do-in-xemacs (when (featurep 'simple) a)) b)

Aka (or (if (featurep 'xemacs) (when (featurep 'simple) a)) b)
which would naturally be rewritten as

   (if (and (featurep 'xemacs) (featurep 'simple)) a b)

>   (with-emacs-type 'xemacs (when (featurep 'simple) a))
>   (with-emacs-type 'emacs b)

(if (featurep 'xemacs) (when (featurep 'simple) a))
(unless (featurep 'xemacs) b)
which would naturally be rewritten as

   (if (featurep 'xemacs) (when (featurep 'simple) a) b)

> Both only warn about `b' and the resulting bytecode has no mention of
> `a'.

Same for my alternatives, which are the most obvious translations of
your code.  Note that the macro form is never simpler or clearer.
So I really fail to see the value of those macros.


        Stefan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-23 19:12             ` Stefan Monnier
@ 2007-08-26 14:52               ` Steve Youngs
  2007-08-26 22:47                 ` Richard Stallman
  0 siblings, 1 reply; 17+ messages in thread
From: Steve Youngs @ 2007-08-26 14:52 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* Stefan Monnier <monnier@iro.umontreal.ca> writes:

  > So I really fail to see the value of those macros.

If nothing else, they're an alternative.  I do agree that #'featurep is
a better way to go, but these macros are an alternative nonetheless.

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkbRk6IACgkQHSfbS6lLMAP3GgCfbY0DELQbMdrovgwOILPlvdI1
Px0An2BhANnKnsW4N5q86ve4I+ALnAqn
=0wSP
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-26 14:52               ` Steve Youngs
@ 2007-08-26 22:47                 ` Richard Stallman
  2007-08-27  3:20                   ` Steve Youngs
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2007-08-26 22:47 UTC (permalink / raw)
  To: Steve Youngs; +Cc: emacs-devel

    If nothing else, they're an alternative.

I would rather not install things in Emacs just because they are
different.  In general I would rather have fewer, rather than more,
ways to do any given job.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] New convenience macros
  2007-08-26 22:47                 ` Richard Stallman
@ 2007-08-27  3:20                   ` Steve Youngs
  0 siblings, 0 replies; 17+ messages in thread
From: Steve Youngs @ 2007-08-27  3:20 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* Richard Stallman <rms@gnu.org> writes:

  >     If nothing else, they're an alternative.

  > I would rather not install things in Emacs just because they are
  > different.  In general I would rather have fewer, rather than more,
  > ways to do any given job.

OK, fair enough.  I'll take them out of SXEmacs.  Thanks for looking at
it, Richard, Stefan.

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|       SXEmacs - The only _______ you'll ever need.       |
|         Fill in the blank, yes, it's THAT good!          |
|------------------------------------<steve@sxemacs.org>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkbSQv8ACgkQHSfbS6lLMAMBbwCfYJUTl8nsbseDFXwcLee+wuI9
AiEAnROWdTyWHtuBh3qGyu/F9qCAB/Hq
=mj4V
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2007-08-27  3:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-18 14:30 [PATCH] New convenience macros Steve Youngs
2007-08-19 15:52 ` Richard Stallman
2007-08-20  2:06   ` Steve Youngs
2007-08-20 10:58     ` Kim F. Storm
2007-08-20 18:30     ` Richard Stallman
2007-08-23 10:54       ` Steve Youngs
2007-08-23 14:12         ` Johan Bockgård
2007-08-23 14:47         ` Stefan Monnier
2007-08-23 18:24           ` Steve Youngs
2007-08-23 19:12             ` Stefan Monnier
2007-08-26 14:52               ` Steve Youngs
2007-08-26 22:47                 ` Richard Stallman
2007-08-27  3:20                   ` Steve Youngs
2007-08-20  4:09 ` Stefan Monnier
2007-08-23 11:13   ` Steve Youngs
2007-08-23 15:11     ` Stefan Monnier
2007-08-23 18:24       ` Steve Youngs

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).