rontolisp
2026-10-24
github.com/making/rontolisp
github.com/making/rontolisp
rontolisp とは
一つの
.class や .jar を.wasm をコアライブラリは
github.com/making/rontolisp
rontolisp とは
この
(defun fact (n)
(if (= n 0) 1 (* n (fact (- n 1)))))
(print (fact 10))Run で 3628800 が
github.com/making/rontolisp
rontolisp とは
Common Lisp
;; sq.lisp
(defun sq (x) (* x x))
(print (sq 12))Scheme
;; sq.scm
(define (sq x) (* x x))
(display (sq 12))Clojure
;; sq.clj
(defn sq [x] (* x x))
(println (sq 12))どの
github.com/making/rontolisp
github.com/making/rontolisp
インストールと
リリースページのPATH に
$ URL=https://github.com/making/rontolisp/releases/download/0.1.0-SNAPSHOT
$ wget $URL/rontolisp-darwin-arm64
$ chmod +x rontolisp-darwin-arm64
$ sudo mv rontolisp-darwin-arm64 /usr/local/bin/rontolisp
$ rontolisp --version
github.com/making/rontolisp
インストールと
引数なしで
$ rontolisp
CL-USER> (+ 1 2)
3
CL-USER> (defun fact (n) (if (= n 0) 1 (* n (fact (- n 1)))))
FACT
CL-USER> (fact 10)
3628800
CL-USER> (quit)
プロンプトには
github.com/making/rontolisp
インストールと
;; program.lisp
(defun square (x) (* x x))
(print (square 5))
(print (square 12))
$ rontolisp program.lisp
25
144
$ rontolisp -e "(print (+ 1 2))"
3
github.com/making/rontolisp
インストールと
| コマンド | 動作 |
|---|---|
rontolisp | REPL |
rontolisp app.lisp | ファイルを |
rontolisp -e "(...)" | 引数の |
rontolisp app.lisp -o OUT | コンパイル。OUT の |
rontolisp format src/ | ソースを |
rontolisp test tests/main.lisp | rove の |
github.com/making/rontolisp
github.com/making/rontolisp
言語
| 機能 | 主な |
|---|---|
| マクロ | defmacro、macroexpand |
| CLOS | defclass、defgeneric、defmethod |
| コンディションと | handler-case、restart-case |
| 多値 | values、multiple-value-bind |
| 繰り返し | loop、dolist、dotimes |
| 数値 | 多倍長整数、 |
github.com/making/rontolisp
言語
19,769 件の
ansi-test/results/interpreter.md (2026-10-23 時点、
github.com/making/rontolisp
言語
コードは S 式で
(defmacro twice (&body body) `(progn ,@body ,@body))
(print (macroexpand-1 '(twice (princ "hi "))))
(twice (princ "hi "))github.com/making/rontolisp
言語
(defclass circle () ((r :initarg :r :reader r)))
(defclass square () ((side :initarg :side :reader side)))
(defgeneric area (shape))
(defmethod area ((c circle)) (* 3 (r c) (r c)))
(defmethod area ((s square)) (* (side s) (side s)))
(print (mapcar #'area (list (make-instance 'circle :r 2)
(make-instance 'square :side 3))))
(handler-case (/ 1 0)
(division-by-zero () :infinity))github.com/making/rontolisp
言語
Scheme の(scheme base) などの R7RS-small のimport して
(import (scheme base) (scheme write))
(define (count-up n)
(let loop ((i 0) (acc '()))
(if (= i n)
(reverse acc)
(loop (+ i 1) (cons (* i i) acc)))))
(display (count-up 5))github.com/making/rontolisp
言語
Clojure の->> などの
(defn fact [n]
(if (< n 2) 1 (* n (fact (- n 1)))))
(println (fact 20))
(println (->> (range 10) (filter odd?) (map #(* % %)) (reduce +)))
(println (frequencies "mississippi"))github.com/making/rontolisp
言語
| 拡張子 | 言語 |
|---|---|
.lisp .asd | Common Lisp |
.scm | Scheme |
.clj .cljc | Clojure |
| それ以外 | --source-language で |
一つの
github.com/making/rontolisp
github.com/making/rontolisp
バックエンド
.class、.wasmgithub.com/making/rontolisp
バックエンド
$ rontolisp hello.lisp # インタプリタ
$ rontolisp hello.lisp -o Hello.class && java Hello # JVM
$ rontolisp hello.lisp -o hello.jar && java -jar hello.jar
$ rontolisp hello.lisp -o hello.wasm && wasmtime run hello.wasm
$ rontolisp hello.lisp -o hello-c.wasm --component && wasmtime run hello-c.wasm
$ rontolisp hello.lisp --native -o hello && ./hello # ネイティブ
どの(print (+ 1 2)) は 3 を
github.com/making/rontolisp
バックエンド
JVM
.jar は java -jar でWASM
--component で WASI 0.3--no-wasi で--no-gc で wasm-GC のgithub.com/making/rontolisp
バックエンド
--native は、
rontolisp:fetch、--native-target で Linux の x86_64 と aarch64、doc/ja/compiling/native.md
github.com/making/rontolisp
バックエンド
fib ベンチマークの
インタプリタ
5,442 ms
JVM
60 ms
WASM
218 ms
ループ中心の
bench-report/results/benchmarks.md (2026-09-04, Linux x86_64, AMD EPYC 9V74)
github.com/making/rontolisp
バックエンド
$ rontolisp program.lisp -o program.jar
$ java -jar program.jar
github.com/making/rontolisp
バックエンド
.class や .wasm へのexamples/browser/ のgithub.com/making/rontolisp
github.com/making/rontolisp
連携と
rontolisp 独自の java パッケージで、
(java:call (java:new "java.lang.StringBuilder" "ab") "length") ; => 2
(java:static "java.lang.Math" "max" 3 7) ; => 7
(java:field "java.lang.Integer" "MAX_VALUE") ; => 2147483647
JVM 上の.class で
github.com/making/rontolisp
連携と
;; my-app.asd
(defsystem :my-app
:depends-on (:base)
:serial t
:components ((:file "package")
(:file "main")))
defsystem に.asd は--system-path でgithub.com/making/rontolisp
連携と
$ rontolisp
CL-USER> (ql:quickload "split-sequence")
(split-sequence)
CL-USER> (split-sequence:split-sequence #\, "a,b,c")
("a" "b" "c")
ql:quickload は Quicklisp の~/.rontolisp/quicklisp/ にgithub.com/making/rontolisp
連携と
| パッケージ | 用途 | rontolisp での |
|---|---|---|
uiop | 環境変数、 | UIOP の API を |
rove | テスト | 上流の |
clack | Web アプリケーション | 上流の |
cffi | C ライブラリの | 上流の |
objc | Objective-C の | LispWorks の API を |
github.com/making/rontolisp
連携と
| 名前 | 用途 |
|---|---|
java | Java API の |
rontolisp:fetch | HTTP リクエスト |
rontolisp test | rove の |
linalg、vec、torch | 行列演算と |
appkit、metal | macOS の GUI と GPU 描画 |
github.com/making/rontolisp
連携と
uiop は、
(print (uiop:split-string "red,green,blue" :separator ","))
(print (uiop:strcat "ronto" "lisp"))
(print (uiop:subpathname "/usr/local/" "bin/rontolisp"))
(print (uiop:emptyp ""))github.com/making/rontolisp
連携と
上流の rove でrontolisp test が
;; tests/main.lisp
(defpackage #:my-app/tests
(:use #:cl #:rove))
(in-package #:my-app/tests)
(defun add (a b) (+ a b))
(deftest add-test
(ok (= (add 1 2) 3))
(ng (= (add 1 2) 4)))
$ rontolisp test tests/main.lisp
add-test
✓ Expect (= (ADD 1 2) 3) to be true.
✓ Expect (= (ADD 1 2) 4) to be false.
Summary:
All 1 test passed.
$ echo $?
0
github.com/making/rontolisp
連携と
rontolisp 独自の rontolisp:fetch は JavaScript の fetch にrontolisp:await で
(let* ((res (rontolisp:await
(rontolisp:fetch "https://httpbin.ik.am/get?lang=lisp")))
(body (rontolisp:await (rontolisp:read-all (getf res :body))))
(json (rontolisp:json-parse body)))
(print (getf res :status))
(print (gethash "lang" (gethash "args" json))))github.com/making/rontolisp
連携と
上流の Clack を
(ql:quickload "clack") ; app.lisp
(clack:clackup
(lambda (env)
(list 200 '(:content-type "text/plain")
(list (format nil "Hello, ~A~%" (getf env :path-info)))))
:server :rontolisp :port 5000 :use-thread nil)
$ rontolisp app.lisp &
$ curl http://127.0.0.1:5000/rontolisp
Hello, /rontolisp
github.com/making/rontolisp
連携と
Clack の
| ビルド | 動かす |
|---|---|
rontolisp app.lisp | インタプリタ |
-o app.jar | JVM、 |
-o app.war | Servlet コンテナ |
--native -o app | ネイティブ実行ファイル |
-o app.wasm --component | wasmtime serve など |
-o worker.wasm --no-wasi | Cloudflare Workers |
examples/net/httpbin-clack.lisp、
github.com/making/rontolisp
連携と
どちらも rontolisp 独自のlinalg は numpy 風のvec は
(print (linalg:matmul #2A((1 2) (3 4)) #2A((5 6) (7 8))))
(print (linalg:solve #2A((4 0) (2 4)) #(8 8)))
(print (linalg:sum #2A((1 2 3) (4 5 6)) :axis 0))
(print (vec:matvec #d((1.0 2.0) (3.0 4.0)) #d(5.0 6.0)))
(print (vec:dot #d(1.0 2.0 3.0) #d(4.0 5.0 6.0)))github.com/making/rontolisp
連携と
linalg と vec の
| フラグ | 計算する |
|---|---|
--simd | CPU の |
--blas | OS の BLAS (Accelerate、 |
--gpu | NVIDIA の GPU (CUDA)、 |
--simd で 0.62 ms、--blas で 0.034 ms にdoc/ja/guides/blas-acceleration.md、
github.com/making/rontolisp
連携と
rontolisp 独自の torch は、linalg の
(linalg:seed 3)
(defparameter *mlp*
(torch:sequential (torch:linear 2 8) #'torch:relu (torch:linear 8 1)))
(defparameter *xs* (torch:tensor '((0.0 0.0) (0.0 1.0) (1.0 0.0) (1.0 1.0))))
(defparameter *ys* (torch:tensor '((0.0) (1.0) (1.0) (0.0))))
(defparameter *sgd* (torch:sgd *mlp* :lr 0.2))
(dotimes (i 200)
(let ((loss (torch:mse-loss (torch:forward *mlp* *xs*) *ys*)))
(torch:zero-grad *sgd*)
(torch:backward loss)
(torch:step *sgd*)))
(print (torch:data (torch:forward *mlp* *xs*)))github.com/making/rontolisp
連携と
上流の CFFI をdefcfun で C の
CL-USER> (ql:quickload :cffi)
CL-USER> (cffi:defcfun "strlen" :long (s :string))
CL-USER> (strlen "hello, world")
12
rontolisp コマンドと、.class や .jar で
github.com/making/rontolisp
連携と
objc で AppKit をappkit でexamples/browser/minesweeper/minesweeper-macos.lisp
github.com/making/rontolisp
連携と
ウィンドウに
(defvar *win*
(appkit:window "rontolisp" :width 240 :height 160 :dark t))
(defvar *face*
(appkit:label *win* "🙂" :x 94 :y 54 :width 52 :height 52
:size 26 :align :center))
(appkit:on-click *face*
(lambda (button) (appkit:set-text *face* "😮")))
(appkit:wait *win*)
github.com/making/rontolisp
連携と
rontolisp 独自の metal パッケージで Metal を
examples/macos/metal-pagoda-garden.lisp
github.com/making/rontolisp
連携と
ウィンドウに Metal を
(defvar *metal*
(metal:attach *window* :clear '(0.02 0.03 0.07 1.0) :depth t))
(defvar *library* (metal:library *metal* *shaders*))
(defvar *solid* (metal:pipeline *metal* *library* "vox_vertex" "vox_fragment"))
(defvar *static-buffer* (metal:buffer *metal* *static*))
;; every frame
(objc:invoke encoder "setRenderPipelineState:" *solid*)
(objc:invoke encoder "setVertexBuffer:offset:atIndex:" *static-buffer* 0 0)
(objc:invoke encoder "drawPrimitives:vertexStart:vertexCount:"
metal:+triangle+ 0 (* 36 *static-count*))
examples/macos/metal-pagoda-garden.lisp (抜粋、
github.com/making/rontolisp
連携と
| 用途 | Common Lisp | Clojure |
|---|---|---|
| Java の | java パッケージ | Java interop |
| 依存ライブラリ | ASDF、 | deps.edn |
| テスト | rove | clojure.test |
| HTTP リクエスト | rontolisp:fetch | rontolisp.http-client |
| Web アプリ | Clack | Ring |
github.com/making/rontolisp
連携と
Clojure のfn は、Comparator と
(ns demo
(:import (java.util ArrayList Collections)))
(let [words (ArrayList. ["kiwi" "fig" "banana"])]
(Collections/sort words (fn [a b] (compare (count a) (count b))))
(println (vec words))) ; [fig kiwi banana]
(println (Integer/parseInt "42") (.toUpperCase "hi") (Math/max 3 7))
;; 42 HI 7
JVM 上の.class で
github.com/making/rontolisp
連携と
deps.edn に
;; deps.edn
{:paths ["src"]
:deps {org.clojure/data.json {:mvn/version "2.5.1"}}}
;; src/app/main.clj
(ns app.main
(:require [clojure.data.json :as json]))
(defn -main [& args]
(println (json/write-str {:lang "clojure" :args args})))
$ rontolisp -M -m app.main x y
{"lang":"clojure","args":["x","y"]}
github.com/making/rontolisp
連携と
clojure.test でdeps.edn のrontolisp test を
(ns demo-test
(:require [clojure.test :refer [deftest is testing run-tests]]))
(defn add [a b] (+ a b))
(deftest add-test
(testing "adding two integers"
(is (= 3 (add 1 2)))
(is (not= 4 (add 1 2)))))
(run-tests)github.com/making/rontolisp
連携と
rontolisp 独自の rontolisp.http-client は、rontolisp:fetch を
(ns example
(:require [rontolisp.http-client :as http]))
(let [r (http/get "https://httpbin.ik.am/get"
{:query-params {"lang" "clojure"}})]
(println (:status r) (get-in r [:headers "content-type"]))
(println (re-find #"\"lang\": ?\"clojure\"" (:body r))))github.com/making/rontolisp
連携と
rontolisp 独自の ring.adapter.rontolisp が Ring の
(ns app
(:require [ring.adapter.rontolisp :refer [run-server]]
[ring.util.response :as response]))
(defn handler [{:keys [uri]}]
(-> (response/response (str "Hello, " uri "\n"))
(response/content-type "text/plain")))
(run-server handler {:port 3000})
$ curl http://127.0.0.1:3000/clojure
Hello, /clojure
github.com/making/rontolisp
github.com/making/rontolisp
次の
| ディレクトリ | 内容 |
|---|---|
console/ | アルゴリズムと |
scheme/ clojure/ | Scheme と Clojure の |
ml/ llm/ | 数値計算、 |
net/ db/ | ソケット、 |
jvm/ macos/ | Java 連携、 |
browser/ | ページで |
asdf/ | 実在の |
github.com/making/rontolisp
次の
github.com/making/rontolisp
インタプリタで
github.com/making/rontolisp