Skip to content

return-from できないときがある #424

@k-okada

Description

@k-okada
(defun hoge ()
  (dolist (x (list 0 1 2 3 4))
    (print x)
    (if (eq x 2)
        (return-from hoge nil))))

(hoge)

(defun fuga ()
  (mapcar #'(lambda (x)
              (print x)
              (if (eq x 2)
                  (return-from fuga nil)))
          (list 0 1 2 3 4)))

(fuga)

を実行すると以下のようになるんですが、そういうもんでしょうか?

0
1
2
0
1
2
Call Stack (max depth: 20):
  0: at (return-from fuga nil)
  1: at (if (eq x 2) (return-from fuga nil))
  2: at (mapcar #'(lambda (x) (print x) (if (eq x 2) (return-from fuga nil))) (list 0 1 2 3 4))
  3: at (mapcar #'(lambda (x) (print x) (if (eq x 2) (return-from fuga nil))) (list 0 1 2 3 4))
  4: at (fuga)
eusgl: ERROR th=0 no such block (x 2) in (return-from fuga nil)E: (exit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions