

;; Unless

inline-macro unless{#data{test, body}}:
   `if{not ^test, ^body}`

unless 0:
   print "yes"


;; A fancy way of writing while [1]: ... :)

inline-macro forever{#data{body}}:
   ;; The label is needed in order for the user to be able
   ;; to break/continue from forever. Without the label, EG
   ;; considers that the while loop is not visible from the
   ;; user's lexical scope, so break ought to skip past it.
   ;; However, if there's a label, EG will look at the its
   ;; environment to determine the whole while loop's
   ;; visibility. @mark{label} will stamp our freshly
   ;; created label with the environment where forever was
   ;; used :)
   lbl = @mark{#value{@gensym{}}}
   `while[^lbl]{1, ^body}`

1..4 each i ->
   forever:
      print "let's not be too crazy and break out while we still can!"
      break ;; comment out the lbl= line and you'll see the above is only printed once


;; Define the ~ operator to define anonymous functions, with the
;; variable $ holding the first argument

inline-macro [~]{#data{#void{}, body}}:
   dolla = @mark{`$`}
   `{^dolla} -> ^body`

add10 = ~[$ + 10]
first4 = ~$.substring{0, 4}

print {
   add10{91}
   first4{"hello"}
}
