Skip to content

Instantly share code, notes, and snippets.

View no-defun-allowed's full-sized avatar

Hayley Patton no-defun-allowed

View GitHub Profile
@no-defun-allowed
no-defun-allowed / sicl_rack_update.tla
Last active June 15, 2021 02:18
Safe CHANGE-CLASS on SICL objects with no double-word CAS
-------------------------- MODULE sicl_rack_update --------------------------
EXTENDS Naturals, TLC
(* --algorithm basic
variables object = <<0, 0>>;
process ChangeClass \in 1..4
variables oldclass = 0, oldrack = 0;
begin
LoadClass:
@no-defun-allowed
no-defun-allowed / dbyol.org
Last active April 28, 2025 23:14
Don't Build Your Own Lisp

Don’t Build Your Own Lisp

I feel somewhat pressed to give a negative review of this book. This comes from someone who has worked on various Lisp implementations, and written some amount of C, but that isn’t an excuse to be overly harsh. This book, however, does not provide many nice things to say, and plenty of un-nice things. My apologies in advance.

First off: God help you if you are going to write your first interpreter in C of all things. No one I know thinks it’s a good idea to start

@no-defun-allowed
no-defun-allowed / base64-cl-simd.lisp
Created March 25, 2021 04:26
1 hour of cl-simd and chill and it gives you this look
(defun char- (character offset)
(- (char-code character) offset))
(defconstant +encode-shift-lut+
(sse:setr-pi8
(char- #\a 26) #1=(char- #\0 52) #1# #1# #1# #1#
#1# #1# #1# #1# #1# (char- #\+ 62)
(char- #\/ 63) (char-code #\A) 0 0))
(declaim (inline encode-lookup))
@no-defun-allowed
no-defun-allowed / 00-TL-DR.md
Last active February 16, 2021 22:11
Some dynamic language benchmarks

The results

Note that only the C "control" example has type information; every other implementation either uses inference or generic arithmetic.

Implementation Language Time (ms) Time rel. C Arithmetic Compilation model
GCC C 20.3 1 mod 2^n AOT
SBCL Common Lisp 36.4 1.79 bignum AOT
SpiderMonkey JavaScript 56.0 2.75 float JIT
Chez Scheme 93.7 4.62 bignum AOT
@no-defun-allowed
no-defun-allowed / selling-lisp-by-the-pound.org
Last active April 17, 2024 06:10
Selling Lisp by the pound

Selling Lisp by the Pound

“Paper late!” cried a voice in the crowd,

“Old man dies!” The note he left was signed,

‘Old Kiczales’ - it seems he’s drowned!

@no-defun-allowed
no-defun-allowed / point.lisp
Last active May 4, 2022 05:56
A metaclass which allocates instance slots in contiguous vectors
(defclass point ()
((x :initarg :x
:reader x
:type single-float
:pool-name *point-xs*)
(y :initarg :y
:reader y
:type single-float
:pool-name *point-ys*))
(:metaclass pooled-class))
@no-defun-allowed
no-defun-allowed / cas-words.lisp
Last active December 31, 2020 15:59
CAS elements of (unsigned-byte 64) words on SBCL
(defpackage cas-word
(:use :cl)
(:export #:word-ref #:run-tests))
(in-package :sb-vm)
(sb-c:defknown cas-word::%cas-word
((simple-array (unsigned-byte 64) 1) fixnum (unsigned-byte 64) (unsigned-byte 64))
(unsigned-byte 64)
()
@no-defun-allowed
no-defun-allowed / install-sicl.sh
Last active December 29, 2020 06:18
A script to download the sources of SICL and its dependencies
#!/bin/bash
PROJECTS=${1:-~/quicklisp/local-projects}
clone() {
TARGET=$PROJECTS/$(basename $1)
if [[ -d $TARGET ]]; then
(cd $TARGET; git pull)
else
git clone $1 $TARGET
@no-defun-allowed
no-defun-allowed / trading-simulation.lisp
Created December 28, 2020 22:18
someone whose only qualifications are getting 90% on a statistics test in high school investigates the Dream speedrun controversy
(declaim (optimize (speed 3) (safety 1)))
(defconstant +pearl-probability+ (float 20/423))
(declaim (inline trade))
(defun trade ()
(if (< (random 1.0) +pearl-probability+)
;; Note that RANDOM returns a value in [0, maximum), i.e.
;; it will only produce numbers below the maximum given.
(+ 4 (random 5))
0))
(ql:quickload :the-cost-of-nothing)
(in-package :cl-user)
(defun foo (x)
(declare (integer x)
(optimize (speed 3)))
(< (- (expt 2 256)) x (expt 2 256)))
(the-cost-of-nothing:bench (foo 7))
(in-package :sb-c)