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

* Re: unexpected result with mapc of lambda form inside catch/throw
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Davis Herring @ 2010-11-27 15:47 UTC (permalink / raw
  To: MON KEY; +Cc: emacs-devel

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

Because the second argument to mapc is the " " near the end, and not the
`sub-str-pfx' just above it?

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.



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

* Re: unexpected result with mapc of lambda form inside catch/throw
  2010-11-27 15:47 ` Davis Herring
@ 2010-11-27 17:19   ` MON KEY
  2010-11-27 18:39     ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: MON KEY @ 2010-11-27 17:19 UTC (permalink / raw
  To: herring; +Cc: emacs-devel

On Sat, Nov 27, 2010 at 10:47 AM, Davis Herring <herring@lanl.gov> wrote:
>> Can someone please explain why the following expression's `lambda' form
>> returns 32 when mapc'ing its arg X?
>
> Because the second argument to mapc is the " " near the end, and not the
> `sub-str-pfx' just above it?

Davis, thank you so much for helping me to see my erorr!!! :)

I certainly managed to confuse the heck out of myself huh?
Sorry for the noise.

This said, maybe if  `return-from' existed I would have been lest
blinded by my convoluted nesting of catch/throw...

> Davis

--
/s_P\



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

* Re: unexpected result with mapc of lambda form inside catch/throw
  2010-11-27 17:19   ` MON KEY
@ 2010-11-27 18:39     ` Thien-Thi Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thien-Thi Nguyen @ 2010-11-27 18:39 UTC (permalink / raw
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

() MON KEY <monkey@sandpframing.com>
() Sat, 27 Nov 2010 12:19:28 -0500

   This said, maybe if  `return-from' existed I would have
   been lest blinded by my convoluted nesting of catch/throw...

To reduce misunderstandings of scope, i use mic-paren.el,
via ‘turn-on-mic-paren’, attached.


[-- Attachment #2: turn-on-mic-paren.el --]
[-- Type: application/emacs-lisp, Size: 851 bytes --]

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