about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDarren Bane <dbane@tilde.institute>2020-05-26 21:22:02 +0100
committerDarren Bane <dbane@tilde.institute>2020-05-26 21:22:02 +0100
commite86f1d02e4c79f6083fd35c851b91f80f9d64cea (patch)
treeaa43e604fc22b8bb1c8c25df2f8421724a7f9773
parent4d40956bf90f368bbb6c864148d9a9c4842199b6 (diff)
downloadlsp-e86f1d02e4c79f6083fd35c851b91f80f9d64cea.tar.gz
Making changes
-rw-r--r--comal.lsp1
-rw-r--r--doc/Makefile4
-rw-r--r--doc/breaking_rules.md36
-rw-r--r--mc.lsp4
-rw-r--r--sim.lsp11
-rwxr-xr-xsysdep.lsp25
-rwxr-xr-xuuid.lsp6
-rw-r--r--v.el3
-rw-r--r--xdr.lsp23
9 files changed, 104 insertions, 9 deletions
diff --git a/comal.lsp b/comal.lsp
index 793575e..77b1c2a 100644
--- a/comal.lsp
+++ b/comal.lsp
@@ -1,5 +1,4 @@
 #!/Users/dbane/openlisp-10.9.0/uxlisp -shell
-;; Does it make more sense to write everything in Lisp rather than a split Lisp/COMAL design?
 (defun error-handler (condition)
    (cond
          ((eq (class-of condition) (class <lexer-error>)) )))
diff --git a/doc/Makefile b/doc/Makefile
index 8e0f283..9cd37e5 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -11,9 +11,9 @@ all: breaking_rules.pdf breaking_rules.html
 breaking_rules.pdf: macros.ms breaking_rules.md refs.i
 	( cat macros.ms; lowdown -sTms breaking_rules.md ) | pdfroff -i -t -R -mspdf -k -Kutf8 > $@
 
-# Headers aren't emitted currently
+# On macOS only, headers aren't emitted currently
 breaking_rules.html: macros.ms breaking_rules.md refs.i
-	( cat macros.ms; lowdown -sTms breaking_rules.md ) | groff -Thtml -i -t -R -ms -k -Kutf8 > $@
+	( cat macros.ms; lowdown -sTms breaking_rules.md ) | groff -Txhtml -i -t -R -ms -k -Kutf8 > $@
 
 refs.i: refs
 	indxbib $^
diff --git a/doc/breaking_rules.md b/doc/breaking_rules.md
index aa3cb89..d5b399c 100644
--- a/doc/breaking_rules.md
+++ b/doc/breaking_rules.md
@@ -22,6 +22,8 @@ beck 1999
 I argue that improvements in development tools have
 invalidated this.
 
+*TODO*: case study
+
 *Colophon*: this document tries to depend only on GFM,
 in the same spirit as the software.
 The use of tools like
@@ -81,9 +83,8 @@ but there is no need to force it at the start.
 
 A JSON-RPC library was not difficult to write.
 
-## Imperative/Object-oriented paradigm
-
-Here, the following technology is recommended:
+It was decided to use the imperative/object-oriented paradigm.
+The following technology is recommended:
 
 * The OpenLisp interpreter.
 * Emacs for the view layer
@@ -98,7 +99,7 @@ Even though this is a prototype, attention should be paid to basic craftsmanship
   to check the types of parameters in public interfaces
 * Some minimal documentation, at least an overview README file and man pages.
 
-### Further work
+## Further Work
 
 This is probably the most work that makes sense
 without earning money.
@@ -109,7 +110,9 @@ without earning money.
 
 # Refinement to Production-Quality
 
-I argue that there is a repeatable procedure to improve the quality of a
+First, software at the level of the previous section is quite usable.
+It should be confirmed that further improvement is, in fact, required.
+If so, I argue that there is a repeatable procedure to improve the quality of a
 (reasonably well-written) prototype to a releaseable product.
 
 First, ensure that the surrounding infrastructure is in place:
@@ -127,6 +130,29 @@ Then, the following code & documentation improvements should be made:
 * Port some of the trivial-\* CL libraries from quicklisp where justified.
 * Port to core-lisp on platform.sh?
 
+## Documentation Details
+
+I think it is a good idea to keep the separation between library and UI code.
+And JSON-RPC is perfectly adequate for that.
+
+### Library
+
+This was the subject of
+\.[
+bane 2008
+\.]
+. However, much of the work of dedicated documentation is better done in source code:
+
+* The summary of functions should be taken care of by having the public functions and classes commented.
+* The formal requirement for function behaviour is better done with contracts.
+  Tables with Simple English are still a good idea for initial work.
+  
+### UI
+
+This involves filling in any blanks that still need to be filled after the man pages have been written.
+There is also the system-level documentation to consider, some of which is fine in a README.
+The specification of input and output variables is best left at the level of tables and Simple English again.
+
 # Conclusion
 
 A method for developing software from an incomplete understanding of the requirements is given.
