Liking cljdoc? Tell your friends :D

beme-clj — begin/end and M-expressions for Clojure

CI Clojure License

;; full — begin/end for structure, parens for one-liners
defn begin stars [owner repo]

  let begin
    [
      url  str("https://api.github.com/repos/" owner "/" repo)
      resp slurp(url)
      data json/read-str(resp :key-fn keyword)
      count :stargazers_count(data)
    ]

    println(str(owner "/" repo ": " count " ⭐"))
  end
end

Why

M-expressions were McCarthy's original intended syntax for Lisp (1960). S-expressions were meant to be internal representation only — but they stuck. beme picks up where McCarthy left off: two rules that make nesting self-evident, while preserving Clojure's semantics exactly.

Rule 1 — head outside the parens: f(x y) => (f x y)

Rule 2 (optional) — begin/end instead of parens: f begin x y end => (f x y)

Everything else is Clojure.

Installation

Add to deps.edn:

io.github.beme-lang/beme-clj {:git/tag "v0.3.0" :git/sha "a3767c4"}

Or clone and use directly:

git clone https://github.com/beme-lang/beme-clj.git
cd beme-clj

All namespaces live under beme.alpha to signal that the API is pre-1.0 and may change. When the API stabilizes, namespaces will move to beme.

Getting Started

Run a .beme file:

$ bb beme run hello.beme                                # Babashka
$ clojure -T:beme run :file '"hello.beme"'              # Clojure JVM
Hello, world!

Interactive REPL:

$ bb beme repl                                          # Babashka
user=> +(1 2)
3
user=> map(inc [1 2 3])
(2 3 4)

Convert between beme and Clojure (direction detected from extension):

$ bb beme convert hello.beme                            # .beme → Clojure
$ bb beme convert hello.clj                             # .clj → beme
$ clojure -T:beme convert :file '"hello.beme"'          # Clojure JVM

Format .beme files (normalize syntax via pprint):

$ bb beme format hello.beme                             # in-place
$ bb beme format src/                                   # directory, recursive

Requires Babashka or Clojure.

Documentation

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close