diff options
-rw-r--r-- | basic.lsp | 2 | ||||
-rw-r--r-- | cap-muck.lsp | 2 | ||||
-rwxr-xr-x | chello.lisp | 1 | ||||
-rw-r--r-- | doc/Makefile | 2 | ||||
-rw-r--r-- | doc/bane.21.cdr16.gmi | 75 | ||||
-rw-r--r-- | loot.lsp | 4 |
6 files changed, 84 insertions, 2 deletions
diff --git a/basic.lsp b/basic.lsp index 2fec591..0662a09 100644 --- a/basic.lsp +++ b/basic.lsp @@ -1,5 +1,7 @@ ;;; BASIC interpreter +;; TODO: rewrite some cond/cases as defmethods. Look for calls to "instancep". + ;;; Abstract syntax ;; If these were only C enums, without any payload, I'd just use symbols and (error) in the t case. diff --git a/cap-muck.lsp b/cap-muck.lsp index 54bfa9a..492ae6e 100644 --- a/cap-muck.lsp +++ b/cap-muck.lsp @@ -32,6 +32,8 @@ (defglobal *write-rooms* nil) +(defconstant +opposite+ #(s n w e d u)) + (defconstant +command-type+ #(say help quit look rooms make-room make-door teleport n s e w diff --git a/chello.lisp b/chello.lisp index 55b5999..7722770 100755 --- a/chello.lisp +++ b/chello.lisp @@ -1,3 +1,4 @@ #!/usr/local/bin/sbcl --script (format *standard-output* "~A~%" "Hello world") +(quit) diff --git a/doc/Makefile b/doc/Makefile index 27cc51e..241ce6f 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,7 +3,7 @@ # Outputs other than Gemini aren't required -GEMINI := breaking_rules.gmi bane.20.cdr15.gmi +GEMINI := breaking_rules.gmi bane.20.cdr15.gmi bane.21.cdr16.gmi .PHONY: all all: $(GEMINI) diff --git a/doc/bane.21.cdr16.gmi b/doc/bane.21.cdr16.gmi new file mode 100644 index 0000000..dcd8d95 --- /dev/null +++ b/doc/bane.21.cdr16.gmi @@ -0,0 +1,75 @@ +title: POSIX API for ISLisp +author: Darren Bane +copyright: 2021 Darren Bane, CC BY_SA + +# Abstract + +A mapping from Scheme's SRFI-170, "POSIX API", to ISLisp is defined. + +# Introduction + +Although they are similar, Scheme and ISLisp are not the same language. This document adapts the standard Scheme POSIX interface to ISLisp accounting for: + +* Different naming conventions (e.g. `predicatep` rather than `predicate?`) +* Historical practice, in particular compatibility with OpenLisp (the only commercial implementation) is prioritised + +# Dependencies + +SRFI-170 depends on at least part of several other SRFIs, in particular: + +* SRFI-19, "Time Data Types and Procedures" +* SRFI-106, "Networking operations" +* SRFI-158, "Generators and Accumulators" + +SRFI-39, "Parameter objects", is superseded by ISLisp's dynamic variables. + +Only SRFI-106 is implemented fully; the subset of required symbols is taken from the others. + +# Mapping + +Any symbols not mentioned in the following are unchanged from SRFI-170. + +## S3.3, "File system" + +```table +┌──────────────────┬──────────────────┐ +│ Scheme │ ISLisp │ +╞══════════════════╪══════════════════╡ +│ file-info? │ file-info-p │ +├──────────────────┼──────────────────┤ +│ delete-directory │ remove-directory │ +└──────────────────┴──────────────────┘ +``` +## S3.5, "Process state" + +```table +┌────────────────────────┬──────────────────┐ +│ Scheme │ ISLisp │ +╞════════════════════════╪══════════════════╡ +│ set-umask! │ set-umask │ +├────────────────────────┼──────────────────┤ +│ set-current-directory! │ change-directory │ +├────────────────────────┼──────────────────┤ +│ pid │ getpid │ +├────────────────────────┼──────────────────┤ +│ user-uid │ getuid │ +└────────────────────────┴──────────────────┘ +``` +## S3.11, "Environment variables" + +```table +┌──────────────────────────┬────────┐ +│ Scheme │ ISLisp │ +╞══════════════════════════╪════════╡ +│ get-environment-variable │ getenv │ +└──────────────────────────┴────────┘ +``` +## S3.12, "Terminal device control" + +```table +┌───────────┬───────────┐ +│ Scheme │ ISLisp │ +╞═══════════╪═══════════╡ +│ terminal? │ terminalp │ +└───────────┴───────────┘ +``` diff --git a/loot.lsp b/loot.lsp index 74378fc..91f8eac 100644 --- a/loot.lsp +++ b/loot.lsp @@ -1,3 +1,4 @@ +;; #lang core-lisp ;;; Port of https://en.wikipedia.org/wiki/ModernPascal#Code_Sample[3]. ;;; And then to CL and ISLisp. ;;; I prefer my version. @@ -14,7 +15,7 @@ (let ((random-value (random (- +max-probability+ 1)))) (for ((loop 0 (+ loop 1))) ((>= (elt (probabilities self) (mod loop 13)) random-value) (elt +loot-type+ (mod loop 13)))))) -(defmethod initialize-object :after ((self <looter>) initargs) +(defmethod initialize-object :after ((self <looter>) &rest initargs) (setf (probabilities self) (vector 10 77 105 125 142 159 172 200 201 202 216 282 +max-probability+))) (defun as-string (l) ;; Could use assoc here, but this is closer to the original. @@ -39,3 +40,4 @@ ((> n 99)) (format (standard-output) "~A~%" (as-string (choose loot)))))) ;; (main) +;; (:export #'main) |