From 443beb2ab4b27f056dfe6c079c847c4177b73b19 Mon Sep 17 00:00:00 2001 From: sforman Date: Mon, 31 Jul 2023 10:36:53 -0700 Subject: [PATCH] Minor edits. --- README.md | 33 +++++++++++++++++++++++++++++++-- vlist.py | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cecab2c..abd493a 100644 --- a/README.md +++ b/README.md @@ -261,11 +261,40 @@ dialect of Joy are defined in terms of these: < > >= <= != <> = - lshift rshift + not - /\ \/ _\/_ (These are the logical ops that work on Booleans.) +They could be grouped: +- Combinators (`branch dip i loop`) +- Stack Chatter (`clear dup pop stack swaack swap`) +- List Manipulation (`concat cons first rest`) +- Math (`+ - * / %`) +- Comparison (`< > >= <= != <> =`) +- Logic (`truthy not`) +Many of these could be definitions, but we don't want to be completely minimal at the cost of efficiency, eh? + + first == [[clear] dip] infra + rest == [pop] infra + +Also, custom error messages are nice? (E.g. `first` and `rest` have distinct errors from `pop` and `dip`, at least in the current design.) + + +### AND, OR, XOR, NOT + +There are three families (categories?) of these operations: + +1. Logical ops that take and return Boolean values. +2. Bitwise ops that treat integers as bit-strings. +3. Short-Circuiting Combinators that accept a Boolean and a quoted program + and run the quote *iff* the Boolean doesn't suffice to resolve the clause. + (in other words `true [P] and` runs `P` whereas `false [P] and` discards + it and leaves `false` on the stack, and similarly for `or` but with the + logical polarity, if you will, reversed.) + +(So far, only the Elm interpreter implements the bitwise ops. The others +two kinds of ops are defined in the `defs.txt` file, but you could implement +them in host language for greater efficiency if you like.) | op | Logical (Boolean) | Bitwise (Ints) | Short-Circuiting Combinators | |-----|-------------------|----------------|------------------------------| diff --git a/vlist.py b/vlist.py index 205d20f..71c4f30 100644 --- a/vlist.py +++ b/vlist.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright © 2022 Simon Forman +# +# This file is part of Thun +# +# Thun is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Thun is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Thun. If not see . +# ''' An exploration of Phil Bagwell's VList. -- 2.11.0