* How about text-property-functions using `equal' rather than `eq'?
@ 2008-02-04 20:53 Alan Mackenzie
2008-02-05 8:04 ` Richard Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2008-02-04 20:53 UTC (permalink / raw)
To: emacs-devel
Hi, Emacs!
All the built in text property functions which compare properties appear
to use `eq' for the comparison. Some of these actually say this in
their doc-strings or the pertinent manual page, some of them might
actually say it in both. ;-(
However, it seems to me that `equal' would be a better comparison. I am
currently playing with syntax-table text-properties, and some characters
need to have the property set to '(1) (i.e. punctuation).
I would dearly love to use text-property-any to locate such a buffer
position, but unfortunately (eq '(1) '(1)) => nil. :-( So I've had to
code up a clumsy equivalent which will certainly be much slower.
Would it not be a good idea to change these functions to use `equal'
instead? No, it wouldn't be a good idea.
How about providing each of these with an optional extra parameter, the
comparison predicate? A much better idea! So we'd have, for example:
(defun text-property-any (start end prop value &optional object pred)
, with PRED defaulting to `eq'.
--
Alan Mackenzie (Nuremberg, Germany)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How about text-property-functions using `equal' rather than `eq'?
2008-02-04 20:53 How about text-property-functions using `equal' rather than `eq'? Alan Mackenzie
@ 2008-02-05 8:04 ` Richard Stallman
2008-02-05 8:48 ` David Kastrup
0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2008-02-05 8:04 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
All the built in text property functions which compare properties appear
to use `eq' for the comparison. Some of these actually say this in
their doc-strings or the pertinent manual page, some of them might
actually say it in both. ;-(
`eq' is faster, and a priori I see no reason to think that `equal'
is better in general.
I would dearly love to use text-property-any to locate such a buffer
position, but unfortunately (eq '(1) '(1)) => nil. :-( So I've had to
code up a clumsy equivalent which will certainly be much slower.
You can write code which uses the primitives to find the next non-eq
property, then comparing it with equal and looping so that you find
the next non-equal property.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How about text-property-functions using `equal' rather than `eq'?
2008-02-05 8:04 ` Richard Stallman
@ 2008-02-05 8:48 ` David Kastrup
0 siblings, 0 replies; 3+ messages in thread
From: David Kastrup @ 2008-02-05 8:48 UTC (permalink / raw)
To: rms; +Cc: Alan Mackenzie, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> All the built in text property functions which compare properties appear
> to use `eq' for the comparison. Some of these actually say this in
> their doc-strings or the pertinent manual page, some of them might
> actually say it in both. ;-(
>
> `eq' is faster,
More importantly, it is constant time.
> I would dearly love to use text-property-any to locate such a
> buffer position, but unfortunately (eq '(1) '(1)) => nil. :-( So
> I've had to code up a clumsy equivalent which will certainly be
> much slower.
>
> You can write code which uses the primitives to find the next non-eq
> property, then comparing it with equal and looping so that you find
> the next non-equal property.
One can also see where the constant '(1) is created and keep a copy of
that for eq-comparison.
--
David Kastrup
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-05 8:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-04 20:53 How about text-property-functions using `equal' rather than `eq'? Alan Mackenzie
2008-02-05 8:04 ` Richard Stallman
2008-02-05 8:48 ` David Kastrup
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).