1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-03 19:31:10 +00:00
PLASMA/doc/DRAWL.md

223 lines
6.0 KiB
Markdown
Raw Normal View History

2024-07-09 19:22:20 +00:00
# LISP 1.5 implemented in PLASMA
2024-07-09 21:25:41 +00:00
LISP interpreted on a bytecode VM running on a 1 MHz 6502 is going to be sssllllooooowwwww. So I called this implementation DRAWL in keeping with the speech theme. DRAWL represents an exploration REPL language for the PLASMA environment. It isn't meant to be a full-blown programming language, more of an interactive sandbox for playing with S-expressions.
2024-07-09 19:21:17 +00:00
## Missing features of LISP 1.5 in DRAWL
2024-07-23 22:46:57 +00:00
- Minimal I/O facilities
2024-08-01 16:00:26 +00:00
- Property lists. Only DEFINE() and CSETQ()/CSET() property functions supported
- General recursion. The 6502 architecture limits recursion (but see tail recursion below), so don't expect too much here
2024-07-20 00:55:01 +00:00
- Many of the built-in functions from the LISP 1.5 manual. Most can be coded in LISP and loaded at startup
2024-07-09 19:21:17 +00:00
However, the code is partitioned to allow for easy extension so some of these missing features could be implemented.
## Features of DRAWL
2024-07-13 20:14:49 +00:00
- 32 bit integers and 80 bit floating point with transcendental math operators by way of the SANE library
2024-07-12 19:09:38 +00:00
- Tail recursion handles deep recursion. Check out [loop.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/loop.lisp)
2024-07-09 19:21:17 +00:00
- Fully garbage collected behind the scenes
- Optionally read LISP source file at startup
2024-07-13 20:56:21 +00:00
- Arrays of up to four dimensions
- Bit-wise logic operations on 32 bit integers
2024-07-23 22:46:57 +00:00
- FUNCTION operation with bound variables
- The PROG Alogol-like programming construct
- Additional testing/looping constructs: IF and FOR
- Hexadecimal input/output
2024-07-22 23:31:38 +00:00
- LoRes Apple II graphics
2024-07-23 22:46:57 +00:00
- Ctrl-C break into running program
2024-08-01 15:55:29 +00:00
- MACROs for meta-programming. See [defun.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/defun.lisp)
2024-08-01 17:13:06 +00:00
- End-of-line comment using ';'
2024-08-02 01:00:19 +00:00
- String handling functions
2024-07-09 19:21:17 +00:00
2024-07-20 04:07:02 +00:00
The DRAWL implementation comes with the following built-in functions:
2024-07-20 00:44:24 +00:00
### Constants
2024-07-23 22:46:57 +00:00
2024-07-20 00:44:24 +00:00
- T = True
- F = False
- NIL = NULL
2024-07-25 18:30:59 +00:00
- CSET() = Set constant value
- CSETQ() = Set constant value
- :=() = Alias got CSETQ()
2024-07-25 18:30:59 +00:00
- DEFINE() = Define function
2024-07-20 00:44:24 +00:00
### Function types
2024-07-20 00:49:56 +00:00
- LAMBDA(...)
- FUNARG() = List constructed by FUNCTION()
- FUNCTION()
2024-08-01 15:55:29 +00:00
- MACRO(...) = Operate on non-evaluated argument list
2024-07-20 00:44:24 +00:00
### Predicates
- ATOM()
- EQ()
- NOT()
- AND(...)
- OR(...)
- NULL()
- NUMBER?()
- STRING?()
2024-07-20 00:44:24 +00:00
### Misc
2024-07-25 18:30:59 +00:00
- SET = Used in array access to set element value
2024-07-20 00:44:24 +00:00
- QUOTE()
2024-07-25 18:30:59 +00:00
- ARRAY() = Arrays up to four dimensions
- EVAL() = Evaluate S-expression
2024-07-20 00:44:24 +00:00
- TRACE() = Turn tracing on/off
- GC() = Run garbage collector and return free memory amount
- QUIT() = Exit REPL
### List manipulation
- CAR()
- CDR()
- CONS()
- LIST(...)
### Conditionals
- COND(...)
2024-07-23 22:46:57 +00:00
- IF() = IF THEN w/ optional ELSE
2024-07-20 00:44:24 +00:00
### Output
- PRHEX() = Turn hexadecimal output on/off
- PRI(...) = Print without newline
- PRINT(...) = Print with newline
- FMTFPI() = Floating point format integer digits
- FMTFPF() = Floating point format fractional digits
- PRINTER() = Turn printer echo on/off on slot#
### Looping
2024-07-20 00:55:01 +00:00
- FOR(...)
2024-07-20 00:44:24 +00:00
### Associations
- LABEL()
- SET()
- SETQ()
- =() = Alias got SETQ()
2024-07-20 00:44:24 +00:00
### Program feature
2024-07-23 22:46:57 +00:00
- PROG(...) = Algol like programming in LISP
2024-07-25 18:30:59 +00:00
- SET() = Update variable value
- SETQ() = Update variable value
- = = Alias for SETQ
2024-07-23 22:46:57 +00:00
- COND(...) = Fall-through COND()
- IF() = Fall-through IF THEN w/ optional ELSE
2024-07-20 00:49:56 +00:00
- GO() = Goto label inside PROG
- RETURN() = Return from PROG with value
2024-07-20 00:44:24 +00:00
### Numbers
2024-07-20 00:49:56 +00:00
- +(...)
2024-07-20 00:44:24 +00:00
- -()
- \*(...)
2024-07-20 00:44:24 +00:00
- /()
- REM()
- NEG()
- ABS()
2024-07-20 00:51:43 +00:00
- \>()
2024-07-20 00:44:24 +00:00
- <()
2024-07-20 00:49:56 +00:00
- MIN(...)
- MAX(...)
- NUMBER?()
2024-07-20 00:44:24 +00:00
### Integers
- BITNOT() = Bit-wise NOT
- ~() = Alias for BITNOT()
2024-07-20 00:44:24 +00:00
- BITAND() = Bit-wise AND
- &() = Alias for BITAND()
2024-07-20 00:44:24 +00:00
- BITOR() = Bit-wise OR
- |() = Alias for BITOR()
- BITXOR = Bit-wise XOR
- ^() = Alias for BITXOR()
- ARITHSHIFT() = Bit-wise arithmetic SHIFT (positive = left, negative = right)
- <<-() = Alias for ARITHSHIFT()
- LOGICSHIFT() = Bit-wise logicalal SHIFT (positive = left, negative = right)
- <<() = Alias for LOGICSHIFT()
2024-07-20 00:44:24 +00:00
- ROTATE() = Bit-wise ROTATE (positive = left, negative = right)
- <<<() = Alias for ROTATE()
2024-07-20 00:44:24 +00:00
### Floating Point (from the SANE library)
- *PI* = Constant value of pi
- *E* = Constant value of e
- NUMBER() = Convert atom to number (symbol and array return NIL)
- INTEGER() = Convert number to integer
2024-07-20 00:44:24 +00:00
- LOGB()
- SCALEB()
2024-07-20 00:44:24 +00:00
- TRUNCATE()
- ROUND()
- SQRT()
- COS()
- SIN()
- TAN()
- ATAN()
- LOG2()
- LOG2_1()
- LN()
- LN_1()
- POW2()
- POW2_1()
- POWE()
- POWE_1()
- POW_I()
2024-07-23 22:46:57 +00:00
- POW()
2024-07-20 00:44:24 +00:00
- COMP()
- ANNUITY()
2024-08-02 01:00:19 +00:00
### Strings
- STRING() = Convert atom to string
- SUBS() = SUB String offset length
- CATS(...) = conCATenate Strings
- LENS() = LENgth String
- CHARS(...) = CHARacter String from integer values
- ASCII() = ASCII value of first character in string
2024-08-02 01:00:19 +00:00
2024-08-02 04:50:19 +00:00
### I/O functions
- HOME()
- GOTOXY()
- KEYPRESSED?()
2024-08-02 04:50:19 +00:00
- READKEY()
- READ()
- READFILE()
- READSTRING()
2024-07-22 23:31:38 +00:00
### Lo-Res Graphics
2024-07-25 18:30:59 +00:00
- GR() = Turn lo-res graphics mode on/off
- COLOR() = Set plotting color
- PLOT() = Plot pixel at X,Y coordinate
2024-07-22 23:31:38 +00:00
2024-07-09 19:21:17 +00:00
LISP is one of the earliest computer languages. As such, it holds a special place in the anals of computer science. I've always wanted to learn why LISP is held in such high regard by so many, so I went about learning LISP by actually implementing a LISP interpreter in PLASMA. PLASMA is well suited to implement other languages due to its rich syntax, performance and libraries.
## Links
Here are some links to get you started.
LISP 1.5 Manual: https://archive.org/details/bitsavers_mitrlelisprammersManual2ed1985_9279667
2024-07-20 00:44:24 +00:00
LISP 1.5 Primer: https://www.softwarepreservation.org/projects/LISP/book/Weismann_LISP1.5_Primer_1967.pdf
Personal LISP on Apple II Manual (PDF): https://archive.org/details/gLISP/gnosisLISPManual
2024-07-20 14:51:56 +00:00
Personal LISP on Apple II Manual (web archive): https://web.archive.org/web/20190603120105/http://jeffshrager.org/llisp/
2024-07-20 00:44:24 +00:00
Apple Numerics Manual (SANE): https://vintageapple.org/inside_o/pdf/Apple_Numerics_Manual_Second_Edition_1988.pdf
2024-07-25 18:30:59 +00:00
Part 1 of DRAWL in action (S-expressions): https://youtu.be/wBMivg6xfSg
Part 2 of DRAWL in action (The rest of LISP 1.5): https://youtu.be/MdKZIrfPN7s
2024-07-09 19:21:17 +00:00
Preconfigured PLASMA ProDOS boot floppy for DRAWL: https://github.com/dschmenk/PLASMA/blob/master/images/apple/DRAWL.po
2024-07-25 03:11:15 +00:00
My blog post about LISP 1.5 and DRAWL: http://schmenk.is-a-geek.com/wordpress/?p=365