diff --git a/mc.lsp b/mc.lsp
index e096376..42b2f8b 100644
--- a/mc.lsp
+++ b/mc.lsp
@@ -1,3 +1,6 @@
+;;; Port of https://stackoverflow.com/questions/3984296/model-view-controller-design-pattern-code-example.
+;;; Model and Controller classes.
+
 (require "json")
 (defpackage #:mc
   (:use #:openlisp #:json)
@@ -26,3 +29,4 @@
 (defgeneric on-button-clicked (controller))
 (defmethod on-button-clicked ((controller <graph-controller>))
   (increase-number (model controller)))
+(provide "mc")
diff --git a/sim.lsp b/sim.lsp
new file mode 100644
index 0000000..80d6f0d
--- /dev/null
+++ b/sim.lsp
@@ -0,0 +1,11 @@
+;; TODO: air resistance, terminal velocity
+(defconstant +G+ 9.81)
+(defglobal *alt* 20000)
+(defglobal *v* 0)
+(defun step ()
+   (setq *alt* (- *alt* *v*))
+   (setq *v* (+ *v* +G+))
+   (format (standard-output) "~A~%" *alt*))
+(defun main ()
+   (while (> *alt* 0)
+	  (step)))
diff --git a/sysdep.lsp b/sysdep.lsp
new file mode 100755
index 0000000..e12cc9a
--- /dev/null
+++ b/sysdep.lsp
@@ -0,0 +1,25 @@
+#!/home/dbane/openlisp-10.9.0/uxlisp -shell
+(defpackage #:sysdep
+  (:use #:openlisp)
+  (:export
+   #:get-ieee-node-identifier))
+(in-package #:sysdep)
+(defglobal *inited* nil)
+(defglobal *saved-node* nil)
+(defun error-handler (condition)
+   (let ((seed (get-random-info)))
+        (setf (elt seed 0) (logior (elt seed 0) 1))
+        (setq *saved-node* (copy-seq seed))
+        (with-open-output-file (outstream "nodeid")
+             (format outstream "~S" *saved-node*))))
+(defun get-ieee-node-identifier ()
+   (if (not *inited*)
+       (progn (with-handler #'error-handler
+                 (with-open-input-file (instream "nodeid")
+                      (read instream)))
+              (setq *inited* t)))
+   *saved-node*)
+(provide "sysdep")
+(defun main ()
+   (format (standard-output) "~A~%" (get-ieee-node-identifier)))
+(main)
diff --git a/uuid.lsp b/uuid.lsp
index 88e3ebb..9f78fa6 100755
--- a/uuid.lsp
+++ b/uuid.lsp
@@ -1,6 +1,10 @@
 #!/home/dbane/openlisp-10.9.0/uxlisp -shell
+
+;;; UUID V1 from https://tools.ietf.org/html/rfc4122#page-18, ported to Lisp.
+
+(require "sysdep")
 (defpackage #:uuid
-  (:use #:openlisp)
+  (:use #:openlisp #:sysdep)
   (:export
     #:main))
 (in-package #:uuid)
diff --git a/v.el b/v.el
index 84903a9..bc96aef 100644
--- a/v.el
+++ b/v.el
@@ -1,3 +1,6 @@
+;;; Port of https://stackoverflow.com/questions/3984296/model-view-controller-design-pattern-code-example.
+;;; View class.
+
 (require 'eieio)
 (eval-when-compile (require 'cl-lib))
 (eval-when-compile (require 'cl-generic))
diff --git a/xdr.lsp b/xdr.lsp
new file mode 100644
index 0000000..34d9024
--- /dev/null
+++ b/xdr.lsp
@@ -0,0 +1,23 @@
+(defpackage #:xdr
+  (:use #:openlisp)
+  (:export
+   #:h-to-xdr
+   #:xdr-to-h))
+(in-package #:xdr)
+(defglobal *encode-buf*)
+(defun buffer-init (buf op)
+   (case op
+	 ((encode) (setq *encode-buf* buf))
+	 ((decode) (setq *decode-buf* buf))
+	 (t (error "bad op"))))
+(defun set-be-x (buf n)
+   (setf (elt buf 0) (logand (ash -56 n) #xFF))
+   (setf (elt buf 1) (logand (ash -48 n) #xFF)))
+(defun h-to-xdr (n)
+   (set-be-x xdr-encode-buf n))
+(provide "xdr")
+
+(deftest wrt-test ()
+   (buffer-init buffer 'encode)
+   (i-to-xdr 1234)
+   (write-file buffer +bytes-per-unit+ fh))