all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* unexpected result with mapc of lambda form inside catch/throw
@ 2010-11-26 21:41 MON KEY
  2010-11-27 15:47 ` Davis Herring
  0 siblings, 1 reply; 4+ messages in thread
From: MON KEY @ 2010-11-26 21:41 UTC (permalink / raw)
  To: emacs-devel

Can someone please explain why the following expression's `lambda' form returns
32 when mapc'ing its arg X?

I am expecting that X successively evaluate to: 59, 59, and 91
Instead, with the first invocation of the `lambda' form X is 32.

Is this an error? If not, why not?


(emacs-version)
; => "GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-05-10"

emacs -Q

(setq tt--global-var ";;; ")

(let* ((tt--global-var ";;[ ")
       (tt--global-var-REAL-DEFAULT ";;; ")
       (sub-str-pfx (reverse (cdr (reverse (append tt--global-var nil))))))
  ;; At this point sub-str-pfx is '(59 59 91)
  (unless
      (catch 'prefix-not-same
        (equal tt--global-var
               (concat
                (mapc #'(lambda (x)
                          (when (and (= (car sub-str-pfx) 59)
                                     (= x 32))
                            (momentary-string-display
                             (format
                              (concat
                               "\nInside lambda form arg X is `mapc'd
over the range (59 59 91)\n"
                               "At this point X _should be_ %d, but
elisp returns %d, why?")
                              (car sub-str-pfx) x)
                             (point)))
                          (unless (= x (car sub-str-pfx))
                            (throw 'prefix-not-same
                                   (progn
                                     (momentary-string-display
                                      (format "prefix chars not
identical, failed-at: %S"
                                              (char-to-string x))
                                      (point))
                                     nil)))
                          sub-str-pfx)
                      " "))))
    (setq tt--global-var tt--global-var-REAL-DEFAULT)
    (equal tt--global-var ";;; ")))

--
/s_P\



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

end of thread, other threads:[~2010-11-27 18:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 21:41 unexpected result with mapc of lambda form inside catch/throw MON KEY
2010-11-27 15:47 ` Davis Herring
2010-11-27 17:19   ` MON KEY
2010-11-27 18:39     ` Thien-Thi Nguyen

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.