Skip to content

antonijn/cheax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cheax

Build status

A Lisp dialect that looks a bit like Haskell. Designed for easy interoperability with C/C++.

Installation

$ mkdir build && cd build && cmake .. && make
# make install

Language demo

Made with VHS

C API example

#include <cheax.h>
#include <stdio.h>

int main(void)
{
	int result;
	CHEAX *c = cheax_init();

	/* Load some "unsafe" functions, e.g. file io and the program
	 * exit function */
	cheax_load_feature(c, "all");

	/* Make sure cheax doesn't cause a stack overflow */
	cheax_config_int(c, "stack-limit", 4096);

	/* Load the standard library */
	if (cheax_load_prelude(c) < 0) {
		/* Display error message on behalf of "example" program */
		cheax_perror(c, "example");
		return EXIT_FAILURE;
	}

	/* Synchronize variable `result' with the eponymous symbol
	 * in cheax */
	cheax_sync_int(c, "result", &result, 0);

	cheax_eval(c, cheax_readstr(c, "(set result (sum (.. 1 100)))"));

	cheax_destroy(c);

	printf("1 + 2 + ... + 100 = %d\n", result);
	return 0;
}

About

A Lisp dialect with C API, REPL and standard library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published