[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33375: 27.0.50; Nested function definitions

From: Andreas Röhler
Subject: bug#33375: 27.0.50; Nested function definitions
Date: Thu, 15 Nov 2018 08:01:41 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 14.11.2018 16:40, Eli Zaretskii wrote:
From: Andreas Röhler <address@hidden>
Date: Wed, 14 Nov 2018 11:06:52 +0100

(defun foo1 ()
    "[Some docu]

(defun other-foo "
    ;; defining another function inside
    (defun foo2 ()
      (message "%s"   "Foo2")
;; another syntactically correct function just badly indented
(defun foo3 ()
    (message "%s" "Foo3"))
    (message "%s" "Foo1"))

Results of evaluation:

(foo1) ==> "Foo1"
(foo2) ==> foo3 ?
(foo3) ==> "Foo3"

Why do you think there's anything wrong here?  AFAICT, each evaluation
returns the last sexp evaluated in the respective function.  foo1 and
foo3 have a call to 'message' as the last sexp, so they return the
message string, but foo2's last sexp evaluates a defun form, so you
get the result of that, which is the function foo3.  IMO, this is
expected and correct behavior.

Basically these forms were made to display a beginning-of-defun bug.

See tests in previous posts.

What puzzles me when evaluating:

(setq a (foo2))
a ==> foo3
(call-interactively 'foo2) ==> foo3

But M-x foo2 RET messages "Foo2"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]