slight refactoring
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 13 Apr 2023 09:12:06 +0000 (19:12 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 13 Apr 2023 09:12:06 +0000 (19:12 +1000)
Makefile
lsp-misc/Makefile [new file with mode: 0644]
lsp-misc/foop.lsp [new file with mode: 0644]
lsp-misc/misc.lsp [new file with mode: 0644]
lsp-util/Makefile [deleted file]
lsp-util/foop.lsp [deleted file]
lsp-util/misc.lsp [deleted file]

index 93cfb4089cceb60f7426001e748b650fe4a1c7a6..a6575e261ee72839242a631d0386d419daf78897 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 
-LSPLIB = -A lsp-util/lsp-util.a -A lsp-dbus/lsp-dbus.a
+LSPLIB = -A lsp-misc/lsp-misc.a -A lsp-dbus/lsp-dbus.a
 
 LSPSRC = lsp-dbus-test.lsp
 
diff --git a/lsp-misc/Makefile b/lsp-misc/Makefile
new file mode 100644 (file)
index 0000000..e691976
--- /dev/null
@@ -0,0 +1,6 @@
+# Create the newlisp library foop.lsplib
+
+LSPSRC = misc.lsp foop.lsp
+
+lsp-misc.a: ${LSPSRC}
+       ar r $@ $^
diff --git a/lsp-misc/foop.lsp b/lsp-misc/foop.lsp
new file mode 100644 (file)
index 0000000..1724d3c
--- /dev/null
@@ -0,0 +1,61 @@
+;; This newlisp module provides FOOP modelling support
+;;
+;; Functional Object-Oriented Programming (FOOP) is an abstraction
+;; overlay using the newlisp context notion as similar to the class
+;; notion in genuine object-oriented programming languages. This is
+;; set out in newlisp by means of the representation principle that an
+;; instance of a FOOP "class" (i.e. context) is a list headed by the
+;; context itself, and followed by the "member values".
+;;
+;; FOOP further includes by the "method invocation" syntax where a
+;; function is preceded by ':' and then followed by the instance
+;; concerned before actual function arguments. That instance is then
+;; stoved away as implicitly available via the (self) function, and
+;; the member values accessible via index, e.g. the term (self 3)
+;; refers to the third member of the instance. The self references are
+;; destructively assignable with setf.
+;;
+;; This modelling support adds member name declaration together with
+;; automatic getter and setter defintions. The (FOOP ...) term is used
+;; for declaring member names in order. For example:
+;;
+;; (context 'MAIN:EX")
+;; (FOOP a b c)
+;; (define (EX:EX n) (list (context) (+ n 4) 3 2))
+;;
+;; That would declare a FOOP context EX with instances having three
+;; members named a, b and c. The declaratin results in a variable EX:.
+;; whose value is (FOOP a b c), as well as three access functions for
+;; each member: the member position index (.member), a getter
+;; (%member) and a setter (!member V).
+;;
+;; As indicated in the example, (FOOP a b c) does not define the
+;; "constructor". It only defines the access functions. 
+
+(context 'FOOP)
+
+;; Helper function to make a new symbol for the context of S by
+;; preceeding it with string P.
+(define (name P S) (sym (string P (term S)) (prefix S)))
+
+;; (FOOP name ...)
+; foop is a language extension to declare the field names of a FOOP
+; object type, and thereby gain getter and setter functions with the
+; naming formats (:%name obj) and (:!name obj value) respectively .
+(define-macro (FOOP:FOOP)
+  (let ((K (sym "." (prefix (first (args)))))
+        (V (cons (context) (args)))
+        (I 0))
+    (set K V)
+    (dolist (S (args))
+      (letex ((GET (name "%" S))
+              (SET (name "!" S))
+              (IT (name "." S))
+              (V (sym "V" (prefix S)))
+              (I (inc I)))
+        (define (IT) I)
+        (define (GET) (self I))
+        (define (SET V) (setf (self I) V))))
+    ))
+
+"foop.lsp"
diff --git a/lsp-misc/misc.lsp b/lsp-misc/misc.lsp
new file mode 100644 (file)
index 0000000..cf92d9c
--- /dev/null
@@ -0,0 +1,16 @@
+(define (prog1 X) X)
+(global 'prog1)
+
+(define (die N)
+  (when (args) (write-line 2 (join (map string (args)) " ")))
+  (exit N))
+(global 'die)
+
+;; Print binary byte as octal or as ASCII character [32-126]
+(define (octal-byte x)
+  (if (and (> x 31) (< x 127)) (char x) (format "\\%o" x)))
+
+;; Print string as binary octals
+(define (octals-string S)
+  (join (map octal-byte (unpack (dup "b" (length S)) S))) "")
+(global 'octals-string 'octal-byte)
diff --git a/lsp-util/Makefile b/lsp-util/Makefile
deleted file mode 100644 (file)
index 526e46f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Create the newlisp library foop.lsplib
-
-LSPSRC = foop.lsp misc.lsp
-
-lsp-util.a: ${LSPSRC}
-       ar r $@ $^
diff --git a/lsp-util/foop.lsp b/lsp-util/foop.lsp
deleted file mode 100644 (file)
index 1724d3c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-;; This newlisp module provides FOOP modelling support
-;;
-;; Functional Object-Oriented Programming (FOOP) is an abstraction
-;; overlay using the newlisp context notion as similar to the class
-;; notion in genuine object-oriented programming languages. This is
-;; set out in newlisp by means of the representation principle that an
-;; instance of a FOOP "class" (i.e. context) is a list headed by the
-;; context itself, and followed by the "member values".
-;;
-;; FOOP further includes by the "method invocation" syntax where a
-;; function is preceded by ':' and then followed by the instance
-;; concerned before actual function arguments. That instance is then
-;; stoved away as implicitly available via the (self) function, and
-;; the member values accessible via index, e.g. the term (self 3)
-;; refers to the third member of the instance. The self references are
-;; destructively assignable with setf.
-;;
-;; This modelling support adds member name declaration together with
-;; automatic getter and setter defintions. The (FOOP ...) term is used
-;; for declaring member names in order. For example:
-;;
-;; (context 'MAIN:EX")
-;; (FOOP a b c)
-;; (define (EX:EX n) (list (context) (+ n 4) 3 2))
-;;
-;; That would declare a FOOP context EX with instances having three
-;; members named a, b and c. The declaratin results in a variable EX:.
-;; whose value is (FOOP a b c), as well as three access functions for
-;; each member: the member position index (.member), a getter
-;; (%member) and a setter (!member V).
-;;
-;; As indicated in the example, (FOOP a b c) does not define the
-;; "constructor". It only defines the access functions. 
-
-(context 'FOOP)
-
-;; Helper function to make a new symbol for the context of S by
-;; preceeding it with string P.
-(define (name P S) (sym (string P (term S)) (prefix S)))
-
-;; (FOOP name ...)
-; foop is a language extension to declare the field names of a FOOP
-; object type, and thereby gain getter and setter functions with the
-; naming formats (:%name obj) and (:!name obj value) respectively .
-(define-macro (FOOP:FOOP)
-  (let ((K (sym "." (prefix (first (args)))))
-        (V (cons (context) (args)))
-        (I 0))
-    (set K V)
-    (dolist (S (args))
-      (letex ((GET (name "%" S))
-              (SET (name "!" S))
-              (IT (name "." S))
-              (V (sym "V" (prefix S)))
-              (I (inc I)))
-        (define (IT) I)
-        (define (GET) (self I))
-        (define (SET V) (setf (self I) V))))
-    ))
-
-"foop.lsp"
diff --git a/lsp-util/misc.lsp b/lsp-util/misc.lsp
deleted file mode 100644 (file)
index cf92d9c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-(define (prog1 X) X)
-(global 'prog1)
-
-(define (die N)
-  (when (args) (write-line 2 (join (map string (args)) " ")))
-  (exit N))
-(global 'die)
-
-;; Print binary byte as octal or as ASCII character [32-126]
-(define (octal-byte x)
-  (if (and (> x 31) (< x 127)) (char x) (format "\\%o" x)))
-
-;; Print string as binary octals
-(define (octals-string S)
-  (join (map octal-byte (unpack (dup "b" (length S)) S))) "")
-(global 'octals-string 'octal-byte)