18 releases

0.4.5 Jun 11, 2023
0.4.4 Jun 5, 2023
0.4.1 Mar 2, 2023
0.3.9 Apr 27, 2021
0.2.1 Feb 21, 2021

#127 in Programming languages

Download history 2/week @ 2024-08-05 7/week @ 2024-08-12 41/week @ 2024-09-23 8/week @ 2024-09-30 5/week @ 2024-10-07 3/week @ 2024-10-14 24/week @ 2024-10-21 46/week @ 2024-10-28 28/week @ 2024-11-04 9/week @ 2024-11-11 17/week @ 2024-11-18

101 downloads per month
Used in blisp-repl

Custom license

245KB
7K SLoC

BLisp

BLisp is a statically typed Lisp like programming language which adopts effect system for no_std environments. BLisp supports higher order RPC like higher order functions of functional programming languages.

This repository provides only a library crate. Please see blisp-repl to use BLisp, and baremetalisp which is a toy OS.

Homepage is here.

Features

  • Algebraic data type
  • Generics
  • Hindley–Milner based type inference
  • Effect system to separate side effects from pure functions
  • Big integer
  • Supporting no_std environments

How to Use

use blisp;

fn main() {
    let code = "(export factorial (n) (Pure (-> (Int) Int))
    (if (<= n 0)
        1
        (* n (factorial (- n 1)))))";
    let exprs = blisp::init(code, vec![]).unwrap();
    let ctx = blisp::typing(exprs).unwrap();

    let e = "(factorial 10)";
    blisp::eval(e, &ctx).unwrap();
}

If Rust compiler or linker says warning of fmod, please add fmod manually as follows.

#[no_mangle]
extern "C" fn fmod(x: f64, y: f64) -> f64 {
    libm::fmod(x, y)
}

Cargo.toml

[dependencies.blisp]
version = "0.4"

Examples

"Hello, World!" ; "Hello, World!"
(+ 0x10 0x20)   ; 48
(+ 0b111 0b101) ; 12
(+ 0o777 0o444) ; 803
(car '(1 2 3))  ; (Some 1)
(cdr '(1 2 3))  ; '(2 3)
(map (lambda (x) (* x 2)) '(8 9 10)) ; '(16 18 20)
(fold + 0 '(1 2 3 4 5 6 7 8 9))      ; 45
(reverse '(1 2 3 4 5 6 7 8 9))       ; '(9 8 7 6 5 4 3 2 1)
(filter (lambda (x) (= (% x 2) 0)) '(1 2 3 4 5 6 7 8 9)) ; '(2 4 6 8)

Dependencies

~1.4–2MB
~40K SLoC