unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: maphash
       [not found] <p04310100bac9ebec6275@[198.17.100.22]>
@ 2003-04-24  1:51 ` Richard Stallman
  2003-04-24  7:46   ` maphash Stephen J. Turnbull
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2003-04-24  1:51 UTC (permalink / raw)
  Cc: emacs-devel

    I have discovered by experimentation that maphash actually does what 
    I hoped it would, which is to pass key/value pairs to the mapping 
    function in the same order in which they were added to the table. 

An small anount of experimentation doesn't show you it will always to
do that.  It would be necessary to study the code and construct a
proof, before we could promise this to the users.

Do you want to study the code?

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

* Re: maphash
  2003-04-24  1:51 ` maphash Richard Stallman
@ 2003-04-24  7:46   ` Stephen J. Turnbull
  2003-04-24 21:58     ` maphash Greg Hill
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen J. Turnbull @ 2003-04-24  7:46 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> "rms" == Richard Stallman <rms@gnu.org> writes:

    I have discovered by experimentation that maphash actually does what 
    I hoped it would, which is to pass key/value pairs to the mapping 
    function in the same order in which they were added to the table. 

    rms> An small anount of experimentation doesn't show you it will
    rms> always to do that.  It would be necessary to study the code
    rms> and construct a proof, before we could promise this to the
    rms> users.

If I understand the OP's description correctly, I can already promise
you that code depending on such a feature won't be portable to XEmacs:

(let ((my-hash (make-hash-table))
      result)
  (puthash "key1" "val1" my-hash)
  (puthash "key2" "val2" my-hash)
  (puthash "key3" "val3" my-hash)
  (maphash (lambda (k v) (setq result (cons k result))) my-hash)
  (reverse result))

=> ("key2" "key3" "key1")


-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.

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

* Re: maphash
  2003-04-24  7:46   ` maphash Stephen J. Turnbull
@ 2003-04-24 21:58     ` Greg Hill
  2003-04-26  2:32       ` maphash Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Hill @ 2003-04-24 21:58 UTC (permalink / raw)
  Cc: emacs-devel

At 4:46 PM +0900 4/24/03, Stephen J. Turnbull wrote:
>  >>>>> "rms" == Richard Stallman <rms@gnu.org> writes:
>
>     I have discovered by experimentation that maphash actually does what
>     I hoped it would, which is to pass key/value pairs to the mapping
>     function in the same order in which they were added to the table.
>
>     rms> An small anount of experimentation doesn't show you it will
>     rms> always to do that.  It would be necessary to study the code
>     rms> and construct a proof, before we could promise this to the
>     rms> users.
>
>If I understand the OP's description correctly, I can already promise
>you that code depending on such a feature won't be portable to XEmacs:
>
>(let ((my-hash (make-hash-table))
>       result)
>   (puthash "key1" "val1" my-hash)
>   (puthash "key2" "val2" my-hash)
>   (puthash "key3" "val3" my-hash)
>   (maphash (lambda (k v) (setq result (cons k result))) my-hash)
>   (reverse result))
>
>=> ("key2" "key3" "key1")

Fortunately for me, in GNU Emacs Stephen's example--and several 
variations thereof--do work the way I described, and not the way they 
work in XEmacs.  Also, fortunately for me, my code does not have to 
be portable.


At 9:51 PM -0400 4/23/03, Richard Stallman wrote:
>Do you want to study the code?

After taking a quick look at the C source code, the simple answer to 
Richard's question is "No, thank you."  I do write code in C, when I 
absolutely have to, but I don't really care for the language.  And in 
general, I don't enjoy the challenge of figuring out how OP's code 
works, especially when it is written in C _and_ chock full of MACROs.

So, I'll just say: That's ok, I understand that you cannot, in good 
faith, make any promises either that this "feature" works relieably 
now, or even that if it happens to now, it always will.  It _is_ 
working for me reliably now, and I'll keep using it as long as it 
does; and I promise I won't complain if my decision to do so comes 
back to haunt me later on.

--Greg

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

* Re: maphash
  2003-04-24 21:58     ` maphash Greg Hill
@ 2003-04-26  2:32       ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2003-04-26  2:32 UTC (permalink / raw)
  Cc: emacs-devel

    Fortunately for me, in GNU Emacs Stephen's example--and several 
    variations thereof--do work the way I described,
    ...

    After taking a quick look at the C source code, the simple answer to 
    Richard's question is "No, thank you."

We can't document this feature unless we know it can be relied on.  I
took a quick look at the code of maphash and it led me to doubt that
this is generally true, but while I have the know-how to study it
carefully, I do not have the time.

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

end of thread, other threads:[~2003-04-26  2:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <p04310100bac9ebec6275@[198.17.100.22]>
2003-04-24  1:51 ` maphash Richard Stallman
2003-04-24  7:46   ` maphash Stephen J. Turnbull
2003-04-24 21:58     ` maphash Greg Hill
2003-04-26  2:32       ` maphash 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).