unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* map-char-table, optimize-char-table and `equal' comparisons
@ 2008-05-10 20:21 Stefan Monnier
  2008-05-14  7:59 ` Kenichi Handa
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-05-10 20:21 UTC (permalink / raw)
  To: emacs-devel


Both map-char-table and optimize-char-table compare consecutive values
using `equal' to determine whether to merge them into ranges.

I can see that it may sometimes be useful, but it is dangerous since it
may lose object identity information (obviously) and more importantly
because `equal' can fail when comparing cyclic objects.

I happened to be manipulating char-tables that map chars to other
char-tables, sometimes in cyclic ways and that makes it impossible to
use map-char-table ;-(

Any objection to changing the internal comparison predicate to `eq'?


        Stefan




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

* Re: map-char-table, optimize-char-table and `equal' comparisons
  2008-05-10 20:21 map-char-table, optimize-char-table and `equal' comparisons Stefan Monnier
@ 2008-05-14  7:59 ` Kenichi Handa
  2008-05-16  4:48   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Kenichi Handa @ 2008-05-14  7:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

In article <jwvej89rjzy.fsf-monnier+emacs@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Both map-char-table and optimize-char-table compare consecutive values
> using `equal' to determine whether to merge them into ranges.

> I can see that it may sometimes be useful, but it is dangerous since it
> may lose object identity information (obviously) and more importantly
> because `equal' can fail when comparing cyclic objects.

> I happened to be manipulating char-tables that map chars to other
> char-tables, sometimes in cyclic ways and that makes it impossible to
> use map-char-table ;-(

> Any objection to changing the internal comparison predicate to `eq'?

I remember that I intentionally made the comparison
predicate `equal' so that optimize-char-table can reduce the
number of elements for some kind of char-table.

How about adding the new property/attribute :test to
char-table (like make-hash-table) and make the default to
`equal'?

---
Kenichi Handa
handa@ni.aist.go.jp




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

* Re: map-char-table, optimize-char-table and `equal' comparisons
  2008-05-14  7:59 ` Kenichi Handa
@ 2008-05-16  4:48   ` Stefan Monnier
  2008-05-16  5:43     ` Kenichi Handa
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-05-16  4:48 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: emacs-devel

>> Both map-char-table and optimize-char-table compare consecutive values
>> using `equal' to determine whether to merge them into ranges.

>> I can see that it may sometimes be useful, but it is dangerous since it
>> may lose object identity information (obviously) and more importantly
>> because `equal' can fail when comparing cyclic objects.

>> I happened to be manipulating char-tables that map chars to other
>> char-tables, sometimes in cyclic ways and that makes it impossible to
>> use map-char-table ;-(

>> Any objection to changing the internal comparison predicate to `eq'?

> I remember that I intentionally made the comparison
> predicate `equal' so that optimize-char-table can reduce the
> number of elements for some kind of char-table.

> How about adding the new property/attribute :test to
> char-table (like make-hash-table) and make the default to
> `equal'?

That's an option, but maybe a better one is to just add a `test'
argument to optimize-char-table (and then optimize-char-table could use
that argument to replace `equal' elements with `eq' ones, so that
subsequent `map-char-table' calls end up behaving as if a `test'
function was provided even tho it's actually using just `eq').

Do you remember which call(s) to optimize-char-table needed the use of
`equal'?


        Stefan




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

* Re: map-char-table, optimize-char-table and `equal' comparisons
  2008-05-16  4:48   ` Stefan Monnier
@ 2008-05-16  5:43     ` Kenichi Handa
  0 siblings, 0 replies; 4+ messages in thread
From: Kenichi Handa @ 2008-05-16  5:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

In article <jwvzlqqn9jg.fsf-monnier+emacs@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca> writes:

> > How about adding the new property/attribute :test to
> > char-table (like make-hash-table) and make the default to
> > `equal'?

> That's an option, but maybe a better one is to just add a `test'
> argument to optimize-char-table (and then optimize-char-table could use
> that argument to replace `equal' elements with `eq' ones, so that
> subsequent `map-char-table' calls end up behaving as if a `test'
> function was provided even tho it's actually using just `eq').

Hmmm, it sounds like a good idea.

> Do you remember which call(s) to optimize-char-table needed the use of
> `equal'?

I don't remember well, perhaps a category table.

---
Kenichi Handa
handa@ni.aist.go.jp




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

end of thread, other threads:[~2008-05-16  5:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-10 20:21 map-char-table, optimize-char-table and `equal' comparisons Stefan Monnier
2008-05-14  7:59 ` Kenichi Handa
2008-05-16  4:48   ` Stefan Monnier
2008-05-16  5:43     ` Kenichi Handa

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