# Design goals ## Compatibility Support the same language as the original interpreter, except for platform differences. ## Architectural faithfulness Try to maintain the spirit of the initial implementation. The original was written in assembly and ran in environments we'd now consider extremely memory constrained. Update the design to fit new platforms, but don't expand its resource requirements to fit the glut of available memory. ## Suitability for new projects The implementation should not be optimized for the PDP at the expense of performance on modern hardware. The language should not be complicated solely for backward compatibility. The runtime should not be larger or slower than necessitated by the dynamism of the language. # Distinctive features ## Package system The package-oriented nature of the language is a huge plus. Easy sharing of packages along the lines of Quicklisp/MELPA/Cargo is a key feature for building a community. ## Coroutines (stackful) ## Interrupt mechanism Very powerful. In combination with coroutines, could be used to implement pre-emptively multitasked green threads. Supports setting "breakpoints" on variable accesses. ## Fexprs In Muddle there are no "magic" forms that can only be provided by the runtime (or, anything can be magic). Disciplined use is required to avoid madness, but sometimes FEXPRs can be clearer than macros. ## First-class term-rewriting fexprs... "CALL" is the most (dangerously) powerful language feature I've ever heard of. ## Re-entrant first-class stack-allocated continuations That can jump forward. With UNWIND. ## Powerful type system ### Slot accessors Simple accessors just evaluate to numbers that perform access into vector slots, but the caller sees the same interface as if it were a function. ### Truthiness is an `Either` type # language features ## no tail call elimination TCE would elide FRAMEs, and mess with ACTIVATIONs and stack introspection. ## variable scope * primarily dynamic, with namespaces * lexical scoping features available * e.g. PROG ## coroutines (stackful) ## evaluation model ### fexprs: FSUBR, CALL/QUOTE/ARGS Any "function" can accept arguments unevaluated, and then it may BIND and EVAL them. Hence short-circuiting operators such as AND could be defined as library functions. ## locatives * reference to a struct field ## interrupts (PL-21) * operationally similar to UNIX signals * checked for a defined times (PL-21.7.1) * could be implemented with an atomic flag ## fixnums * FIX is defined as a 36-bit integer * by default, an error will be produced on overflow! this makes compatibility easier than if software counted on wrapping... * RANDOM returns a 36-bit random * though code that compares to may be ok * out of a 64-bit word, this leaves a lot of room for tags or something... ## truth * false/true is actually: left(list) / any * T exists as true value carrying no additional information ## uvector * type-homogenous vector ## closures * since scope is dynamic, closure variables are captured explicitly ## macros (PL-17) # Packages Package metadata: * MANIFEST GVALs * NEWTYPE definitions * MACROs that don't depend on the package's functions * RSUBR DECLs # Mediation The documentation refers to "mediation" when compiled code calls in to the interpreter or interpreted code calls a compiled subroutine. ## Mediated subroutine calls Calls to `RSUBR`s that haven't been `SUBRIFY`'d are _mediated_ calls; the interpreter does a full `MCALL`, and the compiled code has an entry point that translates to a `BINCALL`. # State machine ## Non-local control flow ### `ERRET` / return from Check `PROCESS` id. Unwind stack until the specified `FRAME`. Return. ### `RESUME` Change `PROCESS` id. Return from new `PROCESS`es previous `RESUME` frame with specified value. ### `GO`/`TAG` `TAG`: holds a pointer to an AST node, and the call depth of that node's enclosing `PROG`. `GO`: unwind to depth specified in `TAG`; resume execution. ### `REPEAT` Uwind to enclosing `PROG`; continue. # License Copyright (C) 2018 Keziah Wesley You can redistribute and/or modify this file under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this file. If not, see .