[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: maphash
From: |
Greg Hill |
Subject: |
Re: maphash |
Date: |
Thu, 24 Apr 2003 14:58:18 -0700 |
At 4:46 PM +0900 4/24/03, Stephen J. Turnbull wrote:
>>>>> "rms" == Richard Stallman <address@hidden> 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
- Re: maphash, Richard Stallman, 2003/04/23
- Re: maphash, Stephen J. Turnbull, 2003/04/24
- Re: maphash,
Greg Hill <=