2025-06-09 00:21:42 +03:00
2025-05-30 12:37:07 +03:00
2025-06-09 00:21:42 +03:00
2025-05-26 22:42:01 +03:00
2025-06-09 00:21:42 +03:00
2025-06-05 17:11:30 +03:00
2025-06-09 00:21:42 +03:00

The Sex language

Sex is a S-expressions language, which transpiles to C.

Sex is also Chicken, since all source processing and compile-time computations are written in Chicken.

And Chicken is R5RS Scheme.

Compilation and usage

First, get yourself a Chicken. Second, some Chicken deps.

Install Chicken Eggs

By the way, there's a way to make Chicken install eggs non-globally. Refer to the documentation for more info: https://wiki.call-cc.org/man/5/Extension%20tools#changing-the-repository-location

chicken-install fmt getopt-long brev-separate

Compilation

make

Usage

You'll also need a C compiler, so pick any.

cat hello-world.sex | sexc > hello_world.c
cc hello_world.c -o hello_world

Example

Here is an example, demonstrating what Sex source looks like, and what it compiles too. An avid reader also shall notice how we call Chicken procedures in Sex source.

The Sex source:

(include stdio.h)

(define (foo)
  "Hello from Chicken code!\n")

(pub fn int main ((int argc) (char **argv))
    (puts "Hello from Sex!")
    (var (array char 512) name)
    (puts "What is your name?")
    (scanf "%s" &name)
    (printf "Hello, %s!\n" name)
    (printf ,(foo))
    0)

The resulting C source:

#include <stdio.h>

int main (int argc, char **argv) {
    puts("Hello from Sex!");
    char name[512];
    puts("What is your name?");
    scanf("%s", &name);
    printf("Hello, %s!\n", name);
    printf("Hello from Chicken code!\n");
    return 0;
}

Features

Full C interoperability

Just (include "Your/Favourite/Library.h") and use it as you would have is C.

For hardcore fans of traditional Lisp naming convention, Sex offers automatic unkebabification of all symbols, i.e. no more ugly GL_ARRAY_BUFFER s in your code, they may be written in their proper form: GL-ARRAY-BUFFER.

Auto typedef for structs

Probably harmless idk.

Use an established environment for development

As Sex is S-expressions, you always have Emacs with paredit as your best option.

COMING SOON: Polymorhpism

Description
Sex: for passionate software developers.
Readme 2.1 MiB
Languages
Scheme 92%
Makefile 6.1%
Emacs Lisp 1.9%