Skip to content

Instantly share code, notes, and snippets.

View mflatt's full-sized avatar

Matthew Flatt mflatt

View GitHub Profile
@mflatt
mflatt / gist:ec2160029e99fa7c7cf095a79fc7eebd
Last active June 28, 2026 21:33
Makefile for Rhombus packages using new pkg destdir support
MAIN_PKG = rhombus-main
PKGS = \
actor-lib \
actor \
box-extra-lib \
box-extra \
enforest-lib \
enforest \
ffi2-lib \
ffi2 \
@mflatt
mflatt / rktio.h
Created June 11, 2026 02:16
rktio.h with comments converted to Doxygen
#ifndef __RKTIO_H__
#define __RKTIO_H__ 1
/** Introduction and Conventions
The rktio library provides a portable I/O layer for the major OS
platforms, targeted specifically at the needs of the Racket
implementation. It is similar to libraries like libuv, but based
on parts of Racket that predate those libraries.
#lang racket/base
(define (f a) '())
(define (f0 a b c x) '())
(define (f1 a b c x #:y [y 'y]) '())
(define (f2 a b c x #:y y) '())
(define (identity x) x)
(define-syntax-rule (time-it wrap ...)
#lang racket/base
(provide text-lines?
(rename-out [empty empty-text-lines])
;; 0 is the position before everything, and the position
;; after a newline is on the subsequent line
text-length ; t -> position at end
insert ; t position str -> t, detecting "\n"
@mflatt
mflatt / demo_armored.rkt
Last active November 1, 2021 17:39
Rhombus demo after armor transformation
#lang rhombus
import:«
rhombus/macro:« no_prefix»»;
use_static_dot;
// Some expressions
10 * (-3) + 2;
@mflatt
mflatt / test.rkt
Created July 24, 2021 15:31
Test for import from weaker code inspector
#lang racket
(let ()
(define work-dir (make-temporary-file "deputy-check-~a" 'directory))
(define m '(module m racket/base
(provide m)
(define (m) '(this is m))))
(define n '(module n racket/base
@mflatt
mflatt / fib_fast.msd
Created March 30, 2021 13:33
Fibonacci (the fast way) in MSDscript
_let pair = _fun (a) _fun (b)
_fun(sel)
_if sel _then a _else b
_in _let fst = _fun (p) p(_true)
_in _let snd = _fun (p) p(_false)
_in _let fib = _fun (fib)
_fun (x)
_if x == 0
_then pair(1)(1)
_else _if x == 1
@mflatt
mflatt / fib.msd
Created March 30, 2021 13:31
Fibonacci (the slow way) in MSDscript
_let fib = _fun (fib)
_fun (x)
_if x == 0
_then 1
_else _if x == 1
_then 1
_else fib(fib)(x + -2) + fib(fib)(x + -1)
_in fib(fib)(30)
#lang racket/base
(require ffi/unsafe
racket/class
ffi/unsafe/alloc
ffi/unsafe/try-atomic
ffi/unsafe/schedule
"utils.rkt"
"types.rkt"
"const.rkt"
"key.rkt"
@mflatt
mflatt / demo.lexpr
Last active September 28, 2019 16:40
let | x : 1
| y : 2
in :
(x + y)
define pi : 3.14
define fib(n) :
log_error("fib called")
cond | (n = 0) : 0