Skip to content

Instantly share code, notes, and snippets.

#lang racket
;; An Expression is a Variable, an Abstraction, or an Application.
;; A Variable is a Symbol, denoting use of a bound variable.
;; An Abstraction is an (abs Symbol Expression), denoting a lambda term and evaluating to a Closure.
(struct abs (var exp))
;; An Application is an (app Expression Expression), denoting a function call
(struct app (fun arg))
@tonyg
tonyg / possible-patch-for-swpal-and-casal.patch
Last active April 19, 2024 14:19
Weird issue with Guile 3.0.9's `atomic-box-swap!`
diff --git a/libguile/lightening/lightening/aarch64-cpu.c b/libguile/lightening/lightening/aarch64-cpu.c
index 13aa351e9..a47900b7c 100644
--- a/libguile/lightening/lightening/aarch64-cpu.c
+++ b/libguile/lightening/lightening/aarch64-cpu.c
@@ -225,6 +225,8 @@ oxxrs(jit_state_t *_jit, int32_t Op,
#define A64_STLR 0xc89ffc00
#define A64_LDAXR 0xc85ffc00
#define A64_STLXR 0xc800fc00
+#define A64_SWPAL 0xf8e08000
+#define A64_CASAL 0xc8e0fc00
;;; markdown-join.el --- Join markdown tables based on cell contents -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Tony Garnock-Jones
;; Author: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
;; Keywords: data, convenience, matching
;; Version: 0.0.1
;; Package-Requires: ((markdown-mode "2.6") (emacs "25.1"))
;; Homepage: https://gist.github.com/tonyg/c951be93656b45027ed7d15e79f07c01
@tonyg
tonyg / Makefile
Last active July 10, 2023 19:14
Exploring uxn
%.run: %.rom
uxncli $<
%.debug: %.rom
uxnemu ~/build/uxn11/beetbug/bin/beetbug.rom $<
%.rom: %.tal
uxnasm $< $@
#lang racket
;; https://github.com/NuxiNL/argdata
(provide (all-defined-out))
;;---------------------------------------------------------------------------
;; Representing values
(struct timestamp (ns) #:transparent)
(struct fd (number) #:transparent)
from syndicate import relay, turn
from syndicate.during import During
import logging
@relay.service(name='inf', debug=True)
@During().add_handler
def main(args):
logging.info(f'in main {args}')
turn.on_stop(lambda: logging.info(f'args retracted {args}'))
@tonyg
tonyg / xml-infoset.prs
Created January 24, 2022 09:35
Sketch of a representation of XML infoset in Preserves Schema
version 1 .
Node = Text / Element .
Text = string .
Element =
/ @withAttributes
<<rec> @localName symbol [@attributes Attributes @children Node ...]>
/ @withoutAttributes
<<rec> @localName symbol @children [Node ...]> .
Attributes = { symbol: string ...:... } .

Semi-automatic Defunctionalization of Continuations

Tony Garnock-Jones. February 2016.

Abstract

Programmers use continuations to achieve all manner of interesting control effects (e.g. Shivers & Turon 2011). But common representations of continuations cause problems in practice in two ways. On one hand, continuations represented as functions are entirely opaque; the only available operation is to invoke the continuation. On the other hand, continuations represented as reified machine stacks expose too much information; irrelevant detail of the program's information becomes visible. In this paper, we present a design for a middle-ground. Using our new language construct, continuations are represented as censored reified machine stacks. Programmers precisely control the information and behavior associated with each frame in the continuation, allowing them the benefits of automatic continuation reification combined with the benefits of a defunctionalized representation of control as data.


#lang racket
(require tabular)
;; A floor of original length x
;; that expands by n
;; but is constrained to fit in a space of length x
;; will buckle.
;;
;; Let's approximate by treating the resulting shape as an isosceles
@tonyg
tonyg / boring.rkt
Created August 26, 2021 07:27 — forked from samdphillips/boring.rkt
syndicate shutdown ...
#lang syndicate
(require racket/set)
(require/activate syndicate/drivers/external-event)
(provide shutdown!)
(define-logger top)
(define log-receiver