* [PATCH] Refactor Ffunctionp into inline function
@ 2012-08-25 13:37 Barry OReilly
2012-08-26 3:31 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Barry OReilly @ 2012-08-25 13:37 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 321 bytes --]
> Yes. The bulk of Ffunctionp should probably be moved to lisp.h into
> a "functionp" inlinable function, then make FUNCTIONP an alias
> for functionp and make Ffunctionp use functionp.
Is this what you have in mind? This patch allows my Key Translation with
lambda test case to work with and without lexical binding.
[-- Attachment #1.2: Type: text/html, Size: 371 bytes --]
[-- Attachment #2: functionpRefactor01.txt --]
[-- Type: text/plain, Size: 4931 bytes --]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: gundaetiapo@gmail.com-20120825132244-a1d8m35g9tvqvzsy
# target_branch: file:///home/epich/bzr/emacs/trunk/
# testament_sha1: 107dfbdd23adeb1928e07603ece9df09558d8649
# timestamp: 2012-08-25 09:22:55 -0400
# base_revision_id: michael.albinus@gmx.de-20120824125540-\
# o73xp777zwrmy52s
#
# Begin patch
=== modified file 'src/eval.c'
--- src/eval.c 2012-08-20 09:39:57 +0000
+++ src/eval.c 2012-08-25 13:22:44 +0000
@@ -2722,33 +2722,9 @@
doc: /* Non-nil if OBJECT is a function. */)
(Lisp_Object object)
{
- if (SYMBOLP (object) && !NILP (Ffboundp (object)))
- {
- object = Findirect_function (object, Qt);
-
- if (CONSP (object) && EQ (XCAR (object), Qautoload))
- {
- /* Autoloaded symbols are functions, except if they load
- macros or keymaps. */
- int i;
- for (i = 0; i < 4 && CONSP (object); i++)
- object = XCDR (object);
-
- return (CONSP (object) && !NILP (XCAR (object))) ? Qnil : Qt;
- }
- }
-
- if (SUBRP (object))
- return (XSUBR (object)->max_args != UNEVALLED) ? Qt : Qnil;
- else if (COMPILEDP (object))
+ if (FUNCTIONP (object))
return Qt;
- else if (CONSP (object))
- {
- Lisp_Object car = XCAR (object);
- return (EQ (car, Qlambda) || EQ (car, Qclosure)) ? Qt : Qnil;
- }
- else
- return Qnil;
+ return Qnil;
}
DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
=== modified file 'src/lisp.h'
--- src/lisp.h 2012-08-24 04:37:57 +0000
+++ src/lisp.h 2012-08-25 13:22:44 +0000
@@ -1906,11 +1906,7 @@
Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
/* Non-zero if OBJ is a Lisp function. */
-#define FUNCTIONP(OBJ) \
- ((CONSP (OBJ) && EQ (XCAR (OBJ), Qlambda)) \
- || (SYMBOLP (OBJ) && !NILP (Ffboundp (OBJ))) \
- || COMPILEDP (OBJ) \
- || SUBRP (OBJ))
+#define FUNCTIONP(OBJ) functionp(OBJ)
/* defsubr (Sname);
is how we define the symbol for function `name' at start-up time. */
@@ -3656,6 +3652,38 @@
Fgarbage_collect ();
}
+LISP_INLINE int
+functionp (Lisp_Object object)
+{
+ if (SYMBOLP (object) && !NILP (Ffboundp (object)))
+ {
+ object = Findirect_function (object, Qt);
+
+ if (CONSP (object) && EQ (XCAR (object), Qautoload))
+ {
+ /* Autoloaded symbols are functions, except if they load
+ macros or keymaps. */
+ int i;
+ for (i = 0; i < 4 && CONSP (object); i++)
+ object = XCDR (object);
+
+ return ! (CONSP (object) && !NILP (XCAR (object)));
+ }
+ }
+
+ if (SUBRP (object))
+ return XSUBR (object)->max_args != UNEVALLED;
+ else if (COMPILEDP (object))
+ return 1;
+ else if (CONSP (object))
+ {
+ Lisp_Object car = XCAR (object);
+ return EQ (car, Qlambda) || EQ (car, Qclosure);
+ }
+ else
+ return 0;
+}
+
INLINE_HEADER_END
#endif /* EMACS_LISP_H */
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWcwf0yYAAspfgHAwef///383
/2C////+UAW4rzbm7dC63ckVLq3RhJJCaZDTJNoaNGk0eonlNk0I0yaaaNNAA0NqCUhNMEYhKeyS
eo9QNADQDIMgAAGgE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pyeiyx3RQoGmnYgvJaq7C+95z3p4+07O220PWZJ1kOYYAg34LWMXSgyUDFJR0N0ZC0y8Zb2
NTus16QmaThqQcEfbtQi4A8YcOY0FmHZtqvOJQgEjpAI0dTnoIOMV5UdrQkMZtT0zWpamFMZYN8b
M+r7rygIX4MV8v1PD/fc738pyFqx4aysf13U7emLKPP5AifVgmKoxPmDjuCy4Wf7I8sz2dctvgaL
+uLimWdMEtyjFNh0aMhMgjFs8Gci1JaRTmijS3+ErwaDlOIWJufYVEFMJxOvyd4wE2py1nNG+gYu
gW5RUx8gLTkymVMSS8axGcTK7BVeSe2tI+OtuQNmWDkwoaOHYyMqsQSZxTyENSM0eIqjvsr+lWRR
zVoYCnYiZdJPXIRTgjEa4YkYVWtKBwSol+Lwil3yJ4t1BVU0E/RDd5y01tSDgNgDbq0FG3hXLdeY
zSDLJHKFRWBKp0ThF4+QBiaHQO7spNp3nIFvCZxeULnJmBhaM8FlBsQTri3SVpKWaM0YxEgtrJRU
X1UZDq51K6+ueXBgzpup5VBiwYYJKm8gpflhFjyUCv7QJoMMoJyKrxFNO5K9jMjnXtL1HPbQqlIS
lmGx7x/Z0WnN2L1whcl2qXDBG99MjcowM0FEQ2sQ2E5AVXcAxYLMCdhcJamT547IojuBY1UwVtcu
0oJqScCcrHUIevA0GC9cFvAzEdbgbNrS5W0IKrpwCurDh64UreKKCeiQDkA8mwTaFfFuUkrcSZF5
wbpEJ2Zq614Ym2amClyAeJa+wdjXg8Sb/i7kinChIZg/pkw=
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-26 3:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-25 13:37 [PATCH] Refactor Ffunctionp into inline function Barry OReilly
2012-08-26 3:31 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.