Quickstart
Install
Koskari publishes to PyPI with wheels for Linux and macOS:
pip install "koskari[repl]"
The repl extra adds syntax highlighting to the REPL. Every release so
far is a weekly development snapshot, a pre-release, so pip install koskari resolves to the newest one; once a final release exists, --pre
keeps selecting snapshots. To build from a source checkout instead, see
Build and test.
First session
Start the REPL:
koskari
The prompt is >>> . Type a form at it and Koskari prints the form’s
value on the next line:
>>> (+ 1 2)
3
>>> (print "Hello, Koskari!")
Hello, Koskari!
A form left open at the end of a line continues on the next, under a
... prompt:
>>> (+ 1
... 2)
3
Leave with (exit) or Ctrl-D.
A file
Save this as hello.ki:
(print "Hello, Koskari!")
Run it:
koskari hello.ki
A small program
A .ki file is written in layout: a line with more than one element is a
call, and a line ending in : opens an indented block. Parentheses still
group nested expressions. Save this as fruits.ki and run it the same
way:
var fruits #["apple" "pear" "plum"]
def shout [word]:
(+ (word.upper) "!")
for-each [fruit fruits]:
print (shout fruit)
print (len fruits) "fruits, starting with" fruits[0]
APPLE!
PEAR!
PLUM!
3 fruits, starting with apple
(word.upper) calls a Python string method and fruits[0] indexes a
Python list. Everything Koskari touches is a Python object.
Compile to bytecode
koskari --compile-kio out.kio hello.ki
koskari --execute-kio out.kio
--compile-kio runs the program as well as writing the .kio, so the
first command prints Hello, Koskari! too.
See CLI and configuration for every flag.
Editor setup
Syntax highlighting, and optionally LSP support, for three editors. The
files are under editors/ in the repository.
Editor |
Included |
Setup |
|---|---|---|
Emacs |
Major mode: highlighting, indentation, comments |
Load |
Helix |
Tree-sitter grammar and LSP integration |
Build the grammar; see |
VSCode / TextMate |
TextMate grammar for highlighting |
Install from the folder or VSIX; see |
For Helix and the language server, install the lsp extra as well:
pip install "koskari[repl,lsp]"
Next
New to programming: Little Koskari.
Know Python: From Python.
Know a Lisp already: the Guide page on Koskari and s-expressions, then the Reference.