JanetDocsPlaygroundI'm feeling luckyGitHub sign in

prompt



    macro
    boot.janet on line 347, column 1

    (prompt tag & body)

    Set up a checkpoint that can be returned to. `tag` should be a 
    value that is used in a `return` statement, like a keyword.


See also:return2 examplesSign in to add an example
Loading...
(defn helper []
  (return :my-tag "Escaped to :my-tag!")) # escape from deeper

(prompt :my-tag
  (print "Start")
  (helper)
  (print "This won't be printed."))

# Output:
# Start
# RESULT> "Escaped to :my-tag!"
oddman621Playground
(print
  (prompt :a 
          (for i 0 1000000000000 
            (print (string "i=" i))
            (if (= i 2) 
                (return :a 10)))))
# output:
# i=0
# i=1
# i=2
# 10
felixrPlayground