id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
24,508
conllc.lisp
jnjcc_cl-nlp/corpora/conllc.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; CoNLL-2000 Shared Task Chunking ;;;; (https://www.clips.uantwerpen.be/conll2000/chunking/) (in-package #:cl-nlp) ;;; CoNLL-2000 Chunking ;;; file format: word pos chunk (defvar *conll-2000-fields* '("w" "pos" "chunking")) (defvar *conll-chunk-label* "chunking") (defvar *conll-word-feats* "__FEATS__") ;; extract features from each CoNLL sentence (defvar *conll-chunk-templates* '( (("w" . -2)) ;; what is the [-2] word? "w" being CoNLL field, -2 being offset (("w" . -1)) (("w" . +0)) ;; what is current word? (("w" . +1)) (("w" . +2)) (("w" . -1) ("w" . 0)) ;; what is prev word and current word? (("w" . +0) ("w" . 1)) (("pos" . -2)) (("pos" . -1)) (("pos" . +0)) (("pos" . +1)) (("pos" . +2)) (("pos" . -2) ("pos" . -1)) (("pos" . -1) ("pos" . +0)) (("pos" . +0) ("pos" . +1)) (("pos" . +1) ("pos" . +2)) (("pos" . -2) ("pos" . -1) ("pos" . 0)) (("pos" . -1) ("pos" . +0) ("pos" . 1)) (("pos" . +0) ("pos" . +1) ("pos" . 2)) )) ;; NOTICE: tricky, not recommended (defvar *conll-line-expand* nil) ;;; CoNLL "word" as adict: ;;; - e.g. (("w" . "Confidence") ("pos" . "NN") ("chunking" . "B-NP") ("__FEATS__" ())) ;;; - where ("w" "pos" "chunking") comes from `fields', "__FEATS__" as features ;;; CoNLL "sentence": ;;; - a list of CoNLL "word" (defun read-conll-sent (stream fields) "read one full sentence from CoNLL dataset, which is a list of CoNLL 'word' Returns: :eof if no more CoNLL sentence; or list of CoNLL words" (let ((sent nil)) (when (stream-eof-p stream) (return-from read-conll-sent :eof)) ;; collect one line of CoNLL corpus into a list `cword' (do-sentence (cword stream :eow #\Space :eol #\Newline) (when (null cword) (return)) (when *conll-line-expand* (setf cword (funcall *conll-line-expand* cword))) (push (zip-adict fields cword) sent)) (nreverse sent))) (defun %sent-ref (sent idx field) "`field' of `idx'-th CoNLL word of `sent'" (adict-ref (nth idx sent) field)) (defun %sent-append (sent idx value) "append `value' to `idx'-th CoNLL word's feature" (when (< idx 0) (setf idx (+ idx (length sent)))) (adict-append (nth idx sent) *conll-word-feats* value)) (defun escape-colon (str) (replace-string str #\: "__COLON__")) (defun parse-conll-sent (sent templates) "parse CoNLL sentence, extract features, and write into `*conll-word-feats*' slot" (dolist (template templates) (let ((name (join-strings ;; w[-1]|w[0], etc (mapcar (lambda (x) (format nil "~A[~A]" (car x) (cdr x))) template) #\|)) (field nil) (idx nil) ;; `name'=`values' (values nil)) (dotimes (ts (length sent)) (setf values nil) (dolist (pair template) (setf field (car pair)) (setf idx (+ ts (cdr pair))) (when (or (< idx 0) (>= idx (length sent))) (setf values nil) (return)) (push (%sent-ref sent idx field) values)) (when values (%sent-append sent ts (format nil "~A=~A" (escape-colon name) (escape-colon (join-strings (nreverse values) "|")))))))) (%sent-append sent 0 "__BOS__") (%sent-append sent -1 "__EOS__") sent) (defun read-parsed-conll (stream fields templates) (let ((sent (read-conll-sent stream fields))) (unless (eq sent :eof) (parse-conll-sent sent templates)) sent)) (defun write-conll-feats (istream fields label templates &optional (ostream t)) (do ((sent (read-parsed-conll istream fields templates) (read-parsed-conll istream fields templates))) ((eq sent :eof)) (dolist (cword sent) (format ostream "~A" (adict-ref cword label)) (dolist (feat (adict-ref cword *conll-word-feats*)) (format ostream "~A~A" #\Tab feat)) (format ostream "~%")) (format ostream "~%"))) (defun write-conll-chunk (istream &optional (ostream t)) (write-conll-feats istream *conll-2000-fields* *conll-chunk-label* *conll-chunk-templates* ostream))
4,258
Common Lisp
.lisp
109
33.192661
89
0.565175
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
67a90bf193ee0563831d226ef36ade5887f50d7672e1202b9a063f3c5c96006c
24,508
[ -1 ]
24,509
treebank.lisp
jnjcc_cl-nlp/corpora/treebank.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; NOTICE: Wall Street Journal treebank from NLTK ;;;; - wsj_0001.mrg: . and `..' and `...', etc ;;;; - wsj_0008.mrg: 's of "it's" ;;;; - wsj_0088.mrg: colon in `3:15' ;;;; - wsj_0118.mrg: `ADVP|PRT' ;;;; NOTICE: some other cases: ;;;; - wsj_0192.mrg: `377.60' reduced to `377.6' (in-package #:cl-nlp) ;;; Reader macros stuff (defvar *punctuations* '(#\, #\. #\; #\# #\' #\` #\: #\|)) (defun stringify (object) (etypecase object (list object) (t (format nil "~A" object)))) (defun read-next-object (stream) (let ((next (peek-non-space stream t nil))) (cond ((char= #\) next) (discard-next-char stream)) ((or (char= #\: next) (char= #\. next)) ;; NOTICE: for `:abc' and `...' (let ((chars (read-chars-until stream (lambda (x) (or (space-char-p x) (char= #\) x)))))) (join-strings chars ""))) (t (read stream t nil t))))) (defun read-left-bracket (stream char) (declare (ignore char)) (loop for object = (read-next-object stream) while object collect (stringify object) into objects finally (return objects))) (defmacro with-treebank-readtable ((readtable) &body body) `(let ((*readtable* (copy-readtable)) (,readtable nil)) (multiple-value-bind (afunc non-terminating-p) (get-macro-character #\a) (declare (ignore non-terminating-p)) (dolist (punct *punctuations*) ;; with `non-terminating-p' being t, we are allowed to read: ;; - `ADVP|PRT' or `A"B' or ''' ;; NOTICE: but _NOT_ for `3:15' and `..' (set-macro-character punct afunc t)) (set-macro-character #\( #'read-left-bracket) (setf (readtable-case *readtable*) :invert)) (setf ,readtable *readtable*) ,@body)) ;;; WSJ treebank 1: load treebank using reader macros (defun read-treebank-sexp (stream) "read one treebank sexp from `treebank/combined/wsj_0*.mrg'" (with-treebank-readtable (rtable) (read stream))) (defun load-treebank (stream) "load treebank sexps into a list" (with-treebank-readtable (rtable) (let ((treebank nil)) (do ((sexp (read stream nil :eof) (read stream nil :eof))) ((eq sexp :eof)) (push sexp treebank)) (nreverse treebank)))) (defun load-treebank-file (fpath) (with-open-file (fp fpath) (load-treebank fp))) ;;; WSJ treebank 2: treebank using search-and-replace (defun read-treebank-regex (fpath) (let* ((content (read-file-content fpath)) (seqs (split-string content #\Space))) (labels ((rewrite (word) ;; NOTICE: for `3:15', etc (replace-string-if word (lambda (ch) (char= ch #\:)) "\\:"))) (join-strings (mapcar #'rewrite seqs) #\Space)))) (defun load-treebank-regex (fpath) (let ((regex (read-treebank-regex fpath))) (with-input-from-string (stream regex) (load-treebank stream)))) ;; TODO: this is ugly in order to process `wsj_0088.mrg' and `wsj_0118.mrg' (defun load-treebank-dir (dir) "`dir' = `treebank/combined/'" (let ((treebank nil)) (setf dir (format nil "~A/wsj_*.mrg" dir)) (dolist (path (directory dir)) (if (or (search "wsj_0088.mrg" (file-namestring path)) (search "wsj_0118.mrg" (file-namestring path))) (setf treebank (append treebank (load-treebank-regex path))) (setf treebank (append treebank (load-treebank-file path))))) treebank)) (defun %parse-treebank-sexp (sexp tagged) (dolist (subtree sexp) (when (listp subtree) (if (and (= (length subtree) 2) (atom (first subtree)) (atom (second subtree))) (push (cons (second subtree) (first subtree)) tagged) (setf tagged (%parse-treebank-sexp subtree tagged))))) tagged) (defun parse-treebank-sexp (sexp) (let ((tagged nil)) (nreverse (%parse-treebank-sexp sexp tagged)))) (defun parse-treebank (treebank) (let ((tagged nil)) (dolist (sexp treebank) (push (parse-treebank-sexp sexp) tagged)) (nreverse tagged)))
4,086
Common Lisp
.lisp
101
35.118812
96
0.620403
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
09f514529747b5d5f879fbc6855b30494eb3277fa8d3c665ced22f67b10cf932
24,509
[ -1 ]
24,510
crfsuite.lisp
jnjcc_cl-nlp/corpora/crfsuite.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; CRFsuite data format for CRF training and tagging ;;;; (http://www.chokkan.org/software/crfsuite/manual.html) ;;;; ;;;; BNF notation representing the data format: ;;;; <line> ::= <item> | <eos> ;;;; <item> ::= <label> ('\t' <attribute>)+ <br> ;;;; <eos> ::= <br> ;;;; <label> ::= <string> ;;;; <attribute> ::= <name> | <name> ':' <scaling> ;;;; <name> ::= (<letter> | "\:" | "\\")+ ;;;; <scaling> ::= <numeric> ;;;; <br> ::= '\n' (in-package #:cl-nlp) ;;; CRFsuite jargons: ;;; - `label': label for an `item', e.g. "B-NP" ;;; - `token': `attr-name', or `attr-scale' ;;; - `attribute': attribute for an `item', i.e. (attr-name . attr-scale) ;;; - `item': label (possibly with word itself) and attributes, e.g. (("B-NP" "Confidence") attr attr ...) ;;; - `instance': a list of `item', (item item ...) ;;; - `dataset': a list of `instance', (instance instance ...) (defun read-crf-label (stream) (let ((chars nil)) (labels ((special (x) (or (char= x #\Tab) (char= x #\Newline)))) (do-char-until (chr stream #'special) (push chr chars))) (when chars (join-strings (nreverse chars) "")))) (defun read-crf-token (stream) "reads `attr-name', or `attr-scale'" (let ((chars nil)) (labels ((special (x) ;; colon has special meanings (or (char= x #\:) (char= x #\Tab) (char= x #\Newline)))) (do-char-until (chr stream #'special) (when (char= chr #\\) (let ((next (peek-next-char stream nil :eof))) ;; escaping #\\ and #\: (when (or (eq next #\\) (eq next #\:)) (setf chr (read-char stream))))) (push chr chars))) (when chars (join-strings (nreverse chars) "")))) (defun read-crf-attribute (stream) "reads (`attr-name' . `attr-scale') pair: if `attr-name' nil, we are reaching eof or end-of-item" (discard-chars-if stream (lambda (x) (char= x #\Tab))) (let ((next (peek-next-char stream nil :eof))) (when (or (eq next :eof) (eq next #\Newline)) (discard-next-char stream nil) (return-from read-crf-attribute (values nil nil)))) (let ((attr-name (read-crf-token stream)) (attr-scale 1.0) (next (peek-next-char stream nil :eof))) (when (eq next #\:) (setf attr-scale (read-from-string (read-crf-token stream)))) (values attr-name attr-scale))) (defun read-crf-item (stream &optional crfdata) "Returns: :eof if end-of-file; :eol if end-of-line; item otherwise; where `crfdata' being object of `crfsuite-dataset', or nil" (let ((next (peek-next-char stream nil :eof))) (cond ((eq next :eof) (return-from read-crf-item :eof)) ((eq next #\Newline) (progn (discard-next-char stream) (return-from read-crf-item :eol))))) ;; item = (("B-NP" ["Confidence"]) attr attr ...) (let ((item nil) (labl (read-crf-label stream))) (when crfdata (setf labl (crfdata-aget-lid crfdata labl))) (setf item (list (list labl))) ;; forever-loop (do () (nil) (multiple-value-bind (name scale) (read-crf-attribute stream) (when (null name) (return)) (when crfdata (setf name (crfdata-aget-aid crfdata name))) (push (cons name scale) item))) (nreverse item))) (defun read-crf-instance (stream &optional crfdata) "Returns :eof if no more instance; or list of items" ;; skip empty lines until the next instance (discard-chars-if stream (lambda (x) (char= x #\Newline))) (let ((inst nil) (eof-item nil)) (do ((item (read-crf-item stream crfdata) (read-crf-item stream crfdata))) ((eq item :eol)) (when (eq item :eof) (setf eof-item t) (return)) (push item inst)) (if (and eof-item (null inst)) :eof (nreverse inst)))) (defun read-crf-datalist (stream) "Returns: dataset as list" (let ((dataset nil)) (do ((inst (read-crf-instance stream) (read-crf-instance stream))) ((eq inst :eof)) (push inst dataset)) (nreverse dataset))) (defclass crfsuite-dataset () ((instances :initform nil :reader instances :documentation "list of training instances, with string replaced by index") (attr-bhdict :initform (make-bhdict) :documentation "attr-name <-> index") (labl-bhdict :initform (make-bhdict) :documentation "labl-name <-> idnex"))) (defmethod crfdata-aget-aid ((crfdata crfsuite-dataset) aname) "Returns: attr-idx `aid' for `aname' NOTICE: will add attr-name `aname' if not exist" (with-slots (attr-bhdict) crfdata (let ((aid (bhdict-ref attr-bhdict aname))) (unless aid (setf aid (bhdict-len attr-bhdict)) (bhdict-add attr-bhdict aname aid)) aid))) (defmethod crfdata-get-aid ((crfdata crfsuite-dataset) aname) (with-slots (attr-bhdict) crfdata (bhdict-ref attr-bhdict aname))) (defmethod crfdata-get-aname ((crfdata crfsuite-dataset) aid) (with-slots (attr-bhdict) crfdata (bhdict-bref attr-bhdict aid))) (defmethod crfdata-aget-lid ((crfdata crfsuite-dataset) labl) "Returns: label-idx `lid' for `labl' NOTICE: will add `labl' if not exists" (with-slots (labl-bhdict) crfdata (let ((lid (bhdict-ref labl-bhdict labl))) (unless lid (setf lid (bhdict-len labl-bhdict)) (bhdict-add labl-bhdict labl lid)) lid))) (defmethod crfdata-get-lid ((crfdata crfsuite-dataset) labl) (with-slots (labl-bhdict) crfdata (bhdict-ref labl-bhdict labl))) (defmethod crfdata-get-labl ((crfdata crfsuite-dataset) lid) (with-slots (labl-bhdict) crfdata (bhdict-bref labl-bhdict lid))) (defmethod crfdata-set-insts ((crfdata crfsuite-dataset) instlst) (with-slots (instances) crfdata (setf instances instlst))) (defun read-crf-dataset (stream) "Returns: dataset as object" (let ((crfdata (make-instance 'crfsuite-dataset)) (instlst nil)) (do ((inst (read-crf-instance stream crfdata) (read-crf-instance stream crfdata))) ((eq inst :eof)) (push inst instlst)) (crfdata-set-insts crfdata instlst) crfdata)) (defmacro do-crf-instance ((inst crfdata) &body body) `(dolist (,inst (instances ,crfdata)) ,@body)) (defmacro do-crf-item ((lid attrs inst) &body body) (let ((item (gensym "ITEM-"))) `(let ((,lid nil) (,attrs nil)) (dolist (,item ,inst) (setf ,lid (caar ,item)) (setf ,attrs (cdr ,item)) ,@body)))) (defmacro do-crf-attr ((aid scale attrs) &body body) (let ((attr (gensym "ATTR-"))) `(let ((,aid nil) (,scale nil)) (dolist (,attr ,attrs) (setf ,aid (car ,attr)) (setf ,scale (cdr ,attr)) ,@body))))
6,862
Common Lisp
.lisp
171
34.584795
108
0.605997
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
29dc5ce6baff2853ac2784e9e5681e0430108ab398bf704778296993fed13c77
24,510
[ -1 ]
24,511
conllt.lisp
jnjcc_cl-nlp/corpora/conllt.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; CoNLL-2000 Shared Task Chunking, for POS tagging (in-package #:cl-nlp) ;;; CoNLL-2000 Chunking (file format: word pos chunk) ;;; - `num': `w' full of digit; `cap': first letter uppercase; `sym': no alnum chars ;;; - `p3': prefix of `w', i.e. `w[0:3]'; `s3': suffix (defvar *conll-pos-fields* '("w" "pos" "chunk" "num" "cap" "sym" "p1" "p2" "p3" "p4" "s1" "s2" "s3" "s4")) (defvar *conll-pos-label* "pos") (defvar *conll-pos-templates* '( (("num" . 0)) (("cap" . 0)) (("sym" . 0)) (("p1" . 0)) (("p2" . 0)) (("p3" . 0)) (("p4" . 0)) (("s1" . 0)) (("s2" . 0)) (("s3" . 0)) (("s4" . 0)) (("w" . 0)) (("w" . -1)) (("w" . 1)) (("w" . -2)) (("w" . 2)) (("w" . -2) ("w" . -1)) (("w" . -1) ("w" . 0)) (("w" . 0) ("w" . 1)) (("w" . 1) ("w" . 2)) (("w" . -2) ("w" . -1) ("w" . 0)) (("w" . -1) ("w" . 0) ("w" . 1)) (("w" . 0) ("w" . 1) ("w" . 2)) (("w" . -2) ("w" . -1) ("w" . 0) ("w" . 1)) (("w" . -1) ("w" . 0) ("w" . 1) ("w" . 2)) (("w" . -2) ("w" . -1) ("w" . 0) ("w" . 1) ("w" . 2)) (("w" . 0) ("w" . -1)) (("w" . 0) ("w" . -2)) (("w" . 0) ("w" . -3)) (("w" . 0) ("w" . -4)) (("w" . 0) ("w" . -5)) (("w" . 0) ("w" . -6)) (("w" . 0) ("w" . -7)) (("w" . 0) ("w" . -8)) (("w" . 0) ("w" . -9)) (("w" . 0) ("w" . 1)) (("w" . 0) ("w" . 2)) (("w" . 0) ("w" . 3)) (("w" . 0) ("w" . 4)) (("w" . 0) ("w" . 5)) (("w" . 0) ("w" . 6)) (("w" . 0) ("w" . 7)) (("w" . 0) ("w" . 8)) (("w" . 0) ("w" . 9)) )) ;; NOTICE: tricky, not recommended: it is better to first preprocess the file (defun expand-cword-pos (cword) "`cword' being (word pos chunk), we need to expand in order the following feats: [num, cap, sym, p1, p2, p3, p4, s1, s2, s3, s4]" (let* ((word (car cword)) (wlen (length word)) (wfeat nil)) (labels ((sym-word-p (word) (every (lambda (chr) (not (alphanumericp chr))) word))) (dolist (fn (list #'digit-word-p #'title-word-p #'sym-word-p)) (if (funcall fn word) (push "1" wfeat) (push "0" wfeat)))) (loop for pf from 1 to 4 do (if (>= wlen pf) (push (subseq word 0 pf) wfeat) (push "" wfeat))) (loop for sf from 1 to 4 do (if (>= wlen sf) (push (subseq word (- wlen sf) wlen) wfeat) (push "" wfeat))) (append cword (nreverse wfeat)))) (defun write-conll-pos (istream &optional (ostream t)) (let ((*conll-line-expand* #'expand-cword-pos)) (write-conll-feats istream *conll-pos-fields* *conll-pos-label* *conll-pos-templates* ostream)))
2,848
Common Lisp
.lisp
83
28.698795
86
0.407475
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
8b1ca383c45532a39b75c3779aa7858ae9b5515285b254b0a064b49443e0fdcc
24,511
[ -1 ]
24,512
word.lisp
jnjcc_cl-nlp/segment/word.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; UTF-8 words (in-package #:cl-nlp)
112
Common Lisp
.lisp
4
26.75
66
0.654206
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
97717669b98eeebfc1abfb25bf40c5f9cb0e3ba882882d481af1e116456cd080
24,512
[ -1 ]
24,513
u8char.lisp
jnjcc_cl-nlp/segment/u8char.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; UTF-8 characters (in-package #:cl-nlp) (defun %segment-keep-alnum (u8str) (let ((chars nil) (len (length u8str)) ;; Finite state machine (state :empty) (beg 0) (chr nil)) (dotimes (i len) (setf chr (char u8str i)) (cond ((eq state :empty) (cond ((alpha-char-p chr) (setf state :alpha)) ((digit-char-p chr) (setf state :digit)) (t (setf state :u8char)))) ((eq state :alpha) (cond ((alpha-char-p chr) (setf state :alpha)) (t (progn (push (subseq u8str beg i) chars) (setf beg i) (if (digit-char-p chr) (setf state :digit) (setf state :u8char)))))) ((eq state :digit) (cond ((digit-char-p chr) (setf state :digit)) (t (progn (push (subseq u8str beg i) chars) (setf beg i) (if (alpha-char-p chr) (setf state :alpha) (setf state :u8char)))))) ((eq state :u8char) (progn (push (subseq u8str beg i) chars) (setf beg i) (cond ((alpha-char-p chr) (setf state :alpha)) ((digit-char-p chr) (setf state :digit)) (t (setf state :u8char))))))) (when (> len 0) (push (subseq u8str beg len) chars)) (nreverse chars))) (defun %segment-all-chars (u8str) (let ((chars nil) (len (length u8str))) (dotimes (i len) (push (subseq u8str i (+ i 1)) chars)) (nreverse chars))) (defun segment-chars (u8str &key (keep-alnum t)) (if keep-alnum (%segment-keep-alnum u8str) (%segment-all-chars u8str)))
1,856
Common Lisp
.lisp
58
22.258621
66
0.494426
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
c3cdd0af5e6d085b76b30151a7908025f50443126f1483fd7c1d99ee273ecdde
24,513
[ -1 ]
24,515
crftag.lisp
jnjcc_cl-nlp/postag/crftag.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; Conditional Random Fields Tagger (in-package #:cl-nlp) (defclass crf-tagger (pos-tagger crf-model) ()) (defmethod crf-tag-sent ((crf crf-tagger) sent) )
237
Common Lisp
.lisp
8
27.75
66
0.70354
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
fcbcc85e2be357686d24185f7c272926eb7f4c83b626b475e34d7e431aa5cc3c
24,515
[ -1 ]
24,516
tagger.lisp
jnjcc_cl-nlp/postag/tagger.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; Part-of-Speech tagging (in-package #:cl-nlp) ;;; observations: ;;; - sentence: (word word ...) ;;; - corpus: (sentence sentence ...) ;;; - tagged sentence: ((word . tag) ...) ;;; - tagged corpus: (tagsent tagsent ...) (defclass pos-tagger () ()) (defun untag-sentence (tagsent) "tagged sentence -> sentence" (mapcar #'car tagsent)) (defun tagsent-tags (tagsent) "tagged sentence -> tags" (mapcar #'cdr tagsent)) (defun untag-corpus (tagcorpus) (mapcar #'untag-sentence tagcorpus)) (defun flatten-tags (tagcorpus) (reduce #'append (mapcar #'tagsent-tags tagcorpus))) (defgeneric pos-tag-sent (pos sent) (:documentation "tag sentence `sent'")) (defmethod pos-tag-corpus ((pos pos-tagger) sents) (let ((tagged nil)) (dolist (sent sents) (push (pos-tag-sent pos sent) tagged)) (nreverse tagged))) (defun accuracy-tags (taglabl tagpred) (let ((acc 0) (num (length taglabl))) (dotimes (i num) (when (string= (nth i tagpred) (nth i taglabl)) (incf acc))) (float (/ acc num)))) (defmethod pos-evaluate ((pos pos-tagger) tagcorpus) (let* ((corpus (untag-corpus tagcorpus)) (pred (pos-tag-corpus pos corpus))) (let ((taglabl (flatten-tags tagcorpus)) (tagpred (flatten-tags pred))) (accuracy-tags tagpred taglabl))))
1,389
Common Lisp
.lisp
40
31.3
66
0.65646
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
84e427bc7ad920b87d01119fc3dc30608d12f14a51d906cff52cf380ef5bce0e
24,516
[ -1 ]
24,517
hmmtag.lisp
jnjcc_cl-nlp/postag/hmmtag.lisp
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; ;;;; Hidden Markov Model Tagger (in-package #:cl-nlp) (defclass hmm-tagger (pos-tagger hmm-model) ()) (defmethod pos-tag-sent ((hmm hmm-tagger) sent) (hmm-decode hmm sent))
252
Common Lisp
.lisp
8
29.625
66
0.701245
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2c4ca8798381beccb1a1a134d134df6614f0740afc0d6a013ac749049c2a5e7f
24,517
[ -1 ]
24,518
cl-nlp.asd
jnjcc_cl-nlp/cl-nlp.asd
;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved. ;;;; (asdf:defsystem #:cl-nlp :description "Natural Language Processing in Common Lisp" :version "0.1.0" :author "jnjcc at live.com" :licence "GPL" :depends-on (#:cl-ml) :serial t :components ((:module "algo" :components ((:file "packages") (:file "distance") (:file "dict") (:file "bidict") )) (:file "packages") (:module "corpora" :components ((:file "treebank") (:file "conllc") (:file "conllt") (:file "crfsuite") )) (:module "probs" :components ( ;; derived probability distribution from frequency distribution (:file "freqdist") (:file "binfreq") (:file "hashfreq") (:file "condfreq") (:file "derivdist") (:file "mutabledist") (:file "api"))) (:module "pgm" :components ((:file "hmm") (:file "crf") (:file "csgd") )) (:module "lm" :components ((:file "wfreq") (:file "ngram") (:file "idvocab") (:file "idngram") (:file "sorted") (:file "reduce") (:file "foftab") (:file "idinfo") (:file "idtree") (:file "discount") (:file "katz") (:file "backoff") (:file "idlm") (:file "arpa") (:file "lm") )) (:module "segment" :components ((:file "u8char") (:file "word") )) (:module "postag" :components ((:file "tagger") (:file "hmmtag") (:file "crftag") )) (:module "ner" :components ((:file "ner") )) (:module "embed" :components ((:file "vocab") (:file "word2vec") (:file "node2vec"))))) (asdf:defsystem #:cl-nlp-test :description "cl-nlp test suite" :version "0.1.0" :author "jnjcc at live.com" :licence "GPL" :depends-on (#:cl-nlp #:lisp-unit) :serial t :components ((:module "test" :components ((:file "packages") (:file "common") (:file "dataset") (:file "algo-test") (:file "lm-test") (:file "corpora-test") (:file "pgm-test") (:file "postag-test") (:file "word2vec-test") (:file "tests")))))
4,055
Common Lisp
.asd
88
19.034091
100
0.283228
jnjcc/cl-nlp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a624c830acab9648a450c04ffbd40a3ecc8a1dba907b8698683636faa2828384
24,518
[ -1 ]
24,589
sql.cl
Duraznos_sqlisp/sql.cl
(defvar *db* nil) (defun prompt-read (prompt) (format *query-io* "~a: " prompt) (force-output *query-io*) (read-line *query-io*)) (defun save-db (filename) (with-open-file (out filename :direction :output :if-exists :supersede) (with-standard-io-syntax (print *db* out)))) (defun load-db (filename) (with-open-file (in filename) (with-standard-io-syntax (setf *db* (read in))))) (defun select (selector-fn) (remove-if-not selector-fn *db*)) (defun delete-rows (selector-fn) (setf *db* (remove-if selector-fn *db*))) (defun make-comparison-expr (field value) `(equal (getf cd ,field) ,value)) (defun make-comparisons-list (fields) (loop while fields collecting (make-comparison-expr (pop fields) (pop fields)))) (defmacro where (&rest clauses) `#'(lambda (cd) (and ,@(make-comparisons-list clauses)))) (defun make-update-expr (field value) `(setf (getf row ,field) ,value)) (defun make-update-list (fields) (loop while fields collecting (make-update-expr (pop fields) (pop fields)))) (defmacro update (selector-fn &rest updates) `(setf *db* (mapcar #'(lambda (row) (when (funcall ,selector-fn row) ,@(make-update-list updates)) row) *db*)))
1,242
Common Lisp
.cl
38
29
66
0.67198
Duraznos/sqlisp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
51eebd74ea76699a63af2943c23785d7a9f75dfb7a8580923fc9bbc68a5a8478
24,589
[ -1 ]
24,590
repl.cl
Duraznos_sqlisp/repl.cl
(defparameter *x* (make-array 1024 :fill-pointer 0 :adjustable t :element-type 'character) "") (defun parse-query (query) (format *query-io* "~a~%" query) (force-output *query-io*)) (defun repl-loop () (let (line) (loop (setf line (read-line *query-io*)) (if (equal line "exit") (return) (parse-query line) )))) (defun input-test() (let (line) (setf line (read-line *query-io*)) (if (equal line "exit") "yay" "boo")))
456
Common Lisp
.cl
13
31.153846
94
0.621868
Duraznos/sqlisp
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
16bd2cb4183a1f4304195c96b5f9acc94133b7a6f69d9ced70cd1d166ad5b4e9
24,590
[ -1 ]
24,608
package.lisp
xFA25E_cl-posix-mqueue/src/package.lisp
(defpackage #:posix-mqueue (:documentation "POSIX message queue bindings.") (:use #:cl) (:import-from #:alexandria #:once-only #:starts-with #:when-let) (:import-from #:babel #:string-to-octets #:octets-to-string) (:import-from #:cffi #:defbitfield #:defcfun #:defcstruct #:defctype #:defcvar #:define-foreign-library #:define-foreign-type #:expand-from-foreign #:expand-to-foreign #:expand-to-foreign-dyn #:foreign-alloc #:foreign-bitfield-symbol-list #:foreign-free #:foreign-pointer #:free-translated-object #:mem-aref #:null-pointer #:null-pointer-p #:translate-from-foreign #:translate-to-foreign #:use-foreign-library #:with-foreign-object #:with-foreign-slots #:with-pointer-to-vector-data) (:import-from #:local-time #:now #:nsec-of #:timestamp #:timestamp-to-unix) (:export ;; types #:open-flags #:open-flagsp #:create-modes #:create-modesp ;; queue #:buffer #:queue #:attributes #:non-blocking-p #:current-messages #:max-messages #:message-size ;; condition #:out-of-memory #:file-exists #:file-table-overflow #:too-many-open-files #:no-space-left-on-device #:name-too-long #:interrupted-system-call #:no-file-or-directory-just-slash #:no-file-or-directory-no-create #:no-file-or-directory-on-unlink #:bad-file-descriptor-invalid #:bad-file-descriptor-on-receive #:bad-file-descriptor-on-send #:access-denied-permission #:access-denied-slashes #:access-denied-on-unlink #:invalid-argument-name #:invalid-argument-sizes #:invalid-argument-attributes #:invalid-argument-on-unlink #:invalid-argument-on-send-receive #:message-too-long-on-receive #:message-too-long-on-send ;; lib #:*retry-on-interrupt-p* #:default-sizes #:close-queue #:open-queue #:receive #:receive-buffer #:receive-displaced #:receive-string #:send #:send-string #:timed-receive #:timed-receive-buffer #:timed-receive-displaced #:timed-receive-string #:timed-send #:timed-send-string #:unlink #:with-open-queue #:set-non-blocking))
2,478
Common Lisp
.lisp
89
20.449438
77
0.59481
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
f7d67408e436771ccd997c80b35a6b93ffda9e8600fa1a91db4dd63659360fba
24,608
[ -1 ]
24,609
types.lisp
xFA25E_cl-posix-mqueue/src/types.lisp
(in-package #:posix-mqueue) (defctype time-t :long "Type used to describe seconds since unix epoch") (define-foreign-type mqd-type () () (:actual-type :int) (:simple-parser mqd) (:documentation "Type used to describe POSIX message queue file descriptor. Also, there are translations defined for this type (:int) from QUEUE class.")) (define-foreign-type result-type () () (:actual-type :int) (:simple-parser result) (:documentation "Type used to describe C-style result of functions. There is a translation that maps -1 to keyword representation of the error through the errno.")) (define-foreign-type mq-size-attr-type () () (:actual-type :pointer) (:simple-parser mq-size-attr-t) (:documentation "Type used to pass ATTRIBUTES as C-function argument. Translation maps ATTRIBUTES to MQ-ATTR CStruct.")) (define-foreign-type mq-non-blocking-attr-type () () (:actual-type :pointer) (:simple-parser mq-non-blocking-attr-t) (:documentation "Type used to get attributes through a pointer. To fill a CStruct through a pointer passed to function. Translation for this type does exactly this, at the end of the function call, it fills Lisp class with values from MQ-ATTR.")) (define-foreign-type timespec-type () () (:actual-type :pointer) (:simple-parser timespec-t) (:documentation "Type used to pass LOCAL-TIME:TIMESTAMP as C timespec.")) (defbitfield oflag "OPEN-FLAGS bitfield, used at opening (or creating) a queue with MAKE." (:read-only #o0) (:write-only #o1) (:read-write #o2) (:close-on-exec #o2000000) (:create #o100) (:exclusive #o200) (:non-blocking #o4000)) (defbitfield mode "MODE bitfield, used at queue creation." (:user-write #o200) (:user-read #o400) (:group-write #o020) (:group-read #o040) (:other-write #o002) (:other-read #o004)) (defbitfield (mq-flags :long) "Flag used in ATTRIBUTES when retrieving queue attributes with mq-getattr." (:non-blocking #o4000)) (defcstruct mq-attr "CStruct with POSIX message queue attributes. MQ-FLAGS can only contain a non-blocking flag." (mq-flags mq-flags) (mq-maxmsg :long) (mq-msgsize :long) (mq-curmsgs :long)) (defcstruct timespec "Timespec CStruct that specifies time in seconds and nanosecands." (tv-sec time-t) (tv-nsec :long)) (defun open-flagsp (thing) "Check if THING is a list and contains only OFLAGs. Also, check for conflicting flags." (let ((all-flags (cons :read-only (foreign-bitfield-symbol-list 'oflag))) (conflicting-flags '(:read-only :write-only :read-write))) (and (listp thing) (null (set-difference thing all-flags)) (= 1 (count conflicting-flags thing :test (lambda (a b) (member b a))))))) (deftype open-flags () "Type used to describe OPEN-FLAGS in OPEN-QUEUE." '(and list (satisfies open-flagsp))) (defun create-modesp (thing) "Check if THING is a list and contains only MODEs." (let ((modes (foreign-bitfield-symbol-list 'mode))) (and (listp thing) (null (set-difference thing modes))))) (deftype create-modes () "Type used to describe CREATE-MODES in OPEN-QUEUE." '(and list (satisfies create-modesp)))
3,186
Common Lisp
.lisp
85
34.517647
83
0.714193
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2e3401bb6252f7ac7626028d0a06af95c091a58d1d25dc683b708970bfc34fbf
24,609
[ -1 ]
24,610
queue.lisp
xFA25E_cl-posix-mqueue/src/queue.lisp
(in-package #:posix-mqueue) (defclass queue () ((mqd :reader mqd :initarg :mqd :type (unsigned-byte 32) :documentation "Message queue's file descriptor.") (buffer :reader buffer :initarg :buffer :type (array (unsigned-byte 8)) :documentation "Buffer used to receive messages form queue.")) (:documentation "Main type used to interact with POSIX message queues. It contains a queue's file descriptor (MQD) and a BUFFER used to receive messages.")) (defclass attributes () ((non-blocking-p :reader non-blocking-p :initarg :non-blocking-p :type boolean :documentation "Whether the receive/send operations would block") (max-messages :reader max-messages :initarg :max-messages :type (unsigned-byte 64) :documentation "Max possible number of messages.") (message-size :reader message-size :initarg :message-size :type (unsigned-byte 64) :documentation "Message size.") (current-messages :reader current-messages :initarg :current-messages :type (unsigned-byte 64) :documentation "Number of messages currently on queue.")) (:documentation "POSIX message queue attributes."))
1,372
Common Lisp
.lisp
31
33.516129
84
0.61435
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
70798101dd8358fbf4472b3c15bb18bb7c091424e6441f98d1c9bc91b29daa07
24,610
[ -1 ]
24,611
translation.lisp
xFA25E_cl-posix-mqueue/src/translation.lisp
(in-package #:posix-mqueue) (defcvar "errno" :int "Global C variable used to get errors of functions.") (defmethod expand-from-foreign (result (type result-type)) "If CFFI function returns -1, then return keyword representation of error code, otherwise, return CFFI function's returned value." (once-only (result) `(if (= -1 ,result) (ecase *errno* (2 :no-file-or-directory) ; ENOENT (4 :interrupted-system-call) ; EINTR (9 :bad-file-descriptor) ; EBADF (11 :try-again) ; EAGAIN (12 :out-of-memory) ; ENOMEM (13 :access-denied) ; EACCES (17 :file-exists) ; EEXIST (22 :invalid-argument) ; EINVAL (23 :file-table-overflow) ; ENFILE (24 :too-many-open-files) ; EMFILE (28 :no-space-left-on-device) ; ENOSPC (36 :name-too-long) ; ENAMETOOLONG (90 :message-too-long) ; EMSGSIZE (110 :connection-timed-out)) ; ETIMEDOUT ,result))) (defmethod expand-to-foreign-dyn (value var body (type timespec-type)) "VALUE is a LOCAL-TIME:TIMESTAMP. Translate VALUE to MQ-TIMESPEC dynamically. On some implementations the value can be allocated on stack." `(with-foreign-object (,var '(:struct timespec)) (with-foreign-slots ((tv-sec tv-nsec) ,var (:struct timespec)) (setf tv-sec (timestamp-to-unix ,value) tv-nsec (nsec-of ,value))) ,@body)) (defmethod expand-to-foreign-dyn (value var body (type mq-size-attr-type)) "Translate VALUE to MQ-ATTR dynamically. On some implementations the value can be allocated on stack. VALUE is a CONS of (MAX-MESSAGES . MESSAGE-SIZE) or NIL. Used in OPEN-QUEUE." `(if ,value (with-foreign-object (,var '(:struct mq-attr)) (with-foreign-slots ((mq-maxmsg mq-msgsize) ,var (:struct mq-attr)) (setf mq-maxmsg (car ,value) mq-msgsize (cdr ,value))) ,@body) (let ((,var (null-pointer))) ,@body))) (defmethod expand-to-foreign-dyn (value var body (type mq-non-blocking-attr-type)) "Translate NON-BLOCKING-P to MQ-ATTR dynamically. On some implementations the value can be allocated on stack. It only sets MQ-FLAGS of MQ-ATTR since the other fields are ignoret in the struct. Used in SET-NON-BLOCKING." `(with-foreign-object (,var '(:struct mq-attr)) (with-foreign-slots ((mq-flags) ,var (:struct mq-attr)) (setf mq-flags (when ,value '(:non-blocking)))) ,@body)) (defmethod expand-to-foreign (queue (type mqd-type)) "This one is used to extract queue file descriptor from queue object." `(typecase ,queue (queue (mqd ,queue)) (t ,queue)))
2,751
Common Lisp
.lisp
54
44.425926
90
0.633222
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
742db7246933e1df0e69f5b258b56571c4fd8deea7810dd6d344f23f71e82123
24,611
[ -1 ]
24,612
spec.lisp
xFA25E_cl-posix-mqueue/src/spec.lisp
(in-package #:posix-mqueue) (define-foreign-library lib-rt (:unix (:or "librt.so" "librt.so.1")) (t (:default "librt.so"))) (use-foreign-library lib-rt) (defcfun "mq_open" result "Open POSIX message queue. See mq_open(3) for more details." (name :string) (oflag oflag) (mode mode) (attr mq-size-attr-t)) (defcfun "mq_close" result "Close POSIX message queue. See mq_close(3) for more details." (mqdes mqd)) (defcfun ("mq_getattr" mq-getattr) result "Get POSIX message queue default attributes. See mq_getattr(3)." (mqdes mqd) (attr (:pointer (:struct mq-attr)))) (defcfun "mq_setattr" result "Set POSIX message queue non-blocking attribute. See mq_setattr(3) for more details." (mqdes mqd) (newattr mq-non-blocking-attr-t) (oldattr (:pointer (:struct mq-attr)))) (defcfun "mq_unlink" result "Unlink POSIX message queue. See mq_unlink(3) for more details." (name :string)) (defcfun "mq_receive" result "Receive a message from POSIX message queue. See mq_receive(3) for more details." (mqdes mqd) (msg-ptr (:pointer :char)) (msg-len :ulong) (msg-prio (:pointer :uint))) (defcfun "mq_timedreceive" result "Receive a message from POSIX message queue. See mq_timedreceive(3) for more details." (mqdes mqd) (msg-ptr (:pointer :char)) (msg-len :ulong) (msg-prio (:pointer :uint)) (abs-timeout timespec-t)) (defcfun "mq_send" result "Send a message to POSIX message queue. See mq_send(3) for more details." (mqdes mqd) (msg-ptr (:pointer :char)) (msg-len :ulong) (msg-prio :uint)) (defcfun "mq_timedsend" result "Send a message to POSIX message queue. See mq_timedsend(3) for more details." (mqdes mqd) (msg-ptr (:pointer :char)) (msg-len :ulong) (msg-prio :uint) (abs-timeout timespec-t))
1,782
Common Lisp
.lisp
56
29.196429
79
0.701458
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
ee59c894e4f0ab6b44a3acc3fb08f731889e267850d7bce3ec803a658c0fc6f8
24,612
[ -1 ]
24,613
posix-mqueue.lisp
xFA25E_cl-posix-mqueue/src/posix-mqueue.lisp
(in-package #:posix-mqueue) (defvar *retry-on-interrupt-p* t "Whether or not to retry send/receive operation on interrupt.") (defun random-queue-name (&key (length 25) (start 97) (end 123)) "Generate random queue name with specified LENGTH, with characters starting from START to END. With slash at the beginning." (check-type length (integer 1)) (let ((result (make-string (+ 1 length)))) (setf (aref result 0) #\/) (loop :for i :from 1 :to length :for generated-char = (code-char (+ start (random (- end start)))) :do (setf (aref result i) generated-char)) result)) (defun default-sizes () "Return default sizes of a queue in a form (MAX-MESSAGES . MESSAGE-SIZE). This is done by creating a queue with a random name and by extracting its attributes. By using a 255 length name, we protect ourselves from name collision." (handler-case (let* ((name (random-queue-name :length 255)) (mqd (mq-open name '(:read-only :create :exclusive) '(:user-read :user-write) nil))) (unwind-protect (progn (check-type mqd (signed-byte 32)) (with-foreign-object (cattrs '(:struct mq-attr)) (mq-getattr mqd cattrs) (with-foreign-slots ((mq-maxmsg mq-msgsize) cattrs (:struct mq-attr)) (cons mq-maxmsg mq-msgsize)))) (ignore-errors (mq-unlink name) (mq-close mqd)))) (file-exists (c) (declare (ignore c)) (default-sizes)))) (defun open-queue (name &key (open-flags '(:read-only)) (create-modes '(:user-read :user-write)) max-messages message-size) "Create a new POSIX message queue or open an existing queue. NAME is a string that identifies a queue. It MUST start with a slash (\"/\") and MUST NOT contain other slashes. Example: \"/myqueue\". OPEN-FLAGS is a list of flags that control the operation of queue. Exactly one of the following must be specified in OPEN-FLAGS: :read-only Open the queue to receive messages only. :write-only Open the queue to send messages only. :read-write Open the queue to both send and receive messages. Zero or more of the following flags: :close-on-exec Set the close-on-exec flag for the message queue descriptor. See open(2) for a discussion of why this flag is useful. :create Create the message queue if it does not exist. The owner (user ID) of the message queue is set to the effective user ID of the calling process. The group ownership (group ID) is set to the effective group ID of the calling process. :exclusive If :create was specified in OPEN-FLAGS, and a queue with the given name already exists, then fail signaling FILE-EXISTS condition. :non-blocking Open the queue in nonblocking mode. In circumstances where RECEIVE and SEND operations would normally block, these operations will return :try-again instead. If :create is specified in OPEN-FLAGS, then three additional arguments can be supplied. The MODE argument specifies the permissions to be placed on the new queue. It is a list of the following possible flags: :user-read :user-write :group-read :group-write :other-read :other-read In addition, MAX-MESSAGES and MESSAGE-SIZE specify the maximum number of messages and the maximum size of messages that the queue will allow. Usually, they default to their maximum values, 10 and 8192 respectively, but these values can be changes through /proc/sys/fs/mqueue/ interface. They must be provided in pair, as in the mq_open(3), but DEFAULT-SIZES function is provided to get default sizes of a queue. This function can signal the following conditions: ACCESS-DENIED-PERMISSION The queue exists, but the caller does not have permission to open it in the specified mode. ACCESS-DENIED-SLASHES NAME contained more than one slash. FILE-EXISTS Both :create and :exclusive were specified in OPEN-FLAGS, but a queue with this NAME already exists. INVALID-ARGUMENT-NAME NAME doesn't follow the format described in mq_overview(7). INVALID-ARGUMENT-SIZES :create was specified in OPEN-FLAGS, but MAX-MESSAGES or MESSAGE-SIZE were invalid. Both of these fields must be greater than zero. In a process that is unprivileged (does not have the CAP_SYS_RESOURCE capability), MAX-MESSAGES must be less than or equal to the msg_max limit, and MESSAGE-SIZE must be less than or equal to the msgsize_max limit. In addition, even in a privileged process, MAX-MESSAGES cannot exceed the HARD_MAX limit. (See mq_overview(7) for details of these limits.). Both of these limits can be changed through the /proc/sys/fs/mqueue/ interface. TOO-MANY-OPEN-FILES The per-process limit on the number of open file and message queue descriptors has been reached (see the description of RLIMIT_NOFILE in getrlimit(2)). NAME-TOO-LONG NAME was too long. FILE-TABLE-OVERFLOW The system-wide limit on the total number of open files and message queues has been reached. NO-FILE-OR-DIRECTORY-JUST-SLASH NAME was just \"/\" followed by no other characters. NO-FILE-OR-DIRECTORY-NO-CREATE The :create flag was not specified in OPEN-FLAGS, and no queue with this NAME exists. OUT-OF-MEMORY Insufficient memory. NO-SPACE-LEFT-ON-DEVICE Insufficient space for the creation of a new message queue. This probably occurred because the queues_max limit was encountered; see mq_overview(7). SIMPLE-ERROR This one can be signalled if the OPEN-FLAGS or the MODE are invalid. BAD-FILE-DESCRIPTOR The message queue file descriptor (MQD) is invalid. This is an internal error that should not happen, it is mainly for the writer of this library." (check-type open-flags open-flags) (check-type create-modes create-modes) (assert (or (and max-messages message-size) (not (or max-messages message-size)))) (check-type max-messages (or null (integer 1 4294967295))) (check-type message-size (or null (integer 1 4294967295))) (let* ((sizes (when (and max-messages message-size) (cons max-messages message-size))) (mqd (mq-open name open-flags create-modes sizes))) (case mqd (:access-denied (if (= 1 (count #\/ name)) (error 'access-denied-permission) (error 'access-denied-slashes))) (:file-exists (error 'file-exists)) (:invalid-argument (if (starts-with #\/ name) (error 'invalid-argument-sizes) (error 'invalid-argument-name))) (:too-many-open-files (error 'too-many-open-files)) (:name-too-long (error 'name-too-long)) (:file-table-overflow (error 'file-table-overflow)) (:no-file-or-directory (if (string= name "/") (error 'no-file-or-directory-just-slash) (error 'no-file-or-directory-no-create))) (:out-of-memory (error 'out-of-memory)) (:no-space-left-on-device (error 'no-space-left-on-device)) (t (let ((buffer-size (with-foreign-object (cattrs '(:struct mq-attr)) (mq-getattr mqd cattrs) (cffi:foreign-slot-value cattrs '(:struct mq-attr) 'mq-msgsize)))) (make-instance 'queue :mqd mqd :buffer (make-array buffer-size :element-type '(unsigned-byte 8)))))))) (defun unlink (name) "Remove the specified message queue NAME. The message queue NAME is removed immediately. The queue itself is destroyed once any other processes that have the queue open close their descriptors referring to the queue. Conditions: ACCESS-DENIED-ON-UNLINK The caller does not have permission to unlink this message queue. NAME-TOO-LONG NAME was too long. NO-FILE-OR-DIRECTORY-ON-UNLINK There is no message queue with the given NAME." (ecase (mq-unlink name) (:access-denied (error 'access-denied-on-unlink)) (:name-too-long (error 'name-too-long)) (:no-file-or-directory (error 'no-file-or-directory-on-unlink)) (0 nil))) (defun close-queue (queue) "Close the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid." (ecase (mq-close queue) (:bad-file-descriptor (error 'bad-file-descriptor-invalid)) (0 nil))) (defun attributes (queue) "Retrieve attributes of the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid." (with-foreign-object (cattrs '(:struct mq-attr)) (ecase (mq-getattr queue cattrs) (:bad-file-descriptor (error 'bad-file-descriptor-invalid)) (0 (with-foreign-slots ((mq-flags mq-maxmsg mq-msgsize mq-curmsgs) cattrs (:struct mq-attr)) (make-instance 'attributes :non-blocking-p (when mq-flags t) :max-messages mq-maxmsg :message-size mq-msgsize :current-messages mq-curmsgs)))))) (defun set-non-blocking (queue non-blocking-p) "Modify NON-BLOCKING-P attribute of the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid. INVALID-ARGUMENT-ATTRIBUTES mq-flags contained flags other than :non-blocking. This is an internal error that should not happen, it is mainly for the writer of this library." (ecase (mq-setattr queue non-blocking-p (cffi:null-pointer)) (:bad-file-descriptor (error 'bad-file-descriptor-invalid)) (:invalid-argument (error 'invalid-argument-attributes)) (0 non-blocking-p))) (defmacro %receive (receive-fn current-fn return-form &rest current-fn-args) "Macro used for generating various receive functions. RECEIVE-FN is a function called to receive a message. CURRENT-FN is a function which will be called on interrupt. RETURN-FORM is a form placed at the end of the macro. It has access to BUFFER, LENGTH (of received message) and PRIORITY (of received message). CURRENT-FN-ARGS are additional arguments placed at the end of RECEIVE-FN and CURRENT-FN." `(let ((buffer (buffer queue))) (with-foreign-object (priority :uint) (let ((length (with-pointer-to-vector-data (ptr buffer) (,receive-fn queue ptr (length buffer) priority ,@current-fn-args)))) (case length (:connection-timed-out :connection-timed-out) (:try-again :try-again) (:invalid-argument (error 'invalid-argument-on-send-receive)) (:message-too-long (error 'message-too-long-on-receive)) (:bad-file-descriptor (error 'bad-file-descriptor-on-receive)) (:interrupted-system-call (if *retry-on-interrupt-p* (,current-fn queue ,@current-fn-args) (restart-case (error 'interrupted-system-call) (retry-on-interrupt () :report "Call to receive was interrupted. Retry the call." (,current-fn queue ,@current-fn-args))))) (t ,return-form)))))) (defun receive (queue) "Remove the oldest message with the highest priority from the message QUEUE and return it as '(ARRAY (UNSIGNED-BYTE 8)). Return the priority associated with the received message as second value. Return the message LENGTH as a third value. Message length could be less than the returned BUFFER length. In fact, this is the same buffer used internally in queue to receive all messages. This function is provided for better control of the message data. Most library users would like to use RECEIVE-STRING, or RECEIVE-BUFFER, or RECEIVE-DISPLACED, instead. If the queue is empty, then, by default, RECEIVE blocks until a message becomes available, or the call is interrupted by a signal handler. If the :non-blocking OPEN-FLAG is enabled for the message queue, then the call instead returns immediately with :try-again. Conditions: BAD-FILE-DESCRIPTOR-INVALID The file descriptor specified MQD was invalid or not opened for reading. INTERRUPTED-SYSTEM-CALL The call was interrupted by a signal handler; see signal(7). MESSAGE-TOO-LONG-ON-RECEIVE Message length was less than the :message-size attribute of the message queue. This is an intarnal error that should not happen, it is mainly for the writer of this library. Restarts: RETRY-ON-INTERRUPT If the call was interrupted by a signal handler, you can restart the call." (%receive mq-receive receive (values buffer (mem-aref priority :uint) length))) (defun receive-buffer (queue) "Behaves just luke RECEIVE, except that it creates a new buffer with ONLY message data." (%receive mq-receive receive-buffer (values (subseq buffer 0 length) (mem-aref priority :uint)))) (defun receive-string (queue) "Behaves just like RECEIVE, except that it tries to convert received message to string." (%receive mq-receive receive-string (values (octets-to-string buffer :end length) (mem-aref priority :uint)))) (defun receive-displaced (queue) "Behaves just like RECEIVE, except that it tries to return a displaced array from internal buffer. You should not use it in a thread, unless protected by a lock." (%receive mq-receive receive-displaced (values (make-array length :element-type '(unsigned-byte 8) :displaced-to buffer) (mem-aref priority :uint)))) (defun timed-receive (queue timestamp) "Behaves just like RECEIVE, except that if the queue is empty and the :non-blocking OPEN-FLAG is not enabled for the message queue, then the TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute, not relative. If no message is available, and the timeout has already expired by the time of the call, TIMED-RECEIVE returns immediately with :connection-timed-out. Look LOCAL-TIME package for more information on timestamps. Additional conditions: INVALID-ARGUMENT-ON-SEND-RECEIVE The call would have blocked, and timeout arguments were invalid, either because :sec was less than zero, or because :nsec was less than zero or greater than 1000 million." (check-type timestamp timestamp) (%receive mq-timedreceive timed-receive (values buffer (mem-aref priority :uint) length) timestamp)) (defun timed-receive-buffer (queue timestamp) "Behaves just like TIMED-RECEIVE, except that it creates a new buffer with ONLY message data." (check-type timestamp timestamp) (%receive mq-timedreceive timed-receive-buffer (values (subseq buffer 0 length) (mem-aref priority :uint)) timestamp)) (defun timed-receive-string (queue timestamp) "Behaves just like TIMED-RECEIVE, except that it tries to convert received message to string." (check-type timestamp timestamp) (%receive mq-timedreceive timed-receive-string (values (octets-to-string buffer :end length) (mem-aref priority :uint)) timestamp)) (defun timed-receive-displaced (queue timestamp) "Behaves just like TIMED-RECEIVE, except that it tries to return a displaced array from internal buffer. You should not use it in a thread, unless protected by a lock." (check-type timestamp timestamp) (%receive mq-timedreceive timed-receive-displaced (values (make-array length :element-type '(unsigned-byte 8) :displaced-to buffer) (mem-aref priority :uint)) timestamp)) (defmacro %send (send-fn current-fn &rest send-fn-args) "A macro used to generate send functions. SEND-FN is a function used to send the actual message. CURRENT-FN is a function which is called on interrupt. SEND-FN-ARGS are additional arguments placed at the end of SEND-FN and CURRENT-FN call." `(ecase (with-pointer-to-vector-data (ptr message-buffer) (,send-fn queue ptr length priority ,@send-fn-args)) (:connection-timed-out :connection-timed-out) (:try-again :try-again) (:invalid-argument (error 'invalid-argument-on-send-receive)) (:message-too-long (error 'message-too-long-on-send)) (:bad-file-descriptor (error 'bad-file-descriptor-on-send)) (:interrupted-system-call (if *retry-on-interrupt-p* (,current-fn queue message-buffer priority ,@send-fn-args length) (restart-case (error 'interrupted-system-call) (retry-on-interrupt () :report "Call to send was interrupted. Retry the call." (,current-fn queue message-buffer priority ,@send-fn-args length))))) (0 nil))) (defun send (queue message-buffer priority &optional (length (length message-buffer))) "Adds the MESSAGE-BUFFER to the message QUEUE. MESSAGE-BUFFER length must be less than or equal to the QUEUE's :message-size attribute. Zero-length messages are allowed. MESSAGE-BUFFER must be an '(array (unsigned-byte 8)). Additional LENGTH argument can be provided to limit the message being sent. By default, it is equal to MESSAGE-BUFFER length. The PRIORITY argument is a nonnegative integer that specifies the priority of new message. Messages are placed on the QUEUE in decreasing order of priority, with newer messages of the same priority being placed after older messages with the same priority. See mq_overview(7) for details on the range for the message priority. If the message QUEUE is already full (i.e., the number of messages on the QUEUE equals the QUEUE's :max-messages attribute), then, by default, SEND blocks until sufficient space becomes available to allow the message to be queued, or until the call is interrupted by a signal handler. If the :non-blocking flag is enabled for the message QUEUE, then the call instead returns :try-again. Note: if you don't want to create a new buffer for sending to save space, you can reuse QUEUE's buffer. Use BUFFER function on a QUEUE to get it. Remember, that its data will be overwritten on next receive call. Conditions: BAD-FILE-DESCRIPTOR-ON-SEND The file descriptor specified MQD was invalid or not opened for writing. INTERRUPTED-SYSTEM-CALL The call was interrupted by a signal handler; see signal(7). MESSAGE-TOO-LONG-ON-SEND MESSAGE length was greater than the :message-size attribute of the message QUEUE. Restarts: RETRY-ON-INTERRUPT If the call was interrupted by a signal handler, you can restart the call." (%send mq-send send)) (defun send-string (queue message-string priority) "Behaves just like SEND, except that it sends a string, not an '(array (unsigned-byte 8)) " (send queue (string-to-octets message-string) priority)) (defun timed-send (queue message-buffer priority timestamp &optional (length (length message-buffer))) "Behaves just like SEND, except that if the QUEUE is full and the :non-blocking flag is not enabled for the message queue, then TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute, not relative. If the message queue is full, and the timeout has already expired by the time of the call, TIMED-SEND returns immediately with :connection-timed-out. Look LOCAL-TIME package for more information on timestamps." (check-type timestamp timestamp) (%send mq-timedsend timed-send timestamp)) (defun timed-send-string (queue message-string priority timestamp) "Behaves just like TIMED-SEND, except that it sends a string, not an '(array (unsigned-byte 8)) " (timed-send queue (string-to-octets message-string) priority timestamp)) (defmacro with-open-queue ((var name &rest options) &body body) "A macro that automatically closes opened queue, even when condition is signaled. For OPTIONS see OPEN-QUEUE. Example: (with-open-queue (mqueue \"/myqueue\" :open-flags '(:read-write :create)) (do-something-with mqueue))" `(let ((,var (open-queue ,name ,@options))) (unwind-protect (progn ,@body) (close-queue ,var))))
20,006
Common Lisp
.lisp
399
44.60401
102
0.718957
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
77b6bbac6dd62b5f22ffa7b4fe65441dad43ad5e7ed5bb36ba497a0d3d53e4fd
24,613
[ -1 ]
24,614
condition.lisp
xFA25E_cl-posix-mqueue/src/condition.lisp
(in-package #:posix-mqueue) (define-condition generic (error) ((strerror :reader strerror :initarg :strerror :type string :documentation "Error string from CFFI's strerror.") (message :reader message :initarg :message :type string :documentation "More specific message string.")) (:report (lambda (condition stream) (format stream "~A.~&~A" (strerror condition) (message condition)))) (:documentation "Generic error used as the base for all conditions. Must contain STRERROR and MESSAGE.")) (define-condition out-of-memory (generic) () (:default-initargs :strerror "Cannot allocate memory" :message "Insufficient memory.")) (define-condition file-exists (generic) () (:default-initargs :strerror "File exists" :message "Both :create and :exclusive were specified in OPEN-FLAGS, but a queue with this NAME already exists.")) (define-condition file-table-overflow (generic) () (:default-initargs :strerror "Too many open files in system" :message "The system-wide limit on the total number of open files and message queues has been reached.")) (define-condition too-many-open-files (generic) () (:default-initargs :strerror "Too many open files" :message "The per-process limit on the number of open file and message queue descriptors has been reached (see the description of RLIMIT_NOFILE in getrlimit(2)).")) (define-condition no-space-left-on-device (generic) () (:default-initargs :strerror "No space left on device" :message "Insufficient space for the creation of a new message queue. This probably occurred because the queues_max limit was encountered; see mq_overview(7).")) (define-condition name-too-long (generic) () (:default-initargs :strerror "File name too long" :message "NAME was too long.")) (define-condition interrupted-system-call (generic) () (:default-initargs :strerror "Interrupted system call" :message "The call was interrupted by a signal handler; see signal(7).")) (define-condition no-file-or-directory (generic) () (:default-initargs :strerror "No such file or directory")) (define-condition no-file-or-directory-just-slash (no-file-or-directory) () (:default-initargs :message "NAME was just \"/\" followed by no other characters.")) (define-condition no-file-or-directory-no-create (no-file-or-directory) () (:default-initargs :message "The :create flag was not specified in OPEN-FLAGS, and no queue with this NAME exists.")) (define-condition no-file-or-directory-on-unlink (no-file-or-directory) () (:default-initargs :message "There is no message queue with the given NAME.")) (define-condition bad-file-descriptor (generic) () (:default-initargs :strerror "Bad file descriptor")) (define-condition bad-file-descriptor-invalid (bad-file-descriptor) () (:default-initargs :message "The message queue file descriptor (MQD) is invalid.")) (define-condition bad-file-descriptor-on-receive (bad-file-descriptor) () (:default-initargs :message "The file descriptor specified MQD was invalid or not opened for reading.")) (define-condition bad-file-descriptor-on-send (bad-file-descriptor) () (:default-initargs :message "The file descriptor specified MQD was invalid or not opened for writing.")) (define-condition access-denied (generic) () (:default-initargs :strerror "Permission denied")) (define-condition access-denied-permission (access-denied) () (:default-initargs :message "The queue exists, but the caller does not have permission to open it in the specified mode.")) (define-condition access-denied-slashes (access-denied) () (:default-initargs :message "NAME contained more than one slash.")) (define-condition access-denied-on-unlink (access-denied) () (:default-initargs :message "The caller does not have permission to unlink this message queue.")) (define-condition invalid-argument (generic) () (:default-initargs :strerror "Invalid argument")) (define-condition invalid-argument-name (invalid-argument) () (:default-initargs :message "NAME doesn't follow the format described in mq_overview(7).")) (define-condition invalid-argument-sizes (invalid-argument) () (:default-initargs :message ":create was specified in OPEN-FLAGS, but MAX-MESSAGES or MESSAGE-SIZE was invalid. Both of these fields must be greater than zero. In a process that is unprivileged (does not have the CAP_SYS_RESOURCE capability), MAX-MESSAGES must be less than or equal to the msg_max limit, and MESSAGE-SIZE must be less than or equal to the msgsize_max limit. In addition, even in a privileged process, :max-messages cannot exceed the HARD_MAX limit. (See mq_overview(7) for details of these limits.). Both of these limits can be changed through the /proc/sys/fs/mqueue/ interface.")) (define-condition invalid-argument-attributes (invalid-argument) () (:default-initargs :message "mq-flags contained flags other than :non-blocking.")) (define-condition invalid-argument-on-unlink (invalid-argument) () (:default-initargs :message "The caller does not have permission to unlink this message queue.")) (define-condition invalid-argument-on-send-receive (invalid-argument) () (:default-initargs :message "The call would have blocked, and timeout arguments were invalid, either because :sec was less than zero, or because :nsec was less than zero or greater than 1000 million.")) (define-condition message-too-long (generic) () (:default-initargs :strerror "Message too long")) (define-condition message-too-long-on-receive (message-too-long) () (:default-initargs :message "Message length was less than the :message-size attribute of the message queue.")) (define-condition message-too-long-on-send (message-too-long) () (:default-initargs :message "Message length was greater than the :message-size attribute of the message queue."))
5,939
Common Lisp
.lisp
125
44.288
81
0.750562
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
3e4d2e86a9a6ecd1aa1ce5af2c7517bb0a89833719c0812f8cc9d6bb00f18784
24,614
[ -1 ]
24,615
posix-mqueue.lisp
xFA25E_cl-posix-mqueue/tests/posix-mqueue.lisp
(defpackage #:posix-mqueue.tests (:use #:cl #:fiveam)) (in-package #:posix-mqueue.tests) (defmacro with-random-queue ((var random-params &rest options) &body body) "Create a random name queue, close and unlink it in the end." (let ((name (gensym "NAME"))) `(let* ((,name (posix-mqueue::random-queue-name ,@random-params)) (,var (posix-mqueue:open-queue ,name ,@options))) (unwind-protect (progn ,@body) (ignore-errors (posix-mqueue:unlink ,name) (posix-mqueue:close-queue ,var)))))) (def-suite posix-mqueue :description "Test posix-mqueue") (def-suite* random-queue-name :in posix-mqueue) (test random-queue-name-negative-length (signals type-error (posix-mqueue::random-queue-name :length (- (random 20))))) (test random-queue-name-normal-usage (let ((name (posix-mqueue::random-queue-name :length 20 :start 97 :end 123))) (is (and (= 21 (length name)) (cl-ppcre:scan "^/[a-z]+$" name))))) (def-suite* unlink :in posix-mqueue) (test unlink-errors (signals posix-mqueue:name-too-long (posix-mqueue:unlink (posix-mqueue::random-queue-name :length 256))) (signals posix-mqueue:no-file-or-directory-on-unlink (posix-mqueue:unlink (posix-mqueue::random-queue-name)))) (test unlink-normal-usage (let ((name (posix-mqueue::random-queue-name))) (posix-mqueue:close-queue (posix-mqueue:open-queue name :open-flags '(:read-only :create))) (finishes (posix-mqueue:unlink name)))) (def-suite* close-queue :in posix-mqueue) (test close-queue-error (let* ((name (posix-mqueue::random-queue-name)) (mq (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (posix-mqueue:close-queue mq) (signals posix-mqueue:bad-file-descriptor-invalid (posix-mqueue:close-queue mq)) (posix-mqueue:unlink name))) (test close-queue-normal-usage (let* ((name (posix-mqueue::random-queue-name)) (mq (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (finishes (posix-mqueue:close-queue mq)) (posix-mqueue:unlink name))) (def-suite* with-open-queue :in posix-mqueue) (test with-open-queue-normal-usage (is (equal (macroexpand-1 '(posix-mqueue:with-open-queue (mq "/hello" :open-flags '(:read-write :create)) (posix-mqueue:send-string mq "hello" 0))) '(let ((mq (posix-mqueue:open-queue "/hello" :open-flags '(:read-write :create)))) (unwind-protect (progn (posix-mqueue:send-string mq "hello" 0)) (posix-mqueue:close-queue mq)))))) (def-suite* attributes :in posix-mqueue) (test attributes-error (let ((q nil)) (with-random-queue (mq nil :open-flags '(:read-only :create)) (setf q mq)) (signals posix-mqueue:bad-file-descriptor-invalid (posix-mqueue:attributes q)))) (test attributes-normal-usage (with-random-queue (mq nil :open-flags '(:read-only :create)) (is (typep (posix-mqueue:attributes mq) 'posix-mqueue:attributes)))) (test attributes-non-blocking (with-random-queue (mq nil :open-flags '(:read-only :create :non-blocking)) (is (posix-mqueue:non-blocking-p (posix-mqueue:attributes mq)))) (with-random-queue (mq nil :open-flags '(:read-only :create)) (is-false (posix-mqueue:non-blocking-p (posix-mqueue:attributes mq))))) (test attributes-maxmsgs-msgsize (let ((maxmsgs 10) (msgsize 20)) (with-random-queue (mq nil :open-flags '(:read-only :create) :max-messages maxmsgs :message-size msgsize) (let ((attrs (posix-mqueue:attributes mq))) (is (= maxmsgs (posix-mqueue:max-messages attrs))) (is (= msgsize (posix-mqueue:message-size attrs))))))) (test attributes-current-messages (with-random-queue (mq nil :open-flags '(:read-only :create)) (is (zerop (posix-mqueue:current-messages (posix-mqueue:attributes mq)))))) (def-suite* open-queue :in posix-mqueue) (test open-queue-errors (let ((name (concatenate 'string (posix-mqueue::random-queue-name) (posix-mqueue::random-queue-name)))) (signals posix-mqueue:access-denied-slashes (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (let ((name (posix-mqueue::random-queue-name))) (posix-mqueue:close-queue (posix-mqueue:open-queue name :open-flags '(:read-only :create) :create-modes '())) (signals posix-mqueue:access-denied-permission (posix-mqueue:open-queue name :open-flags '(:read-write))) (posix-mqueue:unlink name)) (let ((name (posix-mqueue::random-queue-name))) (finishes (posix-mqueue:close-queue (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (signals posix-mqueue:file-exists (posix-mqueue:open-queue name :open-flags '(:read-only :create :exclusive))) (finishes (posix-mqueue:unlink name))) (let ((name (subseq (posix-mqueue::random-queue-name) 1))) (signals posix-mqueue:invalid-argument-name (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (let ((name (posix-mqueue::random-queue-name))) (signals type-error (posix-mqueue:open-queue name :open-flags '(:read-only :create) :max-messages 0 :message-size 0))) (let ((name (posix-mqueue::random-queue-name :length 300))) (signals posix-mqueue:name-too-long (posix-mqueue:open-queue name :open-flags '(:read-only :create)))) (signals posix-mqueue:no-file-or-directory-just-slash (posix-mqueue:open-queue "/" :open-flags '(:read-only :create))) (let ((name (posix-mqueue::random-queue-name))) (signals posix-mqueue:no-file-or-directory-no-create (posix-mqueue:open-queue name :open-flags '(:read-only)))) (let ((name (posix-mqueue::random-queue-name))) (signals type-error (posix-mqueue:open-queue name :open-flags '(:bruh)))) (let ((name (posix-mqueue::random-queue-name))) (signals type-error (posix-mqueue:open-queue name :open-flags '(:create) :create-modes '(:bruh))))) (test attributes-default (let ((max-messages 5) (message-size 30)) (destructuring-bind (default-max-messages . default-message-size) (posix-mqueue:default-sizes) (with-random-queue (mq nil :open-flags '(:read-only :create) :max-messages max-messages :message-size default-message-size) (let ((attr (posix-mqueue:attributes mq))) (is (= (posix-mqueue:message-size attr) default-message-size)) (is (= (posix-mqueue:max-messages attr) max-messages)))) (with-random-queue (mq nil :open-flags '(:read-only :create) :message-size message-size :max-messages default-max-messages) (let ((attr (posix-mqueue:attributes mq))) (is (= (posix-mqueue:message-size attr) message-size)) (is (= (posix-mqueue:max-messages attr) default-max-messages))))))) (test open-queue-existing (let* ((name (posix-mqueue::random-queue-name)) (max-messages 5) (message-size 20) (orig-mq (posix-mqueue:open-queue name :open-flags '(:create :read-only) :max-messages max-messages :message-size message-size))) (unwind-protect (posix-mqueue:with-open-queue (open-mq name :open-flags '(:write-only)) (let ((orig-attrs (posix-mqueue:attributes orig-mq)) (open-attrs (posix-mqueue:attributes open-mq))) (is (= (posix-mqueue:message-size orig-attrs) (posix-mqueue:message-size open-attrs) message-size)) (is (= (posix-mqueue:max-messages orig-attrs) (posix-mqueue:max-messages open-attrs) max-messages)) (is (= (length (posix-mqueue:buffer orig-mq)) (length (posix-mqueue:buffer open-mq)) message-size)))) (ignore-errors (posix-mqueue:unlink name) (posix-mqueue:close-queue orig-mq))))) (def-suite* non-blocking :in posix-mqueue) (test non-blocking-error (with-random-queue (mq nil :open-flags '(:read-only :create)) (posix-mqueue:close-queue mq) (signals posix-mqueue:bad-file-descriptor-invalid (posix-mqueue:set-non-blocking mq t)))) (test non-blocking-normal-usage (with-random-queue (mq nil :open-flags '(:read-only :create)) (is-false (posix-mqueue:non-blocking-p (posix-mqueue:attributes mq))) (is (posix-mqueue:set-non-blocking mq t)) (is (posix-mqueue:non-blocking-p (posix-mqueue:attributes mq))) (is-false (posix-mqueue:set-non-blocking mq nil)) (is-false (posix-mqueue:non-blocking-p (posix-mqueue:attributes mq))))) (def-suite* send :in posix-mqueue) (test send-errors (with-random-queue (mq nil :open-flags '(:read-only :create) :max-messages 1 :message-size 5) (signals posix-mqueue:bad-file-descriptor-on-send (posix-mqueue:send-string mq "hei" 0))) (with-random-queue (mq nil :open-flags '(:read-write :create) :max-messages 1 :message-size 5) (signals posix-mqueue:message-too-long-on-send (posix-mqueue:send-string mq "helloo" 0)) (let ((invalid-timestamp (local-time:unix-to-timestamp -1 :nsec #-ccl -1 #+ccl 0))) (signals posix-mqueue:invalid-argument-on-send-receive (posix-mqueue:timed-send-string mq "hei" 0 invalid-timestamp))) (let ((invalid-timestamp (local-time:unix-to-timestamp -1 :nsec #-ccl (1+ (expt 10 9)) #+ccl 0))) (signals posix-mqueue:invalid-argument-on-send-receive (posix-mqueue:timed-send-string mq "hei" 0 invalid-timestamp))) (ignore-errors (posix-mqueue:close-queue mq)) (signals posix-mqueue:bad-file-descriptor-on-send (posix-mqueue:send-string mq "hei" 0)))) (test send-normal-usage (let ((msg "hei") (prty 5)) (with-random-queue (mq nil :open-flags '(:read-write :create) :max-messages 1 :message-size 5) (finishes (posix-mqueue:send-string mq msg prty)) (multiple-value-bind (m p) (posix-mqueue:receive-string mq) (is (= p prty)) (is (string= m msg))) (finishes (posix-mqueue:send-string mq msg prty)) (is (eq :connection-timed-out (posix-mqueue:timed-send-string mq msg prty (local-time:now)))) (posix-mqueue:set-non-blocking mq t) (is (eq :try-again (posix-mqueue:send-string mq msg prty)))))) (def-suite* receive :in posix-mqueue) (test receive-error (with-random-queue (mq nil :open-flags '(:write-only :create) :max-messages 1 :message-size 5) (signals posix-mqueue:bad-file-descriptor-on-receive (posix-mqueue:receive-string mq))) (with-random-queue (mq nil :open-flags '(:read-write :create) :max-messages 1 :message-size 5) (let ((invalid-timestamp (local-time:unix-to-timestamp -1 :nsec #-ccl -1 #+ccl 0))) (signals posix-mqueue:invalid-argument-on-send-receive (posix-mqueue:timed-receive-string mq invalid-timestamp))) (let ((invalid-timestamp (local-time:unix-to-timestamp -1 :nsec #-ccl (1+ (expt 10 9)) #+ccl 0))) (signals posix-mqueue:invalid-argument-on-send-receive (posix-mqueue:timed-receive-string mq invalid-timestamp))) (ignore-errors (posix-mqueue:close-queue mq)) (signals posix-mqueue:bad-file-descriptor-on-receive (posix-mqueue:receive-string mq)))) (test receive-normal-usage (let ((msg "hei") (prty 5)) (with-random-queue (mq nil :open-flags '(:read-write :create) :max-messages 1 :message-size 5) (finishes (posix-mqueue:send-string mq msg prty)) (multiple-value-bind (m p) (posix-mqueue:receive-string mq) (is (= p prty)) (is (string= m msg))) (is (eq :connection-timed-out (posix-mqueue:timed-receive-string mq (local-time:now)))) (posix-mqueue:set-non-blocking mq t) (is (eq :try-again (posix-mqueue:receive-string mq))))))
11,772
Common Lisp
.lisp
208
49.543269
106
0.666261
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
3b03b410a137b9726d5ceba4d9741a94fac01644609fe84fb6e734d48498d67b
24,615
[ -1 ]
24,616
cl-posix-mqueue.asd
xFA25E_cl-posix-mqueue/cl-posix-mqueue.asd
(defsystem "cl-posix-mqueue" :author "Valeriy Litkovskyy <[email protected]>" :maintainer "Valeriy Litkovskyy <[email protected]>" :license "GPL3" :version "0.1.2" :depends-on ("cffi" "alexandria" "babel" "local-time") :components ((:module "src" :components ((:file "package") (:file "condition") (:file "queue") (:file "types") (:file "translation" :depends-on ("queue" "types")) (:file "spec" :depends-on ("queue" "translation" "types")) (:file "posix-mqueue" :depends-on ("condition" "queue" "spec" "types"))))) :description "POSIX message queue bindings for Common Lisp" :in-order-to ((test-op (test-op "cl-posix-mqueue/tests"))) :long-description #.(let ((file (probe-file* (subpathname *load-pathname* "README.md")))) (when file (read-file-string file)))) (defsystem "cl-posix-mqueue/tests" :depends-on ("cl-posix-mqueue" "fiveam" "cl-ppcre") :components ((:module "tests" :components ((:file "posix-mqueue")))) :description "Test system for cl-posix-mqueue" :perform (test-op (op c) (symbol-call '#:fiveam '#:run! (find-symbol* '#:posix-mqueue '#:posix-mqueue.tests))))
1,311
Common Lisp
.asd
22
48.727273
129
0.587733
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
061a8d2750befa5fd01e17484492b1ff1fa465a55cd9e519a8f427511de081dd
24,616
[ -1 ]
24,619
shell.nix
xFA25E_cl-posix-mqueue/shell.nix
let pkgs = import <nixpkgs> {}; PROJECT_ROOT = builtins.toString ./.; QUICKLISP_DIR = "${PROJECT_ROOT}/.quicklisp"; quicklisp-lisp = builtins.fetchurl https://beta.quicklisp.org/quicklisp.lisp; quickstart = pkgs.writeShellScriptBin "quickstart" '' ${pkgs.sbcl}/bin/sbcl \ --non-interactive \ --no-userinit \ --load "${quicklisp-lisp}" \ --eval "(quicklisp-quickstart:install :path #P\"${QUICKLISP_DIR}/\")" ''; init-lisp = pkgs.writeText "init.lisp" '' #-quicklisp (let ((quicklisp-init #P"${QUICKLISP_DIR}/setup.lisp")) (when (probe-file quicklisp-init) (load quicklisp-init))) ''; make-implementation = name: pkg: flags: pkgs.symlinkJoin { name = name; paths = [ pkg ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/${name} --add-flags '${flags}' ''; }; sbcl = make-implementation "sbcl" pkgs.sbcl "--userinit ${init-lisp}"; ecl = make-implementation "ecl" pkgs.ecl "--norc --load ${init-lisp}"; ccl = make-implementation "ccl" pkgs.ccl "--no-init --load ${init-lisp}"; clisp = make-implementation "clisp" pkgs.clisp "-norc -i ${init-lisp}"; abcl = make-implementation "abcl" pkgs.abcl "--noinit --load ${init-lisp}"; in pkgs.mkShell { CL_SOURCE_REGISTRY="${PROJECT_ROOT}:"; ASDF_OUTPUT_TRANSLATIONS = '' (:output-translations :ignore-inherited-configuration (t ("${PROJECT_ROOT}" ".common-lisp" :implementation))) ''; buildInputs = [ quickstart sbcl ecl ccl clisp abcl ]; shellHook = '' [ -d "${QUICKLISP_DIR}" ] || quickstart ''; }
1,619
Common Lisp
.l
43
33.162791
79
0.641401
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
95d03bee8e79bb5bb3fa6e577887b3a72a7e3984382a4941f11994ad10ef28dd
24,619
[ -1 ]
24,628
cl-posix-mqueue.info
xFA25E_cl-posix-mqueue/doc/cl-posix-mqueue.info
This is cl-posix-mqueue.info, produced by makeinfo version 6.7 from cl-posix-mqueue.texi. INFO-DIR-SECTION Common Lisp START-INFO-DIR-ENTRY * cl-posix-mqueue Reference: (cl-posix-mqueue). The cl-posix-mqueue Reference Manual. END-INFO-DIR-ENTRY  File: cl-posix-mqueue.info, Node: Top, Next: Systems, Prev: (dir), Up: (dir) The cl-posix-mqueue Reference Manual ************************************ This is the cl-posix-mqueue Reference Manual, version 0.1.2, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Apr 06 16:59:14 2021 GMT+1. * Menu: * Systems:: The systems documentation * Modules:: The modules documentation * Files:: The files documentation * Packages:: The packages documentation * Definitions:: The symbols documentation * Indexes:: Concepts, functions, variables and data types  File: cl-posix-mqueue.info, Node: Systems, Next: Modules, Prev: Top, Up: Top 1 Systems ********* The main system appears first, followed by any subsystem dependency. * Menu: * The cl-posix-mqueue system::  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue system, Prev: Systems, Up: Systems 1.1 cl-posix-mqueue =================== *Author* Valeriy Litkovskyy <<[email protected]>> *License* GPL3 *Description* POSIX message queue bindings for Common Lisp *Long Description* Common Lisp bindings to POSIX message queues. POSIX message queue is an IPC (Inter-Process Communication) method that is easy to use and quick to setup. This library uses https://common-lisp.net/project/local-time library for timestamps. Other dependencies are: alexandria, babel and cffi. Cffi should be able to find librt. *Version* 0.1.2 *Dependencies* • cffi • alexandria • babel • local-time *Source* *note cl-posix-mqueue.asd: go to the cl-posix-mqueue․asd file. (file) *Component* *note src: go to the cl-posix-mqueue/src module. (module)  File: cl-posix-mqueue.info, Node: Modules, Next: Files, Prev: Systems, Up: Top 2 Modules ********* Modules are listed depth-first from the system components tree. * Menu: * The cl-posix-mqueue/src module::  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src module, Prev: Modules, Up: Modules 2.1 cl-posix-mqueue/src ======================= *Parent* *note cl-posix-mqueue: go to the cl-posix-mqueue system. (system) *Location* src/ *Components* • *note package.lisp: go to the cl-posix-mqueue/src/package․lisp file. (file) • *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) • *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) • *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) • *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) • *note translation.lisp: go to the cl-posix-mqueue/src/translation․lisp file. (file) • *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file)  File: cl-posix-mqueue.info, Node: Files, Next: Packages, Prev: Modules, Up: Top 3 Files ******* Files are sorted by type and then listed depth-first from the systems components trees. * Menu: * Lisp files::  File: cl-posix-mqueue.info, Node: Lisp files, Prev: Files, Up: Files 3.1 Lisp ======== * Menu: * The cl-posix-mqueue.asd file: The cl-posix-mqueue․asd file. * The cl-posix-mqueue/src/package.lisp file: The cl-posix-mqueue/src/package․lisp file. * The cl-posix-mqueue/src/condition.lisp file: The cl-posix-mqueue/src/condition․lisp file. * The cl-posix-mqueue/src/lib.lisp file: The cl-posix-mqueue/src/lib․lisp file. * The cl-posix-mqueue/src/queue.lisp file: The cl-posix-mqueue/src/queue․lisp file. * The cl-posix-mqueue/src/spec.lisp file: The cl-posix-mqueue/src/spec․lisp file. * The cl-posix-mqueue/src/translation.lisp file: The cl-posix-mqueue/src/translation․lisp file. * The cl-posix-mqueue/src/types.lisp file: The cl-posix-mqueue/src/types․lisp file.  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue․asd file, Next: The cl-posix-mqueue/src/package․lisp file, Prev: Lisp files, Up: Lisp files 3.1.1 cl-posix-mqueue.asd ------------------------- *Location* cl-posix-mqueue.asd *Systems* *note cl-posix-mqueue: go to the cl-posix-mqueue system. (system)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/package․lisp file, Next: The cl-posix-mqueue/src/condition․lisp file, Prev: The cl-posix-mqueue․asd file, Up: Lisp files 3.1.2 cl-posix-mqueue/src/package.lisp -------------------------------------- *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/package.lisp *Packages* *note posix-mqueue: go to the POSIX-MQUEUE package.  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/condition․lisp file, Next: The cl-posix-mqueue/src/lib․lisp file, Prev: The cl-posix-mqueue/src/package․lisp file, Up: Lisp files 3.1.3 cl-posix-mqueue/src/condition.lisp ---------------------------------------- *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/condition.lisp *Exported Definitions* • *note access-denied-on-unlink: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition. (condition) • *note access-denied-permission: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition. (condition) • *note access-denied-slashes: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition. (condition) • *note bad-file-descriptor-invalid: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition. (condition) • *note bad-file-descriptor-on-receive: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition. (condition) • *note bad-file-descriptor-on-send: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition. (condition) • *note file-exists: go to the POSIX-MQUEUE∶∶FILE-EXISTS condition. (condition) • *note file-table-overflow: go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition. (condition) • *note interrupted-system-call: go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition. (condition) • *note invalid-argument-attributes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition. (condition) • *note invalid-argument-name: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition. (condition) • *note invalid-argument-on-send-receive: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition. (condition) • *note invalid-argument-on-unlink: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition. (condition) • *note invalid-argument-sizes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition. (condition) • *note message-too-long-on-receive: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition. (condition) • *note message-too-long-on-send: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition. (condition) • *note name-too-long: go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition. (condition) • *note no-file-or-directory-just-slash: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition. (condition) • *note no-file-or-directory-no-create: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition. (condition) • *note no-file-or-directory-on-unlink: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition. (condition) • *note no-space-left-on-device: go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition. (condition) • *note out-of-memory: go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition. (condition) • *note too-many-open-files: go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition. (condition) *Internal Definitions* • *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) • *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) • *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) • *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) • *note message: go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method. (method) • *note message-too-long: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition. (condition) • *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) • *note strerror: go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method. (method)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/lib․lisp file, Next: The cl-posix-mqueue/src/queue․lisp file, Prev: The cl-posix-mqueue/src/condition․lisp file, Up: Lisp files 3.1.4 cl-posix-mqueue/src/lib.lisp ---------------------------------- *Dependencies* • *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) • *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) • *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) • *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/lib.lisp *Exported Definitions* • *note *retry-on-interrupt-p*: go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable. (special variable) • *note attributes: go to the POSIX-MQUEUE∶∶ATTRIBUTES function. (function) • *note close-queue: go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function. (function) • *note default-sizes: go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function. (function) • *note open-queue: go to the POSIX-MQUEUE∶∶OPEN-QUEUE function. (function) • *note receive: go to the POSIX-MQUEUE∶∶RECEIVE function. (function) • *note receive-buffer: go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function. (function) • *note receive-displaced: go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function. (function) • *note receive-string: go to the POSIX-MQUEUE∶∶RECEIVE-STRING function. (function) • *note send: go to the POSIX-MQUEUE∶∶SEND function. (function) • *note send-string: go to the POSIX-MQUEUE∶∶SEND-STRING function. (function) • *note set-non-blocking: go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function. (function) • *note timed-receive: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function. (function) • *note timed-receive-buffer: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function. (function) • *note timed-receive-displaced: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function. (function) • *note timed-receive-string: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function. (function) • *note timed-send: go to the POSIX-MQUEUE∶∶TIMED-SEND function. (function) • *note timed-send-string: go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function. (function) • *note unlink: go to the POSIX-MQUEUE∶∶UNLINK function. (function) • *note with-open-queue: go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro. (macro) *Internal Definitions* • *note %receive: go to the POSIX-MQUEUE∶∶%RECEIVE macro. (macro) • *note %send: go to the POSIX-MQUEUE∶∶%SEND macro. (macro) • *note random-queue-name: go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function. (function)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/queue․lisp file, Next: The cl-posix-mqueue/src/spec․lisp file, Prev: The cl-posix-mqueue/src/lib․lisp file, Up: Lisp files 3.1.5 cl-posix-mqueue/src/queue.lisp ------------------------------------ *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/queue.lisp *Exported Definitions* • *note attributes: go to the POSIX-MQUEUE∶∶ATTRIBUTES class. (class) • *note buffer: go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method. (method) • *note current-messages: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note max-messages: go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note message-size: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note non-blocking-p: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note queue: go to the POSIX-MQUEUE∶∶QUEUE class. (class) *Internal Definitions* *note mqd: go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method. (method)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/spec․lisp file, Next: The cl-posix-mqueue/src/translation․lisp file, Prev: The cl-posix-mqueue/src/queue․lisp file, Up: Lisp files 3.1.6 cl-posix-mqueue/src/spec.lisp ----------------------------------- *Dependencies* • *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) • *note translation.lisp: go to the cl-posix-mqueue/src/translation․lisp file. (file) • *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/spec.lisp *Internal Definitions* • *note mq-close: go to the POSIX-MQUEUE∶∶MQ-CLOSE function. (function) • *note mq-getattr: go to the POSIX-MQUEUE∶∶MQ-GETATTR function. (function) • *note mq-open: go to the POSIX-MQUEUE∶∶MQ-OPEN function. (function) • *note mq-receive: go to the POSIX-MQUEUE∶∶MQ-RECEIVE function. (function) • *note mq-send: go to the POSIX-MQUEUE∶∶MQ-SEND function. (function) • *note mq-setattr: go to the POSIX-MQUEUE∶∶MQ-SETATTR function. (function) • *note mq-timedreceive: go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function. (function) • *note mq-timedsend: go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function. (function) • *note mq-unlink: go to the POSIX-MQUEUE∶∶MQ-UNLINK function. (function)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/translation․lisp file, Next: The cl-posix-mqueue/src/types․lisp file, Prev: The cl-posix-mqueue/src/spec․lisp file, Up: Lisp files 3.1.7 cl-posix-mqueue/src/translation.lisp ------------------------------------------ *Dependencies* • *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) • *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/translation.lisp *Internal Definitions* • *note %var-accessor-*errno*: go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function. (function) • *note (setf %var-accessor-*errno*): go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function. (function) • *note *errno*: go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro. (symbol macro)  File: cl-posix-mqueue.info, Node: The cl-posix-mqueue/src/types․lisp file, Prev: The cl-posix-mqueue/src/translation․lisp file, Up: Lisp files 3.1.8 cl-posix-mqueue/src/types.lisp ------------------------------------ *Parent* *note src: go to the cl-posix-mqueue/src module. (module) *Location* src/types.lisp *Exported Definitions* • *note create-modes: go to the POSIX-MQUEUE∶∶CREATE-MODES type. (type) • *note create-modesp: go to the POSIX-MQUEUE∶∶CREATE-MODESP function. (function) • *note open-flags: go to the POSIX-MQUEUE∶∶OPEN-FLAGS type. (type) • *note open-flagsp: go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function. (function) *Internal Definitions* • *note mq-attr-tclass: go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class. (class) • *note mq-non-blocking-attr-type: go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class. (class) • *note mq-size-attr-type: go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class. (class) • *note mqd-type: go to the POSIX-MQUEUE∶∶MQD-TYPE class. (class) • *note result-type: go to the POSIX-MQUEUE∶∶RESULT-TYPE class. (class) • *note timespec-tclass: go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class. (class) • *note timespec-type: go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class. (class)  File: cl-posix-mqueue.info, Node: Packages, Next: Definitions, Prev: Files, Up: Top 4 Packages ********** Packages are listed by definition order. * Menu: * The posix-mqueue package::  File: cl-posix-mqueue.info, Node: The posix-mqueue package, Prev: Packages, Up: Packages 4.1 posix-mqueue ================ POSIX message queue bindings. *Source* *note package.lisp: go to the cl-posix-mqueue/src/package․lisp file. (file) *Use List* common-lisp *Exported Definitions* • *note *retry-on-interrupt-p*: go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable. (special variable) • *note access-denied-on-unlink: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition. (condition) • *note access-denied-permission: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition. (condition) • *note access-denied-slashes: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition. (condition) • *note attributes: go to the POSIX-MQUEUE∶∶ATTRIBUTES function. (function) • *note attributes: go to the POSIX-MQUEUE∶∶ATTRIBUTES class. (class) • *note bad-file-descriptor-invalid: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition. (condition) • *note bad-file-descriptor-on-receive: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition. (condition) • *note bad-file-descriptor-on-send: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition. (condition) • *note buffer: go to the POSIX-MQUEUE∶∶BUFFER generic function. (generic function) • *note buffer: go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method. (method) • *note close-queue: go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function. (function) • *note create-modes: go to the POSIX-MQUEUE∶∶CREATE-MODES type. (type) • *note create-modesp: go to the POSIX-MQUEUE∶∶CREATE-MODESP function. (function) • *note current-messages: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function. (generic function) • *note current-messages: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note default-sizes: go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function. (function) • *note file-exists: go to the POSIX-MQUEUE∶∶FILE-EXISTS condition. (condition) • *note file-table-overflow: go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition. (condition) • *note interrupted-system-call: go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition. (condition) • *note invalid-argument-attributes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition. (condition) • *note invalid-argument-name: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition. (condition) • *note invalid-argument-on-send-receive: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition. (condition) • *note invalid-argument-on-unlink: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition. (condition) • *note invalid-argument-sizes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition. (condition) • *note max-messages: go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function. (generic function) • *note max-messages: go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note message-size: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function. (generic function) • *note message-size: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note message-too-long-on-receive: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition. (condition) • *note message-too-long-on-send: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition. (condition) • *note name-too-long: go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition. (condition) • *note no-file-or-directory-just-slash: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition. (condition) • *note no-file-or-directory-no-create: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition. (condition) • *note no-file-or-directory-on-unlink: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition. (condition) • *note no-space-left-on-device: go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition. (condition) • *note non-blocking-p: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function. (generic function) • *note non-blocking-p: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note open-flags: go to the POSIX-MQUEUE∶∶OPEN-FLAGS type. (type) • *note open-flagsp: go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function. (function) • *note open-queue: go to the POSIX-MQUEUE∶∶OPEN-QUEUE function. (function) • *note out-of-memory: go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition. (condition) • *note queue: go to the POSIX-MQUEUE∶∶QUEUE class. (class) • *note receive: go to the POSIX-MQUEUE∶∶RECEIVE function. (function) • *note receive-buffer: go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function. (function) • *note receive-displaced: go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function. (function) • *note receive-string: go to the POSIX-MQUEUE∶∶RECEIVE-STRING function. (function) • *note send: go to the POSIX-MQUEUE∶∶SEND function. (function) • *note send-string: go to the POSIX-MQUEUE∶∶SEND-STRING function. (function) • *note set-non-blocking: go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function. (function) • *note timed-receive: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function. (function) • *note timed-receive-buffer: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function. (function) • *note timed-receive-displaced: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function. (function) • *note timed-receive-string: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function. (function) • *note timed-send: go to the POSIX-MQUEUE∶∶TIMED-SEND function. (function) • *note timed-send-string: go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function. (function) • *note too-many-open-files: go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition. (condition) • *note unlink: go to the POSIX-MQUEUE∶∶UNLINK function. (function) • *note with-open-queue: go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro. (macro) *Internal Definitions* • *note %receive: go to the POSIX-MQUEUE∶∶%RECEIVE macro. (macro) • *note %send: go to the POSIX-MQUEUE∶∶%SEND macro. (macro) • *note %var-accessor-*errno*: go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function. (function) • *note (setf %var-accessor-*errno*): go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function. (function) • *note *errno*: go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro. (symbol macro) • *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) • *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) • *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) • *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) • *note message: go to the POSIX-MQUEUE∶∶MESSAGE generic function. (generic function) • *note message: go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method. (method) • *note message-too-long: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition. (condition) • *note mq-attr-tclass: go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class. (class) • *note mq-close: go to the POSIX-MQUEUE∶∶MQ-CLOSE function. (function) • *note mq-getattr: go to the POSIX-MQUEUE∶∶MQ-GETATTR function. (function) • *note mq-non-blocking-attr-type: go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class. (class) • *note mq-open: go to the POSIX-MQUEUE∶∶MQ-OPEN function. (function) • *note mq-receive: go to the POSIX-MQUEUE∶∶MQ-RECEIVE function. (function) • *note mq-send: go to the POSIX-MQUEUE∶∶MQ-SEND function. (function) • *note mq-setattr: go to the POSIX-MQUEUE∶∶MQ-SETATTR function. (function) • *note mq-size-attr-type: go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class. (class) • *note mq-timedreceive: go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function. (function) • *note mq-timedsend: go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function. (function) • *note mq-unlink: go to the POSIX-MQUEUE∶∶MQ-UNLINK function. (function) • *note mqd: go to the POSIX-MQUEUE∶∶MQD generic function. (generic function) • *note mqd: go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method. (method) • *note mqd-type: go to the POSIX-MQUEUE∶∶MQD-TYPE class. (class) • *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) • *note random-queue-name: go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function. (function) • *note result-type: go to the POSIX-MQUEUE∶∶RESULT-TYPE class. (class) • *note strerror: go to the POSIX-MQUEUE∶∶STRERROR generic function. (generic function) • *note strerror: go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method. (method) • *note timespec-tclass: go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class. (class) • *note timespec-type: go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class. (class)  File: cl-posix-mqueue.info, Node: Definitions, Next: Indexes, Prev: Packages, Up: Top 5 Definitions ************* Definitions are sorted by export status, category, package, and then by lexicographic order. * Menu: * Exported definitions:: * Internal definitions::  File: cl-posix-mqueue.info, Node: Exported definitions, Next: Internal definitions, Prev: Definitions, Up: Definitions 5.1 Exported definitions ======================== * Menu: * Exported special variables:: * Exported macros:: * Exported functions:: * Exported generic functions:: * Exported conditions:: * Exported classes:: * Exported types::  File: cl-posix-mqueue.info, Node: Exported special variables, Next: Exported macros, Prev: Exported definitions, Up: Exported definitions 5.1.1 Special variables ----------------------- -- Special Variable: *retry-on-interrupt-p* Whether or not to retry send/receive operation on interrupt. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file)  File: cl-posix-mqueue.info, Node: Exported macros, Next: Exported functions, Prev: Exported special variables, Up: Exported definitions 5.1.2 Macros ------------ -- Macro: with-open-queue (VAR NAME &rest OPTIONS) &body BODY A macro that automatically closes opened queue, even when condition is signaled. For OPTIONS see OPEN-QUEUE. Example: (with-open-queue (mqueue "/myqueue" :open-flags ’(:read-write :create)) (do-something-with mqueue)) *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file)  File: cl-posix-mqueue.info, Node: Exported functions, Next: Exported generic functions, Prev: Exported macros, Up: Exported definitions 5.1.3 Functions --------------- -- Function: attributes QUEUE Retrieve attributes of the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: close-queue QUEUE Close the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: create-modesp THING Check if THING is a list and contains only MODEs. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) -- Function: default-sizes () Return default sizes of a queue in a form (MAX-MESSAGES . MESSAGE-SIZE). This is done by creating a queue with a random name and by extracting its attributes. By using a 255 length name, we protect ourselves from name collision. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: open-flagsp THING Check if THING is a list and contains only OFLAGs. Also, check that single-flags are present only once. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) -- Function: open-queue NAME &key OPEN-FLAGS CREATE-MODES MAX-MESSAGES MESSAGE-SIZE Create a new POSIX message queue or open an existing queue. NAME is a string that identifies a queue. It MUST start with a slash ("/") and MUST NOT contain other slashes. Example: "/myqueue". OPEN-FLAGS is a list of flags that control the operation of queue. Exactly one of the following must be specified in OPEN-FLAGS: :read-only Open the queue to receive messages only. :write-only Open the queue to send messages only. :read-write Open the queue to both send and receive messages. Zero or more of the following flags: :close-on-exec Set the close-on-exec flag for the message queue descriptor. See open(2) for a discussion of why this flag is useful. :create Create the message queue if it does not exist. The owner (user ID) of the message queue is set to the effective user ID of the calling process. The group ownership (group ID) is set to the effective group ID of the calling process. :exclusive If :create was specified in OPEN-FLAGS, and a queue with the given name already exists, then fail signaling FILE-EXISTS condition. :non-blocking Open the queue in nonblocking mode. In circumstances where RECEIVE and SEND operations would normally block, these operations will return :try-again instead. If :create is specified in OPEN-FLAGS, then three additional arguments can be supplied. The MODE argument specifies the permissions to be placed on the new queue. It is a list of the following possible flags: :user-read :user-write :group-read :group-write :other-read :other-read In addition, MAX-MESSAGES and MESSAGE-SIZE specify the maximum number of messages and the maximum size of messages that the queue will allow. Usually, they default to their maximum values, 10 and 8192 respectively, but these values can be changes through /proc/sys/fs/mqueue/ interface. They must be provided in pair, as in the mq_open(3), but DEFAULT-SIZES function is provided to get default sizes of a queue. This function can signal the following conditions: ACCESS-DENIED-PERMISSION The queue exists, but the caller does not have permission to open it in the specified mode. ACCESS-DENIED-SLASHES NAME contained more than one slash. FILE-EXISTS Both :create and :exclusive were specified in OPEN-FLAGS, but a queue with this NAME already exists. INVALID-ARGUMENT-NAME NAME doesn’t follow the format described in mq_overview(7). INVALID-ARGUMENT-SIZES :create was specified in OPEN-FLAGS, but MAX-MESSAGES or MESSAGE-SIZE were invalid. Both of these fields must be greater than zero. In a process that is unprivileged (does not have the CAP_SYS_RESOURCE capability), MAX-MESSAGES must be less than or equal to the msg_max limit, and MESSAGE-SIZE must be less than or equal to the msgsize_max limit. In addition, even in a privileged process, MAX-MESSAGES cannot exceed the HARD_MAX limit. (See mq_overview(7) for details of these limits.). Both of these limits can be changed through the /proc/sys/fs/mqueue/ interface. TOO-MANY-OPEN-FILES The per-process limit on the number of open file and message queue descriptors has been reached (see the description of RLIMIT_NOFILE in getrlimit(2)). NAME-TOO-LONG NAME was too long. FILE-TABLE-OVERFLOW The system-wide limit on the total number of open files and message queues has been reached. NO-FILE-OR-DIRECTORY-JUST-SLASH NAME was just "/" followed by no other characters. NO-FILE-OR-DIRECTORY-NO-CREATE The :create flag was not specified in OPEN-FLAGS, and no queue with this NAME exists. OUT-OF-MEMORY Insufficient memory. NO-SPACE-LEFT-ON-DEVICE Insufficient space for the creation of a new message queue. This probably occurred because the queues_max limit was encountered; see mq_overview(7). SIMPLE-ERROR This one can be signalled if the OPEN-FLAGS or the MODE are invalid. BAD-FILE-DESCRIPTOR The message queue file descriptor (MQD) is invalid. This is an internal error that should not happen, it is mainly for the writer of this library. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: receive QUEUE Remove the oldest message with the highest priority from the message QUEUE and return it as ’(ARRAY (UNSIGNED-BYTE 8)). Return the priority associated with the received message as second value. Return the message LENGTH as a third value. Message length could be less than the returned BUFFER length. In fact, this is the same buffer used internally in queue to receive all messages. This function is provided for better control of the message data. Most library users would like to use RECEIVE-STRING, or RECEIVE-BUFFER, or RECEIVE-DISPLACED, instead. If the queue is empty, then, by default, RECEIVE blocks until a message becomes available, or the call is interrupted by a signal handler. If the :non-blocking OPEN-FLAG is enabled for the message queue, then the call instead returns immediately with :try-again. Conditions: BAD-FILE-DESCRIPTOR-INVALID The file descriptor specified MQD was invalid or not opened for reading. INTERRUPTED-SYSTEM-CALL The call was interrupted by a signal handler; see signal(7). MESSAGE-TOO-LONG-ON-RECEIVE Message length was less than the :message-size attribute of the message queue. This is an intarnal error that should not happen, it is mainly for the writer of this library. Restarts: RETRY-ON-INTERRUPT If the call was interrupted by a signal handler, you can restart the call. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: receive-buffer QUEUE Behaves just luke RECEIVE, except that it creates a new buffer with ONLY message data. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: receive-displaced QUEUE Behaves just like RECEIVE, except that it tries to return a displaced array from internal buffer. You should not use it in a thread, unless protected by a lock. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: receive-string QUEUE Behaves just like RECEIVE, except that it tries to convert received message to string. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: send QUEUE MESSAGE-BUFFER PRIORITY &optional LENGTH Adds the MESSAGE-BUFFER to the message QUEUE. MESSAGE-BUFFER length must be less than or equal to the QUEUE’s :message-size attribute. Zero-length messages are allowed. MESSAGE-BUFFER must be an ’(array (unsigned-byte 8)). Additional LENGTH argument can be provided to limit the message being sent. By default, it is equal to MESSAGE-BUFFER length. The PRIORITY argument is a nonnegative integer that specifies the priority of new message. Messages are placed on the QUEUE in decreasing order of priority, with newer messages of the same priority being placed after older messages with the same priority. See mq_overview(7) for details on the range for the message priority. If the message QUEUE is already full (i.e., the number of messages on the QUEUE equals the QUEUE’s :max-messages attribute), then, by default, SEND blocks until sufficient space becomes available to allow the message to be queued, or until the call is interrupted by a signal handler. If the :non-blocking flag is enabled for the message QUEUE, then the call instead returns :try-again. Note: if you don’t want to create a new buffer for sending to save space, you can reuse QUEUE’s buffer. Use BUFFER function on a QUEUE to get it. Remember, that its data will be overwritten on next receive call. Conditions: BAD-FILE-DESCRIPTOR-ON-SEND The file descriptor specified MQD was invalid or not opened for writing. INTERRUPTED-SYSTEM-CALL The call was interrupted by a signal handler; see signal(7). MESSAGE-TOO-LONG-ON-SEND MESSAGE length was greater than the :message-size attribute of the message QUEUE. Restarts: RETRY-ON-INTERRUPT If the call was interrupted by a signal handler, you can restart the call. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: send-string QUEUE MESSAGE-STRING PRIORITY Behaves just like SEND, except that it sends a string, not an ’(array (unsigned-byte 8)) *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: set-non-blocking QUEUE NON-BLOCKING-P Modify NON-BLOCKING-P attribute of the message queue. Conditions: BAD-FILE-DESCRIPTOR-INVALID The message queue file descriptor (MQD) is invalid. INVALID-ARGUMENT-ATTRIBUTES mq-flags contained flags other than :non-blocking. This is an internal error that should not happen, it is mainly for the writer of this library. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-receive QUEUE TIMESTAMP Behaves just like RECEIVE, except that if the queue is empty and the :non-blocking OPEN-FLAG is not enabled for the message queue, then the TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute, not relative. If no message is available, and the timeout has already expired by the time of the call, TIMED-RECEIVE returns immediately with :connection-timed-out. Look LOCAL-TIME package for more information on timestamps. Additional conditions: INVALID-ARGUMENT-ON-SEND-RECEIVE The call would have blocked, and timeout arguments were invalid, either because :sec was less than zero, or because :nsec was less than zero or greater than 1000 million. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-receive-buffer QUEUE TIMESTAMP Behaves just like TIMED-RECEIVE, except that it creates a new buffer with ONLY message data. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-receive-displaced QUEUE TIMESTAMP Behaves just like TIMED-RECEIVE, except that it tries to return a displaced array from internal buffer. You should not use it in a thread, unless protected by a lock. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-receive-string QUEUE TIMESTAMP Behaves just like TIMED-RECEIVE, except that it tries to convert received message to string. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-send QUEUE MESSAGE-BUFFER PRIORITY TIMESTAMP &optional LENGTH Behaves just like SEND, except that if the QUEUE is full and the :non-blocking flag is not enabled for the message queue, then TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute, not relative. If the message queue is full, and the timeout has already expired by the time of the call, TIMED-SEND returns immediately with :connection-timed-out. Look LOCAL-TIME package for more information on timestamps. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: timed-send-string QUEUE MESSAGE-STRING PRIORITY TIMESTAMP Behaves just like TIMED-SEND, except that it sends a string, not an ’(array (unsigned-byte 8)) *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Function: unlink NAME Remove the specified message queue NAME. The message queue NAME is removed immediately. The queue itself is destroyed once any other processes that have the queue open close their descriptors referring to the queue. Conditions: ACCESS-DENIED-ON-UNLINK The caller does not have permission to unlink this message queue. NAME-TOO-LONG NAME was too long. NO-FILE-OR-DIRECTORY-ON-UNLINK There is no message queue with the given NAME. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file)  File: cl-posix-mqueue.info, Node: Exported generic functions, Next: Exported conditions, Prev: Exported functions, Up: Exported definitions 5.1.4 Generic functions ----------------------- -- Generic Function: buffer OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: buffer (QUEUE queue) Buffer used to receive messages form queue. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) -- Generic Function: current-messages OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: current-messages (ATTRIBUTES attributes) Number of messages currently on queue. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) -- Generic Function: max-messages OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: max-messages (ATTRIBUTES attributes) Max possible number of messages. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) -- Generic Function: message-size OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: message-size (ATTRIBUTES attributes) Message size. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) -- Generic Function: non-blocking-p OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: non-blocking-p (ATTRIBUTES attributes) Whether the receive/send operations would block *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file)  File: cl-posix-mqueue.info, Node: Exported conditions, Next: Exported classes, Prev: Exported generic functions, Up: Exported definitions 5.1.5 Conditions ---------------- -- Condition: access-denied-on-unlink () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the caller does not have permission to unlink this message queue." -- Condition: access-denied-permission () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the queue exists, but the caller does not have permission to open it in the specified mode." -- Condition: access-denied-slashes () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "name contained more than one slash." -- Condition: bad-file-descriptor-invalid () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the message queue file descriptor (mqd) is invalid." -- Condition: bad-file-descriptor-on-receive () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the file descriptor specified mqd was invalid or not opened for reading." -- Condition: bad-file-descriptor-on-send () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the file descriptor specified mqd was invalid or not opened for writing." -- Condition: file-exists () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "both :create and :exclusive were specified in open-flags, but a queue with this name already exists." :strerror "file exists" -- Condition: file-table-overflow () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the system-wide limit on the total number of open files and message queues has been reached." :strerror "too many open files in system" -- Condition: interrupted-system-call () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the call was interrupted by a signal handler; see signal(7)." :strerror "interrupted system call" -- Condition: invalid-argument-attributes () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "mq-flags contained flags other than :non-blocking." -- Condition: invalid-argument-name () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "name doesn't follow the format described in mq_overview(7)." -- Condition: invalid-argument-on-send-receive () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the call would have blocked, and timeout arguments were invalid, either because :sec was less than zero, or because :nsec was less than zero or greater than 1000 million." -- Condition: invalid-argument-on-unlink () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the caller does not have permission to unlink this message queue." -- Condition: invalid-argument-sizes () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message ":create was specified in open-flags, but max-messages or message-size was invalid. both of these fields must be greater than zero. in a process that is unprivileged (does not have the cap_sys_resource capability), max-messages must be less than or equal to the msg_max limit, and message-size must be less than or equal to the msgsize_max limit. in addition, even in a privileged process, :max-messages cannot exceed the hard_max limit. (see mq_overview(7) for details of these limits.). both of these limits can be changed through the /proc/sys/fs/mqueue/ interface." -- Condition: message-too-long-on-receive () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note message-too-long: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "message length was less than the :message-size attribute of the message queue." -- Condition: message-too-long-on-send () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note message-too-long: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "message length was greater than the :message-size attribute of the message queue." -- Condition: name-too-long () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "name was too long." :strerror "file name too long" -- Condition: no-file-or-directory-just-slash () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "name was just \"/\" followed by no other characters." -- Condition: no-file-or-directory-no-create () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the :create flag was not specified in open-flags, and no queue with this name exists." -- Condition: no-file-or-directory-on-unlink () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "there is no message queue with the given name." -- Condition: no-space-left-on-device () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "insufficient space for the creation of a new message queue. this probably occurred because the queues_max limit was encountered; see mq_overview(7)." :strerror "no space left on device" -- Condition: out-of-memory () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "insufficient memory." :strerror "cannot allocate memory" -- Condition: too-many-open-files () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :message "the per-process limit on the number of open file and message queue descriptors has been reached (see the description of rlimit_nofile in getrlimit(2))." :strerror "too many open files"  File: cl-posix-mqueue.info, Node: Exported classes, Next: Exported types, Prev: Exported conditions, Up: Exported definitions 5.1.6 Classes ------------- -- Class: attributes () POSIX message queue attributes. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) *Direct superclasses* standard-object (class) *Direct methods* • *note current-messages: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note message-size: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note max-messages: go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method. (method) • *note non-blocking-p: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method. (method) *Direct slots* -- Slot: non-blocking-p Whether the receive/send operations would block *Type* boolean *Initargs* :non-blocking-p *Readers* *note non-blocking-p: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function. (generic function) -- Slot: max-messages Max possible number of messages. *Type* (unsigned-byte 64) *Initargs* :max-messages *Readers* *note max-messages: go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function. (generic function) -- Slot: message-size Message size. *Type* (unsigned-byte 64) *Initargs* :message-size *Readers* *note message-size: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function. (generic function) -- Slot: current-messages Number of messages currently on queue. *Type* (unsigned-byte 64) *Initargs* :current-messages *Readers* *note current-messages: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function. (generic function) -- Class: queue () Main type used to interact with POSIX message queues. It contains a queue’s file descriptor (MQD) and a BUFFER used to receive messages. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) *Direct superclasses* standard-object (class) *Direct methods* • *note buffer: go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method. (method) • *note mqd: go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method. (method) *Direct slots* -- Slot: mqd Message queue’s file descriptor. *Type* (unsigned-byte 32) *Initargs* :mqd *Readers* *note mqd: go to the POSIX-MQUEUE∶∶MQD generic function. (generic function) -- Slot: buffer Buffer used to receive messages form queue. *Type* (array (unsigned-byte 8)) *Initargs* :buffer *Readers* *note buffer: go to the POSIX-MQUEUE∶∶BUFFER generic function. (generic function)  File: cl-posix-mqueue.info, Node: Exported types, Prev: Exported classes, Up: Exported definitions 5.1.7 Types ----------- -- Type: create-modes () Type used to describe CREATE-MODES in OPEN-QUEUE. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) -- Type: open-flags () Type used to describe OPEN-FLAGS in OPEN-QUEUE. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file)  File: cl-posix-mqueue.info, Node: Internal definitions, Prev: Exported definitions, Up: Definitions 5.2 Internal definitions ======================== * Menu: * Internal symbol macros:: * Internal macros:: * Internal functions:: * Internal generic functions:: * Internal conditions:: * Internal classes::  File: cl-posix-mqueue.info, Node: Internal symbol macros, Next: Internal macros, Prev: Internal definitions, Up: Internal definitions 5.2.1 Symbol macros ------------------- -- Symbol Macro: *errno* *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note translation.lisp: go to the cl-posix-mqueue/src/translation․lisp file. (file) *Expansion* (posix-mqueue::%var-accessor-*errno*)  File: cl-posix-mqueue.info, Node: Internal macros, Next: Internal functions, Prev: Internal symbol macros, Up: Internal definitions 5.2.2 Macros ------------ -- Macro: %receive RECEIVE-FN CURRENT-FN RETURN-FORM &rest CURRENT-FN-ARGS Macro used for generating various receive functions. RECEIVE-FN is a function called to receive a message. CURRENT-FN is a function which will be called on interrupt. RETURN-FORM is a form placed at the end of the macro. It has access to BUFFER, LENGTH (of received message) and PRIORITY (of received message). CURRENT-FN-ARGS are additional arguments placed at the end of RECEIVE-FN and CURRENT-FN. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file) -- Macro: %send SEND-FN CURRENT-FN &rest SEND-FN-ARGS A macro used to generate send functions. SEND-FN is a function used to send the actual message. CURRENT-FN is a function which is called on interrupt. SEND-FN-ARGS are additional arguments placed at the end of SEND-FN and CURRENT-FN call. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file)  File: cl-posix-mqueue.info, Node: Internal functions, Next: Internal generic functions, Prev: Internal macros, Up: Internal definitions 5.2.3 Functions --------------- -- Function: %var-accessor-*errno* () -- Function: (setf %var-accessor-*errno*) VALUE *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note translation.lisp: go to the cl-posix-mqueue/src/translation․lisp file. (file) -- Function: mq-close MQDES Close POSIX message queue. See mq_close(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-getattr MQDES ATTR Get POSIX message queue default attributes. See mq_getattr(3). *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-open NAME OFLAG MODE ATTR Open POSIX message queue. See mq_open(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-receive MQDES MSG-PTR MSG-LEN MSG-PRIO Receive a message from POSIX message queue. See mq_receive(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-send MQDES MSG-PTR MSG-LEN MSG-PRIO Send a message to POSIX message queue. See mq_send(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-setattr MQDES NEWATTR OLDATTR Set POSIX message queue non-blocking attribute. See mq_setattr(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-timedreceive MQDES MSG-PTR MSG-LEN MSG-PRIO ABS-TIMEOUT Receive a message from POSIX message queue. See mq_timedreceive(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-timedsend MQDES MSG-PTR MSG-LEN MSG-PRIO ABS-TIMEOUT Send a message to POSIX message queue. See mq_timedsend(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: mq-unlink NAME Unlink POSIX message queue. See mq_unlink(3) for more details. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note spec.lisp: go to the cl-posix-mqueue/src/spec․lisp file. (file) -- Function: random-queue-name &key LENGTH START END Generate random queue name with specified LENGTH, with characters starting from START to END. With slash at the beginning. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note lib.lisp: go to the cl-posix-mqueue/src/lib․lisp file. (file)  File: cl-posix-mqueue.info, Node: Internal generic functions, Next: Internal conditions, Prev: Internal functions, Up: Internal definitions 5.2.4 Generic functions ----------------------- -- Generic Function: message CONDITION *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: message (CONDITION generic) *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) -- Generic Function: mqd OBJECT *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: mqd (QUEUE queue) Message queue’s file descriptor. *Source* *note queue.lisp: go to the cl-posix-mqueue/src/queue․lisp file. (file) -- Generic Function: strerror CONDITION *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Methods* -- Method: strerror (CONDITION generic) *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file)  File: cl-posix-mqueue.info, Node: Internal conditions, Next: Internal classes, Prev: Internal generic functions, Up: Internal definitions 5.2.5 Conditions ---------------- -- Condition: access-denied () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct subclasses* • *note access-denied-permission: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition. (condition) • *note access-denied-slashes: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition. (condition) • *note access-denied-on-unlink: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :strerror "permission denied" -- Condition: bad-file-descriptor () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct subclasses* • *note bad-file-descriptor-invalid: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition. (condition) • *note bad-file-descriptor-on-receive: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition. (condition) • *note bad-file-descriptor-on-send: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :strerror "bad file descriptor" -- Condition: generic () Generic error used as the base for all conditions. Must contain STRERROR and MESSAGE. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* error (condition) *Direct subclasses* • *note out-of-memory: go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition. (condition) • *note file-exists: go to the POSIX-MQUEUE∶∶FILE-EXISTS condition. (condition) • *note file-table-overflow: go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition. (condition) • *note too-many-open-files: go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition. (condition) • *note no-space-left-on-device: go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition. (condition) • *note name-too-long: go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition. (condition) • *note interrupted-system-call: go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition. (condition) • *note no-file-or-directory: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition. (condition) • *note bad-file-descriptor: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition. (condition) • *note access-denied: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition. (condition) • *note invalid-argument: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition. (condition) • *note message-too-long: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition. (condition) *Direct methods* • *note message: go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method. (method) • *note strerror: go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method. (method) *Direct slots* -- Slot: strerror Error string from CFFI’s strerror. *Initargs* :strerror *Readers* *note strerror: go to the POSIX-MQUEUE∶∶STRERROR generic function. (generic function) -- Slot: message More specific message string. *Initargs* :message *Readers* *note message: go to the POSIX-MQUEUE∶∶MESSAGE generic function. (generic function) -- Condition: invalid-argument () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct subclasses* • *note invalid-argument-name: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition. (condition) • *note invalid-argument-sizes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition. (condition) • *note invalid-argument-attributes: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition. (condition) • *note invalid-argument-on-unlink: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition. (condition) • *note invalid-argument-on-send-receive: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :strerror "invalid argument" -- Condition: message-too-long () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct subclasses* • *note message-too-long-on-receive: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition. (condition) • *note message-too-long-on-send: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :strerror "message too long" -- Condition: no-file-or-directory () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note condition.lisp: go to the cl-posix-mqueue/src/condition․lisp file. (file) *Direct superclasses* *note generic: go to the POSIX-MQUEUE∶∶GENERIC condition. (condition) *Direct subclasses* • *note no-file-or-directory-just-slash: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition. (condition) • *note no-file-or-directory-no-create: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition. (condition) • *note no-file-or-directory-on-unlink: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition. (condition) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :strerror "no such file or directory"  File: cl-posix-mqueue.info, Node: Internal classes, Prev: Internal conditions, Up: Internal definitions 5.2.6 Classes ------------- -- Class: mq-attr-tclass () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* • translatable-foreign-type (class) • foreign-struct-type (class) -- Class: mq-non-blocking-attr-type () Type used to get attributes through a pointer. To fill a CStruct through a pointer passed to function. Translation for this type does exactly this, at the end of the function call, it fills Lisp class with values from MQ-ATTR. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* enhanced-foreign-type (class) *Direct methods* expand-to-foreign-dyn (method) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :actual-type (quote (:pointer)) -- Class: mq-size-attr-type () Type used to pass ATTRIBUTES as C-function argument. Translation maps ATTRIBUTES to MQ-ATTR CStruct. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* enhanced-foreign-type (class) *Direct methods* expand-to-foreign-dyn (method) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :actual-type (quote (:pointer)) -- Class: mqd-type () Type used to describe POSIX message queue file descriptor. Also, there are translations defined for this type (:int) from QUEUE class. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* enhanced-foreign-type (class) *Direct methods* expand-to-foreign (method) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :actual-type (quote (:int)) -- Class: result-type () Type used to describe C-style result of functions. There is a translation that maps -1 to keyword representation of the error through the errno. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* enhanced-foreign-type (class) *Direct methods* expand-from-foreign (method) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :actual-type (quote (:int)) -- Class: timespec-tclass () *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* • translatable-foreign-type (class) • foreign-struct-type (class) -- Class: timespec-type () Type used to pass LOCAL-TIME:TIMESTAMP as C timespec. *Package* *note posix-mqueue: go to the POSIX-MQUEUE package. *Source* *note types.lisp: go to the cl-posix-mqueue/src/types․lisp file. (file) *Direct superclasses* enhanced-foreign-type (class) *Direct methods* expand-to-foreign-dyn (method) *Direct Default Initargs* Initarg Value ------------------------------------------------------------ :actual-type (quote (:pointer))  File: cl-posix-mqueue.info, Node: Indexes, Prev: Definitions, Up: Top Appendix A Indexes ****************** * Menu: * Concept index:: * Function index:: * Variable index:: * Data type index::  File: cl-posix-mqueue.info, Node: Concept index, Next: Function index, Prev: Indexes, Up: Indexes A.1 Concepts ============ [index] * Menu: * cl-posix-mqueue.asd: The cl-posix-mqueue․asd file. (line 6) * cl-posix-mqueue/src: The cl-posix-mqueue/src module. (line 6) * cl-posix-mqueue/src/condition.lisp: The cl-posix-mqueue/src/condition․lisp file. (line 6) * cl-posix-mqueue/src/lib.lisp: The cl-posix-mqueue/src/lib․lisp file. (line 6) * cl-posix-mqueue/src/package.lisp: The cl-posix-mqueue/src/package․lisp file. (line 6) * cl-posix-mqueue/src/queue.lisp: The cl-posix-mqueue/src/queue․lisp file. (line 6) * cl-posix-mqueue/src/spec.lisp: The cl-posix-mqueue/src/spec․lisp file. (line 6) * cl-posix-mqueue/src/translation.lisp: The cl-posix-mqueue/src/translation․lisp file. (line 6) * cl-posix-mqueue/src/types.lisp: The cl-posix-mqueue/src/types․lisp file. (line 6) * File, Lisp, cl-posix-mqueue.asd: The cl-posix-mqueue․asd file. (line 6) * File, Lisp, cl-posix-mqueue/src/condition.lisp: The cl-posix-mqueue/src/condition․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/lib.lisp: The cl-posix-mqueue/src/lib․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/package.lisp: The cl-posix-mqueue/src/package․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/queue.lisp: The cl-posix-mqueue/src/queue․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/spec.lisp: The cl-posix-mqueue/src/spec․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/translation.lisp: The cl-posix-mqueue/src/translation․lisp file. (line 6) * File, Lisp, cl-posix-mqueue/src/types.lisp: The cl-posix-mqueue/src/types․lisp file. (line 6) * Lisp File, cl-posix-mqueue.asd: The cl-posix-mqueue․asd file. (line 6) * Lisp File, cl-posix-mqueue/src/condition.lisp: The cl-posix-mqueue/src/condition․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/lib.lisp: The cl-posix-mqueue/src/lib․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/package.lisp: The cl-posix-mqueue/src/package․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/queue.lisp: The cl-posix-mqueue/src/queue․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/spec.lisp: The cl-posix-mqueue/src/spec․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/translation.lisp: The cl-posix-mqueue/src/translation․lisp file. (line 6) * Lisp File, cl-posix-mqueue/src/types.lisp: The cl-posix-mqueue/src/types․lisp file. (line 6) * Module, cl-posix-mqueue/src: The cl-posix-mqueue/src module. (line 6)  File: cl-posix-mqueue.info, Node: Function index, Next: Variable index, Prev: Concept index, Up: Indexes A.2 Functions ============= [index] * Menu: * %receive: Internal macros. (line 6) * %send: Internal macros. (line 21) * %var-accessor-*errno*: Internal functions. (line 6) * (setf %var-accessor-*errno*): Internal functions. (line 7) * attributes: Exported functions. (line 6) * buffer: Exported generic functions. (line 6) * buffer <1>: Exported generic functions. (line 10) * close-queue: Exported functions. (line 19) * create-modesp: Exported functions. (line 32) * current-messages: Exported generic functions. (line 15) * current-messages <1>: Exported generic functions. (line 19) * default-sizes: Exported functions. (line 39) * Function, %var-accessor-*errno*: Internal functions. (line 7) * Function, (setf %var-accessor-*errno*): Internal functions. (line 8) * Function, attributes: Exported functions. (line 7) * Function, close-queue: Exported functions. (line 20) * Function, create-modesp: Exported functions. (line 33) * Function, default-sizes: Exported functions. (line 40) * Function, mq-close: Internal functions. (line 14) * Function, mq-getattr: Internal functions. (line 21) * Function, mq-open: Internal functions. (line 28) * Function, mq-receive: Internal functions. (line 35) * Function, mq-send: Internal functions. (line 43) * Function, mq-setattr: Internal functions. (line 51) * Function, mq-timedreceive: Internal functions. (line 59) * Function, mq-timedsend: Internal functions. (line 67) * Function, mq-unlink: Internal functions. (line 75) * Function, open-flagsp: Exported functions. (line 50) * Function, open-queue: Exported functions. (line 59) * Function, random-queue-name: Internal functions. (line 82) * Function, receive: Exported functions. (line 205) * Function, receive-buffer: Exported functions. (line 249) * Function, receive-displaced: Exported functions. (line 257) * Function, receive-string: Exported functions. (line 266) * Function, send: Exported functions. (line 274) * Function, send-string: Exported functions. (line 328) * Function, set-non-blocking: Exported functions. (line 336) * Function, timed-receive: Exported functions. (line 355) * Function, timed-receive-buffer: Exported functions. (line 377) * Function, timed-receive-displaced: Exported functions. (line 385) * Function, timed-receive-string: Exported functions. (line 394) * Function, timed-send: Exported functions. (line 403) * Function, timed-send-string: Exported functions. (line 417) * Function, unlink: Exported functions. (line 425) * Generic Function, buffer: Exported generic functions. (line 7) * Generic Function, current-messages: Exported generic functions. (line 16) * Generic Function, max-messages: Exported generic functions. (line 25) * Generic Function, message: Internal generic functions. (line 7) * Generic Function, message-size: Exported generic functions. (line 34) * Generic Function, mqd: Internal generic functions. (line 15) * Generic Function, non-blocking-p: Exported generic functions. (line 43) * Generic Function, strerror: Internal generic functions. (line 24) * Macro, %receive: Internal macros. (line 8) * Macro, %send: Internal macros. (line 22) * Macro, with-open-queue: Exported macros. (line 7) * max-messages: Exported generic functions. (line 24) * max-messages <1>: Exported generic functions. (line 28) * message: Internal generic functions. (line 6) * message <1>: Internal generic functions. (line 10) * message-size: Exported generic functions. (line 33) * message-size <1>: Exported generic functions. (line 37) * Method, buffer: Exported generic functions. (line 11) * Method, current-messages: Exported generic functions. (line 20) * Method, max-messages: Exported generic functions. (line 29) * Method, message: Internal generic functions. (line 11) * Method, message-size: Exported generic functions. (line 38) * Method, mqd: Internal generic functions. (line 19) * Method, non-blocking-p: Exported generic functions. (line 47) * Method, strerror: Internal generic functions. (line 28) * mq-close: Internal functions. (line 13) * mq-getattr: Internal functions. (line 20) * mq-open: Internal functions. (line 27) * mq-receive: Internal functions. (line 34) * mq-send: Internal functions. (line 42) * mq-setattr: Internal functions. (line 50) * mq-timedreceive: Internal functions. (line 58) * mq-timedsend: Internal functions. (line 66) * mq-unlink: Internal functions. (line 74) * mqd: Internal generic functions. (line 14) * mqd <1>: Internal generic functions. (line 18) * non-blocking-p: Exported generic functions. (line 42) * non-blocking-p <1>: Exported generic functions. (line 46) * open-flagsp: Exported functions. (line 49) * open-queue: Exported functions. (line 57) * random-queue-name: Internal functions. (line 81) * receive: Exported functions. (line 204) * receive-buffer: Exported functions. (line 248) * receive-displaced: Exported functions. (line 256) * receive-string: Exported functions. (line 265) * send: Exported functions. (line 273) * send-string: Exported functions. (line 327) * set-non-blocking: Exported functions. (line 335) * strerror: Internal generic functions. (line 23) * strerror <1>: Internal generic functions. (line 27) * timed-receive: Exported functions. (line 354) * timed-receive-buffer: Exported functions. (line 376) * timed-receive-displaced: Exported functions. (line 384) * timed-receive-string: Exported functions. (line 393) * timed-send: Exported functions. (line 401) * timed-send-string: Exported functions. (line 416) * unlink: Exported functions. (line 424) * with-open-queue: Exported macros. (line 6)  File: cl-posix-mqueue.info, Node: Variable index, Next: Data type index, Prev: Function index, Up: Indexes A.3 Variables ============= [index] * Menu: * *errno*: Internal symbol macros. (line 6) * *retry-on-interrupt-p*: Exported special variables. (line 6) * buffer: Exported classes. (line 93) * current-messages: Exported classes. (line 57) * max-messages: Exported classes. (line 37) * message: Internal conditions. (line 102) * message-size: Exported classes. (line 47) * mqd: Exported classes. (line 84) * non-blocking-p: Exported classes. (line 27) * Slot, buffer: Exported classes. (line 94) * Slot, current-messages: Exported classes. (line 58) * Slot, max-messages: Exported classes. (line 38) * Slot, message: Internal conditions. (line 103) * Slot, message-size: Exported classes. (line 48) * Slot, mqd: Exported classes. (line 85) * Slot, non-blocking-p: Exported classes. (line 28) * Slot, strerror: Internal conditions. (line 96) * Special Variable, *retry-on-interrupt-p*: Exported special variables. (line 7) * strerror: Internal conditions. (line 95) * Symbol Macro, *errno*: Internal symbol macros. (line 7)  File: cl-posix-mqueue.info, Node: Data type index, Prev: Variable index, Up: Indexes A.4 Data types ============== [index] * Menu: * access-denied: Internal conditions. (line 6) * access-denied-on-unlink: Exported conditions. (line 6) * access-denied-permission: Exported conditions. (line 21) * access-denied-slashes: Exported conditions. (line 36) * attributes: Exported classes. (line 6) * bad-file-descriptor: Internal conditions. (line 29) * bad-file-descriptor-invalid: Exported conditions. (line 50) * bad-file-descriptor-on-receive: Exported conditions. (line 64) * bad-file-descriptor-on-send: Exported conditions. (line 79) * cl-posix-mqueue: The cl-posix-mqueue system. (line 6) * Class, attributes: Exported classes. (line 7) * Class, mq-attr-tclass: Internal classes. (line 7) * Class, mq-non-blocking-attr-type: Internal classes. (line 16) * Class, mq-size-attr-type: Internal classes. (line 34) * Class, mqd-type: Internal classes. (line 50) * Class, queue: Exported classes. (line 68) * Class, result-type: Internal classes. (line 67) * Class, timespec-tclass: Internal classes. (line 84) * Class, timespec-type: Internal classes. (line 93) * Condition, access-denied: Internal conditions. (line 7) * Condition, access-denied-on-unlink: Exported conditions. (line 7) * Condition, access-denied-permission: Exported conditions. (line 22) * Condition, access-denied-slashes: Exported conditions. (line 37) * Condition, bad-file-descriptor: Internal conditions. (line 30) * Condition, bad-file-descriptor-invalid: Exported conditions. (line 51) * Condition, bad-file-descriptor-on-receive: Exported conditions. (line 65) * Condition, bad-file-descriptor-on-send: Exported conditions. (line 80) * Condition, file-exists: Exported conditions. (line 95) * Condition, file-table-overflow: Exported conditions. (line 112) * Condition, generic: Internal conditions. (line 53) * Condition, interrupted-system-call: Exported conditions. (line 128) * Condition, invalid-argument: Internal conditions. (line 110) * Condition, invalid-argument-attributes: Exported conditions. (line 143) * Condition, invalid-argument-name: Exported conditions. (line 157) * Condition, invalid-argument-on-send-receive: Exported conditions. (line 171) * Condition, invalid-argument-on-unlink: Exported conditions. (line 189) * Condition, invalid-argument-sizes: Exported conditions. (line 204) * Condition, message-too-long: Internal conditions. (line 139) * Condition, message-too-long-on-receive: Exported conditions. (line 234) * Condition, message-too-long-on-send: Exported conditions. (line 249) * Condition, name-too-long: Exported conditions. (line 264) * Condition, no-file-or-directory: Internal conditions. (line 159) * Condition, no-file-or-directory-just-slash: Exported conditions. (line 278) * Condition, no-file-or-directory-no-create: Exported conditions. (line 292) * Condition, no-file-or-directory-on-unlink: Exported conditions. (line 307) * Condition, no-space-left-on-device: Exported conditions. (line 321) * Condition, out-of-memory: Exported conditions. (line 339) * Condition, too-many-open-files: Exported conditions. (line 353) * create-modes: Exported types. (line 6) * file-exists: Exported conditions. (line 94) * file-table-overflow: Exported conditions. (line 111) * generic: Internal conditions. (line 52) * interrupted-system-call: Exported conditions. (line 127) * invalid-argument: Internal conditions. (line 109) * invalid-argument-attributes: Exported conditions. (line 142) * invalid-argument-name: Exported conditions. (line 156) * invalid-argument-on-send-receive: Exported conditions. (line 170) * invalid-argument-on-unlink: Exported conditions. (line 188) * invalid-argument-sizes: Exported conditions. (line 203) * message-too-long: Internal conditions. (line 138) * message-too-long-on-receive: Exported conditions. (line 233) * message-too-long-on-send: Exported conditions. (line 248) * mq-attr-tclass: Internal classes. (line 6) * mq-non-blocking-attr-type: Internal classes. (line 15) * mq-size-attr-type: Internal classes. (line 33) * mqd-type: Internal classes. (line 49) * name-too-long: Exported conditions. (line 263) * no-file-or-directory: Internal conditions. (line 158) * no-file-or-directory-just-slash: Exported conditions. (line 277) * no-file-or-directory-no-create: Exported conditions. (line 291) * no-file-or-directory-on-unlink: Exported conditions. (line 306) * no-space-left-on-device: Exported conditions. (line 320) * open-flags: Exported types. (line 13) * out-of-memory: Exported conditions. (line 338) * Package, posix-mqueue: The posix-mqueue package. (line 6) * posix-mqueue: The posix-mqueue package. (line 6) * queue: Exported classes. (line 67) * result-type: Internal classes. (line 66) * System, cl-posix-mqueue: The cl-posix-mqueue system. (line 6) * timespec-tclass: Internal classes. (line 83) * timespec-type: Internal classes. (line 92) * too-many-open-files: Exported conditions. (line 352) * Type, create-modes: Exported types. (line 7) * Type, open-flags: Exported types. (line 14)  Tag Table: Node: Top247 Node: Systems827 Node: The cl-posix-mqueue system1043 Ref: go to the cl-posix-mqueue system1179 Node: Modules1993 Node: The cl-posix-mqueue/src module2210 Ref: go to the cl-posix-mqueue/src module2358 Node: Files3163 Node: Lisp files3381 Node: The cl-posix-mqueue․asd file4169 Ref: go to the cl-posix-mqueue․asd file4379 Node: The cl-posix-mqueue/src/package․lisp file4497 Ref: go to the cl-posix-mqueue/src/package․lisp file4768 Node: The cl-posix-mqueue/src/condition․lisp file4942 Ref: go to the cl-posix-mqueue/src/condition․lisp file5226 Node: The cl-posix-mqueue/src/lib․lisp file9360 Ref: go to the cl-posix-mqueue/src/lib․lisp file9630 Node: The cl-posix-mqueue/src/queue․lisp file12617 Ref: go to the cl-posix-mqueue/src/queue․lisp file12886 Node: The cl-posix-mqueue/src/spec․lisp file13948 Ref: go to the cl-posix-mqueue/src/spec․lisp file14223 Node: The cl-posix-mqueue/src/translation․lisp file15560 Ref: go to the cl-posix-mqueue/src/translation․lisp file15849 Node: The cl-posix-mqueue/src/types․lisp file16563 Ref: go to the cl-posix-mqueue/src/types․lisp file16791 Node: Packages18061 Node: The posix-mqueue package18256 Ref: go to the POSIX-MQUEUE package18386 Node: Definitions29250 Node: Exported definitions29526 Node: Exported special variables29882 Ref: go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable30121 Node: Exported macros30369 Ref: go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro30602 Node: Exported functions31032 Ref: go to the POSIX-MQUEUE∶∶ATTRIBUTES function31239 Ref: go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function31609 Ref: go to the POSIX-MQUEUE∶∶CREATE-MODESP function31964 Ref: go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function32235 Ref: go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function32698 Ref: go to the POSIX-MQUEUE∶∶OPEN-QUEUE function33093 Ref: go to the POSIX-MQUEUE∶∶RECEIVE function37709 Ref: go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function39399 Ref: go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function39715 Ref: go to the POSIX-MQUEUE∶∶RECEIVE-STRING function40108 Ref: go to the POSIX-MQUEUE∶∶SEND function40452 Ref: go to the POSIX-MQUEUE∶∶SEND-STRING function42577 Ref: go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function42911 Ref: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function43502 Ref: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function44469 Ref: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function44807 Ref: go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function45222 Ref: go to the POSIX-MQUEUE∶∶TIMED-SEND function45598 Ref: go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function46317 Ref: go to the POSIX-MQUEUE∶∶UNLINK function46631 Node: Exported generic functions47305 Ref: go to the POSIX-MQUEUE∶∶BUFFER generic function47537 Ref: go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method47672 Ref: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function47915 Ref: go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method48070 Ref: go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function48304 Ref: go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method48455 Ref: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function48683 Ref: go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method48834 Ref: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function49045 Ref: go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method49198 Node: Exported conditions49400 Ref: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition49622 Ref: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition50299 Ref: go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition50999 Ref: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition51616 Ref: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition52264 Ref: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition52963 Ref: go to the POSIX-MQUEUE∶∶FILE-EXISTS condition53646 Ref: go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition54421 Ref: go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition55177 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition55866 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition56498 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition57150 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition58039 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition58720 Ref: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition60403 Ref: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition61099 Ref: go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition61787 Ref: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition62400 Ref: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition63051 Ref: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition63768 Ref: go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition64406 Ref: go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition65268 Ref: go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition65875 Node: Exported classes66705 Ref: go to the POSIX-MQUEUE∶∶ATTRIBUTES class66892 Ref: go to the POSIX-MQUEUE∶∶QUEUE class69390 Node: Exported types70762 Ref: go to the POSIX-MQUEUE∶∶CREATE-MODES type70918 Ref: go to the POSIX-MQUEUE∶∶OPEN-FLAGS type71182 Node: Internal definitions71421 Node: Internal symbol macros71734 Ref: go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro71942 Node: Internal macros72205 Ref: go to the POSIX-MQUEUE∶∶%RECEIVE macro72457 Ref: go to the POSIX-MQUEUE∶∶%SEND macro73132 Node: Internal functions73576 Ref: go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function73791 Ref: go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function73840 Ref: go to the POSIX-MQUEUE∶∶MQ-CLOSE function74066 Ref: go to the POSIX-MQUEUE∶∶MQ-GETATTR function74352 Ref: go to the POSIX-MQUEUE∶∶MQ-OPEN function74647 Ref: go to the POSIX-MQUEUE∶∶MQ-RECEIVE function74951 Ref: go to the POSIX-MQUEUE∶∶MQ-SEND function75278 Ref: go to the POSIX-MQUEUE∶∶MQ-SETATTR function75591 Ref: go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function75942 Ref: go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function76291 Ref: go to the POSIX-MQUEUE∶∶MQ-UNLINK function76591 Ref: go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function76897 Node: Internal generic functions77212 Ref: go to the POSIX-MQUEUE∶∶MESSAGE generic function77448 Ref: go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method77590 Ref: go to the POSIX-MQUEUE∶∶MQD generic function77769 Ref: go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method77901 Ref: go to the POSIX-MQUEUE∶∶STRERROR generic function78130 Ref: go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method78273 Node: Internal conditions78420 Ref: go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition78632 Ref: go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition79660 Ref: go to the POSIX-MQUEUE∶∶GENERIC condition80710 Ref: go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition83528 Ref: go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition84886 Ref: go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition85773 Node: Internal classes86818 Ref: go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class86986 Ref: go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class87334 Ref: go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class88123 Ref: go to the POSIX-MQUEUE∶∶MQD-TYPE class88766 Ref: go to the POSIX-MQUEUE∶∶RESULT-TYPE class89443 Ref: go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class90136 Ref: go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class90472 Node: Indexes91040 Node: Concept index91241 Node: Function index95530 Node: Variable index105347 Node: Data type index107243  End Tag Table  Local Variables: coding: utf-8 End:
122,559
Common Lisp
.l
2,432
39.812089
192
0.593345
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
c95ff09d31ca115cd68ddaf6fdda938cde957acc7646c8ef6d55ac6ba4805e6b
24,628
[ -1 ]
24,629
cl-posix-mqueue.texi
xFA25E_cl-posix-mqueue/doc/cl-posix-mqueue.texi
\input texinfo @c cl-posix-mqueue.texi --- Reference manual @c Copyright (C) 2021 Valeriy Litkovskyy @c This file is part of cl-posix-mqueue. @c Commentary: @c Generated automatically by Declt version 3.0 "Montgomery Scott" @c on Tue Apr 06 16:59:14 2021 GMT+1. @c ==================================================================== @c Header @c ==================================================================== @c %**start of header @setfilename cl-posix-mqueue.info @settitle The cl-posix-mqueue Reference Manual @afourpaper @documentencoding UTF-8 @c %**end of header @c ==================================================================== @c Format Specific Tweaks @c ==================================================================== @tex %% Declt uses several Unicode characters to "reveal" blanks. This %% works fine in HTML or Info output, but TeX will have problems with %% these. The code below translates those characters to something that %% TeX can handle. %% U+23B5 (Bottom Square Bracket), used to reveal white spaces, is %% translated to its Computer Modern teletype version. \DeclareUnicodeCharacter{23B5}{{\tt\char'040}} %% U+21B5 (Downwards Arrow With Corner Leftwards), used to reveal %% carriage returns, is translated to \hookleftarrow in math mode. \DeclareUnicodeCharacter{21B5}{\ensuremath\hookleftarrow} %% U+21E5 (Rightwards Arrow To Bar), used to reveal tabs, is %% translated to something that looks similar, based on a rightarrow %% and a vertical bar from the math extension font. \DeclareUnicodeCharacter{21E5}{% \ensuremath{\rightarrow\kern-.5em\mathchar\"130C}} %% Declt uses several Unicode characters to replace "fragile" ones in %% anchor names and references. These characters are chosen to resemble %% the original ones, without interfering with Info syntax. In TeX %% however, we can switch them back to the original versions, because %% cross-references are done differently. In theory, I think we could do %% something similar for HTML output (again, only the Info syntax poses %% problems), but I don't know how to do something similar to what's %% below. %% U+2024 (One Dot Leader) replaces periods. \DeclareUnicodeCharacter{2024}{.} %% U+2236 (Ratio) replaces colons. \DeclareUnicodeCharacter{2236}{:} %% U+2768 (Medium Left Parenthesis Ornament) replaces left parenthesis. \DeclareUnicodeCharacter{2768}{(} %% U+2769 (Medium Right Parenthesis Ornament) replaces right parenthesis. \DeclareUnicodeCharacter{2769}{)} %% U+214B (Turned Ampersand) replaces ampersands. \DeclareUnicodeCharacter{214B}{&} %% U+2216 (Set Minus) replaces backslashes. \DeclareUnicodeCharacter{2216}{\char"5C} %% The following ones are already defined in texinfo.tex so we have nothing %% more to do: %% U+201A (Single Low-9 Quotation Mark) replaces commas. %% U+2205 (Empty Set) replaces empty symbol names. @end tex @c ==================================================================== @c Settings @c ==================================================================== @setchapternewpage odd @documentdescription The cl-posix-mqueue Reference Manual, version 0.1.2. @end documentdescription @c ==================================================================== @c New Commands @c ==================================================================== @c --------------- @c Indexing macros @c --------------- @c Packages @macro packageindex{name} @tpindex \name\ @tpindex @r{Package, }\name\ @end macro @c Systems @macro systemindex{name} @tpindex \name\ @tpindex @r{System, }\name\ @end macro @c Modules @macro moduleindex{name} @cindex @t{\name\} @cindex Module, @t{\name\} @end macro @c Other files @macro otherfileindex{name} @cindex @t{\name\} @cindex Other File, @t{\name\} @cindex File, other, @t{\name\} @end macro @c Lisp files @macro lispfileindex{name} @cindex @t{\name\} @cindex Lisp File, @t{\name\} @cindex File, Lisp, @t{\name\} @end macro @c C files @macro cfileindex{name} @cindex @t{\name\} @cindex C File, @t{\name\} @cindex File, C, @t{\name\} @end macro @c Java files @macro javafileindex{name} @cindex @t{\name\} @cindex Java File, @t{\name\} @cindex File, Java, @t{\name\} @end macro @c Static files @macro staticfileindex{name} @cindex @t{\name\} @cindex Static File, @t{\name\} @cindex File, static, @t{\name\} @end macro @c Doc files @macro docfileindex{name} @cindex @t{\name\} @cindex Doc File, @t{\name\} @cindex File, doc, @t{\name\} @end macro @c HTML files @macro htmlfileindex{name} @cindex @t{\name\} @cindex HTML File, @t{\name\} @cindex File, html, @t{\name\} @end macro @c The following macros are meant to be used within @defxxx environments. @c Texinfo performs half the indexing job and we do the other half. @c Constants @macro constantsubindex{name} @vindex @r{Constant, }\name\ @end macro @c Special variables @macro specialsubindex{name} @vindex @r{Special Variable, }\name\ @end macro @c Symbol macros @macro symbolmacrosubindex{name} @vindex @r{Symbol Macro, }\name\ @end macro @c Slots @macro slotsubindex{name} @vindex @r{Slot, }\name\ @end macro @c Macros @macro macrosubindex{name} @findex @r{Macro, }\name\ @end macro @c Compiler Macros @macro compilermacrosubindex{name} @findex @r{Compiler Macro, }\name\ @end macro @c Functions @macro functionsubindex{name} @findex @r{Function, }\name\ @end macro @c Methods @macro methodsubindex{name} @findex @r{Method, }\name\ @end macro @c Generic Functions @macro genericsubindex{name} @findex @r{Generic Function, }\name\ @end macro @c Setf Expanders @macro setfexpandersubindex{name} @findex @r{Setf Expander, }\name\ @end macro @c Method Combinations @macro shortcombinationsubindex{name} @tpindex @r{Short Method Combination, }\name\ @tpindex @r{Method Combination, Short, }\name\ @end macro @macro longcombinationsubindex{name} @tpindex @r{Long Method Combination, }\name\ @tpindex @r{Method Combination, Long, }\name\ @end macro @c Conditions @macro conditionsubindex{name} @tpindex @r{Condition, }\name\ @end macro @c Structures @macro structuresubindex{name} @tpindex @r{Structure, }\name\ @end macro @c Types @macro typesubindex{name} @tpindex @r{Type, }\name\ @end macro @c Classes @macro classsubindex{name} @tpindex @r{Class, }\name\ @end macro @c ==================================================================== @c Info Category and Directory @c ==================================================================== @dircategory Common Lisp @direntry * cl-posix-mqueue Reference: (cl-posix-mqueue). The cl-posix-mqueue Reference Manual. @end direntry @c ==================================================================== @c Title Page @c ==================================================================== @titlepage @title The cl-posix-mqueue Reference Manual @subtitle POSIX message queue bindings for Common Lisp, version 0.1.2 @author Valeriy Litkovskyy <@email{vlr.ltkvsk@atchar{}protonmail.com}> @page @quotation This manual was generated automatically by Declt 3.0 "Montgomery Scott" on Tue Apr 06 16:59:14 2021 GMT+1. @end quotation @end titlepage @c ==================================================================== @c Table of Contents @c ==================================================================== @contents @c ==================================================================== @c Top @c ==================================================================== @ifnottex @node Top, Systems, (dir), (dir) @top The cl-posix-mqueue Reference Manual This is the cl-posix-mqueue Reference Manual, version 0.1.2, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Apr 06 16:59:14 2021 GMT+1. @menu * Systems:: The systems documentation * Modules:: The modules documentation * Files:: The files documentation * Packages:: The packages documentation * Definitions:: The symbols documentation * Indexes:: Concepts, functions, variables and data types @end menu @end ifnottex @c ==================================================================== @c Systems @c ==================================================================== @node Systems, Modules, Top, Top @chapter Systems The main system appears first, followed by any subsystem dependency. @menu * The cl-posix-mqueue system:: @end menu @c -------------------------- @c The cl-posix-mqueue system @c -------------------------- @node The cl-posix-mqueue system, , Systems, Systems @section @t{cl-posix-mqueue} @anchor{go to the cl-posix-mqueue system}@c @systemindex{cl-posix-mqueue}@c @table @strong @item Author Valeriy Litkovskyy <@email{vlr.ltkvsk@atchar{}protonmail.com}> @item License GPL3 @item Description POSIX message queue bindings for Common Lisp @item Long Description Common Lisp bindings to POSIX message queues.@* POSIX message queue is an IPC (Inter-Process Communication) method that is easy to use and quick to setup.@* This library uses https://common-lisp.net/project/local-time library for timestamps.@* Other dependencies are: alexandria@comma{} babel and cffi. Cffi should be able to find librt. @item Version 0.1.2 @item Dependencies @itemize @bullet @item @t{cffi} @item @t{alexandria} @item @t{babel} @item @t{local-time} @end itemize @item Source @ref{go to the cl-posix-mqueue․asd file, , @t{cl-posix-mqueue.asd}} (file) @item Component @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @end table @c ==================================================================== @c Modules @c ==================================================================== @node Modules, Files, Systems, Top @chapter Modules Modules are listed depth-first from the system components tree. @menu * The cl-posix-mqueue/src module:: @end menu @c ------------------------------ @c The cl-posix-mqueue/src module @c ------------------------------ @node The cl-posix-mqueue/src module, , Modules, Modules @section @t{cl-posix-mqueue/src} @anchor{go to the cl-posix-mqueue/src module}@c @moduleindex{cl-posix-mqueue/src}@c @table @strong @item Parent @ref{go to the cl-posix-mqueue system, , @t{cl-posix-mqueue}} (system) @item Location @t{src/} @item Components @itemize @bullet @item @ref{go to the cl-posix-mqueue/src/package․lisp file, , @t{package.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/translation․lisp file, , @t{translation.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end itemize @end table @c ==================================================================== @c Files @c ==================================================================== @node Files, Packages, Modules, Top @chapter Files Files are sorted by type and then listed depth-first from the systems components trees. @menu * Lisp files:: @end menu @c ---------- @c Lisp files @c ---------- @node Lisp files, , Files, Files @section Lisp @menu * The cl-posix-mqueue.asd file: The cl-posix-mqueue․asd file. * The cl-posix-mqueue/src/package.lisp file: The cl-posix-mqueue/src/package․lisp file. * The cl-posix-mqueue/src/condition.lisp file: The cl-posix-mqueue/src/condition․lisp file. * The cl-posix-mqueue/src/lib.lisp file: The cl-posix-mqueue/src/lib․lisp file. * The cl-posix-mqueue/src/queue.lisp file: The cl-posix-mqueue/src/queue․lisp file. * The cl-posix-mqueue/src/spec.lisp file: The cl-posix-mqueue/src/spec․lisp file. * The cl-posix-mqueue/src/translation.lisp file: The cl-posix-mqueue/src/translation․lisp file. * The cl-posix-mqueue/src/types.lisp file: The cl-posix-mqueue/src/types․lisp file. @end menu @node The cl-posix-mqueue․asd file, The cl-posix-mqueue/src/package․lisp file, Lisp files, Lisp files @subsection @t{cl-posix-mqueue.asd} @anchor{go to the cl-posix-mqueue․asd file}@c @lispfileindex{cl-posix-mqueue.asd}@c @table @strong @item Location @t{cl-posix-mqueue.asd} @item Systems @ref{go to the cl-posix-mqueue system, , @t{cl-posix-mqueue}} (system) @end table @node The cl-posix-mqueue/src/package․lisp file, The cl-posix-mqueue/src/condition․lisp file, The cl-posix-mqueue․asd file, Lisp files @subsection @t{cl-posix-mqueue/src/package.lisp} @anchor{go to the cl-posix-mqueue/src/package․lisp file}@c @lispfileindex{cl-posix-mqueue/src/package.lisp}@c @table @strong @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/package.lisp} @item Packages @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @end table @node The cl-posix-mqueue/src/condition․lisp file, The cl-posix-mqueue/src/lib․lisp file, The cl-posix-mqueue/src/package․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/condition.lisp} @anchor{go to the cl-posix-mqueue/src/condition․lisp file}@c @lispfileindex{cl-posix-mqueue/src/condition.lisp}@c @table @strong @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/condition.lisp} @item Exported Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition, , @t{access-denied-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition, , @t{access-denied-permission}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition, , @t{access-denied-slashes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition, , @t{bad-file-descriptor-invalid}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition, , @t{bad-file-descriptor-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition, , @t{bad-file-descriptor-on-send}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶FILE-EXISTS condition, , @t{file-exists}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition, , @t{file-table-overflow}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition, , @t{interrupted-system-call}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition, , @t{invalid-argument-attributes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition, , @t{invalid-argument-name}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition, , @t{invalid-argument-on-send-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition, , @t{invalid-argument-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition, , @t{invalid-argument-sizes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition, , @t{message-too-long-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition, , @t{message-too-long-on-send}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition, , @t{name-too-long}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition, , @t{no-file-or-directory-just-slash}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition, , @t{no-file-or-directory-no-create}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition, , @t{no-file-or-directory-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition, , @t{no-space-left-on-device}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition, , @t{out-of-memory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition, , @t{too-many-open-files}} (condition) @end itemize @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method, , @t{message}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition, , @t{message-too-long}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method, , @t{strerror}} (method) @end itemize @end table @node The cl-posix-mqueue/src/lib․lisp file, The cl-posix-mqueue/src/queue․lisp file, The cl-posix-mqueue/src/condition․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/lib.lisp} @anchor{go to the cl-posix-mqueue/src/lib․lisp file}@c @lispfileindex{cl-posix-mqueue/src/lib.lisp}@c @table @strong @item Dependencies @itemize @bullet @item @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end itemize @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/lib.lisp} @item Exported Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable, , @t{*retry-on-interrupt-p*}} (special variable) @item @ref{go to the POSIX-MQUEUE∶∶ATTRIBUTES function, , @t{attributes}} (function) @item @ref{go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function, , @t{close-queue}} (function) @item @ref{go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function, , @t{default-sizes}} (function) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-QUEUE function, , @t{open-queue}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE function, , @t{receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function, , @t{receive-buffer}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function, , @t{receive-displaced}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-STRING function, , @t{receive-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SEND function, , @t{send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SEND-STRING function, , @t{send-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function, , @t{set-non-blocking}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function, , @t{timed-receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function, , @t{timed-receive-buffer}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function, , @t{timed-receive-displaced}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function, , @t{timed-receive-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-SEND function, , @t{timed-send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function, , @t{timed-send-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶UNLINK function, , @t{unlink}} (function) @item @ref{go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro, , @t{with-open-queue}} (macro) @end itemize @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶%RECEIVE macro, , @t{%receive}} (macro) @item @ref{go to the POSIX-MQUEUE∶∶%SEND macro, , @t{%send}} (macro) @item @ref{go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function, , @t{random-queue-name}} (function) @end itemize @end table @node The cl-posix-mqueue/src/queue․lisp file, The cl-posix-mqueue/src/spec․lisp file, The cl-posix-mqueue/src/lib․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/queue.lisp} @anchor{go to the cl-posix-mqueue/src/queue․lisp file}@c @lispfileindex{cl-posix-mqueue/src/queue.lisp}@c @table @strong @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/queue.lisp} @item Exported Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶ATTRIBUTES class, , @t{attributes}} (class) @item @ref{go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method, , @t{buffer}} (method) @item @ref{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{current-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{max-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{message-size}} (method) @item @ref{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{non-blocking-p}} (method) @item @ref{go to the POSIX-MQUEUE∶∶QUEUE class, , @t{queue}} (class) @end itemize @item Internal Definitions @ref{go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method, , @t{mqd}} (method) @end table @node The cl-posix-mqueue/src/spec․lisp file, The cl-posix-mqueue/src/translation․lisp file, The cl-posix-mqueue/src/queue․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/spec.lisp} @anchor{go to the cl-posix-mqueue/src/spec․lisp file}@c @lispfileindex{cl-posix-mqueue/src/spec.lisp}@c @table @strong @item Dependencies @itemize @bullet @item @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/translation․lisp file, , @t{translation.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end itemize @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/spec.lisp} @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶MQ-CLOSE function, , @t{mq-close}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-GETATTR function, , @t{mq-getattr}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-OPEN function, , @t{mq-open}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-RECEIVE function, , @t{mq-receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SEND function, , @t{mq-send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SETATTR function, , @t{mq-setattr}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function, , @t{mq-timedreceive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function, , @t{mq-timedsend}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-UNLINK function, , @t{mq-unlink}} (function) @end itemize @end table @node The cl-posix-mqueue/src/translation․lisp file, The cl-posix-mqueue/src/types․lisp file, The cl-posix-mqueue/src/spec․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/translation.lisp} @anchor{go to the cl-posix-mqueue/src/translation․lisp file}@c @lispfileindex{cl-posix-mqueue/src/translation.lisp}@c @table @strong @item Dependencies @itemize @bullet @item @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end itemize @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/translation.lisp} @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function, , @t{%var-accessor-*errno*}} (function) @item @ref{go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function, , @t{(setf %var-accessor-*errno*)}} (function) @item @ref{go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro, , @t{*errno*}} (symbol macro) @end itemize @end table @node The cl-posix-mqueue/src/types․lisp file, , The cl-posix-mqueue/src/translation․lisp file, Lisp files @subsection @t{cl-posix-mqueue/src/types.lisp} @anchor{go to the cl-posix-mqueue/src/types․lisp file}@c @lispfileindex{cl-posix-mqueue/src/types.lisp}@c @table @strong @item Parent @ref{go to the cl-posix-mqueue/src module, , @t{src}} (module) @item Location @t{src/types.lisp} @item Exported Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶CREATE-MODES type, , @t{create-modes}} (type) @item @ref{go to the POSIX-MQUEUE∶∶CREATE-MODESP function, , @t{create-modesp}} (function) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-FLAGS type, , @t{open-flags}} (type) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function, , @t{open-flagsp}} (function) @end itemize @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class, , @t{mq-attr-tclass}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class, , @t{mq-non-blocking-attr-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class, , @t{mq-size-attr-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQD-TYPE class, , @t{mqd-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶RESULT-TYPE class, , @t{result-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class, , @t{timespec-tclass}} (class) @item @ref{go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class, , @t{timespec-type}} (class) @end itemize @end table @c ==================================================================== @c Packages @c ==================================================================== @node Packages, Definitions, Files, Top @chapter Packages Packages are listed by definition order. @menu * The posix-mqueue package:: @end menu @c ------------------------ @c The posix-mqueue package @c ------------------------ @node The posix-mqueue package, , Packages, Packages @section @t{posix-mqueue} @anchor{go to the POSIX-MQUEUE package}@c @packageindex{posix-mqueue}@c POSIX message queue bindings. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/package․lisp file, , @t{package.lisp}} (file) @item Use List @t{common-lisp} @item Exported Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable, , @t{*retry-on-interrupt-p*}} (special variable) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition, , @t{access-denied-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition, , @t{access-denied-permission}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition, , @t{access-denied-slashes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ATTRIBUTES function, , @t{attributes}} (function) @item @ref{go to the POSIX-MQUEUE∶∶ATTRIBUTES class, , @t{attributes}} (class) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition, , @t{bad-file-descriptor-invalid}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition, , @t{bad-file-descriptor-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition, , @t{bad-file-descriptor-on-send}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BUFFER generic function, , @t{buffer}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method, , @t{buffer}} (method) @item @ref{go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function, , @t{close-queue}} (function) @item @ref{go to the POSIX-MQUEUE∶∶CREATE-MODES type, , @t{create-modes}} (type) @item @ref{go to the POSIX-MQUEUE∶∶CREATE-MODESP function, , @t{create-modesp}} (function) @item @ref{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function, , @t{current-messages}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{current-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function, , @t{default-sizes}} (function) @item @ref{go to the POSIX-MQUEUE∶∶FILE-EXISTS condition, , @t{file-exists}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition, , @t{file-table-overflow}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition, , @t{interrupted-system-call}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition, , @t{invalid-argument-attributes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition, , @t{invalid-argument-name}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition, , @t{invalid-argument-on-send-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition, , @t{invalid-argument-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition, , @t{invalid-argument-sizes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function, , @t{max-messages}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{max-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function, , @t{message-size}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{message-size}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition, , @t{message-too-long-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition, , @t{message-too-long-on-send}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition, , @t{name-too-long}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition, , @t{no-file-or-directory-just-slash}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition, , @t{no-file-or-directory-no-create}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition, , @t{no-file-or-directory-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition, , @t{no-space-left-on-device}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function, , @t{non-blocking-p}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{non-blocking-p}} (method) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-FLAGS type, , @t{open-flags}} (type) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function, , @t{open-flagsp}} (function) @item @ref{go to the POSIX-MQUEUE∶∶OPEN-QUEUE function, , @t{open-queue}} (function) @item @ref{go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition, , @t{out-of-memory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶QUEUE class, , @t{queue}} (class) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE function, , @t{receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function, , @t{receive-buffer}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function, , @t{receive-displaced}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RECEIVE-STRING function, , @t{receive-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SEND function, , @t{send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SEND-STRING function, , @t{send-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function, , @t{set-non-blocking}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function, , @t{timed-receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function, , @t{timed-receive-buffer}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function, , @t{timed-receive-displaced}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function, , @t{timed-receive-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-SEND function, , @t{timed-send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function, , @t{timed-send-string}} (function) @item @ref{go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition, , @t{too-many-open-files}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶UNLINK function, , @t{unlink}} (function) @item @ref{go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro, , @t{with-open-queue}} (macro) @end itemize @item Internal Definitions @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶%RECEIVE macro, , @t{%receive}} (macro) @item @ref{go to the POSIX-MQUEUE∶∶%SEND macro, , @t{%send}} (macro) @item @ref{go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function, , @t{%var-accessor-*errno*}} (function) @item @ref{go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function, , @t{(setf %var-accessor-*errno*)}} (function) @item @ref{go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro, , @t{*errno*}} (symbol macro) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE generic function, , @t{message}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method, , @t{message}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition, , @t{message-too-long}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class, , @t{mq-attr-tclass}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQ-CLOSE function, , @t{mq-close}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-GETATTR function, , @t{mq-getattr}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class, , @t{mq-non-blocking-attr-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQ-OPEN function, , @t{mq-open}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-RECEIVE function, , @t{mq-receive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SEND function, , @t{mq-send}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SETATTR function, , @t{mq-setattr}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class, , @t{mq-size-attr-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function, , @t{mq-timedreceive}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function, , @t{mq-timedsend}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQ-UNLINK function, , @t{mq-unlink}} (function) @item @ref{go to the POSIX-MQUEUE∶∶MQD generic function, , @t{mqd}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method, , @t{mqd}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MQD-TYPE class, , @t{mqd-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function, , @t{random-queue-name}} (function) @item @ref{go to the POSIX-MQUEUE∶∶RESULT-TYPE class, , @t{result-type}} (class) @item @ref{go to the POSIX-MQUEUE∶∶STRERROR generic function, , @t{strerror}} (generic function) @item @ref{go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method, , @t{strerror}} (method) @item @ref{go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class, , @t{timespec-tclass}} (class) @item @ref{go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class, , @t{timespec-type}} (class) @end itemize @end table @c ==================================================================== @c Definitions @c ==================================================================== @node Definitions, Indexes, Packages, Top @chapter Definitions Definitions are sorted by export status, category, package, and then by lexicographic order. @menu * Exported definitions:: * Internal definitions:: @end menu @c -------------------- @c Exported definitions @c -------------------- @node Exported definitions, Internal definitions, Definitions, Definitions @section Exported definitions @menu * Exported special variables:: * Exported macros:: * Exported functions:: * Exported generic functions:: * Exported conditions:: * Exported classes:: * Exported types:: @end menu @node Exported special variables, Exported macros, Exported definitions, Exported definitions @subsection Special variables @defvr {Special Variable} *retry-on-interrupt-p* @anchor{go to the POSIX-MQUEUE∶∶*RETRY-ON-INTERRUPT-P* special variable}@c @specialsubindex{*retry-on-interrupt-p*}@c Whether or not to retry send/receive operation on interrupt. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end defvr @node Exported macros, Exported functions, Exported special variables, Exported definitions @subsection Macros @deffn {Macro} {with-open-queue} (VAR NAME &rest OPTIONS) &body BODY @anchor{go to the POSIX-MQUEUE∶∶WITH-OPEN-QUEUE macro}@c @macrosubindex{with-open-queue}@c A macro that automatically closes opened queue@comma{} even when condition is signaled. For OPTIONS see OPEN-QUEUE.@* Example:@* (with-open-queue (mqueue "/myqueue" :open-flags '(:read-write :create)) (do-something-with mqueue)) @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @node Exported functions, Exported generic functions, Exported macros, Exported definitions @subsection Functions @deffn {Function} {attributes} QUEUE @anchor{go to the POSIX-MQUEUE∶∶ATTRIBUTES function}@c @functionsubindex{attributes}@c Retrieve attributes of the message queue.@* Conditions:@* BAD-FILE-DESCRIPTOR-INVALID@* The message queue file descriptor (MQD) is invalid. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {close-queue} QUEUE @anchor{go to the POSIX-MQUEUE∶∶CLOSE-QUEUE function}@c @functionsubindex{close-queue}@c Close the message queue.@* Conditions:@* BAD-FILE-DESCRIPTOR-INVALID@* The message queue file descriptor (MQD) is invalid. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {create-modesp} THING @anchor{go to the POSIX-MQUEUE∶∶CREATE-MODESP function}@c @functionsubindex{create-modesp}@c Check if THING is a list and contains only MODEs. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end table @end deffn @deffn {Function} {default-sizes} () @anchor{go to the POSIX-MQUEUE∶∶DEFAULT-SIZES function}@c @functionsubindex{default-sizes}@c Return default sizes of a queue in a form (MAX-MESSAGES . MESSAGE-SIZE). This is done by creating a queue with a random name and by extracting its attributes. By using a 255 length name@comma{} we protect ourselves from name collision. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {open-flagsp} THING @anchor{go to the POSIX-MQUEUE∶∶OPEN-FLAGSP function}@c @functionsubindex{open-flagsp}@c Check if THING is a list and contains only OFLAGs. Also@comma{} check that single-flags are present only once. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end table @end deffn @deffn {Function} {open-queue} NAME &key OPEN-FLAGS CREATE-MODES MAX-MESSAGES MESSAGE-SIZE @anchor{go to the POSIX-MQUEUE∶∶OPEN-QUEUE function}@c @functionsubindex{open-queue}@c Create a new POSIX message queue or open an existing queue.@* NAME is a string that identifies a queue. It MUST start with a slash ("/") and MUST NOT contain other slashes. Example: "/myqueue".@* OPEN-FLAGS is a list of flags that control the operation of queue. Exactly one of the following must be specified in OPEN-FLAGS:@* :read-only@* Open the queue to receive messages only.@* :write-only@* Open the queue to send messages only.@* :read-write@* Open the queue to both send and receive messages.@* Zero or more of the following flags:@* :close-on-exec@* Set the close-on-exec flag for the message queue descriptor. See open(2) for a discussion of why this flag is useful.@* :create@* Create the message queue if it does not exist. The owner (user ID) of the message queue is set to the effective user ID of the calling process. The group ownership (group ID) is set to the effective group ID of the calling process.@* :exclusive@* If :create was specified in OPEN-FLAGS@comma{} and a queue with the given name already exists@comma{} then fail signaling FILE-EXISTS condition.@* :non-blocking@* Open the queue in nonblocking mode. In circumstances where RECEIVE and SEND operations would normally block@comma{} these operations will return :try-again instead.@* If :create is specified in OPEN-FLAGS@comma{} then three additional arguments can be supplied. The MODE argument specifies the permissions to be placed on the new queue. It is a list of the following possible flags:@* :user-read :user-write :group-read :group-write :other-read :other-read@* In addition@comma{} MAX-MESSAGES and MESSAGE-SIZE specify the maximum number of messages and the maximum size of messages that the queue will allow. Usually@comma{} they default to their maximum values@comma{} 10 and 8192 respectively@comma{} but these values can be changes through /proc/sys/fs/mqueue/ interface. They must be provided in pair@comma{} as in the mq_open(3)@comma{} but DEFAULT-SIZES function is provided to get default sizes of a queue.@* This function can signal the following conditions:@* ACCESS-DENIED-PERMISSION@* The queue exists@comma{} but the caller does not have permission to open it in the specified mode.@* ACCESS-DENIED-SLASHES@* NAME contained more than one slash.@* FILE-EXISTS@* Both :create and :exclusive were specified in OPEN-FLAGS@comma{} but a queue with this NAME already exists.@* INVALID-ARGUMENT-NAME@* NAME doesn't follow the format described in mq_overview(7).@* INVALID-ARGUMENT-SIZES@* :create was specified in OPEN-FLAGS@comma{} but MAX-MESSAGES or MESSAGE-SIZE were invalid. Both of these fields must be greater than zero. In a process that is unprivileged (does not have the CAP_SYS_RESOURCE capability)@comma{} MAX-MESSAGES must be less than or equal to the msg_max limit@comma{} and MESSAGE-SIZE must be less than or equal to the msgsize_max limit. In addition@comma{} even in a privileged process@comma{} MAX-MESSAGES cannot exceed the HARD_MAX limit. (See mq_overview(7) for details of these limits.).@* Both of these limits can be changed through the /proc/sys/fs/mqueue/ interface.@* TOO-MANY-OPEN-FILES@* The per-process limit on the number of open file and message queue descriptors has been reached (see the description of RLIMIT_NOFILE in getrlimit(2)).@* NAME-TOO-LONG@* NAME was too long.@* FILE-TABLE-OVERFLOW@* The system-wide limit on the total number of open files and message queues has been reached.@* NO-FILE-OR-DIRECTORY-JUST-SLASH@* NAME was just "/" followed by no other characters.@* NO-FILE-OR-DIRECTORY-NO-CREATE@* The :create flag was not specified in OPEN-FLAGS@comma{} and no queue with this NAME exists.@* OUT-OF-MEMORY@* Insufficient memory.@* NO-SPACE-LEFT-ON-DEVICE@* Insufficient space for the creation of a new message queue. This probably occurred because the queues_max limit was encountered; see mq_overview(7). SIMPLE-ERROR@* This one can be signalled if the OPEN-FLAGS or the MODE are invalid.@* BAD-FILE-DESCRIPTOR@* The message queue file descriptor (MQD) is invalid. This is an internal error that should not happen@comma{} it is mainly for the writer of this library. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {receive} QUEUE @anchor{go to the POSIX-MQUEUE∶∶RECEIVE function}@c @functionsubindex{receive}@c Remove the oldest message with the highest priority from the message QUEUE and return it as '(ARRAY (UNSIGNED-BYTE 8)). Return the priority associated with the received message as second value. Return the message LENGTH as a third value. Message length could be less than the returned BUFFER length. In fact@comma{} this is the same buffer used internally in queue to receive all messages. This function is provided for better control of the message data. Most library users would like to use RECEIVE-STRING@comma{} or RECEIVE-BUFFER@comma{} or RECEIVE-DISPLACED@comma{} instead.@* If the queue is empty@comma{} then@comma{} by default@comma{} RECEIVE blocks until a message becomes available@comma{} or the call is interrupted by a signal handler. If the :non-blocking OPEN-FLAG is enabled for the message queue@comma{} then the call instead returns immediately with :try-again.@* Conditions:@* BAD-FILE-DESCRIPTOR-INVALID@* The file descriptor specified MQD was invalid or not opened for reading. INTERRUPTED-SYSTEM-CALL@* The call was interrupted by a signal handler; see signal(7).@* MESSAGE-TOO-LONG-ON-RECEIVE@* Message length was less than the :message-size attribute of the message queue. This is an intarnal error that should not happen@comma{} it is mainly for the writer of this library.@* Restarts:@* RETRY-ON-INTERRUPT@* If the call was interrupted by a signal handler@comma{} you can restart the call. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {receive-buffer} QUEUE @anchor{go to the POSIX-MQUEUE∶∶RECEIVE-BUFFER function}@c @functionsubindex{receive-buffer}@c Behaves just luke RECEIVE@comma{} except that it creates a new buffer with ONLY message data. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {receive-displaced} QUEUE @anchor{go to the POSIX-MQUEUE∶∶RECEIVE-DISPLACED function}@c @functionsubindex{receive-displaced}@c Behaves just like RECEIVE@comma{} except that it tries to return a displaced array from internal buffer. You should not use it in a thread@comma{} unless protected by a lock. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {receive-string} QUEUE @anchor{go to the POSIX-MQUEUE∶∶RECEIVE-STRING function}@c @functionsubindex{receive-string}@c Behaves just like RECEIVE@comma{} except that it tries to convert received message to string. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {send} QUEUE MESSAGE-BUFFER PRIORITY &optional LENGTH @anchor{go to the POSIX-MQUEUE∶∶SEND function}@c @functionsubindex{send}@c Adds the MESSAGE-BUFFER to the message QUEUE. MESSAGE-BUFFER length must be less than or equal to the QUEUE's :message-size attribute. Zero-length messages are allowed. MESSAGE-BUFFER must be an '(array (unsigned-byte 8)). Additional LENGTH argument can be provided to limit the message being sent. By default@comma{} it is equal to MESSAGE-BUFFER length.@* The PRIORITY argument is a nonnegative integer that specifies the priority of new message. Messages are placed on the QUEUE in decreasing order of priority@comma{} with newer messages of the same priority being placed after older messages with the same priority. See mq_overview(7) for details on the range for the message priority.@* If the message QUEUE is already full (i.e.@comma{} the number of messages on the QUEUE equals the QUEUE's :max-messages attribute)@comma{} then@comma{} by default@comma{} SEND blocks until sufficient space becomes available to allow the message to be queued@comma{} or until the call is interrupted by a signal handler. If the :non-blocking flag is enabled for the message QUEUE@comma{} then the call instead returns :try-again.@* Note: if you don't want to create a new buffer for sending to save space@comma{} you can reuse QUEUE's buffer. Use BUFFER function on a QUEUE to get it. Remember@comma{} that its data will be overwritten on next receive call.@* Conditions:@* BAD-FILE-DESCRIPTOR-ON-SEND@* The file descriptor specified MQD was invalid or not opened for writing. INTERRUPTED-SYSTEM-CALL@* The call was interrupted by a signal handler; see signal(7).@* MESSAGE-TOO-LONG-ON-SEND@* MESSAGE length was greater than the :message-size attribute of the message QUEUE.@* Restarts:@* RETRY-ON-INTERRUPT@* If the call was interrupted by a signal handler@comma{} you can restart the call. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {send-string} QUEUE MESSAGE-STRING PRIORITY @anchor{go to the POSIX-MQUEUE∶∶SEND-STRING function}@c @functionsubindex{send-string}@c Behaves just like SEND@comma{} except that it sends a string@comma{} not an '(array (unsigned-byte 8)) @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {set-non-blocking} QUEUE NON-BLOCKING-P @anchor{go to the POSIX-MQUEUE∶∶SET-NON-BLOCKING function}@c @functionsubindex{set-non-blocking}@c Modify NON-BLOCKING-P attribute of the message queue.@* Conditions:@* BAD-FILE-DESCRIPTOR-INVALID@* The message queue file descriptor (MQD) is invalid.@* INVALID-ARGUMENT-ATTRIBUTES@* mq-flags contained flags other than :non-blocking. This is an internal error that should not happen@comma{} it is mainly for the writer of this library. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-receive} QUEUE TIMESTAMP @anchor{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE function}@c @functionsubindex{timed-receive}@c Behaves just like RECEIVE@comma{} except that if the queue is empty and the :non-blocking OPEN-FLAG is not enabled for the message queue@comma{} then the TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute@comma{} not relative. If no message is available@comma{} and the timeout has already expired by the time of the call@comma{} TIMED-RECEIVE returns immediately with :connection-timed-out.@* Look LOCAL-TIME package for more information on timestamps.@* Additional conditions:@* INVALID-ARGUMENT-ON-SEND-RECEIVE@* The call would have blocked@comma{} and timeout arguments were invalid@comma{} either because :sec was less than zero@comma{} or because :nsec was less than zero or greater than 1000 million. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-receive-buffer} QUEUE TIMESTAMP @anchor{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-BUFFER function}@c @functionsubindex{timed-receive-buffer}@c Behaves just like TIMED-RECEIVE@comma{} except that it creates a new buffer with ONLY message data. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-receive-displaced} QUEUE TIMESTAMP @anchor{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-DISPLACED function}@c @functionsubindex{timed-receive-displaced}@c Behaves just like TIMED-RECEIVE@comma{} except that it tries to return a displaced array from internal buffer. You should not use it in a thread@comma{} unless protected by a lock. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-receive-string} QUEUE TIMESTAMP @anchor{go to the POSIX-MQUEUE∶∶TIMED-RECEIVE-STRING function}@c @functionsubindex{timed-receive-string}@c Behaves just like TIMED-RECEIVE@comma{} except that it tries to convert received message to string. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-send} QUEUE MESSAGE-BUFFER PRIORITY TIMESTAMP &optional LENGTH @anchor{go to the POSIX-MQUEUE∶∶TIMED-SEND function}@c @functionsubindex{timed-send}@c Behaves just like SEND@comma{} except that if the QUEUE is full and the :non-blocking flag is not enabled for the message queue@comma{} then TIMESTAMP specifies how long the call will block. The TIMESTAMP is absolute@comma{} not relative. If the message queue is full@comma{} and the timeout has already expired by the time of the call@comma{} TIMED-SEND returns immediately with :connection-timed-out. Look LOCAL-TIME package for more information on timestamps. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {timed-send-string} QUEUE MESSAGE-STRING PRIORITY TIMESTAMP @anchor{go to the POSIX-MQUEUE∶∶TIMED-SEND-STRING function}@c @functionsubindex{timed-send-string}@c Behaves just like TIMED-SEND@comma{} except that it sends a string@comma{} not an '(array (unsigned-byte 8)) @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Function} {unlink} NAME @anchor{go to the POSIX-MQUEUE∶∶UNLINK function}@c @functionsubindex{unlink}@c Remove the specified message queue NAME. The message queue NAME is removed immediately. The queue itself is destroyed once any other processes that have the queue open close their descriptors referring to the queue.@* Conditions:@* ACCESS-DENIED-ON-UNLINK@* The caller does not have permission to unlink this message queue.@* NAME-TOO-LONG@* NAME was too long.@* NO-FILE-OR-DIRECTORY-ON-UNLINK@* There is no message queue with the given NAME. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @node Exported generic functions, Exported conditions, Exported functions, Exported definitions @subsection Generic functions @deffn {Generic Function} {buffer} OBJECT @anchor{go to the POSIX-MQUEUE∶∶BUFFER generic function}@c @genericsubindex{buffer}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {buffer} (QUEUE @t{queue}) @anchor{go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method}@c @methodsubindex{buffer}@c Buffer used to receive messages form queue. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {current-messages} OBJECT @anchor{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function}@c @genericsubindex{current-messages}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {current-messages} (ATTRIBUTES @t{attributes}) @anchor{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method}@c @methodsubindex{current-messages}@c Number of messages currently on queue. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {max-messages} OBJECT @anchor{go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function}@c @genericsubindex{max-messages}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {max-messages} (ATTRIBUTES @t{attributes}) @anchor{go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method}@c @methodsubindex{max-messages}@c Max possible number of messages. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {message-size} OBJECT @anchor{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function}@c @genericsubindex{message-size}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {message-size} (ATTRIBUTES @t{attributes}) @anchor{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method}@c @methodsubindex{message-size}@c Message size. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {non-blocking-p} OBJECT @anchor{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function}@c @genericsubindex{non-blocking-p}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {non-blocking-p} (ATTRIBUTES @t{attributes}) @anchor{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method}@c @methodsubindex{non-blocking-p}@c Whether the receive/send operations would block @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @node Exported conditions, Exported classes, Exported generic functions, Exported definitions @subsection Conditions @deftp {Condition} {access-denied-on-unlink} () @anchor{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition}@c @conditionsubindex{access-denied-on-unlink}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the caller does not have permission to unlink this message queue."} @end multitable @end table @end deftp @deftp {Condition} {access-denied-permission} () @anchor{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition}@c @conditionsubindex{access-denied-permission}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the queue exists@comma{} but the caller does not have permission to open it in the specified mode."} @end multitable @end table @end deftp @deftp {Condition} {access-denied-slashes} () @anchor{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition}@c @conditionsubindex{access-denied-slashes}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"name contained more than one slash."} @end multitable @end table @end deftp @deftp {Condition} {bad-file-descriptor-invalid} () @anchor{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition}@c @conditionsubindex{bad-file-descriptor-invalid}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the message queue file descriptor (mqd) is invalid."} @end multitable @end table @end deftp @deftp {Condition} {bad-file-descriptor-on-receive} () @anchor{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition}@c @conditionsubindex{bad-file-descriptor-on-receive}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the file descriptor specified mqd was invalid or not opened for reading."} @end multitable @end table @end deftp @deftp {Condition} {bad-file-descriptor-on-send} () @anchor{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition}@c @conditionsubindex{bad-file-descriptor-on-send}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the file descriptor specified mqd was invalid or not opened for writing."} @end multitable @end table @end deftp @deftp {Condition} {file-exists} () @anchor{go to the POSIX-MQUEUE∶∶FILE-EXISTS condition}@c @conditionsubindex{file-exists}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"both :create and :exclusive were specified in open-flags@comma{} but a queue with this name already exists."} @item @t{:strerror} @tab @t{"file exists"} @end multitable @end table @end deftp @deftp {Condition} {file-table-overflow} () @anchor{go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition}@c @conditionsubindex{file-table-overflow}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the system-wide limit on the total number of open files and message queues has been reached."} @item @t{:strerror} @tab @t{"too many open files in system"} @end multitable @end table @end deftp @deftp {Condition} {interrupted-system-call} () @anchor{go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition}@c @conditionsubindex{interrupted-system-call}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the call was interrupted by a signal handler; see signal(7)."} @item @t{:strerror} @tab @t{"interrupted system call"} @end multitable @end table @end deftp @deftp {Condition} {invalid-argument-attributes} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition}@c @conditionsubindex{invalid-argument-attributes}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"mq-flags contained flags other than :non-blocking."} @end multitable @end table @end deftp @deftp {Condition} {invalid-argument-name} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition}@c @conditionsubindex{invalid-argument-name}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"name doesn't follow the format described in mq_overview(7)."} @end multitable @end table @end deftp @deftp {Condition} {invalid-argument-on-send-receive} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition}@c @conditionsubindex{invalid-argument-on-send-receive}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the call would have blocked@comma{} and timeout arguments were invalid@comma{} either because :sec was less than zero@comma{} or because :nsec was less than zero or greater than 1000 million."} @end multitable @end table @end deftp @deftp {Condition} {invalid-argument-on-unlink} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition}@c @conditionsubindex{invalid-argument-on-unlink}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the caller does not have permission to unlink this message queue."} @end multitable @end table @end deftp @deftp {Condition} {invalid-argument-sizes} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition}@c @conditionsubindex{invalid-argument-sizes}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{":create was specified in open-flags@comma{} but max-messages or message-size was invalid. both of these fields must be greater than zero. in a process that is unprivileged (does not have the cap_sys_resource capability)@comma{} max-messages must be less than or equal to the msg_max limit@comma{} and message-size must be less than or equal to the msgsize_max limit. in addition@comma{} even in a privileged process@comma{} :max-messages cannot exceed the hard_max limit. (see mq_overview(7) for details of these limits.). both of these limits can be changed through the /proc/sys/fs/mqueue/ interface."} @end multitable @end table @end deftp @deftp {Condition} {message-too-long-on-receive} () @anchor{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition}@c @conditionsubindex{message-too-long-on-receive}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition, , @t{message-too-long}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"message length was less than the :message-size attribute of the message queue."} @end multitable @end table @end deftp @deftp {Condition} {message-too-long-on-send} () @anchor{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition}@c @conditionsubindex{message-too-long-on-send}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition, , @t{message-too-long}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"message length was greater than the :message-size attribute of the message queue."} @end multitable @end table @end deftp @deftp {Condition} {name-too-long} () @anchor{go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition}@c @conditionsubindex{name-too-long}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"name was too long."} @item @t{:strerror} @tab @t{"file name too long"} @end multitable @end table @end deftp @deftp {Condition} {no-file-or-directory-just-slash} () @anchor{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition}@c @conditionsubindex{no-file-or-directory-just-slash}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"name was just @backslashchar{}"/@backslashchar{}" followed by no other characters."} @end multitable @end table @end deftp @deftp {Condition} {no-file-or-directory-no-create} () @anchor{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition}@c @conditionsubindex{no-file-or-directory-no-create}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the :create flag was not specified in open-flags@comma{} and no queue with this name exists."} @end multitable @end table @end deftp @deftp {Condition} {no-file-or-directory-on-unlink} () @anchor{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition}@c @conditionsubindex{no-file-or-directory-on-unlink}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"there is no message queue with the given name."} @end multitable @end table @end deftp @deftp {Condition} {no-space-left-on-device} () @anchor{go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition}@c @conditionsubindex{no-space-left-on-device}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"insufficient space for the creation of a new message queue. this probably occurred because the queues_max limit was encountered; see mq_overview(7)."} @item @t{:strerror} @tab @t{"no space left on device"} @end multitable @end table @end deftp @deftp {Condition} {out-of-memory} () @anchor{go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition}@c @conditionsubindex{out-of-memory}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"insufficient memory."} @item @t{:strerror} @tab @t{"cannot allocate memory"} @end multitable @end table @end deftp @deftp {Condition} {too-many-open-files} () @anchor{go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition}@c @conditionsubindex{too-many-open-files}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:message} @tab @t{"the per-process limit on the number of open file and message queue descriptors has been reached (see the description of rlimit_nofile in getrlimit(2))."} @item @t{:strerror} @tab @t{"too many open files"} @end multitable @end table @end deftp @node Exported classes, Exported types, Exported conditions, Exported definitions @subsection Classes @deftp {Class} {attributes} () @anchor{go to the POSIX-MQUEUE∶∶ATTRIBUTES class}@c @classsubindex{attributes}@c POSIX message queue attributes. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item Direct superclasses @t{standard-object} (class) @item Direct methods @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{current-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{message-size}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MAX-MESSAGES POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{max-messages}} (method) @item @ref{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P POSIX-MQUEUE∶∶ATTRIBUTES method, , @t{non-blocking-p}} (method) @end itemize @item Direct slots @defvr {Slot} non-blocking-p @slotsubindex{non-blocking-p}@c Whether the receive/send operations would block @table @strong @item Type @t{boolean} @item Initargs @t{:non-blocking-p} @item Readers @ref{go to the POSIX-MQUEUE∶∶NON-BLOCKING-P generic function, , @t{non-blocking-p}} (generic function) @end table @end defvr @defvr {Slot} max-messages @slotsubindex{max-messages}@c Max possible number of messages. @table @strong @item Type @t{(unsigned-byte 64)} @item Initargs @t{:max-messages} @item Readers @ref{go to the POSIX-MQUEUE∶∶MAX-MESSAGES generic function, , @t{max-messages}} (generic function) @end table @end defvr @defvr {Slot} message-size @slotsubindex{message-size}@c Message size. @table @strong @item Type @t{(unsigned-byte 64)} @item Initargs @t{:message-size} @item Readers @ref{go to the POSIX-MQUEUE∶∶MESSAGE-SIZE generic function, , @t{message-size}} (generic function) @end table @end defvr @defvr {Slot} current-messages @slotsubindex{current-messages}@c Number of messages currently on queue. @table @strong @item Type @t{(unsigned-byte 64)} @item Initargs @t{:current-messages} @item Readers @ref{go to the POSIX-MQUEUE∶∶CURRENT-MESSAGES generic function, , @t{current-messages}} (generic function) @end table @end defvr @end table @end deftp @deftp {Class} {queue} () @anchor{go to the POSIX-MQUEUE∶∶QUEUE class}@c @classsubindex{queue}@c Main type used to interact with POSIX message queues. It contains a queue's file descriptor (MQD) and a BUFFER used to receive messages. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @item Direct superclasses @t{standard-object} (class) @item Direct methods @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶BUFFER POSIX-MQUEUE∶∶QUEUE method, , @t{buffer}} (method) @item @ref{go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method, , @t{mqd}} (method) @end itemize @item Direct slots @defvr {Slot} mqd @slotsubindex{mqd}@c Message queue's file descriptor. @table @strong @item Type @t{(unsigned-byte 32)} @item Initargs @t{:mqd} @item Readers @ref{go to the POSIX-MQUEUE∶∶MQD generic function, , @t{mqd}} (generic function) @end table @end defvr @defvr {Slot} buffer @slotsubindex{buffer}@c Buffer used to receive messages form queue. @table @strong @item Type @t{(array (unsigned-byte 8))} @item Initargs @t{:buffer} @item Readers @ref{go to the POSIX-MQUEUE∶∶BUFFER generic function, , @t{buffer}} (generic function) @end table @end defvr @end table @end deftp @node Exported types, , Exported classes, Exported definitions @subsection Types @deftp {Type} {create-modes} () @anchor{go to the POSIX-MQUEUE∶∶CREATE-MODES type}@c @typesubindex{create-modes}@c Type used to describe CREATE-MODES in OPEN-QUEUE. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end table @end deftp @deftp {Type} {open-flags} () @anchor{go to the POSIX-MQUEUE∶∶OPEN-FLAGS type}@c @typesubindex{open-flags}@c Type used to describe OPEN-FLAGS in OPEN-QUEUE. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @end table @end deftp @c -------------------- @c Internal definitions @c -------------------- @node Internal definitions, , Exported definitions, Definitions @section Internal definitions @menu * Internal symbol macros:: * Internal macros:: * Internal functions:: * Internal generic functions:: * Internal conditions:: * Internal classes:: @end menu @node Internal symbol macros, Internal macros, Internal definitions, Internal definitions @subsection Symbol macros @defvr {Symbol Macro} *errno* @anchor{go to the POSIX-MQUEUE∶∶*ERRNO* symbol macro}@c @symbolmacrosubindex{*errno*}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/translation․lisp file, , @t{translation.lisp}} (file) @item Expansion @t{(posix-mqueue::%var-accessor-*errno*)} @end table @end defvr @node Internal macros, Internal functions, Internal symbol macros, Internal definitions @subsection Macros @deffn {Macro} {%receive} RECEIVE-FN CURRENT-FN RETURN-FORM &rest CURRENT-FN-ARGS @anchor{go to the POSIX-MQUEUE∶∶%RECEIVE macro}@c @macrosubindex{%receive}@c Macro used for generating various receive functions.@* RECEIVE-FN is a function called to receive a message. CURRENT-FN is a function which will be called on interrupt. RETURN-FORM is a form placed at the end of the macro. It has access to BUFFER@comma{} LENGTH (of received message) and PRIORITY (of received message). CURRENT-FN-ARGS are additional arguments placed at the end of RECEIVE-FN and CURRENT-FN. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @deffn {Macro} {%send} SEND-FN CURRENT-FN &rest SEND-FN-ARGS @anchor{go to the POSIX-MQUEUE∶∶%SEND macro}@c @macrosubindex{%send}@c A macro used to generate send functions. SEND-FN is a function used to send the actual message. CURRENT-FN is a function which is called on interrupt. SEND-FN-ARGS are additional arguments placed at the end of SEND-FN and CURRENT-FN call. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @node Internal functions, Internal generic functions, Internal macros, Internal definitions @subsection Functions @deffn {Function} {%var-accessor-*errno*} () @anchor{go to the POSIX-MQUEUE∶∶%VAR-ACCESSOR-*ERRNO* function}@c @functionsubindex{%var-accessor-*errno*}@c @deffnx {Function} {(setf %var-accessor-*errno*)} VALUE @anchor{go to the POSIX-MQUEUE∶∶❨SETF %VAR-ACCESSOR-*ERRNO*❩ function}@c @functionsubindex{(setf %var-accessor-*errno*)}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/translation․lisp file, , @t{translation.lisp}} (file) @end table @end deffn @deffn {Function} {mq-close} MQDES @anchor{go to the POSIX-MQUEUE∶∶MQ-CLOSE function}@c @functionsubindex{mq-close}@c Close POSIX message queue. See mq_close(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-getattr} MQDES ATTR @anchor{go to the POSIX-MQUEUE∶∶MQ-GETATTR function}@c @functionsubindex{mq-getattr}@c Get POSIX message queue default attributes. See mq_getattr(3). @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-open} NAME OFLAG MODE ATTR @anchor{go to the POSIX-MQUEUE∶∶MQ-OPEN function}@c @functionsubindex{mq-open}@c Open POSIX message queue. See mq_open(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-receive} MQDES MSG-PTR MSG-LEN MSG-PRIO @anchor{go to the POSIX-MQUEUE∶∶MQ-RECEIVE function}@c @functionsubindex{mq-receive}@c Receive a message from POSIX message queue. See mq_receive(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-send} MQDES MSG-PTR MSG-LEN MSG-PRIO @anchor{go to the POSIX-MQUEUE∶∶MQ-SEND function}@c @functionsubindex{mq-send}@c Send a message to POSIX message queue. See mq_send(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-setattr} MQDES NEWATTR OLDATTR @anchor{go to the POSIX-MQUEUE∶∶MQ-SETATTR function}@c @functionsubindex{mq-setattr}@c Set POSIX message queue non-blocking attribute. See mq_setattr(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-timedreceive} MQDES MSG-PTR MSG-LEN MSG-PRIO ABS-TIMEOUT @anchor{go to the POSIX-MQUEUE∶∶MQ-TIMEDRECEIVE function}@c @functionsubindex{mq-timedreceive}@c Receive a message from POSIX message queue. See mq_timedreceive(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-timedsend} MQDES MSG-PTR MSG-LEN MSG-PRIO ABS-TIMEOUT @anchor{go to the POSIX-MQUEUE∶∶MQ-TIMEDSEND function}@c @functionsubindex{mq-timedsend}@c Send a message to POSIX message queue. See mq_timedsend(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {mq-unlink} NAME @anchor{go to the POSIX-MQUEUE∶∶MQ-UNLINK function}@c @functionsubindex{mq-unlink}@c Unlink POSIX message queue. See mq_unlink(3) for more details. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/spec․lisp file, , @t{spec.lisp}} (file) @end table @end deffn @deffn {Function} {random-queue-name} &key LENGTH START END @anchor{go to the POSIX-MQUEUE∶∶RANDOM-QUEUE-NAME function}@c @functionsubindex{random-queue-name}@c Generate random queue name with specified LENGTH@comma{} with characters starting from START to END. With slash at the beginning. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/lib․lisp file, , @t{lib.lisp}} (file) @end table @end deffn @node Internal generic functions, Internal conditions, Internal functions, Internal definitions @subsection Generic functions @deffn {Generic Function} {message} CONDITION @anchor{go to the POSIX-MQUEUE∶∶MESSAGE generic function}@c @genericsubindex{message}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {message} (CONDITION @t{generic}) @anchor{go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method}@c @methodsubindex{message}@c @table @strong @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {mqd} OBJECT @anchor{go to the POSIX-MQUEUE∶∶MQD generic function}@c @genericsubindex{mqd}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {mqd} (QUEUE @t{queue}) @anchor{go to the POSIX-MQUEUE∶∶MQD POSIX-MQUEUE∶∶QUEUE method}@c @methodsubindex{mqd}@c Message queue's file descriptor. @table @strong @item Source @ref{go to the cl-posix-mqueue/src/queue․lisp file, , @t{queue.lisp}} (file) @end table @end deffn @end table @end deffn @deffn {Generic Function} {strerror} CONDITION @anchor{go to the POSIX-MQUEUE∶∶STRERROR generic function}@c @genericsubindex{strerror}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Methods @deffn {Method} {strerror} (CONDITION @t{generic}) @anchor{go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method}@c @methodsubindex{strerror}@c @table @strong @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @end table @end deffn @end table @end deffn @node Internal conditions, Internal classes, Internal generic functions, Internal definitions @subsection Conditions @deftp {Condition} {access-denied} () @anchor{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition}@c @conditionsubindex{access-denied}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-PERMISSION condition, , @t{access-denied-permission}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-SLASHES condition, , @t{access-denied-slashes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED-ON-UNLINK condition, , @t{access-denied-on-unlink}} (condition) @end itemize @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:strerror} @tab @t{"permission denied"} @end multitable @end table @end deftp @deftp {Condition} {bad-file-descriptor} () @anchor{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition}@c @conditionsubindex{bad-file-descriptor}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-INVALID condition, , @t{bad-file-descriptor-invalid}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-RECEIVE condition, , @t{bad-file-descriptor-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR-ON-SEND condition, , @t{bad-file-descriptor-on-send}} (condition) @end itemize @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:strerror} @tab @t{"bad file descriptor"} @end multitable @end table @end deftp @deftp {Condition} {generic} () @anchor{go to the POSIX-MQUEUE∶∶GENERIC condition}@c @conditionsubindex{generic}@c Generic error used as the base for all conditions. Must contain STRERROR and MESSAGE. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @t{error} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶OUT-OF-MEMORY condition, , @t{out-of-memory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶FILE-EXISTS condition, , @t{file-exists}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶FILE-TABLE-OVERFLOW condition, , @t{file-table-overflow}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶TOO-MANY-OPEN-FILES condition, , @t{too-many-open-files}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-SPACE-LEFT-ON-DEVICE condition, , @t{no-space-left-on-device}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NAME-TOO-LONG condition, , @t{name-too-long}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INTERRUPTED-SYSTEM-CALL condition, , @t{interrupted-system-call}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition, , @t{no-file-or-directory}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶BAD-FILE-DESCRIPTOR condition, , @t{bad-file-descriptor}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶ACCESS-DENIED condition, , @t{access-denied}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition, , @t{invalid-argument}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition, , @t{message-too-long}} (condition) @end itemize @item Direct methods @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE POSIX-MQUEUE∶∶GENERIC method, , @t{message}} (method) @item @ref{go to the POSIX-MQUEUE∶∶STRERROR POSIX-MQUEUE∶∶GENERIC method, , @t{strerror}} (method) @end itemize @item Direct slots @defvr {Slot} strerror @slotsubindex{strerror}@c Error string from CFFI's strerror. @table @strong @item Initargs @t{:strerror} @item Readers @ref{go to the POSIX-MQUEUE∶∶STRERROR generic function, , @t{strerror}} (generic function) @end table @end defvr @defvr {Slot} message @slotsubindex{message}@c More specific message string. @table @strong @item Initargs @t{:message} @item Readers @ref{go to the POSIX-MQUEUE∶∶MESSAGE generic function, , @t{message}} (generic function) @end table @end defvr @end table @end deftp @deftp {Condition} {invalid-argument} () @anchor{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT condition}@c @conditionsubindex{invalid-argument}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-NAME condition, , @t{invalid-argument-name}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-SIZES condition, , @t{invalid-argument-sizes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ATTRIBUTES condition, , @t{invalid-argument-attributes}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-UNLINK condition, , @t{invalid-argument-on-unlink}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶INVALID-ARGUMENT-ON-SEND-RECEIVE condition, , @t{invalid-argument-on-send-receive}} (condition) @end itemize @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:strerror} @tab @t{"invalid argument"} @end multitable @end table @end deftp @deftp {Condition} {message-too-long} () @anchor{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG condition}@c @conditionsubindex{message-too-long}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-RECEIVE condition, , @t{message-too-long-on-receive}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶MESSAGE-TOO-LONG-ON-SEND condition, , @t{message-too-long-on-send}} (condition) @end itemize @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:strerror} @tab @t{"message too long"} @end multitable @end table @end deftp @deftp {Condition} {no-file-or-directory} () @anchor{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY condition}@c @conditionsubindex{no-file-or-directory}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/condition․lisp file, , @t{condition.lisp}} (file) @item Direct superclasses @ref{go to the POSIX-MQUEUE∶∶GENERIC condition, , @t{generic}} (condition) @item Direct subclasses @itemize @bullet @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-JUST-SLASH condition, , @t{no-file-or-directory-just-slash}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-NO-CREATE condition, , @t{no-file-or-directory-no-create}} (condition) @item @ref{go to the POSIX-MQUEUE∶∶NO-FILE-OR-DIRECTORY-ON-UNLINK condition, , @t{no-file-or-directory-on-unlink}} (condition) @end itemize @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:strerror} @tab @t{"no such file or directory"} @end multitable @end table @end deftp @node Internal classes, , Internal conditions, Internal definitions @subsection Classes @deftp {Class} {mq-attr-tclass} () @anchor{go to the POSIX-MQUEUE∶∶MQ-ATTR-TCLASS class}@c @classsubindex{mq-attr-tclass}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @itemize @bullet @item @t{translatable-foreign-type} (class) @item @t{foreign-struct-type} (class) @end itemize @end table @end deftp @deftp {Class} {mq-non-blocking-attr-type} () @anchor{go to the POSIX-MQUEUE∶∶MQ-NON-BLOCKING-ATTR-TYPE class}@c @classsubindex{mq-non-blocking-attr-type}@c Type used to get attributes through a pointer. To fill a CStruct through a pointer passed to function. Translation for this type does exactly this@comma{} at the end of the function call@comma{} it fills Lisp class with values from MQ-ATTR. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @t{enhanced-foreign-type} (class) @item Direct methods @t{expand-to-foreign-dyn} (method) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:actual-type} @tab @t{(quote (:pointer))} @end multitable @end table @end deftp @deftp {Class} {mq-size-attr-type} () @anchor{go to the POSIX-MQUEUE∶∶MQ-SIZE-ATTR-TYPE class}@c @classsubindex{mq-size-attr-type}@c Type used to pass ATTRIBUTES as C-function argument. Translation maps ATTRIBUTES to MQ-ATTR CStruct. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @t{enhanced-foreign-type} (class) @item Direct methods @t{expand-to-foreign-dyn} (method) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:actual-type} @tab @t{(quote (:pointer))} @end multitable @end table @end deftp @deftp {Class} {mqd-type} () @anchor{go to the POSIX-MQUEUE∶∶MQD-TYPE class}@c @classsubindex{mqd-type}@c Type used to describe POSIX message queue file descriptor. Also@comma{} there are translations defined for this type (:int) from QUEUE class. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @t{enhanced-foreign-type} (class) @item Direct methods @t{expand-to-foreign} (method) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:actual-type} @tab @t{(quote (:int))} @end multitable @end table @end deftp @deftp {Class} {result-type} () @anchor{go to the POSIX-MQUEUE∶∶RESULT-TYPE class}@c @classsubindex{result-type}@c Type used to describe C-style result of functions. There is a translation that maps -1 to keyword representation of the error through the errno. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @t{enhanced-foreign-type} (class) @item Direct methods @t{expand-from-foreign} (method) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:actual-type} @tab @t{(quote (:int))} @end multitable @end table @end deftp @deftp {Class} {timespec-tclass} () @anchor{go to the POSIX-MQUEUE∶∶TIMESPEC-TCLASS class}@c @classsubindex{timespec-tclass}@c @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @itemize @bullet @item @t{translatable-foreign-type} (class) @item @t{foreign-struct-type} (class) @end itemize @end table @end deftp @deftp {Class} {timespec-type} () @anchor{go to the POSIX-MQUEUE∶∶TIMESPEC-TYPE class}@c @classsubindex{timespec-type}@c Type used to pass LOCAL-TIME:TIMESTAMP as C timespec. @table @strong @item Package @ref{go to the POSIX-MQUEUE package, , @t{posix-mqueue}} @item Source @ref{go to the cl-posix-mqueue/src/types․lisp file, , @t{types.lisp}} (file) @item Direct superclasses @t{enhanced-foreign-type} (class) @item Direct methods @t{expand-to-foreign-dyn} (method) @item Direct Default Initargs @multitable @columnfractions 0.3 0.5 @headitem Initarg @tab Value @item @t{:actual-type} @tab @t{(quote (:pointer))} @end multitable @end table @end deftp @c ==================================================================== @c Indexes @c ==================================================================== @node Indexes, , Definitions, Top @appendix Indexes @menu * Concept index:: * Function index:: * Variable index:: * Data type index:: @end menu @c ------------- @c Concept index @c ------------- @node Concept index, Function index, Indexes, Indexes @appendixsec Concepts @printindex cp @page @c -------------- @c Function index @c -------------- @node Function index, Variable index, Concept index, Indexes @appendixsec Functions @printindex fn @page @c -------------- @c Variable index @c -------------- @node Variable index, Data type index, Function index, Indexes @appendixsec Variables @printindex vr @page @c --------------- @c Data type index @c --------------- @node Data type index, , Variable index, Indexes @appendixsec Data types @printindex tp @bye @c cl-posix-mqueue.texi ends here
104,277
Common Lisp
.l
2,660
37.304511
144
0.748351
xFA25E/cl-posix-mqueue
1
0
1
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
58fbf855e96489c1b7ec9ba8a1f4733035a5ac97172a5b3f6f38ca2c454e9c02
24,629
[ -1 ]
24,644
lodash-sdf.lisp
vlad-km_lodash/lodash-sdf.lisp
;;; -*- mode:lisp; coding:utf-8 -*- ;;; Lisp wrapper for lodash.js ;;; Copyright © 2018 Vladimir Mezentsev ;;; (lores:defsys :loadsh :path "git/lodash" :components ((:file "lodash"))) ;;; EOF
206
Common Lisp
.lisp
8
23.125
40
0.642487
vlad-km/lodash
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
88967ad40d56eef55e9373e8f84960051d0f42d1f1cc0dab51cadeb8cd48cd62
24,644
[ -1 ]
24,645
lodash.lisp
vlad-km_lodash/lodash.lisp
;;; -*- mode:lisp; coding:utf-8 -*- ;;; Lisp wrapper for lodash.js ;;; Copyright © 2018 Vladimir Mezentsev ;;; (in-package :cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (unless #j:lodash_loaded (klib:resloadjs "node_modules/lodash/lodash.js" (lambda () (setf #j:lodash_loaded 1) (push :lodash *features*))))) ;;; template (defmacro lodef (fn rn) `(fset ',fn (oget JSCL::*ROOT* "_" ,rn))) (lodef _.replace "replace") (lodef _.filter "filter" ) (lodef _.eq "eq") (lodef _.isEqual "isEqual") (lodef _.isDate "isDate") (lodef _.isArrayLike "isArrayLike") (lodef _.isArrayLikeObject "isArrayLikeObject") (lodef _.isElement "isElement") (lodef _.isEmpty "isEmpty") (lodef _.isError "isError") (lodef _.isFunction "isFunction") (lodef _.isNative "isNative") (lodef _.isNil "isNil") (lodef _.isNull "isNull") (lodef _.isObject "isObject") (lodef _.isObjectLike "isObjectLike") (lodef _.isPlainObject "isPlainObject") (lodef _.isRegExp "isRegExp") (lodef _.isUndefined "isUndefined") (lodef _.isMatch "isMatch") (lodef _.camelCase "camelCase") ;;; EOF
1,136
Common Lisp
.lisp
37
27.72973
54
0.674033
vlad-km/lodash
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
08c9bc6431423dd088ec6fcfb90b878fbb707cd20e24e764c7202887c03915d6
24,645
[ -1 ]
24,663
util.lisp
petelliott_peroku/peroku-client/util.lisp
(defpackage :peroku-client.util (:nicknames :pcli.util :util) (:use :cl) (:export #:auth-header #:write-websocket #:write-ws-logs #:tar-and-b64 #:prepare-tar-dir #:relative-dir)) (in-package :peroku-client.util) (defun auth-header (token &optional headers) "return the auth header in an alist with other headers" (if token (cons `("Authorization" . ,(concatenate 'string "Bearer " token)) headers) headers)) (defun write-websocket (uri &key output-stream insecure additional-headers) "writes the contents of a websocket to output-stream. defaults to stdout. will block until the socket is closed" (let ((sem (bt-sem:make-semaphore)) (ws (wsd:make-client uri :additional-headers additional-headers))) (wsd:start-connection ws :verify (not insecure)) (wsd:on :message ws (lambda (message) (write-string message output-stream))) (wsd:on :close ws (lambda (&key code reason) (declare (ignore code) (ignore reason)) (bt-sem:signal-semaphore sem))) (bt-sem:wait-on-semaphore sem))) (defun write-ws-logs (uri &key insecure additional-headers) "writes docker container logs to the appropriate streams" (let ((sem (bt-sem:make-semaphore)) (ws (wsd:make-client uri :additional-headers additional-headers))) (wsd:start-connection ws :verify (not insecure)) (wsd:on :message ws (lambda (message) (let* ((json (json:decode-json-from-string message)) (strm (cdr (assoc :stream json))) (data (cdr (assoc :data json)))) (write-string data (cond ((string= strm "stdout") *standard-output*) ((string= strm "stderr") *error-output*)))))) (wsd:on :close ws (lambda (&key code reason) (declare (ignore code) (ignore reason)) (bt-sem:signal-semaphore sem))) (handler-case (bt-sem:wait-on-semaphore sem) (sb-sys:interactive-interrupt () (wsd:close-connection ws) (format t "~%"))))) (defun tar-and-b64 (path) "creates a tarfile from path and outputs a base64 string" (base64:usb8-array-to-base64-string (flexi-streams:with-output-to-sequence (s :element-type '(unsigned-byte 8)) (let ((archive (archive:open-archive 'archive:tar-archive s :direction :output)) (files (prepare-tar-dir path))) (dolist (file files (archive:finalize-archive archive)) (archive:write-entry-to-archive archive (archive:create-entry-from-pathname archive file))))))) (defun prepare-tar-dir (dir) "prepares a list of files for a direcotry to tar" (apply #'concatenate 'list (mapcar (lambda (elem) (if (fad:directory-pathname-p elem) (prepare-tar-dir elem) (list (relative-dir elem)))) (fad:list-directory dir)))) (defun relative-dir (path &optional relto) "gets a directory relative to relto. if relto is not specified *default-pathname-defaults is used" (unless relto (setf relto *default-pathname-defaults*)) (fad:canonical-pathname (subseq (namestring path) (length (namestring relto)))))
3,388
Common Lisp
.lisp
88
30.193182
79
0.616413
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
eb7c7f36c013f11db7fb31db3f4b225347dde160e33382de7fc1da0e49c596ad
24,663
[ -1 ]
24,664
main.lisp
petelliott_peroku/peroku-client/main.lisp
(defpackage :peroku-client.main (:nicknames :pcli.main) (:use :cl) (:export #:main #:start-peroku)) (in-package :peroku-client.main) (defun main (args) (let ((insecure (when (string= (car args) "noverify") (setf args (cdr args)) t))) (config:with-config (#P".peroku.json") (handler-case (cond ((string= (car args) "list") (core:list-projects config:*token* config:*peroku* :insecure insecure)) ((string= (car args) "logs") (core:logs config:*token* config:*peroku* config:*project* :insecure insecure)) ((string= (car args) "up") (core:up config:*token* config:*peroku* config:*project* config:*rule* :insecure insecure)) ((string= (car args) "down") (core:down config:*token* config:*peroku* config:*project* :insecure insecure)) (t (format t "~&useage: perok [noverify] [up|down|list|logs]~%"))) (CL+SSL:SSL-ERROR-VERIFY () (format *error-output* "~&Unable to verify ssl certificate.~%") (format *error-output* "~&Use 'perok noverify *' to not check certificate validity.~%") (uiop:quit 1)) (DEXADOR.ERROR:HTTP-REQUEST-FORBIDDEN () (format *error-output* "~&Missing or Invalid token~%") (uiop:quit 1)))))) (defun start-peroku () (main (uiop:command-line-arguments)))
1,388
Common Lisp
.lisp
31
36.709677
102
0.597489
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e862682d6783ed42ad51fa71aa6f5d519d204b8b9478a537f7a3adf4eaad700b
24,664
[ -1 ]
24,665
config.lisp
petelliott_peroku/peroku-client/config.lisp
(defpackage :peroku-client.config (:nicknames :pcli.config :config) (:use :cl) (:export *token* *peroku* *project* *rule* #:load-config #:with-config)) (in-package :peroku-client.config) (defvar *token*) (defvar *peroku*) (defvar *project*) (defvar *rule*) (defgeneric load-config (config)) (defmacro with-config ((config) &rest body) "provides an environment with the peroku config bound" `(multiple-value-bind (*token* *peroku* *project* *rule*) (load-config ,config) (progn ,@body))) (defmethod load-config :around (config) "load a configuration" (let ((params (call-next-method))) (values (cdr (assoc :token params)) (cdr (assoc :peroku params)) (cdr (assoc :project params)) (cdr (assoc :rule params))))) (defmethod load-config ((config string)) "load a configuration from a json string" (json:decode-json-from-string config)) (defmethod load-config ((config stream)) "load a configuration from a stream" (json:decode-json config)) (defmethod load-config ((config pathname)) "load a configuration from a filename" (handler-case (with-open-file (strm config :direction :input) (json:decode-json strm)) (SB-INT:SIMPLE-FILE-ERROR () (format *error-output* "could not open .peroku.json~%") (uiop:quit 1))))
1,333
Common Lisp
.lisp
43
27.093023
61
0.681499
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
59f64c249ab42da1e2fded441868ad7553e3864e21f423fa5f81db43380ba648
24,665
[ -1 ]
24,666
core.lisp
petelliott_peroku/peroku-client/core.lisp
(defpackage :peroku-client.core (:nicknames :pcli.core :core) (:use :cl) (:export #:list-projects #:logs #:up #:down)) (in-package :peroku-client.core) (defun list-projects (token peroku &key insecure) "list all projects managed by peroku" (let ((projects (json:decode-json-from-string (dex:get (concatenate 'string "https://" peroku "/list") :headers (util:auth-header token) :insecure insecure)))) (mapc (lambda (alist) (format t "~&~20a~a~%" (cdr (assoc :project alist)) (cdr (assoc :rule alist)))) projects))) (defun logs (token peroku project &key insecure) "display a projects logs" (util:write-ws-logs (concatenate 'string "wss://" peroku "/projects/" project "/logs") :insecure insecure :additional-headers (util:auth-header token))) (defun up (token peroku project rule &key insecure) "bring up the project" (let ((logid (cdr (assoc :logid (json:decode-json-from-string (dex:post (concatenate 'string "https://" peroku "/run") :headers (util:auth-header token '(("Content-Type" . "application/json"))) :content (json:encode-json-to-string `(("project" . ,project) ("rule" . ,rule) ("data" . ,(util:tar-and-b64 #P".")))) :insecure insecure)))))) (util:write-websocket (concatenate 'string "wss://" peroku "/logs/" logid) :insecure insecure :additional-headers (util:auth-header token)))) (defun down (token peroku project &key insecure) "take down a project" (handler-case (progn (dex:delete (concatenate 'string "https://" peroku "/projects/" project) :headers (util:auth-header token) :insecure insecure) (format t "~&deleted ~a~%" project)) (DEXADOR.ERROR:HTTP-REQUEST-NOT-FOUND () (format t "~&project ~a not found~%" project))))
2,670
Common Lisp
.lisp
73
21.493151
78
0.447836
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
b34e1a48b08784a24421dd24eab4a6172e76ce36225e1cfb750d366054854d71
24,666
[ -1 ]
24,667
logger.lisp
petelliott_peroku/peroku/logger.lisp
(defpackage :peroku.logger (:nicknames :logger) (:use :cl) (:export #:make-logger #:logger-send #:logger-attach #:logger-close)) (in-package :peroku.logger) (defstruct logger (lock (bt:make-lock)) (closed nil) (history '()) (websockets '())) (defun logger-send (logger message) "sends a message to a websocket logger" (bt:with-lock-held ((logger-lock logger)) (push message (logger-history logger)) (setf (logger-websockets logger) (remove-if (lambda (sock) (wsd:send sock message) (eq (wsd:ready-state sock) :closed)) (logger-websockets logger))))) (defun logger-attach (logger ws) "attaches a websocket to the logger, catching it up with the previous messages" (bt:with-lock-held ((logger-lock logger)) (loop for entry in (reverse (logger-history logger)) do (wsd:send ws entry)) (if (logger-closed logger) (wsd:close-connection ws) (push ws (logger-websockets logger))))) (defun logger-close (logger) "close the connected websockets, and close new websockets after sending them the history" (bt:with-lock-held ((logger-lock logger)) (loop for ws in (logger-websockets logger) do (wsd:close-connection ws)) (setf (logger-closed logger) t)))
1,320
Common Lisp
.lisp
42
26.214286
59
0.663515
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a5d1b472f910df44ea6ee5d4eb6b2a1b82948645d78eee5473353a56f2e6f2ba
24,667
[ -1 ]
24,668
core.lisp
petelliott_peroku/peroku/core.lisp
(defpackage :peroku.core (:nicknames core) (:use :cl) (:export #:+label+ #:build #:create-container #:replace-container #:list-projects #:delete-project)) (in-package :peroku.core) (defvar +label+ "ca.pelliott.peroku.managed") (defun build (tarstring &key strmfun) "builds a project image from a name and base64 tarfile string" (cdr (assoc :+ID+ (docker:build-image (base64:base64-string-to-usb8-array tarstring) :call strmfun)))) (defun create-container (project rule image) "creates the containers for a project" (docker:create-container image :name project :json `(("Labels" (,+label+ . "") ("traefik.port" . "80") ("traefik.enable" . "true") ("traefik.frontend.rule" . ,rule)) ("HostConfig" . (("NetworkMode" . "peroku_default") ("RestartPolicy" . (("Name" . "always") ("RestartPolicy" . 0)))))))) (defun replace-container (project rule image) "creates a new container but deletes the old one first (if it exists)" (ignore-errors (delete-project project)) (create-container project rule image)) (defun list-projects () "lists all containers manged by peroku" (let ((dockerinfo (docker:list-containers :all t :filters `(("label" . #(,+label+)))))) (mapcar (lambda (cont) `(("project" . ,(subseq (car (cdr (assoc :*NAMES cont))) 1)) ("rule" . ,(cdr (assoc :traefik.frontend.rule (cdr (assoc :*LABELS cont))))))) dockerinfo))) (defun delete-project (project) "delete a project" ;TODO: prune after project deletion (docker:remove-container project :force t))
1,841
Common Lisp
.lisp
54
26.018519
72
0.577853
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
68d138c4c5b360c96789e581942b6018b75557465923d312325594a34adb43ec
24,668
[ -1 ]
24,669
log-manager.lisp
petelliott_peroku/peroku/log-manager.lisp
(defpackage :peroku.log-manager (:nicknames :logman :log-manager) (:use :cl) (:export #:*log-manager* #:log-manager-endpoints #:*log-manager-mw* #:make-log-endpoint #:make-log-manager #:*log-manager* #:is-endpoint #:log-manager-attach)) (in-package :peroku.log-manager) (defstruct log-manager (lock (bt:make-lock)) (endpoints (make-hash-table :test 'equal)) (single-use (make-hash-table :test 'equal))) (defvar *log-manager* "a global log manager bound by lexical let with the *log-manager-mw*") (defvar *log-manager-mw* (lambda (app) (let ((*log-manager* (make-log-manager))) (lambda (env) (funcall app env)))) "a lack middleware that provides a global log-manager") (defun is-endpoint (logid) "returns t if logid is an endpoint, otherwise nil" (bt:with-lock-held ((log-manager-lock *log-manager*)) (if (gethash logid (log-manager-endpoints *log-manager*)) t nil))) (defun log-manager-attach (logid ws) "attach a new websocket to an endpoint" (bt:with-lock-held ((log-manager-lock *log-manager*)) (wsd:on :open ws (lambda () (logger:logger-attach (gethash logid (log-manager-endpoints *log-manager*)) ws) (when (gethash logid (log-manager-single-use *log-manager*)) (remhash logid (log-manager-single-use *log-manager*)) (remhash logid (log-manager-endpoints *log-manager*))))))) (defun make-log-endpoint (&key single-use) "create a new logging endpoint. returns the endpoint id and the endpoints logger" (let ((logid (random-string))) (if (is-endpoint logid) (make-log-endpoint *log-manager*) (let ((logger (logger:make-logger))) (setf (gethash logid (log-manager-endpoints *log-manager*)) logger) (when single-use (setf (gethash logid (log-manager-single-use *log-manager*)) t)) (values logid logger))))) (defvar +ascii-alphabet+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNIPQRSTUVWXYZ0123456789") (defun random-string (&optional (length 16) (alphabet +ascii-alphabet+)) "Returns a random alphabetic string. The returned string will contain LENGTH characters chosen from the vector ALPHABET. " (loop with id = (make-string length) with alphabet-length = (length alphabet) for i below length do (setf (cl:aref id i) (cl:aref alphabet (random alphabet-length))) finally (return id)))
2,577
Common Lisp
.lisp
69
30.637681
90
0.645783
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
c5880f86b335cd262c34f2b04aca08a3be015f7e51ac3bdaf6727802ae3b5485
24,669
[ -1 ]
24,670
example.lisp
petelliott_peroku/example/example.lisp
(defpackage :example (:use :cl) (:export #:*app*)) (in-package :example) (defvar *app* (lambda (env) (declare (ignore env)) '(200 (:content-type "text/plain") ("peroku example"))))
201
Common Lisp
.lisp
9
19.111111
60
0.615789
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
8b0c8b897dcb42f4b51b2217d5de614888581e33bf8970b8fcb18695d7408ee9
24,670
[ -1 ]
24,671
api.lisp
petelliott_peroku/peroku-api/api.lisp
(defpackage :peroku.api (:nicknames api) (:use :cl :peroku.api.app) (:export)) (in-package :peroku.api) (setf (ningle:route *app* "/" :method :GET) (lambda (params) (declare (ignore params)) (format nil "peroku ~a" (asdf:component-version (asdf:find-system :peroku-api))))) (setf (ningle:route *app* "/list" :method :GET :secured t) (lambda (params) (declare (ignore params)) (headers :content-type "application/json") (let ((projects (core:list-projects))) (if projects (json:encode-json-to-string projects) "[]")))) (auth:unauth "/list" :method :GET) (setf (ningle:route *app* "/run" :method :POST :secured t) (lambda (params) (headers :content-type "application/json") (let ((project (cdr (assoc "project" params :test #'string=))) (rule (cdr (assoc "rule" params :test #'string=))) (data (cdr (assoc "data" params :test #'string=)))) (multiple-value-bind (logid logger) (logman:make-log-endpoint :single-use t) (bt:make-thread (lambda () (let* ((image (core:build data :strmfun (lambda (message) (logger:logger-send logger message)))) (cont (core:replace-container project rule image))) (logger:logger-close logger) (docker:start-container project)))) (json:encode-json-to-string `(("logid" . ,logid))))))) (auth:unauth "/run" :method :POST) (setf (ningle:route *app* "/projects/:project" :method :GET :secured t) (lambda (params) (declare (ignore params)) "getting project not yet implemented")) (auth:unauth "/project/:project" :method :GET) (setf (ningle:route *app* "/projects/:project" :method :DELETE :secured t) (lambda (params) (handler-case (core:delete-project (cdr (assoc :project params))) (error () `(404 (:content-type "text/plain") (,(format nil "project '~a' not found." (cdr (assoc :project params))))))))) (auth:unauth "/project/:project" :method :DELETE) (defun headers (&rest headers) (setf (lack.response:response-headers ningle:*response*) (append (lack.response:response-headers ningle:*response*) headers)))
2,540
Common Lisp
.lisp
60
31.266667
74
0.548845
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e80d2f563861ba5b374c17a5cb2252beb77adb41a5b423936f9a1f1a57ecfd58
24,671
[ -1 ]
24,672
logs.lisp
petelliott_peroku/peroku-api/logs.lisp
(defpackage :peroku.api.logs (:nicknames :logs) (:use :cl)) (in-package :peroku.api.logs) (setf (ningle:route peroku.api.app:*app* "/logs/:logid" :method :GET :secured t) (lambda (params) (let ((ws (wsd:make-server (lack.request:request-env ningle:*request*))) (logid (cdr (assoc :logid params)))) (if (logman:is-endpoint logid) (progn (logman:log-manager-attach logid ws) (lambda (responder) (declare (ignore responder)) (wsd:start-connection ws))) '(404 (:content-type "text/plain") ("logging endpoint not found")))))) (auth:ws-unauth "/logs/:logid" :method :GET) (defun forward-docker-stream (strm ws) "copies a docker stream to json messages to a websocket" (let* ((sem (bt:make-semaphore)) (thread (bt:make-thread (lambda () (bt:wait-on-semaphore sem) (loop for line = (docker:read-docker-line strm) until (null line) do (wsd:send ws (json:encode-json-to-string `(("stream" . ,(first line)) ("data" ., (third line)))))) (wsd:close-connection ws))))) (wsd:on :open ws (lambda () (bt:signal-semaphore sem))) (wsd:on :close ws (lambda (&key code reason) (declare (ignore code reason)) (bt:destroy-thread thread))))) (setf (ningle:route peroku.api.app:*app* "/projects/:project/logs" :method :GET :secured t) (lambda (params) (let* ((ws (wsd:make-server (lack.request:request-env ningle:*request*))) (project (cdr (assoc :project params))) (thread nil) (strm (docker:container-logs project :follow 1))) (forward-docker-stream strm ws) (lambda (responder) (declare (ignore responder)) (wsd:start-connection ws))))) (auth:ws-unauth "/projects/:project/logs" :method :GET) (setf logman:*log-manager* (logman:make-log-manager)) ; TODO: fix this #| (print peroku.api:*app*) (setf peroku.api:*app* (lack:builder logman:*log-manager-mw* peroku.api:*app*)) (print peroku.api:*app*) (print "") |#
2,363
Common Lisp
.lisp
63
27.396825
91
0.547005
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2f7aae312ae84815d5699213c22463b392ec0dcc1710d66478bc6a4a249fbbbf
24,672
[ -1 ]
24,673
app.lisp
petelliott_peroku/peroku-api/app.lisp
(defpackage :peroku.api.app (:use :cl) (:export #:*app*)) (in-package :peroku.api.app) (defparameter *app* (make-instance 'ningle:<app>))
148
Common Lisp
.lisp
6
22
50
0.664286
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
1346c5d2d78289670ff7d488b3530bd1ef87de8990b08a24c9f63a607ca9c006
24,673
[ -1 ]
24,674
auth.lisp
petelliott_peroku/peroku-api/auth.lisp
(defpackage :peroku.api.auth (:nicknames auth) (:use :cl) (:export #:*token* #:unauth #:ws-unauth)) (in-package :peroku.api.auth) (defparameter *token* (uiop:getenv "PEROKU_TOK")) (setf (ningle:requirement peroku.api.app:*app* :secured) (lambda (value) (declare (ignore value)) (or (null *token*) (string= *token* (get-token (lack.request:request-headers ningle:*request*)))))) (defun get-token (headers) (let ((auth (gethash "authorization" headers))) (let* ((parts (cl-ppcre:split "\\s+" auth)) (atype (first parts)) (aval (second parts))) (cond ((string= atype "Bearer") aval) ((string= atype "Basic") (let* ((authparts (cl-ppcre:split ":" (base64:base64-string-to-string aval))) (username (first authparts)) (password (second authparts))) password)))))) (defun unauth (&rest args) "define an unautorised endpoint for correct error codes" (setf (apply #'ningle:route peroku.api.app:*app* args) (lambda (params) (declare (ignore params)) '(403 (:content-type "text/plain") ("Invalid token."))))) (defun ws-unauth (&rest args) "define an unautorised websocket endpoint for correct error codes" (setf (apply #'ningle:route peroku.api.app:*app* args) (lambda (params) (let ((ws (wsd:make-server (lack.request:request-env ningle:*request*)))) (wsd:on :open ws (lambda () (wsd:close-connection ws "invalid token" 4001))) (lambda (responder) (declare (ignore responder)) (wsd:start-connection ws))))))
1,820
Common Lisp
.lisp
51
26.411765
72
0.558272
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
005935e79e9442f7fe25fbab352799155bf47862fa37c83f4ce842fa97271259
24,674
[ -1 ]
24,675
peroku-client.asd
petelliott_peroku/peroku-client.asd
(defpackage :peroku-client-asd (:use :cl :asdf)) (in-package :peroku-client-asd) (defsystem peroku-client :version "0.3.1" :author "Peter Elliott" :license "AGPL" :depends-on (:cl-json :cl-base64 :archive :flexi-streams :websocket-driver-client :bt-semaphore :cl-fad :dexador) :components ((:module "peroku-client" :components ((:file "util") (:file "config") (:file "core") (:file "main")))) :description "the peroku client" :build-operation program-op :build-pathname "perok" :entry-point "peroku-client.main:start-peroku")
737
Common Lisp
.asd
25
20.08
49
0.535211
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
8e3cd4abd7759476433bff2501e9a574f21999c8a69aba8a2be1da46ea6b422c
24,675
[ -1 ]
24,676
peroku.asd
petelliott_peroku/peroku.asd
(defpackage :peroku-asd (:use :cl :asdf)) (in-package :peroku-asd) (defsystem peroku :version "0.3.1" :author "Peter Elliott" :license "AGPL" :depends-on (:docker :cl-json :uiop :websocket-driver-server :cl-base64 :bordeaux-threads) :components ((:module "peroku" :components ((:file "core") (:file "logger") (:file "log-manager")))) :description "the core of a peroku server")
536
Common Lisp
.asd
19
18.947368
45
0.516505
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
f2de0ff917564716debc2badaaed64ba422ea2020d9373f08fcfe22861b2b251
24,676
[ -1 ]
24,677
peroku-api.asd
petelliott_peroku/peroku-api.asd
(defpackage :peroku-api-asd (:use :cl :asdf)) (in-package :peroku-api-asd) (defsystem peroku-api :version "0.3.1" :author "Peter Elliott" :license "AGPL" :depends-on (:ningle :cl-json :uiop :websocket-driver-server :bordeaux-threads :lack :peroku) :components ((:module "peroku-api" :components ((:file "app") (:file "auth") (:file "api") (:file "logs")))) :description "the peroku server")
581
Common Lisp
.asd
21
17.666667
39
0.485663
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
132ead37c09fbb0bd006753a0a3b4c3279a1ebbef60e8f5492d13cf87c0d4d1c
24,677
[ -1 ]
24,678
peroku-example.asd
petelliott_peroku/example/peroku-example.asd
(defpackage :peroku-example-asd (:use :cl :asdf)) (in-package :peroku-example-asd) (defsystem peroku-example :components ((:file "example")))
148
Common Lisp
.asd
5
27.4
34
0.730496
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e974977bac0f6bd3f36dae676ccef3106b71b5e1efe8c5015c4efb6feb40d9ad
24,678
[ -1 ]
24,681
traefik.toml
petelliott_peroku/traefik.toml
debug = false logLevel = "ERROR" defaultEntryPoints = ["https","http"] [entryPoints] [entryPoints.http] address = ":80" [entryPoints.http.redirect] entryPoint = "https" [entryPoints.https] address = ":443" [entryPoints.https.tls] [retry] [docker] endpoint = "unix:///var/run/docker.sock" watch = true exposedByDefault = false # uncomment and modify for letsenrypt #[acme] #email = "[email protected]" #storage = "acme.json" #entryPoint = "https" #onHostRule = true #onDemand = true #[acme.httpChallenge] #entryPoint = "http"
565
Common Lisp
.l
25
20.68
45
0.73271
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
ebd3a2624ed1ff3fdda945ea404a5450f4e9c8ed32c27a934b3a342ba6a88bbc
24,681
[ -1 ]
24,682
docker-compose.yml
petelliott_peroku/docker-compose.yml
version: '3' services: peroku-traefik: image: traefik:v1.7 # The official Traefik docker image restart: always command: --api --docker # Enables the web UI and tells Traefik to listen to docker ports: - "80:80" # The HTTP port - "443:443" # The HTTPS port - "8080:8080" # The Web UI (enabled by --api) volumes: - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events - ./traefik.toml:/traefik.toml #- ./acme.json:/acme.json labels: # change this to expose peroku to your domain name - "traefik.frontend.rule=Host:traefik.localhost" peroku: image: petelliott/peroku # the peroku image environment: - PEROKU_TOK restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock # So that peroku can listen to the Docker events labels: # change this to expose peroku to your domain name - "traefik.frontend.rule=Host:peroku.localhost" - "traefik.port=80"
1,030
Common Lisp
.l
28
31.107143
99
0.662338
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
0f4c1fe44f88b40c3c303793e082cf951d89ea7ad1ff5f9865065c016c0f7a28
24,682
[ -1 ]
24,683
deploy.sh
petelliott_peroku/deploy.sh
#!/usr/bin/env bash PEROKU=$1 PROJECT=$2 RULE=$3 DATA=$(tar -zc . | base64 -w 0) PAYLOAD="{\"project\": \"$PROJECT\", \"rule\": \"$RULE\", \"data\": \"$DATA\"}" curl -H "Content-Type: application/json" \ -H "Authorization: Bearer $PEROKU_TOK" \ -X POST \ --data "$PAYLOAD" \ $PEROKU/run # to prevent missing newline from curl echo
345
Common Lisp
.l
13
24.461538
79
0.631098
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
f469ba9b700d1b099985fed83c6a60e5920b8e0efa8c20cf6e96ef6221617a88
24,683
[ -1 ]
24,684
Dockerfile
petelliott_peroku/Dockerfile
FROM ubuntu:18.04 RUN apt-get update && apt-get install -y sbcl curl git RUN curl -O https://beta.quicklisp.org/quicklisp.lisp RUN sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)'\ --eval '(ql-util:without-prompting (ql:add-to-init-file))' --quit RUN git clone https://github.com/Petelliott/cl-docker.git \ /root/quicklisp/local-projects/cl-docker #TODO: remove this when upstream websocket-driver is fixed RUN git clone https://github.com/Petelliott/websocket-driver.git \ /root/quicklisp/local-projects/websocket-driver # preload some dependencies for better cacheing # missing ones here will be added up when peroku is loaded RUN sbcl --eval '(ql:quickload :clack)' \ --eval '(ql:quickload :bordeaux-threads)' \ --eval '(ql:quickload :ningle)' \ --eval '(ql:quickload :docker)' \ --eval '(ql:quickload :cl-base64)' \ --eval '(ql:quickload :cl-json)' \ --eval '(ql:quickload :websocket-driver-server)' \ --quit COPY peroku-api.asd /root/quicklisp/local-projects/peroku/peroku-api.asd COPY peroku-api/ /root/quicklisp/local-projects/peroku/peroku-api/ COPY peroku.asd /root/quicklisp/local-projects/peroku/peroku.asd COPY peroku/ /root/quicklisp/local-projects/peroku/peroku/ # preload all of the dependancies RUN sbcl --eval '(ql:quickload :peroku-api)' --quit CMD sbcl --eval "(ql:quickload '(:clack :peroku-api))" \ --eval '(clack:clackup peroku.api.app:*app* :use-thread nil :address "0.0.0.0" :port 80)' \ --quit
1,493
Common Lisp
.l
29
48.551724
95
0.730769
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
54807d9ce6cbd285d49e9fc92379a2662abff68f3bf2d0b0c544fc6f66ae08a4
24,684
[ -1 ]
24,695
Dockerfile
petelliott_peroku/example/Dockerfile
FROM ubuntu:18.04 RUN apt-get update && apt-get install -y sbcl curl libssl-dev RUN curl -O https://beta.quicklisp.org/quicklisp.lisp && \ sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)'\ --eval '(ql-util:without-prompting (ql:add-to-init-file))' --quit RUN sbcl --eval '(ql:quickload :clack)' --quit COPY . /root/quicklisp/local-projects/peroku-example RUN sbcl --eval '(ql:quickload :peroku-example)' --quit CMD sbcl --eval '(ql:quickload :clack)' \ --eval '(ql:quickload :peroku-example)' \ --eval '(clack:clackup example:*app* :use-thread nil :address "0.0.0.0" :port 80)' \ --quit
631
Common Lisp
.l
12
49.416667
88
0.693312
petelliott/peroku
1
0
7
AGPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
8bb2e88c5ffcedb5eca913891007f8fce4f21296d9820fd5f4df93d2fde0ab76
24,695
[ -1 ]
24,714
canvas.lisp
VitoVan_scoreboard/canvas.lisp
(in-package #:calm) ;; change this to suit yourself (defparameter *board-items* '("A" "B" "C" "D" "E")) (unless (str:starts-with? "dist" (uiop:getenv "CALM_CMD")) (swank:create-server)) (setf *calm-window-flags* '(:shown :allow-highdpi :always-on-top)) (setf *calm-window-height* 100) (defun calculate-calm-width () (setf *calm-window-width* (* *calm-window-height* (length *board-items*)))) (calculate-calm-width) (defparameter *calm-window-title* "Score Board") (defparameter *board-colors* (list (list (/ 41 255) (/ 52 255) (/ 98 255)) (list (/ 214 255) (/ 28 255) (/ 78 255)) (list (/ 63 255) (/ 167 255) (/ 150 255)) (list (/ 88 255) (/ 0 255) (/ 255 255)) (list (/ 245 255) (/ 55 255) (/ 236 255)) (list 1 0 0) (list 1 1 0) (list 1 1 1) (list 0 0 0))) (defparameter *board-scores* (list 0 0 0 0 0 0 0 0 0 0)) (defun incf-score (n &optional (delta 1)) (incf (nth n *board-scores*) delta) (with-open-file (s (str:concat (uiop:getenv "APP_DIR") "score.log") :direction :output :if-exists :append :if-does-not-exist :create) (format s "~A: ~A~%" (get-universal-time) *board-scores*))) (defun draw-button (x y w h callback) (c:save) (c:rectangle x y w h) (when (and (c:in-fill *calm-state-mouse-x* *calm-state-mouse-y*) *calm-state-mouse-up* callback) (funcall callback)) (c:fill-path) (c:restore)) (defun draw() (c:move-to 10 10) (loop for item in *board-items* for i from 0 to (length *board-items*) for x = (* i 100) do (apply #'c:set-source-rgb (nth i *board-colors*)) (draw-button x 0 100 100 (lambda () (cond ((= *calm-state-mouse-up* 1) (incf-score i)) ((= *calm-state-mouse-up* 3) (incf-score i -1))))) (c:set-source-rgb 1 1 1) (c:select-font-face "Courier New" :normal :normal) (c:set-font-size 30) (c:move-to (+ x 40) 28) (c:show-text item) (c:set-font-size 60) (c:move-to (+ x 12) 85) (c:show-text (format nil "~2,'0d" (nth i *board-scores*))) ) (setf *calm-state-mouse-up* nil *calm-state-mouse-down* nil))
2,325
Common Lisp
.lisp
62
29.983871
96
0.549822
VitoVan/scoreboard
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e6f533a11ee0a03ac97c4fb950bd2cfd414415163a6d78c9e4cb6902b4ddf38e
24,714
[ -1 ]
24,731
searx.lisp
accraze_cl-searx/searx.lisp
(in-package #:searx) (defun websearch (query) (let* ( (endpoint (uiop:getenv "SEARX_ENDPOINT")) (command (concatenate 'string "curl -v -X GET \"" endpoint "?q=" (drakma:url-encode query :utf-8) "&format=json\"" )) (response (uiop:run-program command :output :string))) (with-input-from-string (s response) (json:decode-json s)) ))
452
Common Lisp
.lisp
17
18.470588
56
0.523041
accraze/cl-searx
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
14a90f6b785e23b8ec6ce104319f915f3376a3b7a1f60767b5876cd502c6ff4a
24,731
[ -1 ]
24,732
searx.asd
accraze_cl-searx/searx.asd
(asdf:defsystem #:searx :description "Searx meta-search client" :author "[email protected]" :license "GPL 3.0" :depends-on (#:drakma #:cl-json) :components ((:file "package") (:file "searx")))
218
Common Lisp
.asd
7
26.571429
41
0.635071
accraze/cl-searx
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
9ea814ba739091f195e8e0489a929e2025d3d101b7a749fa3cbbc6d8110c54bb
24,732
[ -1 ]
24,749
package.lisp
pocket7878_cl-rc/src/package.lisp
;;Copyright (C) <2011> <Pocket7878> ;; ;;This program is free software: you can redistribute it and/or modify ;;it under the terms of the GNU General Public License as published by ;;the Free Software Foundation, either version 3 of the License, or ;;(at your option) any later version. ;; ;;This program 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 General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program. If not, see <http://www.gnu.org/licenses/>. ;; (cl:defpackage :cl-rc (:use :common-lisp :cl-irregsexp :cl-interpol) (:export #:vars #:param #:update #:save #:get-value-from-rc-line #:parse-rc-file))
884
Common Lisp
.lisp
24
33.625
72
0.713953
pocket7878/cl-rc
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
ef36020de7e4f7c927b678d9c1d88cd37788033ddb729e0e56159226b3c1b2a8
24,749
[ -1 ]
24,750
cl-rc.lisp
pocket7878_cl-rc/src/cl-rc.lisp
;;Copyright (C) <2011> <Pocket7878> ;; ;;This program is free software: you can redistribute it and/or modify ;;it under the terms of the GNU General Public License as published by ;;the Free Software Foundation, either version 3 of the License, or ;;(at your option) any later version. ;; ;;This program 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 General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program. If not, see <http://www.gnu.org/licenses/>. ;; (in-package :cl-rc) (defclass config () ((filepath :initform nil :initarg :filepath :reader filepath) (data :initform nil :initarg :data :accessor data))) (defmethod param ((cfg config) key) (with-slots (data) cfg (gethash key data))) (defmethod vars ((cfg config)) (with-slots (data) cfg data)) ;; update data or add new pair (defmethod update ((cfg config) key value) (with-slots (data) cfg (setf (gethash key data) value))) ;; save data (defmethod save ((cfg config) &optional file-path) (let ((out-stm (if file-path (open file-path :direction :output :if-does-not-exist :create) (open (filepath cfg) :direction :output :if-does-not-exist :create :if-exists :supersede)))) (maphash #'(lambda (key value) (format out-stm "~A=~A~%" key value)) (vars cfg)) (close out-stm))) (defun alist-to-hash (alist) (let ((hash (make-hash-table :test #'equal))) (loop for (key . value) in alist do (setf (gethash key hash) value)) hash)) (defun get-value-from-rc-line (line) (cl-irregsexp:if-match-bind (key (or "=" ":") value) line (cons key value))) ;; Create config instance and retern (defun parse-rc-file (file-path) (with-open-file (rc-input file-path :direction :input :if-does-not-exist nil) (when rc-input (make-instance 'config :filepath file-path :data (alist-to-hash (loop for line = (read-line rc-input nil 'foo) until (equal line 'foo) collect (get-value-from-rc-line line)))))))
2,285
Common Lisp
.lisp
57
35.175439
98
0.670444
pocket7878/cl-rc
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2f5bbf9e24a68c64843c0ef208d2410f6f7d514734604d5343481369d14831ce
24,750
[ -1 ]
24,751
main-test.lisp
pocket7878_cl-rc/t/main-test.lisp
;;Copyright (C) <2011> <Pocket7878> ;; ;;This program is free software: you can redistribute it and/or modify ;;it under the terms of the GNU General Public License as published by ;;the Free Software Foundation, either version 3 of the License, or ;;(at your option) any later version. ;; ;;This program 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 General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program. If not, see <http://www.gnu.org/licenses/>. ;; (5am:def-suite all) (5am:def-suite equal-line :in all) (5am:def-suite colon-line :in all) (5am:def-suite parse-file :in all) (5am:in-suite equal-line) (5am:test get-value-from-equal-line (5am:is (equal (cl-rc:get-value-from-rc-line "TEST=1") (cons "TEST" "1")))) (5am:in-suite colon-line) (5am:test get-value-from-colon-line (5am:is (equal (cl-rc:get-value-from-rc-line "TEST:1") (cons "TEST" "1")))) (5am:in-suite parse-file) (5am:test parse-rc-file-test (5am:is (not (null (cl-rc:parse-rc-file ".\\t\\test-rc-file"))))) (5am:test get-param-test (5am:is (equal "1" (cl-rc:param (cl-rc:parse-rc-file ".\\t\\test-rc-file") "TEST"))) (5am:is (equal "2" (cl-rc:param (cl-rc:parse-rc-file ".\\t\\test-rc-file") "TEST2")))) (5am:test update-data-test (5am:is (equal "dat" (let ((cfg (cl-rc:parse-rc-file ".\\t\\test-rc-file"))) (cl-rc:update cfg "TEST" "dat") (cl-rc:param cfg "TEST"))))) (5am:test add-new-data-test (5am:is (equal "dat" (let ((cfg (cl-rc:parse-rc-file ".\\t\\test-rc-file"))) (cl-rc:update cfg "TEST3" "dat") (cl-rc:param cfg "TEST3")))))
1,805
Common Lisp
.lisp
45
37.555556
80
0.676906
pocket7878/cl-rc
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
47aa06ca6c0ab84405e16f0a363be4a587b7860b933b6749f650fb26cf123cba
24,751
[ -1 ]
24,752
cl-rc.asd
pocket7878_cl-rc/cl-rc.asd
;;Copyright (C) <2011> <Pocket7878> ;; ;;This program is free software: you can redistribute it and/or modify ;;it under the terms of the GNU General Public License as published by ;;the Free Software Foundation, either version 3 of the License, or ;;(at your option) any later version. ;; ;;This program 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 General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program. If not, see <http://www.gnu.org/licenses/>. (asdf:defsystem :cl-rc :version "1.0" :license "GPLv3" :components ((:module :src :components ( (:file "package") (:file "cl-rc" :depends-on ("package"))))) :depends-on (:cl-irregsexp :cl-interpol))
937
Common Lisp
.asd
23
37.043478
72
0.702407
pocket7878/cl-rc
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
4c27009157237bc747163e2c8a6ba0d432ca86feab084c767020a9b2621ef1ee
24,752
[ -1 ]
24,753
cl-rc-test.asd
pocket7878_cl-rc/cl-rc-test.asd
;;Copyright (C) <2011> <Pocket7878> ;; ;;This program is free software: you can redistribute it and/or modify ;;it under the terms of the GNU General Public License as published by ;;the Free Software Foundation, either version 3 of the License, or ;;(at your option) any later version. ;; ;;This program 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 General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program. If not, see <http://www.gnu.org/licenses/>. ;; (asdf:defsystem #:cl-rc-test :name "cl-rc-test" :author "Pocket7878 <[email protected]>" :version "1.0" :description "Test for cl-rc" :components ( (:module :t :components ( (:file "main-test")))) :depends-on ( :fiveam :cl-rc))
956
Common Lisp
.asd
27
32.777778
71
0.717976
pocket7878/cl-rc
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e39523e4a6568d5431ab9c2b19da84ff10560b16d9e06be1455ce8aa754b4019
24,753
[ -1 ]
24,789
url.lisp
vlad-km_url/url.lisp
;;; -*- mode:lisp; coding:utf-8 -*- ;;; Lisp interface for Node API URL ;;; Copyright © 2017,2018 Vladimir Mezentsev (eval-when (:compile-toplevel :load-toplevel :execute) (unless (find :url *features*) (push :url *features*)) (unless #j:url (setf #j:url (require "url"))) ) (defpackage #:url (:use #:cl) (:export #:parse #:resolve #:to-string)) (in-package :url) ;;; ;;; url.parse(urlStr, [parseQueryString], [slashesDenoteHost]) ;;; Take a URL string, and return an object. ;;; (defun parse (str &optional query slashes) (if query (#j:url:parse str query) (if slashes (#j:parse str query slashes) (#j:parse str)))) ;;; ;;; url.resolve(from, to) ;;; Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. ;;; (defun resolve (from to) (#j:url:resolve from to)) ;;; url:format -> to-string ;;; ;;; (url:to-string :protocol "file" :pathname (concat (cwd) "//" "about.html")) ;;; => "file:///C:\\tmp\\abc\\about.html" ;;; (defun to-string (&key href (protocol "file") host auth hostname port pathname query hash (slashes t)) (let ((options)) (flet ((mark (name val) (if val (push (list name val) options)))) (mark "href" href) (mark "protocol" protocol) (mark "host" host) (mark "auth" auth) (mark "hostname" hostname) (mark "port" port) (mark "pathname" pathname) (mark "query" query) (mark "hash" hash) (mark "slashes" slashes) (#j:url:format (apply 'jso:mk (reduce 'append options)))))) (in-package :cl-user) ;;; EOF
1,706
Common Lisp
.lisp
50
28.06
102
0.582217
vlad-km/url
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
82cd7ba4dc27d74cc3b1d8c4221205f543a1e484a17b31faca447cf65d13865a
24,789
[ -1 ]
24,790
url-sdf.lisp
vlad-km_url/url-sdf.lisp
;;; -*- mode:lisp; coding:utf-8 -*- (lores:defsys :url :path "/git/url" :components ((:file "url"))) ;;; EOF
119
Common Lisp
.lisp
5
20.8
35
0.553571
vlad-km/url
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
5a44f1e20ae44a3ee1b8b615f03d467cbbf3b7d97628652b537540ca482f24ee
24,790
[ -1 ]
24,808
measure-test.lisp
MetaCommunity_igneous-math/src/test/cltl/measure-test.lisp
;; ... ;; To Do: scan the entire codebase for inline tests, ;; and refactor for application here ;; ;; e.g. ;; (measurement-domain-base-measure (domain-of (make-instance 'gram))) ;; => #<BASE-MASS KILOGRAM> ;; see also: SCALE-SI methods defined in prefix.lisp ;; esp. SCALE-SI (MEASUREMENT &OPTIONAL T) ;; (make-measurement 1 :|kg|) ;; =should=> #<KILOGRAM 1 kg {10082A9083}> ;; OK ;; (scale-si (make-measurement 1 :|kg|)) ;; => 1, 0 ;; OK - SCALE-SI KILOGRAM #+NIL (let ((m (base-convert-measurement (make-measurement 1 :|kg|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - BASE-CONEVERT-MEASUREMENT 1 KG ;; (make-measurement 1 :|g|) ;; =should=> #<GRAM 1 g {...}> ;; FAIL - PRINT-LABEL GRAM ;; (scale-si (make-measurement 1 :|g|)) ;; => 1000, -3 ;; OK - SCALE-SI 1 GRAM => 1000 * 10^-3 KG (SCALED) ;; see also: PRINT-LABEL (MEASUREMENT STREAM) #+NIL (let ((m (make-measurement 1 :|g|))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - MAKE-MEASUREMENT, MEASUREMENT INITIALIZATION, MEASUREMENT PROPERTIES #+NIL (let ((m (base-convert-measurement (make-measurement 1 :|g|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1/1000, 0 ;; OK - BASE-CONVERT-MEASUREMENT 1 GRAM = 1/1000 KG (SCALED) ;; (make-measurement 1000 :|g|) ;; => #<GRAM 1000 g {10075C92B3}> ;; OK ;; (scale-si (make-measurement 1000 :|g|)) ;; => 1000, 0 ;; FAIL - SCALE-SI 1000 GRAM => 1 * 10^0 KG (SCALED) ;; =SHOULD=> 1, 0 #+NIL (let ((m (base-convert-measurement (make-measurement 1000 :|g|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - BASE-CONVERT-MEASUREMENT 1000 GRAM => 1 KG (SCALED) ;; (convert-measurement (make-measurement 1 :|kg|) :|g|) ;; =should=> #<GRAM 1000 g {...}> ;; FAIL ;; (convert-measurement (make-measurement 1000 :|g|) :|kg|) ;; =should=> #<KILOGRAM 1 kg {...}> ;; FAIL - PRINT-LABEL MEASUREMENT STREAM ? ;; (measurement-magnitude (convert-measurement (make-measurement 1 :|kg|) :|g|)) ;; => 1 ;; (measurement-degree (convert-measurement (make-measurement 1 :|kg|) :|g|)) ;; => 3 ;; OK ;; (base-convert-measurement (make-measurement 1 :|g|)) ;; =should=> #<KILOGRAM 1 g {...}> ;; OK ;; (measurement-magnitude (base-convert-measurement (make-measurement 1 :|g|))) ;; => 1/1000 ;; OK ;; (base-magnitude (make-measurement 1 :|g|)) ;; =should=> 1/1000 ;; OK ;; (find-conversion-factor :|g| :|kg|) ;; => #<CONVERSION-FACTOR (1 g) => (1/1000 kg)> ;; OK ;; (find-conversion-factor :|kg| :|g|) ;; => #<CONVERSION-FACTOR (1 kg) => (1000 g)> ;; OK
2,642
Common Lisp
.lisp
61
41.016393
87
0.629064
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
8c6077bcd496a49562d5700893d8116a2a9144b6e19d5b9297198f227b807744
24,808
[ -1 ]
24,809
math-test-package.lisp
MetaCommunity_igneous-math/src/test/cltl/math-test-package.lisp
;; math-test-package.lisp - package definition for igneous-math tests (in-package #:cl-user) (defpackage #:info.metacommunity.cltl.math.test (:nicknames #:mcicl.math.test) (:use #:info.metacommunity.cltl.test #:info.metacommunity.cltl.utils #:cl ))
267
Common Lisp
.lisp
9
26.666667
69
0.730469
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
310b0e9ecf4ed7400b42f5053403cc693473ae82f289759bbc31a697452a45fd
24,809
[ -1 ]
24,810
ov-seq.lisp
MetaCommunity_igneous-math/src/main/cltl/ov-seq.lisp
;; ov-seq.lisp - overloading for simple mathematical operations onto Lisp sequence objects (in-package #:mcicl.math) #+NIL (defmethod @= ((a list) (b list)) ) #+NIL (defmethod @= ((a simple-vector) (b simple-vector)) ) ;; trivial example: (defmethod @* ((a real) (b vector)) ;; NOTE: This assumes B is a vector of numbers (let* ((len (length b)) (retv (make-array len :element-type (array-element-type b)))) (declare (type array-dimension-designator len)) (dotimes (n len retv) (setf (aref retv n) (* a (aref b n))) ))) ;; (@* 5 #(4 0 5 2)) ;; => #(20 0 25 10) ;; (@* 1 #(4 0 5 2)) ;; => #(4 0 5 2) #+SCALAR_TO-DO (defmethod @* ((a scalar) (b vector)) (let* ((len (length b)) (retv (make-array len :element-type (array-element-type b)))) (declare (type array-dimension-designator len)) (dotimes (n len retv) (setf (aref retv n) (@* a (aref b n))) ))) (defmethod @- ((a vector) (b vector)) ;; NOTE: This assumes A, B are vector of numbers (let* ((len (length b)) (retv (make-array len :element-type (array-element-type b)))) (declare (type array-dimension-designator len)) (dotimes (n len retv) (setf (aref retv n) (- (aref a n) (aref b n))) ))) ;; (@- #(20 0 25 10) #(4 0 5 2)) ;; => #(16 0 20 8) ;; Trivial application: see linear.lisp
1,439
Common Lisp
.lisp
43
27.860465
90
0.562319
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
624395a671f550e1dbf8c96b572afcb3d27569d0364c2cb8ceef8d92eb197f59
24,810
[ -1 ]
24,811
math-reader.lisp
MetaCommunity_igneous-math/src/main/cltl/math-reader.lisp
;; math-reader.lisp - ... (in-package #:mcicl.math) (defun read-unit (s) (declare (type stream s) (values (or prefix null) measurement-class)) (let* ((name (read-name-string s)) (len (length name))) (declare (type simple-string name)) (case len ;; FIXME: Interning arbitrary strings in :KEYWORD creates an ;; effective memory leak. ;; ;; Implement FIND-MEASUREMENT-CLASS-USING-NAME, and use that ;; function here (1 (values nil (find-measurement-class (intern name '#:keyword)))) (t ;; 1: parse for prefix ;; 2: parse for unit ;; 3. return measurement ;; (let ((maybe-prefix (read-characters s %prefix-length-limit% :eof-error-p nil))) ;; FIXME: This needs a grammar of some kind? ;; Note, however, the effective grammer is defined by the ;; ordered set of: the set of registered prefixes and the set ;; of registered measurements. ;; So, must: ;; A) Implement a parse-tree framework ;; B) Within REGISTER-MEASUREMENT and REGISTER-PREFIX, update ;; the parse-tree with the OBJECT-PRINT-LABEL and the ;; INSTANCE of any any registered measurement or prefix ;; object ;; C) Apply that parse tree framework, here ;; ;; For each node in the parse tree, possible subnodes: ;; <parse-tree-node> ;; <prefix-class> ;; <measurement-class> ;; ;; If both a <measurement-class> and a <prefix-class> would ;; be regisered as a subnode of a given node N, then that ;; would denote an ambiguity onto N, and an error must be ;; signaled before the second of the two would be regisetered ;; ;; Then, consider implementing the same parse-tree framework ;; also onto a URI parser. ;; ;; 1: Read a character ;; 2? Compute whether the character denotes a prefix or a ;; measurement value ;; 2A: If prefix: goto 1 ;; 2B: If measurement, then: ;; 2B1: Find named prefix ;; 2C1: read-unit ;; 3: Make measurement ;; 4: Return (error "PARSER ALGORITHM NOT IMPLEMENTED")) ;; "fail" )))) (defun read-measurement (s) (declare (type stream s) (values measurement &optional)) (let ((mag (read s))) ;; FIXME: provide CERROR form for ASSERT (assert (numberp mag)) (let ((c (peek-char t s nil))) (cond (c (multiple-value-bind (prefix unit-class) (read-unit s) (cond (prefix (setq prefix (prefix-degree prefix))) (t (setq prefix 0))) (make-measurement mag unit-class prefix))) (t ;; null C (make-measurement mag (find-class 'unity))))))) (defun read-measurement-from-string (str) (declare (type string str) (values measurement &optional)) (with-input-from-string (s str) (read-measurement s))) ;; (read-measurement-from-string "1 m") ;; => #<METER 1 m {...}> ;; (read-measurement-from-string "1.5E+03 km") ;; (read-measurement-from-string "1 km") ;; (read-measurement-from-string "1 m^3") ;; (read-measurement-from-string "1 mm^3")
2,984
Common Lisp
.lisp
87
30.137931
72
0.658917
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
6bef41f69cbff146158683442327f065f1adb5ab4e36cd5d1b79b8150aaa774b
24,811
[ -1 ]
24,812
parse-tree.lisp
MetaCommunity_igneous-math/src/main/cltl/parse-tree.lisp
;; parse-tree.lisp - generic parser framework ;; see also: math-reader.lisp ;; FIXME: Move this code into an indep system in the mci-cltl-utils source tree #| Documentation, draft nr. 1 From a perspective of the _data space_ in a software program, the igneous-math _prefix_ and _measurement-class_ objects are defined, each, in its own respective namespace. From a perspective of a conventional measurement unit syntax, however, the _prefix_ and _measurement-class_ objects all occupy the same namespace, effectively. Thus, it might seem that one could develop a uniform _parse tree_ for _prefix_ and _measurement-class_ objects -- updating the _parse tree_, as it being representative of the _string syntax namespace_, when any new _measurement-class_ or _prefix_ value would be registered to its respective _object-model namespace_. Programmatically it becomes a non-trivial endeavor, but some documentation about it might serve to clear that up, somehow. It might need something of an illustration -- that would be a break from writing so many _(lisp (code (software (lines)))_ of So, continuing in context, with an illustration: given: _S_ =_{{"k", <prefix "k">} {"m" <prefix "m"> <measurement-class "meter">}_ function("m", _S_ ) should => 0, <measurement-class "meter"> function("mm", _S_) should => -3, <measurement-class "meter"> In the instance of parsing the string "m", the _function_ may need to _prefer_ a _measurement-class_ to a _prefix_ object, as in this instance in which "m" is the designator both of a _prefix_ object and a _measurement-class_, within the _parse tree, S_. In the instance of parsing the string, "mm", the _function_ should firstly arrive at the _prefix_ "m", then parsing the same _S_ -- but in the second time, effectively ignoring _prefix_ type objetcs -- should arrive at the _measurement-class_ "m", in completing the computation. The respective digit value would be derived from the the respective <prefix>, if any is registered. I see, now, that it doesn't need to be a hundreds-deep node tree, at least for that simple example onto fundamental _measurement units_ objects. The _parser architecture_ also needs to be _scalable_, in a sense -- e.g. onto inputs such as "m^2" representing degrees of a given base unit of measure -- for an arbitrary base unit of measure and an arbitrary degree, as such -- and such as "V" (volt) vs "W/A" vs "m^2 kg s^-3 A^-1", the last of which representing a derived unit as a relation of base units, in a composition more complex than e.g. "m^2" ...and it needs to have "Ambiguity detection," as well as to present "Redefinition warnings," when "appropriate" Pursued to a logical end, Igneous-Math has a partly functional measurement unit module, already, but it can be fairly tedious to interact with. The _parse-tree_ item, pictured, would be defined simply for supporting a convenient input syntax for measurement objects, within the broader Igneous-math system. |# (in-package #:mcicl.math) ;;; % Condition Classes (define-condition node-condition () ((node :initarg :node :reader node-condition-node))) (define-condition node-not-found (entity-not-found node-condition ) () (:report (lambda (c s) (format s "No node ~S defined as subnode of ~`S" (entity-condition-name c) (node-condition-node c))))) (define-condition node-exists (entity-condition container-condition node-condition) () (:report (lambda (c s) (format s "Node ~S already defined for ~S within ~S" (node-condition-node c) (entity-condition-name c) (container-condition-container c) )))) (define-condition node-exists-error (error node-exists) ()) (define-condition node-redefinition (redefinition-condition container-condition node-condition) () (:report (lambda (c s) (format s "Redefining ~S with ~S (previosuly ~S) within ~S" (node-condition-node c) (redefinition-condition-new-object c) (redefinition-condition-previous-object c) (container-condition-container c))))) ;;; % Node class and basic protocol (defclass* node () ((character character) (subnodes (vector node) :initform (make-array 0 :fill-pointer 0 :element-type 'node)))) (defun make-node (c) (declare (type character c)) (values (make-instance 'node :character c))) (defun finalize-parse-tree (node) (declare (type node node) (values node)) (with-accessors ((subnodes node-subnodes)) node (setf subnodes (simplify-vector subnodes)) (do-vector (%node subnodes node) (finalize-parse-tree %node)))) ;;; %% 'Parse' interface onto Node trees (defun parse (str tree &key (start 0) error-p) (declare (type string str) (type node tree) (type array-dimension-designator start) (values (or node null) array-dimension-designator)) (let ((len (length str))) (when (>= start len) (simple-program-error ;; FIXME: #I18N "~<At node ~S parsing ~S:~> ~<Start ~S >= string length ~S~>" tree str start len)) (with-slot-lock-held (parent subnodes :READ) (let* ((c (char str start)) (node (find c (node-subnodes :test #'char= :key #'node-character)))) (cond (node (incf start) (cond ((= start len) (values node (1- start))) (t (parse str node start)))) (error-p (error 'node-not-found :name c :node tree)) (t (values nil start))))))) ;;; % Node Registry interface (defun register-node (string node parent &optional redefine-p) (declare (type string string) (type node node parent) (values node)) (let ((c (node-character node))) ;; FIXME: HERE, THE SUBNODES SLOT VALUE LOCKED, MUST BE ;; so, this needs the instance-locking slot value extension to DEFINE (multiple-value-bind (%node index) (parse string parent :error-p nil) (cond ((and %node redefine-p) ;; FIXME: ONLY: IF (= (+1 INDEX) (LENGTH STRING)) (warn 'node-redefinition :new node :previous %node :node c :container parent) (let* ((n (position %node (node-subnodes parent) :test #'eq))) ;; WHY THE LOCK HELD, IT. ;; ONLY :WRITE LOCK THE WHERE IT NEEDS HELD, IT. ;; DEFINE, MUST, THE :READ :WRITE LOCKNG EXTENSION, FIRSTLY ;; ^ FIRSTLY BEFORE, THEN LOCK SLOT: DO. ;; ^ ^ THEN HERE, THE LOCK :WRITE DO (with-slot-lock (parent subnodes :write) ;; FIXME: WRITE ABOUT RECURSIVE TIMING CONDITIONS FOR LOCKING IN THIS, A TREE-SHAPED, CHARACTER-INDEXED PARSING ALGORITHM, "NOVEL" (setf (aref (node-subnodes parent) n) node)))) (%node (error 'node-exists-error :name c :node %node :container node)) (index ;; initialize generic NODE instances ;; starting at (SCHAR STRING INDEX) ;; continuing to limit INDEX=(LENGTH STRING) (ERROR "Not complete, this branch. Program arrived here, and ~S ~S ~S ~S" index %node node parent) ) )))) #+NIL (defvar %tree% (make-node #\f))
6,962
Common Lisp
.lisp
165
38.490909
136
0.703802
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
3e138723599714ec9bde40e1a908c09daae1e1411e5df4e49c5880ed83ba6124
24,812
[ -1 ]
24,813
defclass-star.lisp
MetaCommunity_igneous-math/src/main/cltl/defclass-star.lisp
(in-package #:mcicl.math) ;: ^ FIXME: move into #:utils (defun ensure-forward-referenced-class (name) (declare (type symbol name)) (ensure-class name :direct-slots nil :direct-superclasses nil :metaclass (find-class 'forward-referenced-class))) ;; (ensure-forward-referenced-class (gensym)) (defmacro defclass* (name-form (&rest superclasses) (&rest slot-definitions) &rest initargs) ;; FIXME: This macro does not, of itself, provide a complete ;; "DEFCLASS* SOMEWHAT LIKE DEFSTRUCT" implementation. Features ;; presently lacking of this implementation, in that regards ;; may include: ;; ;; * Many of the features avaialble for structure classes defined ;; via DEFSTRUCT are altogether lacking from this protocol, such ;; as: ;; * Naming and definition of a <type-p> predicate function ;; * Naming and definition of a <copier> function ;; * Specification of an object printer function ;; * Naming and lambda list syntax for constructor functions ;; * Nothing such as DEFSTRUCT's linear :INHERIT ;; * Nothing such as a list type or vector type syntax for instances ;; * Other qualities, as denoted in the following ;; ;; * In that this DEFCLASS* macro implements a syntax "Somewhat like ;; defstruct", the following features are noted: ;; ;; * NAME-FORM may be a symbol or a list. If a symbol, then ;; NAME-FORM denotes the name of the class. If a list, then ;; NAME-FORM denotes -- as its first element -- the name of the ;; class, with a syntax similar to DEFTTRUCT <name-and-options>. ;; ;; DEFCLASS* emulates DEFSTRUCT' :CONC-NAME option ;; ;; * For all direct slots of the class, a set of reader and writer ;; methods will be defined, as named according to CONC-NAME ;; interpreted in a manner similar to as with DEFSTRUCT (FIXME: ;; However, in its present revisin, DEFCLASS* rather interprets ;; a NULL CONC-NAME as a "flag" that no reader or writer methods ;; should be defined). Unless the slot-definition is denoted as ;; :READ-ONLY, a writer method will be defined for the slot ;; definition, named as per <that naming convention>. In <all ;; instances>, a reader method will be defined for the slot ;; instances>definition (NOTE: Unless CONC-NAME is NULL ; FIXME: Redefine DEFCLASS* to interpret CONC-NAME in a manner more ; consissent onto DEFSTRUCT; provide an additional slot definition ; "flag" value for denoting if a slot defintion is not to have any ; reader or writer methods defined for it; revise this ; documentation, subsequent to that changeset. (Firstly, move ; DEFCLASS* into the mci-cltl-utils source tree). Lastly, describe ; the complete syntax for slot definition specifiers, as implemented ; of this DEFCLASS* macro -- and make a more direct reference to the ; X3J13 discussions surrounding the definition of the syntax of each ; of DEFSTRUCT and DEFCLASS in CLtL2 -- all of this, to proceed ; after implementation of Jetbrains' YouTrack and TeamCity ; components into a Glasfish server in an AWS instance. ;; ;; * When a class' slot is redefined from "not read only" to "read ;; only" then the SLOT-DEFINITION-WRITER methods defined for slots ;; in the class as side-effects of its definition as "not read ;; only" are not undefined. Those "then invalid" writer methods ;; should be made undefined, however, as consequent with the ;; change in slot definition qualities ;; ;; * Concerning the :READ-ONLY value for slot specifiers for this ;; macro, presently that value may seem to represent something of ;; a misnomer. <Presently> : ;; ;; * The READ-ONLY value is not stored with the slot ;; definition - whether its direct slot definition of ;; effective slot defintion ;; ;; * The READ-ONLY value will not be inherited by subclasses ;; ;; * The READ-ONLY value does not actually prevent SETF access ;; to slots, as by way of (SETF SLOT-VALUE) ;; ;; Those shortcomings may be addressed, subsequently, with a ;; definition of a READ-ONLY-INSTANCE-SLOT-DEFINITION ;; protocol. However, as one's experiences in developing ;; extensions onto CLOS might seem to prove: Once the proverbial ;; Pandora's box of slot definition extension is opened, then -- ;; in less figurative terms -- it may be difficult to develop any ;; effectively "layered" extensions onto STANDARD-SLOT-DEFINITION, ;; as well as the direct and effective slot definition subclasses ;; of STANDARD-SLOT-DEFINITION. Certainly, that is not to ;; criticise the design of MOP, whereas -- presently -- one ;; considers that it may be possible to develop an extensional ;; architecture for facilitating a definition of "layered", ;; domain-specific slot definition extensions ;; ;; As well as that such an architecture may be applied in ;; developing this READ-ONLY-INSTANCE-SLOT-DEFINITION proposal, ;; but furthtermore: Such an architecture may be applied for ;; developing a MODALLY-LOCKED-SLOT-DEFINITION protocol namely ;; using read-write locking onto slot values, as may be ;; facilitative of thread safety in Common Lisp programs. ;; ;; Thirdly, such an architecture may be applied for developing an ;; L10N-SLOT-DEFINITION proposal, namely to facilitate ;; internationalization of locale-specific values - especially, ;; language-specific strings -- within Common Lisp applications. ;; See also: The #I18N notes peppered throughout the codebases ;; provided of the MetaCommunity.info project ;; ;; Thus, effectively five "Architectural FIXME" items are defined here: ;; ;; * DEFCLASS*-MORE-SOMEWHAT-LIKE-DEFSTRUCT ;; * LAYRED-SLOT-DEFINITON-ARCHITECTURE ;; * READ-ONLY-SLOT-DEFINITION ;; * MODALLY-LOCKED-SLOT-DEFINITION ;; * L10N-SLOT-DEFINITION liketly to be followed with ;; I18N-STRING-SLOT-DEFINITION and a broader I18N protocol ;; integrating with existing internationalization frameworks, e.g ;; "PO files" (destructuring-bind (name &key (conc-name nil cnp)) (cond ((symbolp name-form) (list name-form)) (t name-form)) (unless (or cnp conc-name) (setq conc-name (make-symbol (format nil "~A-" name)))) (labels ((acc (slot read-only-p) (when conc-name (list (if read-only-p :reader :accessor) (intern-formatted "~A~A" conc-name slot)))) (initarg (slot) (list :initarg (intern* slot :keyword))) (initform (form infp) (when infp (list :initform form)))) `(defclass ,name (,@superclasses) ,(mapcar (lambda (spec) (destructuring-bind (name &optional (type t) &key read-only (initform nil infp)) spec `(,name ,@(acc name read-only) ,@(initarg name) :type ,type ,@(initform initform infp)))) slot-definitions) ,@initargs)))) #+NIL (macroexpand-1 (quote (defclass* (frob :conc-name #:a-frob-) () ((b) (c real :read-only t))) ))
7,483
Common Lisp
.lisp
152
43.230263
74
0.668584
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
4e08f326c3ffe0830f04dce8930609e09902ff71a6e35ccb17ea2eca0ec454d4
24,813
[ -1 ]
24,814
math-ov.lisp
MetaCommunity_igneous-math/src/main/cltl/math-ov.lisp
;; math-ov.lisp : definition of 'overloaded' mathematical operations (in-package #:mcicl.math) (eval-when (:compile-toplevel :load-toplevel :execute) (defun compute-end-classes (c) ;; compute list of "end classes of C" ;; i.e. classes being subclasses of C, with no subclasses (let ((cds (class-direct-subclasses c))) (cond (cds (mapcan #'compute-end-classes (copy-list cds))) (t (list c))))) ) (defconstant* %integer-instance-classes% (let ((c (compute-end-classes (find-class 'integer)))) #+CCL (cons (find-class 'fixnum) c) #-CCL c)) (defconstant* %float-instance-classes% (compute-end-classes (find-class 'float))) (defconstant* %rational-instance-classes% (cons (find-class 'ratio) %integer-instance-classes%)) (defconstant* %complex-instance-classes% (compute-end-classes (find-class 'complex))) (defconstant* %numeric-instance-classes% (append %rational-instance-classes% %float-instance-classes%)) ;;; % Overloading for Comutative Functions (defun defop (op &key (classes %numeric-instance-classes%) (monadic-p t) (diadic-p t) (variadic-p diadic-p) (default (when diadic-p (find-class 'number)))) (declare (type symbol op) (type (or class-designator null) default) (type cons classes) (values (or generic-function null) (or generic-function null) (or generic-function null))) "For a funtion <OP> acccepting zero or more arguments, define and return generic functions: %<OP> (A) @<OP> (A B) @<OP>@ (&REST VALUES) For each class C in CLASSES, then define methods: %<OP> ((A C)) evaluating (<OP> A) with A declared as type C @<OP> ((A C) (B C)) evaluating (<OP> A B) with A and B declared as type C @<OP>@ (&REST VALUES) performing a recrusive evaluation of <OP> onto VALUES, using each of @<OP> and %<OP> " ;; NB: Though this allows for compier optimizations on numeric ;; classes, but it will not allow for optimizations onto types ;; derived of numeric classes, e.g. signed/unsigned values (let (#+SBCL (src (sb-c:source-location))) (labels ((mklambda (ll op specializers form) `(lambda ,ll (declare (inline ,op) ,@(when specializers (mapcar #'(lambda (arg c) `(type ,(class-name c) ,arg)) ll specializers))) ,form)) (defop-error (message args) (simple-program-error "~<[DEFOP ~s]~> ~<~?:~>" op message args)) (require-monadic (message &rest args) (unless monadic-p (defop-error message args))) (require-diadic (message &rest args) (unless diadic-p (defop-error message args))) (ensure-gfn (name lambda &optional (prec lambda)) (ensure-generic-function name :lambda-list lambda :argument-precedence-order prec :generic-function-class (find-class 'monotonic-generic-function) #+SBCL :definition-source #+SBCL src)) (makem (gf op specializers lambda form) (let* ((lform (mklambda lambda op specializers form)) (m (make-instance (generic-function-method-class gf) :specializers specializers :lambda-list lambda #+SBCL :definition-source #+SBCL src :function ;; FIXME: Catch errors/warnings ;; from COMPILE (compile* nil (compute-method-lambda gf lform nil))))) (add-method gf m)))) (let* ((monadic-op-name (when monadic-p (intern (format nil "%~A" op)))) (gf-monadic (when monadic-p (ensure-gfn monadic-op-name '(a)))) (diadic-op-name (when diadic-p (intern (format nil "@~A" op)))) (gf-diadic (when diadic-p (ensure-gfn diadic-op-name '(a b))))) (dolist (c classes) (let* ((%c (compute-class c))) ;; Define methods for diadic and monadic functions ;; specialized onto each C (when diadic-p (makem gf-diadic op (list %c %c) '(a b) `(funcall (function ,op) a b))) (when monadic-p (makem gf-monadic op (list %c) '(a) `(funcall (function ,op) a))))) (when default ;; Define a diadic method specialized onto DEFAULT ;; ;; NB: In some implementations, this "default" method may ;; effectively loose compiler optimizations, such that may be ;; available for some instances of A and B delcared ;; explicitly for their respective numeric types -- moreover, ;; in instances when the classes of A and B are not EQ. ;; ;; With OP declared incline, however, maybe it would be ;; possible for the compiler to further optimize the following ;; form. ;; FIXME: #I18N (require-diadic "Cannot define DEFAULT diadic method for DEFOP with :DIADIC-P NIL") (let ((%c (compute-class default))) (makem gf-diadic op (list %c %c) '(a b) `(funcall (function ,op) a b)))) (cond (variadic-p ;; FIXME: #I18N (require-diadic "VARIADIC-P specified for DEFOP with :DIADIC-P NIL") (require-monadic "VAIRADIC-P specified for DEFOP with :MONADIC-P NIL") ;; Define a variadic function. ;; ;; FIXME: This produces a generic function that canot be ;; any further specialized (let* ((variadic-op-name (intern (format nil "@~A@" op))) (gf-variadic (ensure-gfn variadic-op-name '(&rest values) nil))) (makem gf-variadic op nil '(&rest values) `(progn (unless (consp values) (simple-program-error `,(format* "~A called with no arguments" (quote ,variadic-op-name)))) (let ((rest (cdr values))) (cond (rest (funcall (function ,diadic-op-name) (car values) (apply (function ,variadic-op-name) rest))) (t (funcall (function ,monadic-op-name) (car values))))))) (values gf-diadic gf-monadic gf-variadic))) (t (values gf-diadic gf-monadic nil))))))) ;;; % Overloading for Monadic/Diadic/Variadic Functions ;;; %% Nary Basic Math Operations ;; %+ @+ @+@ ;; %- @- @-@ ;; %* @* @*@ ;; %/ @/ @/@ (defop '+) (defop '-) (defop '*) (defop '/) ;; single instance test, ensure + ;; (%+ 1) ;; => 1 ;; single instance test, ensure + ;; (@+ 1 1) ;; => 2 ;; single instance test, ensure + ;; (@+@ 1 2 3) ;; => 6 ;; FIXME : run unit tests on each operation, for each %NUMERIC-END-CLASSES% ;; single instance test, ensure error ;; (@+@) ;;; %% Nary Comparison Functions (defop '=) (defop '/=) (defop '<) (defop '>) (defop '<=) (defop '>=) ;;; %% MAX, MIN (defop 'max) (defop 'min) ;; redefine @max@ to apply @> internally (defmethod @max@ (&rest values) (let ((top (car values)) (stack (cdr values))) (cond (stack (let* ((stack-max (apply #'@max stack)) (top-gt-p (@> top stack-max))) (if top-gt-p top stack-max))) (t top)))) ;; (%max 1) ;; => 1 ;; (@max 2 1) ;; => 2 ;; (@max@ 1 3 2) ;; => 3 ;; redefine @min@ to apply @< internally (defmethod @min@ (&rest values) (let ((top (car values)) (stack (cdr values))) (cond (stack (let* ((stack-min (apply #'@min stack)) (top-lt-p (@< top stack-min))) (if top-lt-p top stack-min))) (t top)))) ;; (%min 1) ;; => 1 ;; (@min 2 1) ;; => 1 ;; (@min@ 3 1 2) ;; => 1 ;;; % GCD, LCM (defop 'gcd :classes %integer-instance-classes%) (defop 'lcm :classes %integer-instance-classes%) ;;; % Overloading for Strictly Diadic, Non-Comutative Functions ;;; %% Exponentiation with arbitrary degree (labels ((defop-2 (name) (defop name :monadic-p nil :diadic-p t :variadic-p nil))) (defop-2 'expt ) ;; (@expt 2 2) ;; => 4 ;;; %% MOD, REM (defop-2 'mod) (defop-2 'rem)) ;;; % Overloading for Alternately Monadic/Diadic Functions ;;; %% FLOOR, FFLOOR &FAMILY (defop 'floor :variadic-p nil) (defop 'ffloor :variadic-p nil) ;; (%ffloor 1) ;; => 1.0, 0 ;; ;; (@ffloor@ 2.0 2.0) ;; => 1.0, 0.0 ;; ;; (@ffloor@ 2.0 2.0d0) ;; => 1.0D0, 0.0D0 ;; %% ATAN (defop 'atan :variadic-p nil) ;; (= (/ pi 4) (%atan 1d0)) ;; => T ;; (= (/ pi 4) (@atan 2d0 2d0)) ;; => T ;; (= (/ pi 4) (@atan 2 2)) ;; => NIL ;; also ;; (= (rationalize (/ pi 4d0)) (rationalize (@atan 2d0 2d0))) ;; = T ;; ;; as well: ;; (= (rationalize (/ pi 4)) (rationalize (@atan 2d0 2d0))) ;; => T ;; noting, pi is already a doulbe-float value ;; ;; although ;; (= (/ (rationalize pi) 4) (rationalize (@atan 2d0 2d0))) ;; => NIL ;; ;; however ;; (= (/ (rational pi) 4) (rational (@atan 2d0 2d0))) ;; => T ;; ;; ;; thus illustrating some of the contrasting qualities of CL:RATIONAL ;; and CL:RATIONALIZE - onto that simple wrapper for diadic ATAN ;; Considering the examples in the previous, it may seem to be ;; advisable to apply a methodology of using DOUBLE-FLOAT values, ;; internally, with RATIONALIZE applied when a rational return value ;; is sought? ;; furthermore: ;; ;; (defun rad-to-deg (r) (* r #.(/ 180 (rationalize pi)))) ;; ;; double-float=>rational=>..=>ratio onto pi/4 via effective (atan 1d0) ;; (rad-to-deg (rational (atan 2d0 2d0))) ;; => <large ratio> ;; ;; double-float=>rational=>...=>ratio=>single-float onto pi/4 via effective (atan 1d0) ;; (float (rad-to-deg (rational (atan 2d0 2d0)))) ;; => 45.0 ;; ;; furthermore, redefining RAD-TO-DEG ;; ;; (defun rad-to-deg (r) (rational (* r #.(/ 180d0 pi)))) ;;; ^ double-float => rational (consistently) ;; ;; (rad-to-deg (/ pi 4)) ;; => 45 ;; ;; lastly: ;; ;; (defun rad-to-deg (r) (rationalize (* r #.(/ 180d0 pi)))) ;; (rad-to-deg (/ pi 4)) ;; => 45 ;; ;; The function RAD-TO-DEG is applied as an example, in this instance, ;; considering the common practice of denoting degree type phase ;; angles within methodologies of electrical circuit analysis onto ;; inductive, capacitive, and resistive circuits with AC electrical ;; components -- although Common Lisp uses radians, canonically. ;; ;; %% LOG (defop 'log :variadic-p nil) ;;; % Overloading for Other Monadic Functions ;; FIXME : Observing the implementation of the respetive CL functions ;; in CCL -- e.g. cl:minusp -- it seems that some optimization is being ;; lost in the broad dispatching on NUMBER. Ideally, this ;; implementation would present all possible optimizations to the ;; compiler ;;; %% Miscellaneous Monadic Functions (labels ((defop-monadic (op &optional (classes %numeric-instance-classes%)) (defop op :diadic-p nil :classes classes))) ;;; %%% EXP (defop-monadic 'exp) ;;; %%% SIGNUM (defop-monadic 'signum) ;;; %%% SQRT, ISQRT (defop-monadic 'sqrt) (defop-monadic 'isqrt %integer-instance-classes%) ;;; %%% CIS (defop-monadic 'cis) ;;; %%% CONJUGATE ;: FIXME: Note for possible relevance within AC circuit analysis ;; (RC / RL) (defop-monadic 'conjugate) ;;; %%% PHASE (defop-monadic 'phase) ;;; %%% Structural Accessor Functions ;;; %%%% REALPART, IMAGPART ;; NB: This is in leaving all of the optimization to the ;; implementation -- including any behaviors in numeric type ;; handling. In evaluation of DEFOP, notably the numeric OP is ;; declared as INLINE within each respective method lambda. ;; ;; Of course (%REALPART REAL) => REAL ;; (%IMAGPART REAL) => ZERO (defop-monadic 'realpart) (defop-monadic 'imagpart) ;;; %%%% NUMERATOR, DENOMINATOR (defop-monadic 'numerator %rational-instance-classes%) (defop-monadic 'denominator %rational-instance-classes%) ;;; %% Overloading for Monadic Predicate Functions ;;; %%% "Number-Line" Predicates (defop-monadic 'minusp) (defop-monadic 'plusp) (defop-monadic 'zerop) ;; %%% EVENP, ODDP (defop-monadic 'evenp %integer-instance-classes%) (defop-monadic 'oddp %integer-instance-classes%) ;;; %% Overloading for Monadic Increment Functions ;;; 1+, 1- (defop-monadic '1+) (defop-monadic '1-) ;;; INCF, DECF (?) ;; FIXME: Define overloaded macro forms for INCF, DECF ;; using GET-SETF-EXPANSION in each - possibly, applying %1+ and %1- ;; within the respective macroexpansions ;;; %% Overloading for Strictly Monadic Transcendental Functions ;; %%% SIN, COS, TAN (defop-monadic 'sin) (defop-monadic 'cos) (defop-monadic 'tan) ;; %%% ASIN, ACOS (defop-monadic 'asin) (defop-monadic 'acos) ) ;;; % New Functions (defgeneric @geometric-sum (a b) (:generic-function-class monotonic-generic-function) (:method ((a number) (b number)) ;; FIXME: This completely looses optimizations, ;; though it does allow for overloaded math operations (%sqrt (@+ (@expt (coerce a 'double-float) 2d0) (@expt (coerce b 'double-float) 2d0))))) ;; (@geometric-sum 3 4) ;; => 5.0d0 ;; (@geometric-sum 3d0 4d0) ;; => 5.0d0 ;; Host library integration in [SBCL] ; ;; Note the applications of foreign-function calls into the host's ;; floating point library, namely within #p"sbcl:src;code;irrat" ;; ;; ...used in the instance of such as (EXPT DOUBLE-FLOAT DOUBLE-FLOAT) ;; ;; ;; If applicable, the DEF-MATH-RTN calls within that file may be ;; called, instead, directly onto the native VFP[+NEON] (armhf) or ;; SSE2 (intel) hardware. ;; regarding reading of floating point values, ;; on a sidebar, see also SB-IMPL::MAKE-FLOAT (defun log10 (a) "Calculate the decimal logarithm of A" (declare (inline @log)) (@log a 10)) (defop 'log10 :diadic-p nil) (defun log-10 (a) "Calcluate the inverse decimal logarithm of A, i.e 10 rasied to A degree" (declare (inline @expt)) (@expt 10 a)) (defop 'log-10 :diadic-p nil)
13,602
Common Lisp
.lisp
410
29.031707
86
0.638246
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
972273c22d5c109d0750841420d6b432c6da1bb9db23c4f025e25527aab65fb1
24,814
[ -1 ]
24,815
matrix-clim.lisp
MetaCommunity_igneous-math/src/main/cltl/matrix-clim.lisp
(in-package #:clim-user) ;; CLIM-CLX is not loading. ;; Something about presentation types + defmethod ;; Refer to debug output in SLIME. (defun display-frob (frame pane) ;; FIXME: provide the matrix value via an attribute of the PANE ;; FIXME: also draw the conventional brackets on the pane (declare (ignore frame)) (let ((*standard-output* pane)) (let ((m #2A((1 2 3 4) (4 3 2 1) (4 2 3 1) (1 3 2 4)))) (formatting-table () (dotimes (i (array-dimension m 0)) (formatting-row () (dotimes (j (array-dimension m 1)) (formatting-cell () (present (aref m i j)) )))))))) (define-application-frame frob-frame () () (:panes (matrix :application :height 90 :width 100 :display-function #'display-frob)) (:layouts (default (vertically () matrix)))) #| (let ((f (make-application-frame 'frob-frame :pretty-name "Frob"))) (run-frame-top-level f)) |#
1,015
Common Lisp
.lisp
30
27.1
65
0.588115
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
ce9e79e466a3c5dc8dbb7133ebf4ad67741a0a92b98d24e75cd92730b555f571
24,815
[ -1 ]
24,816
unit-expr-proto.lisp
MetaCommunity_igneous-math/src/main/cltl/unit-expr-proto.lisp
;; unit-expr-proto.lisp -- prototyeps for expression of measurement units (in-package #:mcicl.math) #+PROTOTYPE (defstruct (expr (:constructor make-expr (unit &key (factor 1) (degree 1)))) (factor 1) (unit)) #+PROTOTYPE (defun domain-analyze (op u1 u2) (let* ((unit-1 (expr-unit u1)) (unit-2 (expr-unit u2))) (multiple-value-bind (base-1 factor-1) (factor-for-base-unit unit-1) (multiple-value-bind (base-2 factor-2) (factor-for-base-unit unit-2) (let ((computed-unit (compute-unit op base-1 base-2))) (values computed-unit factor-1 factor-2)))))) #+PROTOTYPE (labels ((unit* (u1 u2) (multiple-value-bind (base-unit u1-factor u2-factor) (domain-analyze '* u1 u2) (make-expr base-unit :factor (* (expr-factor u1) u1-factor (expr-factor u2) u2-factor)))) (unit+ (u1 u2) (multiple-value-bind (base-unit u1-factor u2-factor) (domain-analyze '+ u1 u2) (make-expr base-unit :factor (+ (* (expr-factor u1) u1-factor) (* (expr-factor u2) u2-factor)))))) (let ((u1 (make-expr :m)) (u2 (make-expr :m))) (values (unit* u1 u2) #+TO-DO (unit+ u1 u2)))) ;; --------- (defun diadic-measurement-type-query (op u1 u2) ;; values: base-unit, u1-adjust-factor, u1-adjust-factor-exponent, ;; u2-adjust-factor, u2-adjust-factor-exponent ;; FIXME: Applicable only for diadic operations (declare (type measurement-class u1 u2)) "Find a unit of meaurement expressive of the diadic relation: u1 op u2" (cond ((eq u1 u2) ;; use unit-EQ optimizations (ecase op ;; FROB (PROTOTYPE) ((+ -) (values u1 1 0 1 0)) (* (values (find-geometric-measurement-type (measurement-domain-base-measure (class-of u1)) (+ (mesurement-domain-degree u1) (mesurement-domain-degree u2))) ;; e.g for (@* #m<1 m> #m<1 m>) ?? ?? ?? ?? )) (/ (values ;; may => #<UNITY ...> (find-geometric-measurement-type (measurement-domain-base-measure (class-of u1)) (-1 (mesurement-domain-degree u1) (mesurement-domain-degree u2))) ;; e.g for (@/ #m<1 m> #m<1 m>) ?? ?? ?? ??)))) (t (let ((d-1 (class-of u1)) (d-2 (class-of u2))) (cond ((eq d-2 (find-class 'dimensionless-measure)) ;; OP: EXPT, LOG ) ((eq d-1 d-2) ;; OP : +, -, =, /=, <, >, <=, >=, MAX, MIN, ;; GCD, LCM, ;; return values for shifting each of u1 and u2 onto the ;; base mesurement unit of the domain, similar to ;; diadic-domain-analyze ) ((eq (measurement-domain-base-domain d-1) (measurement-domain-base-domain d-2)) ;; OP must be a geometric operation, e.g. *, /, MOD, REM, FLOOR &family, diadic ATAN ;; Return the degree of the subsequent measurement unit ;; resulting from D-1 OP D-1 (let ((deg-1 (measurement-domain-degree d-1)) (deg-2 (measurement-domain-degree d-2))) ;;; prototype: (ecase op (* (values the-unit-fu (+ deg-1 deg-2))) (/ (values the-unit-fu (- deg-1 deg-2)))))) ) )))) #+NIL (defun compute-measurement-type (op u1 u2) ;; FIXME: Functionally redundant onto DIADIC-MEASUREMENT-TYPE-QUERY ;; FIXME: Applicable only for diadic operations (declare (type measurement-class u1 u2)) ;; frob - prototype - should dispatch on 'OP' ) (defun diadic-domain-analyze (op m1 m2) ;; FIXME: Functionally redundant onto DIADIC-MEASUREMENT-TYPE-QUERY ;; FIXME: Applicable only for diadic operations ;; values: base-unit, u1-factor, u1-factor-exponent, ;; u2-factor, u2-factor-exponent (let* ((unit-1 (class-of m1)) (unit-2 (class-of m2)) (domain-1 (class-of unit-1)) (domain-2 (class-of unit-2)) (base-1 (measurement-domain-base-measure domain-1)) (base-2 (measurement-domain-base-measure domain-2))) (let ((unit (diadic-measurement-type-query op base-1 base-2))) (values unit (measurement-base-factor unit-1) (measurement-base-factor-exponent unit-1) (measurement-base-factor unit-2) (measurement-base-factor-exponent unit-2))))) (labels ((m* (m1 m2) (multiple-value-bind (base-unit m1-factor m1-factor-exponent m2-factor m2-factor-exponent) (diadic-domain-analyze '* m1 m2) (make-expr base-unit :factor (* (expr-factor m1) m1-factor (expr-factor m2) m2-factor)))) (m+ (m1 m2) (multiple-value-bind (base-unit m1-factor m1-factor-exponent m2-factor m2-factor-exponent) (diadic-domain-analyze '+ m1 m2) (let ((m1-m (measurement-magnitude m1)) (m1-d (measurement-degree m1)) (m2-m (measurement-magnitude m2)) (m2-d (measurement-degree m2))) (make-measurement ;; FROB not handling DEGREE per decimal scaling, ;; not seperate to handling the measurement magnitudes (+ (* m1-m m1-factor (expt 10 m1-factor-exponent) (expt 10 m1-d)) (* m2-m m2-factor (expt 10 m2-factor-exponent) (expt 10 m2-d))) base-unit))))) ;; FIXME: Testing only for diadic operations (let ((m1 (make-measurement 1 :|m|)) (m2 (make-measurement 1 :|ft_1893|))) (let ((plus-test (m+ m1 m2))) (values #+TO-DO (m* m1 m2) plus-test (float (base-magnitude plus-test ) pi) (= (base-magnitude plus-test) (+ 1 (/ 1200 3937))) ) ;; "CHECK" on the PLUS-TEST ))) ;; FIXME: Also develop tests onto monadic operaitons
5,430
Common Lisp
.lisp
154
30.168831
89
0.626455
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
e7fab3dafd558bea12fda8b8b58fe568f8e121b6d6b83d2d7ac3263ed825a23b
24,816
[ -1 ]
24,817
math-package.lisp
MetaCommunity_igneous-math/src/main/cltl/math-package.lisp
;; math-package.lisp (in-package #:cl-user) (defpackage #:info.metacommunity.cltl.math (:nicknames #:mcicl.math) (:use #:info.metacommunity.cltl.utils #:info.metacommunity.cltl.utils.mop #:bordeaux-threads #:c2mop #:cl) (:shadowing-import-from ;; prefer the implementation's own forms to those defined in c2mop ;; towards debugging, etc. #:cl #:defgeneric #:defmethod #:standard-generic-function #:standard-method #:standard-class ) #+CCL ;; FIXME MOP-PORT (:shadowing-import-from #:ccl #:compute-effective-method ;; #:make-method-lambda ;; not defined in CCL (?) ;; #:compute-applicable-methods ) #+SBCL ;; FIXME: MOP-PORT (:shadowing-import-from #:SB-PCL #:method-combination-type-name ) (:export ;;; utils ;; #:vsubsetp ;; move this into the utils system ) (:export #:measurement-domain #:measurement-domain-base-measure #:measurement-domain-symbol ;; #:measurement-domain-cf-lock ;; #:measurement-domain-conversion-factors #:domain-of #:measurement-domain-not-found #:measurement-domain-redefinition #:find-measurement-domain #:register-measurement-domain #:enumerate-measurement-domains #:integer-shift-digits #:float-shift-digits #:measurement-symbol #:measurement-base-factor #:measurement-base-factor-exponent #:measurement-class #:measurement-class-designator #:measurement-class-not-found #:measurement-class-redefinition ;; #:linear-measurement-class #:register-measurement-class #:find-measurement-class #:conversion-factor #:conversion-factor-source-unit #:conversion-factor-magnitude #:conversion-factor-magnitude #:conversion-factor-exponent #:conversion-factor-destination-unit #:make-conversion-factor #:find-conversion-factor #:register-conversion-factor #:measurement-magnitude #:measurement-degree #:measurement #:measurement-base-measure #:measurement-symbol #:measurement-symbol #:base-measurement-class #:derived-measurement-class #:length #:meter #:foot #:mass #:kilogram #:gram #:time #:second #:electrical-current #:ampere #:temperature #:kelvin #:amount-substance #:mole #:luminous-intensity #:candela #:rescale #:nrescale #:prefix-degree #:prefix-symbol #:find-nearest-degree #:prefix #:prefix-not-found #:prefix-degree-not-found #:find-prefix #:find-prefix= #:register-prefix #:prefix-of #:shift-magnitude #:scale-si #:conversion-domains-mismatch #:conversion-source-domains #:conversion-destination-domains ;; #:verify-conversion-domain ;; internal util #:convert-measurement ;; #:base-convert-measurement ;; ambiguous function ;; #:base-magnitude ;; ambiguous function ;; #:scalar-magnitude ;; ambiguous function ) ) #+NIL (in-package #:mcicl.math) ;; FIXME: "Do this somewhere else" #-(or SBCL CMU) (declaim (declaration values))
3,013
Common Lisp
.lisp
111
23
69
0.703022
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a43a32c00eb0fde34fb59a813b983e110b00c12dc8d8c3810d35ba6360bc7a53
24,817
[ -1 ]
24,818
geometry.lisp
MetaCommunity_igneous-math/src/main/cltl/geometry.lisp
(in-package #:mcicl.math) ;;; % Geometry Domain ;; TO DO (defclass scalar (measurement) ;; effectively a coordinate onto a number line ()) ;;; % Concepts of Plane and Space ;; (defclass plane ...) ;; (defclass euclidian-plane ...) ;; ^ alternate name for cartesian coordinate plane ?(?) ;; ;; (defclass rectangular-plane ...) ;; ^ a coordiate "two space" onto (i, j), complex number system ;; (defclass space ...) ;; ... reference vectors ... ;;; % Concepts of Point and Location ;; The term "Coordinate" will be applied informaly, in the following ;; ;; (defclass diadic-coordinate ...) ;; ^ a <point> onto a <planar surface> ;; ;; (defclass triadic-coordinate ...) ;; ^ a <point> onto orthogonal <3 space> ;; ;; (defclass polar-coordinate ...) ;; ^ a <point> within a <polar coordinate> system on a <planar surface> ;; ;; (defclass spherical-coordinate ...) ;; ^ a <point> within a <spherical coordinate space>, ;; using a single reference model for spherical coordinates ;; cf. RA, AZ, DEC, and broader astrometry ;;; % VECTOR as a formal mathematical object type ;; Note that this sytem will use radian notation for vectors, internally ;; (def-frob* *null-vector* ...) ;; (defun null-vector-p vector ...) ;; (def-frob @= vector vector) ;; (def-frob @+ vector vector) ;; (def-frob @* scalar vector) ;; vector dot product ;; (def-frob @* vector vector) ;; vector cross product ;; (def-frob @=@ &rest objects) ;; tail recursion ;; thence to extend this system onto the integral and differential ;; calculus, with applications for frequency domain analysis of ;; electronic system components ;; to do: add a seperate CLIM presentations system, focusing on ;; applications within electronic design and analysis, ;; and emphasiziing CLIM's definition of a standard approach for ;; visualization of arbitrary coordinate systems onto a planar ;; display screen
1,891
Common Lisp
.lisp
48
37.791667
72
0.714756
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
5c86e8ac0b6edfbeb0a61caad208a56be6889f8e7ea39e9f01a8336176e765bb
24,818
[ -1 ]
24,819
math-system-utils.lisp
MetaCommunity_igneous-math/src/main/cltl/math-system-utils.lisp
;; math-system-utils.lisp - misc. utility forms (in-package #:mcicl.math) (defmacro vsubsetp (v1 v2 &key (key nil kp) (test #'eql tp) (test-not nil tnp)) ;; cf. subsetp (with-gensym (%v1 %v2 %elt %test %test-not) `(let ((,%v1 ,v1) (,%v2 ,v2) ,@(when tp `((,%test ,test))) ,@(when tnp `((,%test-not ,test-not)))) (declare (type (simple-array t (*)) ,%v1 ,%v2)) (do-vector (,%elt ,%v1 t) (unless (find ,%elt ,%v2 ,@(when kp `(:key ,key)) ,@(when tp `(:test ,%test)) ,@(when tnp `(:test-not ,%test-not))) (return nil)))))) ;; (vsubsetp #(4 2) #(2 3 4) :test #'=) ;; => T ;; (vsubsetp #(4 8) #(2 3 4) :test #'=) ;; => NIL
826
Common Lisp
.lisp
22
27.090909
60
0.42428
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
3625a33d16280137bcd59d91e0e7210e7fb2cbdfec213226d44594a984f5ffdf
24,819
[ -1 ]
24,820
linear.lisp
MetaCommunity_igneous-math/src/main/cltl/linear.lisp
;; linear.lisp - matrix operations (in-package #:mcicl.math) ;;; % Matrix class #+NIL (defstruct (matrix-2d (:constructor %make-matrix-2d (vector matrix))) ;; a two-dimensional matrix displaced to a row-major vector (vector #() :type (simple-array * (*))) (matrix #() :type (array * (* *)))) #+NIL (defun make-matrix-2d (i j &optional (element-type 'real)) (declare (type array-dimension-designator i j) (type type-designator element-type)) (let* ((v (make-array (* i j) :element-type element-type)) (m (make-array (list i j) :element-type element-type :displaced-to v :displaced-index-offset 0))) (%make-matrix-2d v m))) ;; (make-matrix-2d 2 4) #+NIL (defmethod print-object ((object matrix-2d) stream) (print-unreadable-object (object stream :type t :identity t) (let ((m (matrix-2d-matrix object))) (format stream "(~D ~D)" (array-dimension m 0) (array-dimension m 1))))) ;;; % Array utilities (defun copy-array (m) (declare (type array m) (values array)) (let* ((dims (array-dimensions m)) (rm-len (apply #'* dims)) (retv (make-array dims :element-type (array-element-type m)))) (declare (type cons dims)) (dotimes (n rm-len retv) (setf (row-major-aref retv n) (row-major-aref m n))))) (defun compute-array-vector (m) (declare (type array m) (values (simple-array * (*)))) (let* ((len (apply #'* (the cons (array-dimensions m)))) (retv (make-array len :element-type (array-element-type m)))) (dotimes (n len retv) (setf (aref retv n) (row-major-aref m n))))) ;; (compute-array-vector #2A((1 2 3 4) (4 3 2 1))) ;; => #(1 2 3 4 4 3 2 1) ;; (compute-array-vector #3A(((1 2 3 4) (4 3 2 1)) ((4 3 2 1) (1 2 3 4)))) ;; => #(1 2 3 4 4 3 2 1 4 3 2 1 1 2 3 4) ;; (compute-array-vector (make-array nil)) ;; --> error (defun compute-array-vector* (m) (declare (type array m) (values (simple-array * (*)))) (let ((dims (array-dimensions m))) (labels ((frob (m dims &optional (upper-offset 0)) (let* ((this-dim (car dims)) (rest-dim (cdr dims)) (this-offset (* this-dim upper-offset))) (declare (type array-dimension-designator this-offset)) (cond (rest-dim (let ((retv (make-array this-dim :element-type 'vector))) (dotimes (n this-dim retv) (declare (type array-dimension-designator n)) (setf (aref retv n) (frob m rest-dim (+ n this-offset)))))) (t (let ((retv (make-array this-dim :element-type (array-element-type m)))) (dotimes (n this-dim retv) (declare (type array-dimension-designator n)) (setf (aref retv n) (row-major-aref m (+ n this-offset)))))))))) (frob m dims)))) ;; (compute-array-vector* #2A((1 2 3 4) (4 3 2 1))) ;; => #(#(1 2 3 4) #(4 3 2 1)) ;; (compute-array-vector* #3A(((1 2 3 4) (4 3 2 1)) ((4 3 2 1) (1 2 3 4)))) ;; => #(#(#(1 2 3 4) #(4 3 2 1)) #(#(4 3 2 1) #(1 2 3 4))) ;; (compute-array-vector* #2A()) ;; => #() (defun row (m i) (declare (type array-dimension-designator i) (type (array * (* *)) m) (values (array * (1 *)))) (let* ((n-cols (array-dimension m 1)) (reslt (make-array (list 1 n-cols) :element-type (array-element-type m)))) (declare (type array-dimension-designator n-cols) (type (array * (1 *)) reslt)) (dotimes (n n-cols reslt) (setf (aref reslt 0 n) (aref m i n)) ))) ;; (row #2A((1 2 3 4) (4 3 2 1)) 0) ;; => #2A((1 2 3 4)) (defun column (m j) (declare (type array-dimension-designator j) (type (array * (* *)) m) (values (array * (* 1)))) (let* ((n-rows (array-dimension m 0)) (reslt (make-array (list n-rows 1) :element-type (array-element-type m)))) (declare (type array-dimension-designator n-rows) (type (array * (* 1)) reslt)) (dotimes (n n-rows reslt) (setf (aref reslt n 0) (aref m n j)) ))) ;; (column #2A((1 2 3 4) (4 3 2 1)) 0) ;; => #2A((1) (4)) #+TO-DO ;; depends-on : ov-seq.lisp (defun gaussian-reduction (m) ;; cf. pages.pacificcoast.net/~cazelais/251/gauss-jordan.pdf ;; defunct prototype (declare (type (array * (* *)) m) (inline copy-array) #+TO-DO (values vector)) (let* ((n-rows (array-dimension m 0)) (n-cols (array-dimension m 1)) (rm-len (* n-rows n-cols)) (vector-form (compute-array-vector* m)) (retv (make-array (array-dimensions m) :element-type (array-element-type m)))) (declare (type array-dimension-designator n-rows n-cols) (type (simple-array * (*)) vector-form)) (labels ((nth-element (mv row col) (declare (type array-dimension-designator posn) (type (simple-array * (*)) mv) (values number)) (aref (aref mv row) col))) (dotimes (row n-rows #-TO-DO vector-form #+TO-DO retv) (let* ((refr (aref vector-form row))) (dotimes (col (1- n-cols)) (unless (= col row) (let* ((col-value (aref refr col))) ;; reduce following rows to zero (dotimes (%row-next (- n-rows (1+ row))) (let* ((row-next (+ %row-next (1+ row))) (this-row (aref vector-form row-next)) (factor (gcd col-value (aref this-row col))) (factored-refr (@* factor refr)) (result (@- this-row factored-refr))) (declare (type (simple-array * (*)) vector-form)) (dotimes (n (1- n-cols)) (setf (aref refr n) (aref result n))))) )))))))) ;; (gaussian-reduction #2A((1 1 1 5) (2 3 5 8) (4 0 5 2))) ;; (gaussian-reduction #2A((21 1 1 5) (2 3 5 8) (4 0 5 2))) ;; (gaussian-reduction #2A((1 1 2 0 1) (2 -1 0 1 -2) (2 -1 -1 -2 4) (2 -2 2 -1 0)))
6,737
Common Lisp
.lisp
160
30.675
83
0.488305
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
d8a350e5745e416a803646de31623a6a9dd6d21ff3716a22cffef2bcd1a281ff
24,820
[ -1 ]
24,821
monotonic-genf.lisp
MetaCommunity_igneous-math/src/main/cltl/monotonic-genf.lisp
;; monotonic-genf.lisp - definition of a MONOTONIC-GENERIC-FUNCTION (in-package #:mcicl.math) ;; FIXME: Move code to mci-cltl-utils system ;; FIXME: This does not work in CCL ;; ;; Tested with (DEFGENERIC @GEOMETRIC-SUM ...) ;; followed by (geometric-sum 3 4) ;; using native MOP forms (C2MOP) ;;; % MOP Util (defgeneric compute-method-lambda (genf lambda enviornment) (:documentation "Utility function for MAKE-METHOD-LAMBDA See also: * Initialization of Generic Function and Metahod Metaobjects. (The Common Lisp Object System MetaObject Protocol) Available: <http://www.alu.org/mop/concepts.html#init-generic>") (:method ((genf standard-generic-function) lambda environment) "Call MAKE-METHOD-LAMBDA on GENF, the class prototype of the generic function method class of GENF, LAMBDA, and ENVIRONMENT" (make-method-lambda genf (class-prototype (generic-function-method-class genf)) lambda environment))) (defmacro class-prototype* (class) (with-gensym (c) `(let ((,c ,class)) (class-prototype (etypecase ,c (symbol (find-class ,c)) (class ,c)))))) #+NIL ;; unused (defgeneric method-specifier (method) (:documentation "create a specifier for a method, such that would be compatible with MAKE-LOAD-FORM") (:method ((method standard-method)) (list* (generic-function-name (method-generic-function genf)) (mapcar #'(lambda (a c) (typecase c (class (list a (class-name c))) (t (list a c)))) (method-lambda-list method) (method-specializers method)) (method-qualifiers method)))) ;; (method-specifier (car (generic-function-methods #'@+))) ;;; %% Monotonic Generic Functions, Methods, and Method Combination ;; A Monotonic Generic Functions' effective method, when provided ;; with a set of arguments for which an applicable method is ;; avaialble, will call exactly one of the methods specialized on the ;; generic function -- namely, the most specific method. ;; ;; As such, the functions CALL-NEXT-METHOD and NEXT-METHOD-P wll not ;; be appliable within the METHOD-LAMBDA of a MONOTONIC-METHOD. (defclass monotonic-method-combination (method-combination) ()) #+SBCL ;; FIXME: portability (defmethod method-combination-type-name ((cmbn monotonic-method-combination)) ;; e.g. for (DESCRIBE #'@+) (class-name (class-of cmbn))) (defgeneric method-lambda-body (method)) (defgeneric (setf method-lambda-body) (new-value method)) (defclass monotonic-method (standard-method) ((lambda-body :initarg :lambda-body :type list :accessor method-lambda-body))) (defclass monotonic-generic-function (standard-generic-function) () (:metaclass funcallable-standard-class) (:default-initargs :method-combination (class-prototype* 'monotonic-method-combination) :method-class (find-class 'monotonic-method))) (defmethod compute-applicable-methods ((gf monotonic-generic-function) args) (declare (ignore args)) (let ((std-set (call-next-method))) (when std-set (list (car std-set))))) (defmethod make-method-lambda ((genf monotonic-generic-function) (method monotonic-method) lambda environment) (declare (ignore genf environment)) (with-gensym (method-lambda-args next-methods this-method) ;; referencing the MOP specification, CLOSER-MOP, and SB-PCL (setf (method-lambda-body method) lambda) `(lambda (,method-lambda-args ,next-methods ,this-method) (declare (ignore ,next-methods)) (labels ((call-next-method (&rest cnm-args) (apply #'no-next-method (method-generic-function ,this-method) ,this-method cnm-args)) (this-method () (values ,this-method)) (next-method-p () nil)) (declare (ignorable (function call-next-method) (function this-method) (function next-method-p))) ;; KLUDGE. A direct reference to the compiled form of LAMBDA ;; most likely cannot be dumped to a FASL file. ;; ;; Note that the COMPILE call should only be called once, ;; however, when the METHOD-LAMBDA itself is compiled. ;; ;; FIXME: Capture errors and warnings from the COMPILE call (apply (compile* nil ,lambda) ,method-lambda-args))))) (defmethod compute-effective-method ((genf monotonic-generic-function) (combin monotonic-method-combination) applicable-methods) (declare (ignore genf combin)) (let ((the-method (car applicable-methods))) (values `(call-method ,the-method nil ,the-method) nil))) #+NIL (defgeneric frob (a b) (:generic-function-class monotonic-generic-function) (:method ((a number) (b number)) (complex a b)) (:method ((a fixnum) (b fixnum)) (+ a b))) ;; (frob 1 2) ;; => 3 ;; (frob 1.0 2.0) ;; => #C(1.0 2.0) ;; (frob 1.0d0 2.0d0) ;; => #C(1.0d0 2.0d0) ;; (frob 1 2.0) ;; => #C(1.0 2.0)
4,801
Common Lisp
.lisp
124
35.064516
88
0.709185
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2c33f03869680934a6f6c4dd8fcbf6801019ab5999be6a92e2f9e6e4642fdd60
24,821
[ -1 ]
24,822
prefix.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/prefix.lisp
;; prefix.lisp (in-package #:math) (defgeneric rescale (scalar prefix) (:documentation "Return a new scalar object representing the magnitude of SCALAR multiplied by the effective factor-base of the measurement rasied to the PREFIX degree. For measurements using SI decimal prefixes, the effective factor base is 10 See also: `nrescale'")) (defgeneric nrescale (scalar prefix ) (:documentation "Return the SCALAR object, destructively modified such that the magnitude and degree of the SCALAR will have been scaled for the new PREFIX degree. The SCALAR-MAGNITUDE of a SCALAR is calcualted as the magnitude of SCALAR multiplied by the effective factor-base of the measurement rasied to the PREFIX degree. For measurements using SI decimal prefixes, the effective factor base is 10. See also: `rescale'")) ;; nb. Methods for RESCALE and NRESCALE are defined after the class ;; PREFIX is defined ;;; % Prefix Notation - SI Decimal Prefix Notation, specifically ;; NB: "Engineering notation" typically uses only prefixes for degrees ;; in multiples of 3 (defgeneric prefix-degree (instance) (:method ((instance measurement)) (measurement-degree instance))) (defgeneric prefix-symbol (instance) (:method ((instance measurement)) (prefix-symbol (prefix-of instance)))) (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant* %si-degrees% (make-array 21 :element-type '(integer -24 24) :initial-contents '(24 21 18 15 12 9 6 3 2 1 0 -1 -2 -3 -6 -9 -12 -15 -18 -21 -24)) )) ;; (map 'list #'find-prefix= %si-degrees%) (deftype prefix-degree () '(and (integer -24 24) ;; formally onto the SI standard for decimal prefixes #.(cons 'member (coerce %si-degrees% 'list)))) ;; (typep -5 'prefix-degree) ;; => NIL ;; (typep 9 'prefix-degree) ;; => T (defun find-nearest-degree (deg &optional ee-p) ;; ee-p : "prefer engineering notation" ;; i.e. for a non-zero degree, ;; require that the prefix degree is a multiple of 3 (declare (type fixnum deg) (values prefix-degree)) (macrolet ((find* (test) `(find deg %si-degrees% :test (function ,test)))) (labels ((ee-prefix= (a b) (declare (type fixnum a) (type (integer -24 24) b)) (and (= (gcd b 3) 3) (= a b))) (ee-prefix> (a b) (declare (type fixnum a) (type (integer -24 24) b)) (and (= (gcd b 3) 3) (> a b))) (find-or-approximate () (or (find* =) (find* >) ;; the error condition should not ever be reached, ;; but this would satisfy the compiler's walker [SBCL] (error 'prefix-degree-not-found :name deg))) (find-or-approximate-ee () (or (find* ee-prefix=) (find* ee-prefix>) (error 'prefix-degree-not-found :name deg)))) (cond ((zerop deg) (values 0)) ((> deg 24) (values 24)) ((< deg -24) (values -24)) (ee-p (find-or-approximate-ee)) (t (find-or-approximate)))))) ;; (find-nearest-degree 0) ;; => 0 ;; (find-nearest-degree 3) ;; => 3 ;; (find-nearest-degree 3 t) ;; => 3 ;; (find-nearest-degree 25) ;; => 24 ;; (find-nearest-degree 25 t) ;; => 24 ;; (find-nearest-degree -25) ;; => -24 ;; (find-nearest-degree -25 t) ;; => -24 ;; (find-nearest-degree 5) ;; => 3 ;; (find-nearest-degree -5) ;; => -6 ;; (find-nearest-degree -5 t) ;; => -6 ;; (find-nearest-degree -2) ;; => -2 ;; (find-nearest-degree -2 t) ;; => -3 ;; (find-nearest-degree 1) ;; => 1 ;; (find-nearest-degree 1 t) ;; => 0 (defclass* prefix (pretty-printable-object) ;; NOTE: This class is applied effectively as a DECIMAL-PREFIX ;; FIXME: Rename PREFIX class to DECIMAL-PREFIX, ;; FIXME: Implement class PREFIX-CLASS with accessor PREFIX-BASE ;; FIXME: Implement class DECIMAL-PREFIX-CLASS with PREFIX-BASE 10 ;; FIXME: Implement class OCTAL-PREFIX-CLASS with PREFIX-BASE 8 ;; FIXME: Implement a measurement-domain for information quantity, ;; supporting an OCTAL-PREFIX-CLASS for prefixes thereof. ;; FIXME: Seperately, impelement a measurement-domain for ;; virtual (e.g. display screen, cf HyTime) measurements ((degree prefix-degree :read-only t) (symbol symbol :read-only t))) ;; FIXME: Define classes DECIMAL-PREFIX, BINARY-PREFIX ;; as well as accessor PREFIX-FACTOR-BASE ;; ;; Hypothetically, also consider defining an experimental range of ;; prefixes: LOGARITHMIC-PREFIX <ABSTRACT>, DECIMAL-LOGARITHMIC-PREFIX, ;; and NATURAL-LOGARITHMIX-PREFIX cf. frequency domain analysis, ;; with documentation clearly and succinctly describing the syntax and ;; characteristics of the same measurement domain (perhaps to a ;; discrete sense of technical Goodwill for MetaCommunity, if well ;; done) as well as its origins in frequency domain analysis of ;; electrical systems -- also with an xref onto CLIM, then, as with ;; regards to graphs of ideal frequency response in analysis of ;; electrical systems components (use cases? radio communication ;; systems namely onto HAM radio standards; audio-digital converstion ;; components; power factor analysis for industrial-quality electrical ;; systems with a big, red, blinking HTML label for safety analysis.) (defmethod print-object ((instance prefix) stream) (print-unreadable-object (instance stream :type t :identity nil) (princ (object-print-name instance) stream) (write-char #\Space stream) (write-char #\( stream) (princ (object-print-label instance) stream) (write-char #\) stream))) ;; (make-instance 'prefix :symbol :|frob| :degree -15 :print-name "frob" :print-label "f") ;; => #<PREFIX frob (f)> (define-condition prefix-not-found (entity-not-found) () (:report (lambda (c s) (format s "No measurement prefix registered for name ~S" (entity-condition-name c))))) (define-condition prefix-degree-not-found (entity-not-found) () (:report (lambda (c s) (format s "No measurement prefix registered for degree ~S" (entity-condition-name c))))) (declaim (type (vector prefix) %prefixes% ) (type array-dimension-designator %prefix-length-limit%)) (defvar %prefixes% (make-array 20 :fill-pointer 0 :element-type 'prefix) "Internal storage for measurement prefixes. This variable should be accessed with `%PREFIXES-LOCK%' held See also: * `find-prefix' * `find-prefix=' * `prefix-of'") (defvar %prefixes-lock% (make-lock "%PREFIXES%") "Mutex lock for accessing `%PREFIXES%'") (defvar %prefix-length-limit% 0) (defun find-prefix (s) "Locate a measurement prefix with symbolic name S. If no prefix is defined with symbolic name S, an error of type PREFIX-NOT-FOUND is singaled" (declare (type symbol s) (values prefix)) (with-lock-held (%prefixes-lock%) (or (find s %prefixes% :test #'eq :key #'prefix-symbol) (error 'prefix-not-found :name s)))) ;; (find-prefix :|m|) (defun find-prefix= (d) "Locate a measurement prefix with prefix degree D. If no prefix is defined with prefix degree D, an error of type PREFIX-NOT-FOUND is singaled" (declare (type prefix-degree d) #+NIL (values prefix)) (with-lock-held (%prefixes-lock%) (or (find d %prefixes% :test #'(lambda (a b) (declare (type fixnum a b)) (= a b)) :key #'prefix-degree) (error 'prefix-degree-not-found :name d)))) ;; (find-prefix= -9) ;; => #<PREFIX nano (n)> (defun register-prefix (p) (declare (type prefix p) #+NIL (values prefix)) (with-lock-held (%prefixes-lock%) (let* ((len (length (object-print-label p))) (s (prefix-symbol p)) (n (position s %prefixes% :test #'eq :key #'prefix-symbol))) (cond (n (setf (aref %prefixes% n) p)) (t (vector-push-extend p %prefixes%))) (when (> len %prefix-length-limit%) (setq %prefix-length-limit% len)) (values p)))) ;; (map 'list #'find-prefix= (remove 0 %si-degrees%)) ;; define prefix classes (labels ((do-def (p degree label name) (let ((p (make-instance 'prefix :symbol name :degree degree :print-name (string-downcase (symbol-name p)) :print-label label ))) (register-prefix p) (values p)))) (mapcar (lambda (spec) (destructuring-bind (c degree label name) spec (do-def c degree label name))) ;; FIXME: Update the documentation (README.md namely) as ;; to denote the syntax for measurement symbols, applied ;; here - with a sidebar note as with regards to readtable ;; case and prefix-symbol '((yotta 24 "Y" :|Y|) (zetta 21 "Z" :|Z|) (exa 18 "E" :|E|) (peta 15 "P" :|P|) (tera 12 "T" :|T|) (giga 9 "G" :|G|) (mega 6 "M" :|M|) (kilo 3 "k" :|k|) (hecto 2 "h" :|h|) (deca 1 "da" :|da|) (deci -1 "d" :|d|) (centi -2 "c" :|c|) (milli -3 "m" :|m|) (micro -6 #.(string (code-char #x3BC)) :|u|) (nano -9 "n" :|n|) (pico -12 "p" :|p|) (femto -15 "f" :|f|) (atto -18 "a" :|a|) (zepto -21 "z" :|z|) (yocto -24 "y" :|y|)))) ;; (map 'list #'(lambda (p) (cons (prefix-symbol p) (prefix-degree p))) %prefixes%) ;; (object-print-label (find-prefix= 9)) ;; => "G" (defmethod print-label ((object measurement) (stream stream)) (multiple-value-bind (mag boundp) (slot-value* object 'magnitude) (cond ((and boundp (slot-boundp object 'degree)) (multiple-value-bind (adj-mag deg-si) (scale-si object t) (declare (type real adj-mag) (type fixnum deg-si)) (princ adj-mag stream) (write-char #\Space stream) (unless (zerop deg-si) (let ((prefix (find-prefix= deg-si))) (princ (object-print-label prefix) stream))))) (boundp (princ mag stream)) (t (princ "{no magnitude} " stream)))) (princ (object-print-label (class-of object)) stream)) (defmethod print-object ((object measurement) stream) (print-unreadable-object (object stream :type t :identity t) (print-label object stream))) (defmethod object-print-label ((object measurement)) (with-output-to-string (s) (print-label object s))) (defun prefix-of (m &optional (ee-p t)) ;; FIXME: Rename to SCALAR-PREFIX "Select and return a PREFIX object representative of the scalar magnitude and degree of measurement M. The second return value will represent the magnitude of M scaled for decimal degrees of the prefix value. If the deree of M is not equivalent to a degree of an SI prefix value, a corresponding prefix value will be calculated and returned. In such an instance, the second return value will be inequivalent to the actual magnitude of M. See also: * `measurement-magnitude' * `scalar-magnitude' [?] * `rescale', `nrescale' * `find-prefix' * `find-prefix='" (declare (type measurement m) (values prefix fixnum)) (multiple-value-bind (magnitude deg-si) (scale-si m ee-p) (let ((prefix (find-prefix= deg-si))) (values prefix magnitude)))) ;; (prefix-of (make-measurement 1 :|m| 24)) ;; => #<PREFIX yotta (Y)>, 1 ;; ;; (prefix-of (make-measurement 1 :|m| 23)) ;; => #<PREFIX zetta (Z)>, 100 ;; ;; (prefix-of (make-measurement 1 :|m| 22)) ;; => #<PREFIX zetta (Z)>, 10 ;; ;; (prefix-of (make-measurement 1 :|m| 21)) ;; => #<PREFIX zetta (Z)>, 1 ;; ;; (prefix-of (make-measurement 1 :|m| 3)) ;; => #<PREFIX kilo (k)>, 1 ;; ;; (prefix-of (make-measurement 1 :|m| -16)) ;; => #<PREFIX atto (a)>, 100 ;; Trivial decimal exponential mathematics, ad hoc syntax: ;; ;; 1 m => 1000 mm ;; => 0.001 km ;; ;; syntax: ;; (<magnitude>, <degree>) ;; <A> =[<decimal shift>]=> <B> ;; <=> i.e. "equivalent to" ;; ;; (1, 0) =[3]=> (.001, 3) <=> (1 * 10^-3, 3) ;; (1, 0) =[-3]=> (1000, -3) <=> (1 * 10^3, -3) ;; ;; e.g in a conventional syntax ;; 1 m = .001 km ;; 1 m = 1000 mm #+NIL ;; algorithm test ;; 1. define an implicit measurment instance via LET ;; ;; 2. return values representative of the original implicit ;; measurement instance, as "decimal shifted" for a new decimal ;; prefix degree ;; (let ((magnitude 1) (degree 0) (factor-base 10)) (flet ((decimal-shift (new-degree) (cons (* magnitude (expt factor-base (- degree new-degree))) (+ degree new-degree)))) (values (decimal-shift 3) (decimal-shift -3)))) ;; (fmakunbound 'shift-magnitude) (defgeneric shift-magnitude (measurement new-degree) ;; utility function - implementation of the "decimal shift" ;; algorithm denoted in the above ;; NOTE: This function allows for shifting to an arbitrary decimal ;; DEGREE unlike SCALE-SI ;; see also: `SCALE-SI' ;; FIXME: SBCL is unable to evaluate the encosed DEFMETHOD form, ;; when the specified VALUES declaration is included. ;; ;; tested with SBCL 1.2.1 (win32 x86-64) ;; and SBCL 1.2.3 (Linux x86-64) (:method ((measurement measurement) (new-degree fixnum)) (let ((magnitude (measurement-magnitude measurement)) (degree (measurement-degree measurement)) (factor-base (measurement-factor-base measurement))) (declare (type real magnitude) (type fixnum degree factor-base) #-:SBCL (values real fixnum)) (values (* magnitude (expt factor-base (- degree new-degree))) (+ degree new-degree))))) (defmethod rescale ((scalar measurement) (prefix fixnum)) (multiple-value-bind (new-mag new-deg) (shift-magnitude scalar prefix) (make-measurement new-mag (class-of scalar) new-deg))) (defmethod rescale ((scalar measurement) (prefix prefix)) (rescale scalar (prefix-degree prefix))) #+NIL (let* ((m (make-measurement 1 :m)) (m-2 (rescale m 3)) (m-3 (rescale m -3))) (values (apply #'= (mapcar #'scalar-magnitude (list m m-2 m-3))))) ;; => T (defmethod nrescale ((scalar measurement) (prefix fixnum)) (multiple-value-bind (new-mag new-deg) (shift-magnitude scalar prefix) (setf (measurement-degree scalar) new-deg) (setf (measurement-magnitude scalar) new-mag) (values scalar))) (defmethod nrescale ((scalar measurement) (prefix prefix)) (nrescale scalar (prefix-degree prefix)) (values scalar)) #+NIL ;; instance test - rescale, equivalent magnitude (let* ((m (make-measurement 1 :m)) (m-2 (rescale m 3)) (m-3 (rescale m -3))) (values m m-2 m-3 #+NIL (mapcar #'scalar-magnitude (list m m-2 m-3)) (apply #'= (mapcar #'scalar-magnitude (list m m-2 m-3))))) ;; => #<METER 1 m {1006330FD3}>, ;; #<METER 1/1000 km {1006331AF3}>, ;; "RATIO QUIRK" (Unscaled) ;; #<METER 1 m {1006332293}>, ;; T ;; ^ Implementation note: The magnitude of the measurement is 1, ;; in each of those three instances. ;; ;; The convenient, printed representation -- as illustrated -- may ;; seem to suggest as though a floating-point value was used in the ;; third instance. In the third instances, in the previous, the ;; measurement's magnitude is 1 and its degree is -3. At no time ;; does any of those instanes use a floating-point object in its ;; implementation. ;; ;; Though, of course, floating-point values would occur throughout a ;; mathematical system, in application, but insofar as discrete ;; ratios and integral values may be utilized within mathematical ;; calculations -- insofar as of integral and ratio values serving ;; as mathematically accurate alternatives to mathematically ;; equivalent floating point values -- then perhaps it may serve ;; towards a greater development of a basis for systematic ;; measurement accuracy, within mathematical systems extending of ;; this system, that a simple magnitude/degree model is developed -- ;; as in preference to a completely "dot decimal" model for ;; expression of measuremnt values, within digital information ;; objects. Of course, this model is developed as an extension of ;; the subset of ANSI Common Lisp implemented as with regards to ;; numeric types and mathematical procedures. ;; ;; In a sense, it is a goal in the design of this system that ;; numbers will be applied without truncation, insofar as towards ;; calculation of "end values". So far as procedures for addition, ;; multiplication, subtraction, and divsion may be conducted ;; thoroughly with integral and ratio values, then such integral ;; and ratio values may be used iternally, within program objects. ;; A floating point notation may be applied, nonetheless, for ;; printed representation of objects' numeric values, in a ;; conventional syntax. ;; ;; Of course, as in calculations effectively applying the ANSI CLtL ;; definition of 'pi', it may be fortuitous to extend on ANSI CLtL ;; with a methdology similar to the the 'thunk'[1] in which the ;; evaluation of the constant 'pi' would be delayed until ;; construction of a comprehensive formula for calculation of an ;; "end value" within a mathematical system. See also: Garnet KR[2] ;; ;; [1] http://www.chadbraunduin.com/2011/07/common-lisp-lazy-sequences.html ;; [2] http://sourceforge.net/projects/garnetlisp/files/ #+NIL ;; instance test - nrescale (let* ((m (make-measurement 1 :m)) (m-2 (nrescale m 3))) (values m-2 (eq m-2 m) (= 1 (scalar-magnitude m)))) ;; => #<METER 1/1000 km {1005F4C4D3}>, ;; T, T ;; rescale of ratio magnitude ;; (let ((m (make-measurement 1/5 :m))) (rescale m -3)) ;; => #<METER 2 dm {1005F4C4D3}>, ;; rescale "outside of SI" ;; (rescale (make-measurement 1/8 :m) 5) ;; => #<METER 1/8000 km {1007AD9433}> ;; ;; (rescale (make-measurement 1/8 :m) -5) ;; => #<METER 125 mm {1007B71283}> (defgeneric scale-si (measurement &optional engineering-notation-p) (:method :around ((measurement gram) &optional ee-p) ;; NB: SCALE-SI GRAM effectively converts the input MEASUREMENT ;; onto the SI base measure for units of mass, namely KILOGRAM. ;; ;; This behavior may not be reflected for other units of mass. ;; e.g. (scale-si <<1 cal>>) => <<1 cal>> NOT <<... joule>> ;; ;; [FIXME: Put this into the documentation] ;; ;; In the implementation specifically of the measurement units ;; KILOGRAM and GRAM, this system endeavors to work around the SI ;; convention of KILOGRAM being the base measure of units of ;; mass. ;; ;; Concerning applications of measurements of mass: ;; ;; Notably, the unit KILOGRAM is applied in some physical ;; formulas, such as with regards to specific heat. ;; ;; Concerning applications of the SI prefix system for measurements: ;; ;; Orthogonally to the convention, 'kilogram as base measure', ;; GRAM is the measurement unit of mass with prefix 0 ;; ;; ;; Specifially with regards to SCALE-SI GRAM: Calling programs ;; should ensure appropriate selection of the measurement unit for ;; the return value ;; ;; i.e. (measurement-domain-base-measure (domain-of #<GRAM 1 g {10075C92B3}>)) ;; => #<BASE-MASS KILOGRAM> ;; for MEASUREMENT being of type GRAM ;; (declare (ignore ee-p)) (multiple-value-bind (magnitude degree) (call-next-method) ;; FIXME; DEGREE not always - ;; ;; TO DO: define BASE-CONVERT-MEASUREMENT* => magnitude, degree (let ((deg-base (- degree 3))) (values (shift-magnitude measurement deg-base) deg-base)))) (:method ((measurement measurement) &optional (ee-p t)) (declare (values real prefix-degree)) (let ((magnitude (measurement-magnitude measurement)) (scale (measurement-degree measurement))) (declare (type real magnitude) (type fixnum scale)) (cond ((zerop scale) (values magnitude scale)) (t (let ((deg (find-nearest-degree scale ee-p))) (values (shift-magnitude measurement deg) deg))))))) ;; (scale-si (make-measurement 1 :m 5)) ;; => 100, 3 ;; (= 1E+05 100E+03) ;; => T ;; (scale-si (make-measurement 10 :m 5)) ;; => 1, 6 ;; (= 10E+05 1E+06) ;; => T ;; (scale-si (make-measurement 1 :m -5)) ;; => 10, -6 ;; ;; (= 1E-05 10E-06) ;; => T ;; (scale-si (make-measurement 10 :m -5)) ;; => 100, -6 ;; (scale-si (make-measurement 1 :m -2)) ;; => 10, -3 ;; (scale-si (make-measurement 1 :m 2)) ;; => 100, 0
20,685
Common Lisp
.lisp
545
33.526606
90
0.650756
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a06b76fb9c64df5ad5c94694e5a71169b3adb54798691a29699183565f495267
24,822
[ -1 ]
24,823
decimal-scale.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/decimal-scale.lisp
;; decimal-scale.lisp - exponent-based rational storage for decimal values (in-package #:math) #| (defun total-integer-part-digits (n) (1+ (truncate (log n 10)))) (total-integer-part-digits 1020.1) ;; => 4 (total-integer-part-digits 102.1) ;; => 3 |# (defun integer-shift-digits (d) "Perform a decimal shift of D to the minimum significant digits of D, returning the scale and the shifted magnitude Example: (multiple-value-bind (scale magnitude) (integer-shift-digits 1020) (= (* magnitude (expt 10 scale)) 1020)) => T " (declare (type integer d) (values integer fixnum)) (cond ((zerop d) (values 0 0)) (t (let ((n 0)) (declare (fixnum n)) (loop #+NIL (format t "~%FROB: ~s ~S" d n) (multiple-value-bind (a r) (truncate d 10) (cond ((zerop r) (setq d a) (incf n)) (t (return (values d n)))))))))) #+NIL ;;instance tests (labels ((frob-test (n) (multiple-value-bind (magnitude scale) (integer-shift-digits n) (values scale magnitude (= n (* magnitude (expt 10 scale))))))) ;; (frob-test 1020) ;; => 102, 1, T ;; (frob-test 102) ;; => 102, 0, T ;; (frob-test 10) ;; => 1, 1, T ;; (frob-test 1) ;; => 1, 0, T ;; (frob-test 0) ;; => 0, 0, T ) (defun float-shift-digits (d) "A floating point value, `d`, with a known number of significant decimal digits, `n`, may be represented as a sequence of rational values `(a, n)` for `a = d * 10^n`. For example, with d=3.14, then n=-2, d=314 For rhetorical purposes, `a` may be denoted as the magnitude of `d`, and `n` denoted as the scale of `d`. When `n` is known, then calculations evaluated on `d`, may instead be evaluated on `(a, n)`, with `a` and `n` both being of type, rational. In implementations of mathematical operations with this manner of decimal scaling, it may serve to avoid some floating point errors, in some implementations -- moreover, allowing for an implementation of strictly rational calculations for mathematical operations. This function implements a calculation similar to a base-10 calculation of the significand and exponent of `d`." (declare (type (or integer float) d) (values integer fixnum)) (let ((b d) (n 1)) (declare (type (or integer float) b) (type fixnum n) ) (loop #+NIL (format t "~%FROB.: ~s ~s" b n) (setq b (* b 10)) (multiple-value-bind (b r) (truncate b) (declare (ignore b)) (cond ((zerop r) ;; n.b: This effectively works around some matters ;; of floating point error, such as when ;; ;; (* 10 1.201d0) ;; => 12.010000000000002d0 ;; ;; however ;; (float-shift-digits 1.201d0) ;; => 1201, -3 (multiple-value-bind (scaled-magnitude r) ;; truncate so as to ensure an integral value is passed (truncate (* d (expt 10 n))) (unless (zerop r) ;; effectively, "Round up" ;; ;; e.g. when ;; ;; d = 4.159265358979312d0 ;; n = 15 ;; ;; i.e ;; ;; (truncate (* 4.159265358979312d0 (expt 10 15))) ;; => 4159265358979311, 0.5d0 ;; ;; That may be a result of rounding in the floating ;; point implementation. ;; ;; Without the following adjustment, the containing ;; function would return an inaccurate value, ;; in that instance. (incf scaled-magnitude)) (multiple-value-bind (magnitude scale-shift) (integer-shift-digits scaled-magnitude) (return (values magnitude (- scale-shift n)))))) (t (incf n))))))) ;; (float-shift-digits 1) ;; => 1, 0 ;; (float-shift-digits 12) ;; => 12, 0 ;; (float-shift-digits 12.0) ;; => 12, 0 ;; (float-shift-digits 12.1) ;; => 121, -1 ;; ;; (float-shift-digits 120.1) ;; => 1201, -1 ;; (float-shift-digits pi) ;; => 3141592653589793, -15 ;; ^ not all the same as (RATIONALIZE PI) ;; (float-shift-digits 12000) ;; => 12, 3 ;; n.b: ;; (* 10 314.1592653589793d0) ;; => 3141.5926535897934d0 ;; ^ a decimal digit is introduced ;; (float-shift-digits 1.201d0) ;; => 1201, -3 ;; ^ subtly works around a matter of floating point error ;; i.e. in which (* 10 1.201d0) ;; => 12.010000000000002d0 ;; (float-shift-digits 1.201) ;; => 1201, -3 ;; (float-shift-digits 11.0d0) ;; => 11, 0 ;; n.b ;; (* 10 4.159265358979312d0) ;; => 41.592653589793116d0 ;; ;; thus, towards numerical filtering, i.e. float-to-rational conversion ;; ;; (float-shift-digits 4.159265358979312d0) ;; => 4159265358979312, -15 ;; previously, without the filtering, would => 4159265358979311, -15 ;; ;; for example: ;; (truncate (* 4.159265358979312d0 (expt 10 15))) ;; 4159265358979311, 0.5d0 ;; ^ thus the additional filtering is defined ;; (float-shift-digits (rationalize 4.159265358979312d0)) ;; ^ N/A (FIXME) ;; ... ;; (defstruct (decimal ;; (:constructor %make-decimal (magnitude scale))) ;; ;; FIXME: This reproduces MEASUREMENT and SCALAR ;; (magnitude 0 :type fixnum) ;; (scale 0 :type fixnum)) ;; (defun make-decimal (n) ;; (declare (type real n) ;; (values decimal)) ;; (multiple-value-bind (scale magnitude) ;; (float-shift-digits n) ;; (%make-decimal magnitude scale))) ;; (defun decimal-value (d) ;; (declare (type decimal d) ;; (values real)) ;; (* (decimal-magnitude d) ;; (expt 10 (decimal-scale d)))) ;; ;; (make-decimal pi) ;; ;; (= (float (decimal-value (make-decimal pi)) most-positive-double-float) pi) ;; => T
6,014
Common Lisp
.lisp
181
27.132597
137
0.57582
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
625cf365e323d3c1751e57fbe973c99dc2f35bf706b1423da8e61a75935f215a
24,823
[ -1 ]
24,824
measurement-base.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/measurement-base.lisp
;; measurement.lisp - measurement object model (in-package #:math) ;; see also: ;; * http://www.bipm.org/en/publications/si-brochure/ ;; * http://physics.nist.gov/pubs/sp811/contents.html ;; * IUPAC 'Gold Book' http://goldbook.iupac.org/list_math.html ;; esp. <http://goldbook.iupac.org/list_goldbook_quantities_defs_A.html> ;; * <http://physics.nist.gov/cuu/units/> ;; * <http://physics.nist.gov/pubs/sp811/appenb.html> ;; * ^ esp. for formal conversions regarding foot, mile, yard , ... (defgeneric measurement-symbol (instance)) (defgeneric measurement-base-factor (measurement)) (defgeneric measurement-base-factor-exponent (measurement)) ;; ^ FIXME: Clarify applications of those generic functions ;;; % Measurement Class (defclass* (measurement-class :conc-name #:measurement-) (pretty-printable-object standard-class) ((symbol symbol :read-only t) (domain measurement-domain :read-only t) (base-factor real :read-only t :initform 1) (base-factor-exponent fixnum :read-only t :initform 0) )) (validate-class measurement-class) (defmethod shared-initialize :after ((instance measurement-class) slots &rest initargs &key &allow-other-keys) (declare (ignore initargs)) (when-slot-init (instance domain slots) (setf (slot-value instance 'domain) (class-of instance))) (unless (documentation instance 'type) (handler-case (with-accessors ((domain measurement-domain) (print-name object-print-name) (print-label object-print-label) (s measurement-symbol)) instance (let ((domain-name (object-print-name domain))) (setf (documentation instance 'type) (simplify-string (format nil "Measurement class for quantities of ~A ~ in base unit ~A (~A)~2%~ Symbolic representation: ~S" domain-name print-name print-label s))))) (unbound-slot (c) (simple-style-warning "~<Unable to set documentation for ~S~> ~<(~A)~>" instance c))))) (defmethod domain-of ((instance measurement-class)) ;; FIXME : Call MEASUREMENT-DOMAIN here? (measurement-domain instance)) (deftype measurement-class-designator () '(or symbol measurement-class)) (define-condition measurement-class-not-found (entity-not-found) () (:report (lambda (c s) (format s "No measurement class registered for name ~S" (entity-condition-name c))))) (define-condition measurement-class-redefinition (redefinition-condition) () (:report (lambda (c s) ;; FIXME: #I18N (let* ((p (redefinition-condition-previous-object c)) (n (redefinition-condition-new-object c)) (sym (measurement-domain-symbol p))) (format s "~<Redefining measurement class ~S~> ~<(previous: ~S)~> ~<(new: ~S)~>" sym n p))))) (defclass linear-measurement-class (measurement-class) ;; FIXME: Reconsider necessity of this class' definition ;; This class is defined, here, for purpose of convenience. ;; See also: ;; `GEOMETRIC-MEASUREMENT-CLASS' ;; `COMPOUND-MEASUREMENT-CLASS' ;; `LINEAR-DERIVED-MEASUREMENT-CLASS' ;; ;; The concept of whether a measurement class C is a linear, ;; geometric, or compound measurement class, essentially, is ;; orthogonal to whether C is a base measurement class or derived ;; measurement class. ;; ;; In some pragmatic terms: Every BASE-MEASUREMENT-CLASS is also a ;; LINEAR-MEASUREMENT-CLASS, but not every LINEAR-MEASUREMENT-CLASS ;; is a BASE-MEASUREMENT-CLASS. ;; ;; Furthermore, as to whether a linear measurement class defines ;; a unit of measure for length: Though there may seem to be some ;; ambiguity in the terminology of the object model, but the concept ;; of linearity in a measurement class is essentially orthogonal to ;; the concept linearity in measurement units. In the first ;; instance, the concept of a "linear measurement unit" ;; (such as 'm') is contrasted to the concept of a "geometric ;; measurement unit" (such as 'm^2' or 'm^3') ()) ;;; %%% Global Measurement Class Storage (Symbol Key) ;;; %%%% Storage (declaim (type (vector measurement-class) %measurement-classes% )) (defvar %measurement-classes% (make-array 7 :fill-pointer 0 :element-type 'measurement-class) "Internal storage for measurement classes. This variable should be accessed with `%MEASUREMENT-CLASSES-LOCK%' held") ;;; %%%% Locking (Thread Safety) (defvar %measurement-classes-lock% (make-lock "%MEASUREMENT-CLASSES%") "Mutex lock for accessing `%MEASUREMENT-CLASSES%'") ;;; %%%% Access Functions (defun register-measurement-class (c) (declare (type measurement-class-designator c) ;; "Type assertion too complex to check" (SBCL) #+NIL (values measurement-class)) (with-lock-held (%measurement-classes-lock%) (let* ((%c (compute-class c)) (s (measurement-symbol %c)) (n (position s %measurement-classes% :test #'eq :key #'measurement-symbol))) (finalize-inheritance %c) (cond (n (let ((obj (aref %measurement-classes% n))) (unless (eq obj %c) (warn 'measurement-class-redefinition :previous-object obj :new-object c))) (setf (aref %measurement-classes% n) %c)) (t (vector-push-extend %c %measurement-classes%))) (let ((base-ftor (measurement-base-factor %c)) (base-ftor-exp (measurement-base-factor-exponent %c))) (unless (and (zerop base-ftor-exp) (eql base-ftor 1)) (let* ((domain (domain-of %c)) (base-m (measurement-domain-base-measure domain)) (cf-to (make-conversion-factor %c base-m base-ftor base-ftor-exp)) (cf-from (make-conversion-factor base-m %c (/ base-ftor) (- base-ftor-exp)))) (register-conversion-factor cf-to domain) (register-conversion-factor cf-from domain)))) (values %c)))) (defun find-measurement-class (s) (declare (type symbol s) (values measurement-class &optional)) (with-lock-held (%measurement-classes-lock%) (or (find s %measurement-classes% :test #'eq :key #'measurement-symbol) (error 'measurement-class-not-found :name s)))) ;;; % CONVERSION-FACTOR (defgeneric conversion-factor-source-unit (instance)) (defgeneric conversion-factor-magnitude (instance)) (defgeneric conversion-factor-exponent (instance)) (defgeneric conversion-factor-destination-unit (instance)) (defclass* (conversion-factor :conc-name #:factor-) () ((source-unit measurement-class :read-only t) (magnitude real :read-only t) (exponent fixnum :initform 0 :read-only t) (destination-unit measurement-class :read-only t))) (defmethod print-object ((object conversion-factor) stream) (macrolet ((safely (form) `(ignore-errors ,form))) (print-unreadable-object (object stream :type t) (let ((exp (or (safely (factor-exponent object)) 0))) (format stream "(1 ~A) => (~A~@[ * 10^~D~] ~A)" (safely (object-print-label (factor-source-unit object))) (safely (factor-magnitude object)) (unless (zerop exp) exp) (safely (object-print-label (factor-destination-unit object)))))))) (defun make-conversion-factor (source-unit dest-unit factor-magnitude &optional (factor-exponent 0)) (declare (type measurement-class source-unit dest-unit) (type real factor-magnitude) (type fixnum factor-exponent)) (values (make-instance 'conversion-factor :source-unit source-unit :destination-unit dest-unit :magnitude factor-magnitude :exponent factor-exponent))) (defgeneric find-conversion-factor (source-unit dest-unit) (:method ((source-unit symbol) (dest-unit symbol)) (find-conversion-factor (find-measurement-class source-unit) (find-measurement-class dest-unit))) (:method ((source-unit measurement-class) (dest-unit measurement-class)) (let ((domain (verify-conversion-domain source-unit dest-unit))) (with-lock-held ((measurement-domain-cf-lock domain)) (let ((factors (measurement-domain-conversion-factors domain))) ;; This does not completely walk the measurement-domains table, ;; performing only a cursory, one-off search towards DST. ;; ;; If each derived unit, within a single measurement domain, ;; registers a factor for converting that unit to the domain's ;; base measure, and the reciptrocal conversion is also ;; registered, then it would be possible to convert ;; between any registered units within a measurement domain, ;; using only a table of factors (or (find source-unit factors :test #'(lambda (u cf) (declare (ignore u)) (and (eq source-unit (factor-source-unit cf)) (eq dest-unit (factor-destination-unit cf))))) (simple-program-error "No conversion factor available for converting ~S to ~S within ~S" source-unit dest-unit domain))))))) (defgeneric register-conversion-factor (factor domain) (:method ((factor conversion-factor) (domain measurement-domain)) (with-lock-held ((measurement-domain-cf-lock domain)) ;; FIXME: This vector storage model may not be very efficient, ;; onto a "two part" key, contrasted to an EQUALP hash table. (let* ((table (measurement-domain-conversion-factors domain)) (n (position factor table :test (lambda (f-in f-test) (and (eq (factor-source-unit f-in) (factor-source-unit f-test)) (eq (factor-destination-unit f-in) (factor-destination-unit f-test))))))) (cond (n (setf (aref table n) factor)) (t (vector-push-extend factor table))))))) ;;; % MEASUREMENT (defgeneric measurement-magnitude (instance) (:documentation "Return the scalar magnitude of the INSTANCE See also: * `scalar-magnitude' [?] * `measurement-degree' * `measurement-factor-base'")) (defgeneric (setf measurement-magnitude) (new-value instance)) (defgeneric measurement-degree (instance) (:documentation "Return the degree of the scale factor of the INSTANCE. See also: * `measurement-factor-base' * `measurement-magnitude'")) (defgeneric (setf measurement-degree) (new-value instance)) (defclass* measurement () ;; magnitude : a real value that, when multplied by 10^degree, ;; then serves as an effective element for calculating the ;; `scalar-magnitude' for the measurement [?] ((magnitude real :initform 0) ;; degree : an exponent of 10, denoting the degree of the decimal ;; prefix factor for the measurement; serves as like a scale ;; value. see also: PREFIX class and protocol ;; ;; TO DO: For measures of information content (byte, etc) define an ;; additional prefix system - onto powers of 8, rather than of 10. ;; The DEGREE slot for MEASUREMENT may be interpreted in simply an ;; alternate regards, then -- as in (expt 8 DEGREE) rather than ;; (expt 10 DEGREE) -- respectively, an effective FACTOR-BASE of 8 ;; rather than 10 (degree fixnum :initform 0))) (defmethod domain-of ((instance measurement)) (domain-of (class-of instance))) #+NIL ;; unused (FIXME) (defgeneric measurement-base-measure (instance) ;; FIXME: FUNCTION NAME AMBIGUITY ;; ;; RENAME TO: MEASUREMENT-BASE-UNIT (?) ;; (or delete) (:method ((instance measurement)) (measurement-domain-base-measure (domain-of instance)))) (defgeneric measurement-factor-base (instance) ;; FIXME: Concept, "numeric factor" for measurement values ;; - consider adding to documentation (:documentation "Return the base of the degree scale factor of the INSTANCE See also: * `measurement-degree' * `measurement-magnitude'") (:method ((instance measurement-class)) (values 10)) (:method ((instance measurement)) (measurement-factor-base (class-of instance)))) (defmethod measurement-symbol ((instance measurement)) (measurement-symbol (class-of instance))) ;;; %% Base Measurement and Derived Measurement Classes (defclass base-measurement-class (measurement-class) ()) (defmethod domain-of ((instance base-measurement-class)) (class-of (class-of instance))) (defmethod measurement-domain-base-measure ((instance base-measurement-class)) (values instance)) (defclass derived-measurement-class (measurement-class) ()) (defmethod domain-of ((instance derived-measurement-class)) (class-of (class-of instance))) (defmethod measurement-domain-base-measure ((instance derived-measurement-class)) ;; example: derived-length (labels ((frob () (dolist (c (class-precedence-list (class-of instance)) nil) (let ((bm (when (typep c 'measurement-domain) (measurement-domain-base-measure c)))) (when bm (return bm)))))) (handler-case (cond ((next-method-p) (or (call-next-method) (frob))) (t (frob))) ;; FIXME: KLUDGE! Hairy subtle kludge. ;; ;; THIS METHOD SHOULD NOT HAVE TO WORK AROUND UNBOUND SLOTS (FIXME) (unbound-slot () (frob))))) ;;; %% Initialize fundamental measurement domains and base unit classes (let ((kwd (find-package '#:keyword)) (md-mc (find-class 'measurement-domain)) (mc-mc (find-class 'measurement-class)) (bm-mc (find-class 'base-measurement-class)) (lm-mc (find-class 'linear-measurement-class)) (dm-mc (find-class 'derived-measurement-class)) (m-c (find-class 'measurement)) ;; FIXME: Portable source locations - see also, SLIME/SWANK #+SBCL (src (sb-c:source-location))) (labels ((do-def (domain domain-name class print-name print-label name) (let* ((b-d-name (intern-formatted "BASE-~A" domain)) (d-d-name (intern-formatted "DERIVED-~A" domain)) (d (ensure-class domain :symbol (intern* domain kwd) :base-measure class :print-name domain-name :print-label domain-name :direct-superclasses (list mc-mc) :metaclass md-mc #+SBCL :definition-source #+SBCL src)) (b-d ;; base measurement class for DOMAIN ;; This class serves to allow for a base ;; measurement class to be defined as an instance ;; of a class specific to base measurement ;; units. (ensure-class b-d-name :domain d :direct-superclasses (list bm-mc lm-mc) :metaclass domain #+SBCL :definition-source #+SBCL src)) (d-d ;; derived measurement class for DOMAIN (aux) ;; ;; FIXME: There may seem to be a certain ;; ambiguity with regards to the term "Base ;; measure," as being developed in this software ;; system. ;; ;; Classically, a "Base measure" would be one of ;; the seven SI base measurement units. That ;; sense of the term, "Base measure" should be ;; retained within this system, and not shadowed ;; with any ambiguous applications of the same ;; term. ;; ;; So, this system shall define a concept of ;; "fundamental measure" as with regards to ;; measurement domains. A measurement domain's ;; fundamental measure may be a base unit ;; (e.g. meter, in domain 'length') or a derived ;; unit (e.g. joule, in domain 'energy'). ;; ;; For every measurement domain defined within an ;; "Accepted standard" (e.g. as published of the ;; BIPM, the NIST, or the IUPAC), there must be ;; one "fundamental unit" (e.g joule) to which ;; any additinal derived units ;; (e.g. horsepower(E)) may be reduced. ;; ;; Whether a fundamental unit B of a measurement ;; domain A would be defined as a base ;; measurement unit, or defined as a derived ;; measurement unit, that would be essentially ;; orthogonal to the role of B as a fundamental ;; measurement unit within domain A. ;; ;; Tangentially: The nature of a measurement as ;; a base measurement unit would have some ;; meaning as in a contesxt of calculations on ;; measurement values - see also, ;; `NORMALIZE-UNIT-EXPRESSION' (ensure-class d-d-name :domain d :direct-superclasses (list dm-mc lm-mc) :metaclass domain #+SBCL :definition-source #+SBCL src)) (c ;; measurement class denoted by 'class' name (ensure-class class :direct-superclasses (list m-c) :symbol name :print-name print-name :print-label print-label :metaclass b-d #+SBCL :definition-source #+SBCL src ))) (setf (slot-value d 'base-measure) c) (finalize-inheritance d) (finalize-inheritance b-d) (finalize-inheritance d-d) (finalize-inheritance c) (register-measurement-domain d) (register-measurement-class c) (values d c)))) (mapcar (lambda (spec) (destructuring-bind (domain domain-name class print-name print-label name) spec (multiple-value-bind (d c) (do-def domain domain-name class print-name print-label name) (cons d c)))) ;; N.B: With regards to normalization of compound unit ;; expressions, the set of measurement units defined with ;; this form may be stored in a seperate, constant ;; (stack allocated) vector of SI base units. The order of ;; storage of measurement units within that vector will be ;; significant, and must correspond with section 2.1.2 of ;; http://www.bipm.org/en/publications/si-brochure/ ;; ;; Considering the possibly appolications of an "SI Units" ;; vector, as such: ;; * The "SI Units" vector may be applied for a normal ;; ordering of elements within compound unit expressions ;; * Not only the previous, but the "SI Units" vector may ;; also be aplied in normalization of _partially ;; normalized_ compound unit expressions (e.g. `W A^-1`) ;; See also: Documentation, section "Compound unit ;; expressions" '((length "length" meter "metre" "m" :|m|) (mass "mass" kilogram "kilogram" "kg" :|kg|) (time "time, duration" second "second" "s" :|s|) (electrical-current "electric current" ampere "ampere" "A" :|a|) (temperature "thermodyamic temperature" kelvin "kelvin" "K" :|k|) (amount-substance "amount of substance" mole "mole" "mol" :|mol|) (luminous-intensity "luminous intensity" candela "candela" "cd" :|cd|))) )) ;; (eq (find-class 'length) (class-of (find-class 'meter))) ;; => T ;; ;; (typep (find-class 'meter) 'measurement-class) ;; => T ;; ;; (measurement-domain (make-instance 'meter)) ;; => #<MEASUREMENT-DOMAIN BASE-LENGTH> ;; (find-measurement-class :|m|) ;; (find-measurement-class :|kg|) ;; (find-measurement-class :|s|) ;; (find-measurement-class :|a|) ;; (find-measurement-class :|k|) ;; (find-measurement-class :|mol|) ;; (find-measurement-class :|cd|) (defclass gram (kilogram) ;; Kilogram is the base unit of measurement for mass, under the ;; Systeme International. ;; ;; The method PRINT-LABEL (KILOGRAM T) will ensure that an ;; appropriate magnitude and unit will be printed for KILOGRAM ;; measurements. ;; ;; Though it may be more semantically consistent, if to ensure that ;; a class, GRAM, is defined in parallel to KILOGRAM, however ;; insofar as that such application presently lacks a necessary ;; usage case, the class GRAM will remain directly undefined of this ;; system. () (:metaclass derived-mass) (:base-factor . 1/1000) (:print-name . "gram") ;; FIXME: #I18N (EN_UK => gramme) (:print-label . "g") (:symbol . :|g|)) (register-measurement-class 'gram) ;; (measurement-domain-base-measure (domain-of (make-instance 'gram))) ;; => #<BASE-MASS KILOGRAM> ;; see also: SCALE-SI methods defined in prefix.lisp ;; esp. SCALE-SI (MEASUREMENT &OPTIONAL T) ;; (make-measurement 1 :|kg|) ;; =should=> #<KILOGRAM 1 kg {10082A9083}> ;; OK ;; (scale-si (make-measurement 1 :|kg|)) ;; => 1, 0 ;; OK - SCALE-SI KILOGRAM #+NIL (let ((m (base-convert-measurement (make-measurement 1 :|kg|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - BASE-CONEVERT-MEASUREMENT 1 KG ;; (make-measurement 1 :|g|) ;; =should=> #<GRAM 1 g {...}> ;; FAIL - PRINT-LABEL GRAM ;; (scale-si (make-measurement 1 :|g|)) ;; => 1000, -3 ;; OK - SCALE-SI 1 GRAM => 1000 * 10^-3 KG (SCALED) ;; see also: PRINT-LABEL (MEASUREMENT STREAM) #+NIL (let ((m (make-measurement 1 :|g|))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - MAKE-MEASUREMENT, MEASUREMENT INITIALIZATION, MEASUREMENT PROPERTIES #+NIL (let ((m (base-convert-measurement (make-measurement 1 :|g|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1/1000, 0 ;; OK - BASE-CONVERT-MEASUREMENT 1 GRAM = 1/1000 KG (SCALED) ;; (make-measurement 1000 :|g|) ;; => #<GRAM 1000 g {10075C92B3}> ;; OK ;; (scale-si (make-measurement 1000 :|g|)) ;; => 1000, 0 ;; FAIL - SCALE-SI 1000 GRAM => 1 * 10^0 KG (SCALED) ;; =SHOULD=> 1, 0 #+NIL (let ((m (base-convert-measurement (make-measurement 1000 :|g|)))) (values (measurement-magnitude m) (measurement-degree m))) ;; => 1, 0 ;; OK - BASE-CONVERT-MEASUREMENT 1000 GRAM => 1 KG (SCALED) ;; (convert-measurement (make-measurement 1 :|kg|) :|g|) ;; =should=> #<GRAM 1000 g {...}> ;; FAIL ;; (convert-measurement (make-measurement 1000 :|g|) :|kg|) ;; =should=> #<KILOGRAM 1 kg {...}> ;; FAIL - PRINT-LABEL MEASUREMENT STREAM ? ;; (measurement-magnitude (convert-measurement (make-measurement 1 :|kg|) :|g|)) ;; => 1 ;; (measurement-degree (convert-measurement (make-measurement 1 :|kg|) :|g|)) ;; => 3 ;; OK ;; (base-convert-measurement (make-measurement 1 :|g|)) ;; =should=> #<KILOGRAM 1 g {...}> ;; OK ;; (measurement-magnitude (base-convert-measurement (make-measurement 1 :|g|))) ;; => 1/1000 ;; OK ;; (base-magnitude (make-measurement 1 :|g|)) ;; =should=> 1/1000 ;; OK ;; (find-conversion-factor :|g| :|kg|) ;; => #<CONVERSION-FACTOR (1 g) => (1/1000 kg)> ;; OK ;; (find-conversion-factor :|kg| :|g|) ;; => #<CONVERSION-FACTOR (1 kg) => (1000 g)> ;; OK ;;; % Measurement Initialization (defun make-measurement (magnitude unit &optional (degree 0)) "Crate a MEAUREMENT object of the specified MAGNITUDE of a decimal scale denoted by DEGREE, representing a scalar measurement of the measurement unit denoted by UNIT. Examples: (make-measurement 1 :|m|) => #<METER 1 m {1006289003}> (make-measurement 1 :|m| -3) => #<METER 1 mm {10062E90C3}> See also: * `scalar-magnitude' [?] * `prefix-of' * `rescale', `nrescale'" (declare (type real magnitude) (type fixnum degree) (type measurement-class-designator unit) (values measurement)) (let ((class (etypecase unit (symbol (find-measurement-class unit)) (measurement-class unit)))) ;; FIXME: This does not explicitly scale the {MAGNITUDE, DEGREE} ;; down to the base measurement unit. ;; In an optimized implementation, all measurement values may be ;; scaled to integer/magnitude+exponent values onto the base ;; measurement unit -- thus, allowing for direct application of ;; formulas likewise defined onto the base measurement unit, ;; without further magnitude+exponent scaling -- essentially, ;; leaving any conversion from/to non-base measurement units to the ;; input/display components of the implementation. ;; ;; Presently, this system applies a mehtodology essentialy of ;; "Scaling to significant digits". (etypecase magnitude (ratio (values (make-instance class :magnitude magnitude :degree degree))) (real (multiple-value-bind (adj-magnitude scale) (float-shift-digits magnitude) (values (make-instance class :magnitude adj-magnitude :degree (+ degree scale)))))))) ;; (make-measurement 1 :|m| 5) ;; => #<METER 100 km {1003FF93A3}> ;; (measurement-magnitude (make-measurement 1 :|m| 5)) ;; => 1 ;; Arbitrary instance tests (FIXME: Formalize these instance tests) ;; Example: Scaling to significant digits ;; ;; (measurement-magnitude (make-measurement 103 :|m| 10)) ;; => 103 ;; (measurement-degree (make-measurement 103 :|m| 10)) ;; => 10 ;; ;; (measurement-magnitude (make-measurement 1030 :|m| 9)) ;; => 103 ;; (measurement-degree (make-measurement 1030 :|m| 9)) ;; => 10 ;;- Ratio magnitude (unscaled) ;; (make-measurement 1/5 :|m|) ;; => #<METER 1/5 m {1003FF93A3}> ;; (measurement-magnitude (make-measurement 1/5 :|m|)) ;; => 1/5 ;; ;; (make-measurement 1/5 :|m| 3) ;; => #<METER 1/5 km {1007B81023}> ;; (measurement-magnitude (make-measurement 1/5 :|m| 3)) ;; => 1/5 ;; ;; (base-magnitude (make-measurement 1/5 :|m| 3)) ;; => 200 ;; i.e. 200 m ;; ;; (base-magnitude (make-measurement 1/5 :|m|)) ;; => 1/5 ;; i.e. 1/5 m ;; (make-measurement 0.2 :|m|) ;; => #<METER 200 mm {1006CC13C3}> ;; (make-measurement 0.2222 :|m|) ;; => #<METER 222200 μm {1006E29433}> ;; (make-measurement 1 :|kg|) ;; => #<KILOGRAM 1000 g {10065C1043}> ;; (make-measurement 1 :|kg| 6) ;; => #<KILOGRAM 1000 Mg {10066090B3}> ;; (make-measurement 1 :|m| 3) ;; => #<METER 1 km {1003FF93A3}> ;; (measurement-magnitude (make-measurement 1 :|m| 3)) ;; => 1 ;; (measurement-degree (make-measurement 1 :|m| 3)) ;; => 3 ;; (measurement-magnitude (make-measurement 1000 :|m| 3)) ;; => 1 ;; (measurement-degree (make-measurement 1000 :|m| 3)) ;; => 6 ;; (object-print-label (class-of (make-measurement 1 :|m|))) ;; => "m" ;; (object-print-name (class-of (make-measurement 1 :|m|))) ;; % Measurement Unit Expressions (Linear) (defgeneric unit-expr-unit (expr)) (defgeneric (setf unit-expr-unit) (new-value expr)) (defgeneric unit-expr-degree (expr)) (defgeneric (setf unit-expr-degree) (new-value expr)) (defgeneric unit-expr-elements (expr)) (defgeneric (setf unit-expr-elements) (new-value expr)) (defclass unit-expr () ()) (defclass linear-unit-expr (unit-expr) ((unit :initarg :unit :accessor unit-expr-unit :type measurement-class)))
28,259
Common Lisp
.lisp
658
35.203647
87
0.621435
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
481f02ce62eb21ae30a66e241bb811f121c4653f975318183db306096b1fe618
24,824
[ -1 ]
24,825
mconv.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/mconv.lisp
;; mconv.lisp - procedures for measurement conversion (in-package #:math) (define-condition conversion-domains-mismatch (error) ((source-domain :initarg :source-domain :reader conversion-source-domain) (dest-domain :initarg :destination-domain :reader conversion-destination-domain)) (:report (lambda (c s) (format s "Domains Mismatch - Cannot convert measument of domain ~A to domain ~A" (conversion-source-domain c) (conversion-destination-domain c))))) (defun verify-conversion-domain (src-type dst-type) (let ((src-domain (domain-of src-type)) (dst-domain (domain-of dst-type))) (cond ((eq src-domain dst-domain) (values dst-domain)) (t (error 'conversion-domain-mismatch :source-domain src-domain :destination-domain dst-domain))))) (defgeneric convert-measurement (measurement to-type) ;; FIXME: Misaligned with `BASE-MAGNITUDE', `BASE-CONVERT-MEASUREMENT' (:method ((measurement measurement) (to-type symbol)) (convert-measurement measurement (find-measurement-class to-type))) (:method ((measurement measurement) (to-type measurement-class)) (let* ((src-type (class-of measurement)) (domain (verify-conversion-domain src-type to-type)) (base-type (measurement-domain-base-measure domain))) (cond ((eq src-type to-type) ;; FIXME: Should copy-object ? (values measurement)) ((eq base-type to-type) ;; use BASE-MAGNITUDE as shortcut (?) (make-measurement (base-magnitude measurement) base-type)) (t ;; factoring (let ((cf (find-conversion-factor src-type to-type))) (make-measurement (* (measurement-magnitude measurement) (factor-magnitude cf)) to-type (+ (measurement-degree measurement) (factor-exponent cf ))))))))) ;; (scalar-magnitude (convert-measurement (make-measurement 1 :|ft_1893|) :|m|)) ;; => 1200/3937 (m) ;; (scalar-magnitude (convert-measurement (make-measurement 1 :|m|) :|ft_1893|)) ;; => 3937/1200 (ft) ;; (scalar-magnitude (convert-measurement (make-measurement 1 :|m| 3) :|mi_1893|)) ;; => 3937/6336 (mi) (defun base-convert-measurement (measurement) ;; FIXME : Misaligned with `BASE-MAGNITUDE' (declare (type measurement measurement) (values measurement)) (let ((base-mc (measurement-domain-base-measure (domain-of measurement)))) (cond ((eq base-mc (class-of measurement)) ;; ? ;; FIXME: TEST THIS (values measurement)) (t (values (convert-measurement measurement base-mc)))))) ;; (scalar-magnitude (base-convert-measurement (make-measurement 1 :|ft_1893|))) ;; => 1200/3937 ;; (scalar-magnitude (base-convert-measurement (make-measurement 1 :|m|))) ;; => 1 (defun base-magnitude (m) "Calculate the scalar magnitude of the measurement M for the base measurement unit of M" ;; FIXME : Misaligned with `BASE-CONVERT-MEASUREMENT', ;; `CONVERT-MEASUREMENT', `SCALAR-MAGNITUDE' (declare (type measurement m) (values real)) (let* ((unit (class-of m)) ;; assuming same exponent base for both M and BASE - SHORTCUT (expt-base (measurement-factor-base unit)) (base-m (measurement-base-factor unit)) (base-d (measurement-base-factor-exponent unit)) (m-m (measurement-magnitude m)) (m-d (measurement-degree m))) ;; Comment from during Ig1m sprints: ;; ;; Note that this effectively ignores the measurement conversion ;; model, and makes no reference to the domain of the MEASUREMENT (?) ;; ;; Essentially, this function uses a "Short cut" for conversion to ;; base measurement, using the BASE-FACTOR and ;; BASE-FACTOR-EXPONENT of the UNIT for the measurement (?) ;; Comment from during Ig2m sprints: ;; ;; FIXME - DESIGN AMBIGUITY => MISALIGNMENT ;; ;; This function appears to return not the magnitude as in ;; {magnitude, degree} but rather the value of the magnitude ;; reduced per degrees in measurement conversion (i.e. source ;; degree => dest-degree) (let ((new-deg (+ m-d base-d))) (values ;; FIXME - DESIGN/CODE ALIGNMENT ;; This may be redundant onto other functions defined in this system (* m-m base-m (expt expt-base new-deg)) new-deg)))) ;; BEGIN: Example ;; (measurement-factor-base (find-class 'meter)) ;; => 10 ;; ;; (measurement-base-factor (find-class 'meter)) ;; => 1 ;; ;; (measurement-base-factor-exponent (find-class 'meter)) ;; => 0 ;; (measurement-factor-base (find-class 'gram)) ;; => 10 ;; ;; (measurement-base-factor (find-class 'gram)) ;; => 1/1000 ;; ;; (measurement-base-factor-exponent (find-class 'meter)) ;; => 0 ;; :END ;; (base-magnitude (make-measurement 1 :|m| 3)) ;; => 1000, 3 ;; (base-magnitude (make-measurement 1 :|m| -3)) ;; => 1/1000, -3 ;; (base-magnitude (make-measurement 1/5 :|m|)) ;; => 1/5, 0 ;; (base-magnitude (make-measurement 1/5 :|m| -3)) ;; => 1/5000, -3 ;; (base-magnitude (make-measurement 1 :|kg|)) ;; => 1, 0 ;; ;; (base-magnitude (make-measurement 1000 :|kg|)) ;; =SHOULD=> 1000, 0 ;; FAIL (!) ;; SEE ALSO: ;; * MEASUREMENT-BASE-FACTOR <<GRAM>> ;; * MEASUREMENT-BASE-FACTOR-EXPONENT <<GRAM>> ;; (base-magnitude (make-measurement 1 :|g|)) ;; => 1/1000, 0 ;; ;; (base-magnitude (make-measurement 1000 :|g|)) ;; => 1, 3 (defgeneric scalar-magnitude (scalar) ;; This function had its origins in the definition of the ;; measurement prefix model ;; FIXME: AMBIGUITY/MISALIGNMENT ONTO: ;; * `SCALAR-MAGNITUDE' ;; * `BASE-MAGNITUDE' ;; * `MESAUREMENT-MAGNITUDE' ;; ;; See also: README.md, specifically the discussion under the ;; heading, "Meaning and Application of 'Magnitude' and 'Value' in ;; Measurements" (:method ((scalar measurement)) "Return the magnitude of the SCALAR measurement onto the base unit for the measurement" (base-magnitude scalar))) ;; (scalar-magnitude (make-measurement 1 :|m| -3)) ;; => 1/1000
6,156
Common Lisp
.lisp
159
33.603774
86
0.654053
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
9de47e6b4501de40d2848e370f5d738eb2b47bf6e0ca1fa0034eb783b04bab43
24,825
[ -1 ]
24,826
measurement-ov.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/measurement-ov.lisp
;; measurement-ov.lisp - math operations for measurement values ;; [prototype 0] ;; ;; see also: unit-expr-proto.lisp (in-package #:math) #+PROTOTYPE-0 (defgeneric unit-degree (measurement-unit)) ;; FIXME: Move to other file #+PROTOTYPE-0 (defgeneric compute-measurement-class (operation a b) ;; avoiding EQL specializers, "as a matter of principle" ;; @+ => base measurement unit of domain of A, B + conversion ;; @- => base measurement unit of domain of A, B + conversion ;; @* => exponent (!) of base measurement unit of domain of A, B ;; ...as per the sum of the "unit degree" of each of A, B ;; + conversion ;; @/ => "Unity" unit + conversion ;; In such unit conversions as must be performed within a ;; mathematical operation OP onto measurement objects (A,B), the ;; application should prefer to convert to a base unit of measure, ;; per the domains of A,B onto OP. ;; ;; For A,B subtype LENGTH, and OP being @+ or @- (linear op) ;; the result should be of type METER ;; i.e. the base measurement unit of the LENGTH domain ;; ;; For A,B subtype LENGTH, and OP being @* (geometric op) ;; the result should be of type METER^2 ;; i.e. the square of the base measurement unit ;; of the LENGTH measuremnet domain ;; e.g for A,B of any type, and OP being @/ ;; the result should be of type UNITY ;; for A,B of different measurement domains ;; ... must query the measurement units database, per (OP, A, B) #+NIL (:method ((operation math-op) (a measurement) (b measurement)) (funcall (the function (measurement-unit-selector-function opreation)) a b))) #+PROTOTYPE-0 (defmacro with-values ((a-m a-d b-m b-d base class) (op a b) &body body) (with-gensym (%a %b) `(let ((,%a ,a) (,%b ,b)) (declare (type (measurement ,%a ,%b)) (inline + - * / expt)) (let ((,class (compute-measurement-class (function ,op) ,%a ,%b)) (,a-m (measurement-magnitude ,%a)) (,a-d (measurement-degree ,%a)) (,b-m (measurement-magnitude ,%b)) (,b-d (measurement-degree ,%b)) (,base (measurement-factor-base ,%a))) (declare (type rational ,a-m ,b-m) (type fixnum ,a-d ,b-d ,base)) ,@body)))) (defmethod %+ ((a measurement)) (values a)) #+PROTOTYPE-0 (defmethod @+ ((a measurement) (b measurement)) ;; ISSUE: To ensure that (class-of A) is subtypep (class-of b)) ;; ISSUE: To determine of which class the resulting measurement ;; should be. Arbitrary approach uses A (with-values (a-m a-d b-m b-d base class) (@+ a b) (labels ((scale+ (c-m d-m s) (declare (type rational c-m d-m) (type fixnum s)) (cond ((zerop s) (+ c-m d-m)) (t (+ c-m (* d-m (expt base s))))))) (multiple-value-bind (m d) (cond ((< a-d b-d) (values (scale+ a-m b-m (- b-d a-d)) a-d)) (t (values (scale+ b-m a-m (- a-d b-d)) b-d))) (make-measurement m class d))))) ;; 5*10^2 + 5*10^2 = 10^2(5 + 5)) = 1000 ;; (scalar-magnitude (@+ (make-measurement 5 :|m| 2) (make-measurement 5 :|m| 2))) ;; => 1000 ;; 5*10^2 + 5*10^3 = 10^2(5*10^0 + 5*10^1) = 5500 ;; (scalar-magnitude (@+ (make-measurement 5 :|m| 2) (make-measurement 5 :|m| 3))) ;; => 5500 ;; (scalar-magnitude (@+ (make-measurement 5 :|m| 3) (make-measurement 5 :|m| 2))) ;; => 5500 ;; 5*10^-2 + 5*10^3 = 10^-2(5*10^0 + 5*10^5) = 100001/20 = 5000.05 ;; (scalar-magnitude (@+ (make-measurement 5 :|m| -2) (make-measurement 5 :|m| 3))) ;; => 100001/20 ;; (scalar-magnitude (@+ (make-measurement 5 :|m| 3) (make-measurement 5 :|m| -2))) ;; => 100001/20 #+NIL (defmethod @+ ((a measurement) (b measurement)) (let ((base-measure (verify-same-domain-and-degree a b))) (make-measurement (+ (scalar-magnitude a) (scalar-magnitude b)) base-measure))) (defmethod %- ((a measurement)) (values (make-measurement (- (measurement-magnitude a)) (class-of a) (measurement-degree a)))) ;; (= (scalar-magnitude (%- (make-measurement 1 :|m|))) -1) ;; => T ;; (= (scalar-magnitude (%- (make-measurement -1 :|m|))) 1) ;; => T #+PROTOTYPE-0 (defmethod @- ((a measurement) (b measurement)) ;; ISSUE: To ensure that (class-of A) is subtypep (class-of b)) ;; ISSUE: To determine of which class the resulting measurement ;; should be. Arbitrary approach uses A (with-values (a-m a-d b-m b-d base class) (@- a b) (labels ((scale- (c-m d-m s) (declare (type rational c-m d-m) (type fixnum s)) (cond ((zerop s) (- c-m d-m)) (t (- c-m (* d-m (expt base s))))))) (multiple-value-bind (m d) (cond ((< a-d b-d) (values (scale- a-m b-m (- b-d a-d)) a-d)) (t (values (scale- b-m a-m (- a-d b-d)) b-d))) (make-measurement m class d))))) ;; 5*10^2 - 5*10^2 = 10^2(5 - 5)) = 0 ;; (scalar-magnitude (@- (make-measurement 5 :|m| 2) (make-measurement 5 :|m| 2))) ;; => 0 ;; 5*10^2 - 5*10^3 = 10^2(5*10^0 - 5*10^1) = -4500 ;; (scalar-magnitude (@- (make-measurement 5 :|m| 2) (make-measurement 5 :|m| 3))) ;; => -4500 ;; 5*10^-2 - 5*10^3 = 10^-2(5*10^0 - 5*10^5) = -99999/20 = -4999.95 ;; (scalar-magnitude (@- (make-measurement 5 :|m| -2) (make-measurement 5 :|m| 3))) ;; => -99999/20 (defmethod %* ((a measurement)) (values a)) #+NIL ;; FIXME: Must return measurement of type unit^2 (defmethod @* ((a measurement) (b measurement)) (with-values (@* a-m a-d b-m b-d base class) (a b) (declare (ignore base)) (make-measurement (* a-m b-m) class (+ a-d b-d)))) (defmethod %/ ((a measurement)) (values (make-measurement (/ (measurement-magnitude a)) (class-of a) (- (measurement-degree a))))) ;; (= (scalar-magnitude (%/ (make-measurement 1 :|m|))) 1) ;; => T ;; (= (scalar-magnitude (%/ (make-measurement 10 :|m|))) 1/10) ;; => T ;; (= (scalar-magnitude (%/ (make-measurement 1 :|m| 1))) 1/10) ;; => T ;; FIXME: Must return measurement of a "dimensionless" unit #+NIL (defmethod @/ ((a measurement) (b measurement)) (let ((a-d (measurement-domain a)) (b-d (measurement-domain b))) (cond ((and (eq a-d b-d) (= (measurement-unit-degree (class-of a)) (measurement-unit-degree (class-of b)))) (make-measurement (/ (measurement-magnitude a) (measurement-magnitude b)) (find-class 'unity) (- (measurement-degree a) (measurement-degree b)))) ((eq a-d b-d) (error "UNIMPLEMENTED: Cross-degree division")) (t (error "UNIMPLEMENTED: Cross-domain division")))))
6,535
Common Lisp
.lisp
174
33.591954
83
0.601931
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
3aad04102100297c834d81a7d4b0c6014580609562db9f2f2d6b10d8314c48e3
24,826
[ -1 ]
24,827
domain.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/domain.lisp
;; domain-lisp - measurement domains (in-package #:math) (defgeneric measurement-domain-base-measure (instance)) (defgeneric measurement-domain-symbol (instance)) (defgeneric measurement-domain-cf-lock (instance)) (defgeneric measurement-domain-conversion-factors (instance)) (defclass measurement-domain (pretty-printable-object standard-class) ;; FIXME: #I18N slot definitions - PRINT-NAME/PRINT-LABEL ((base-measure :initarg :base-measure :type class :reader measurement-domain-base-measure) (symbol :initarg :symbol :type symbol :reader measurement-domain-symbol) (cf-lock :initform (make-lock "CONVERSION-FACTORS") :reader measurement-domain-cf-lock) (conversion-factors ;; Table of conversion factors for within the same measurement domain :initarg :conversion-factors :type vector :initform (make-array 0 :fill-pointer 0) :reader measurement-domain-conversion-factors))) (validate-class measurement-domain) (defgeneric domain-of (instance) (:method ((instance measurement-domain)) (values instance))) (defmethod shared-initialize :around ((instance measurement-domain) slots &rest initargs &key (base-measure nil bmp) &allow-other-keys) (let (args-changed-p) (when bmp (let ((c (or (find-class base-measure nil) (ensure-forward-referenced-class base-measure)))) (setf (getf initargs :base-measure) c) (setq args-changed-p t))) (cond (args-changed-p (apply #'call-next-method instance slots initargs)) (t (call-next-method))))) (defmethod finalize-inheritance :after ((class measurement-domain)) (labels ((find-slot (sl where) (find sl (class-slots where) :key #'slot-definition-name :test #'eq)) (find-super-value (slot sought-type &optional (supers (cdr (class-precedence-list class)))) (dolist (c supers (values nil nil)) (when (and (typep c sought-type) (find-slot slot c) (slot-boundp c slot)) (return (values (slot-value c slot) t))))) (maybe-inherit-slot (slot sought-type) (when (not (slot-boundp class slot)) (multiple-value-bind (super-v foundp) (find-super-value slot sought-type) (when foundp (setf (slot-value class slot) super-v)))))) (maybe-inherit-slot 'utils::print-label 'pretty-printable-object) (maybe-inherit-slot 'utils::print-name 'pretty-printable-object) ;; FIXME: WHY is BASE-MEASURE still not being inherited? (maybe-inherit-slot 'base-measure 'measurement-domain) #+NO (maybe-inherit-slot 'symbol 'measurement-domain) ;; KLUDGE ) (unless (documentation class 'type) (handler-case (with-accessors ((print-name object-print-name)) class (setf (documentation class 'type) (simplify-string ;; FIXME: Note Base / Derived measurement domain here... ;; (KLUDGE) (format nil "Measurement domain for quantities of ~A" print-name)))) (unbound-slot (c) (simple-style-warning "~<Unable to set documentation for ~S~> ~<(~A)~>" class c))))) (define-condition measurement-domain-not-found (entity-not-found) () (:report (lambda (c s) ;; FIXME: #I18N (format s "No measurement domain registered for name ~S" (entity-condition-name c))))) (define-condition measurement-domain-redefinition (redefinition-condition) () (:report (lambda (c s) ;; FIXME: #I18N (let* ((p (redefinition-condition-previous-object c)) (n (redefinition-condition-new-object c)) (sym (measurement-domain-symbol p))) (format s "~<Redefining measurement domain ~S~> ~<(previous: ~S)~> ~<(new: ~S)~>" sym n p))))) (declaim (type (vector measurement-domain) %domains% )) (defvar %domains% (make-array 7 :fill-pointer 0 :element-type 'measurement-domain) "Internal storage for measurement domains. This variable should be accessed with `%DOMAINS-LOCK%' held") (defvar %domains-lock% (make-lock "%DOMAINS%") "Mutex lock for accessing `%DOMAINS%'") (defun find-measurement-domain (name) ;; FIXME: #I18N query (declare (type (or symbol string) name) ;; unable to check return type #+NIL (values measurement-domain)) (let ((s (etypecase name (symbol name) (string (intern* (read-from-string name) (find-package '#:keyword)))))) (with-lock-held (%domains-lock%) (or (find s %domains% :test #'eq :key #'measurement-domain-symbol) (error 'measurement-domain-not-found :name name))))) (defun register-measurement-domain (domain) (declare (type class-designator domain) ;; "Type assertion too complex to check" (SBCL) #+NIL (values measurement-domain)) (with-lock-held (%domains-lock%) (let* ((c (compute-class domain)) (s (measurement-domain-symbol c)) (n (position s %domains% :test #'eq :key #'measurement-domain-symbol))) (declare (type measurement-domain c)) (cond (n (warn 'measurement-domain-redefinition :previous (aref %domains% n) :new c) (setf (aref %domains% n) c)) (t (vector-push-extend c %domains%))) (values c)))) (defun enumerate-measurement-domains (&optional (return-type 'list)) (declare (values sequence)) (coerce %domains% return-type)) ;; (find-measurement-domain :electrical-current) ;; (mapcar #'measurement-domain-symbol (enumerate-measurement-domains))
5,901
Common Lisp
.lisp
146
32.267123
86
0.627204
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
216b6edb1ee40ad327fc82d19f35f30980507a76bc89cdc06df7677053eb2a71
24,827
[ -1 ]
24,828
derived-length.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/derived/derived-length.lisp
;; length-measure.lisp - derived measurements of length (in-package #:math) ;;; %% Derived Measures of Length ;; referencing [NIST SP811] (defclass us-survey-foot (measurement) ;; prototypical, derived measurement unit ;; ;; FIXME: Denote this as a "US Survey Foot" [1893], per NIST SP811 ;; section B.6 ;; ;; Also define: ;; * US Survey Mile [1893] (5280 US Survey ft) ;; * International foot [1959] 0.3048 m ;; * International mile [1959] 5280 US internationa foot () (:metaclass derived-length) (:print-name . "foot [1893]") (:print-label . "ft [1893]") (:base-factor . 1200/3937) (:symbol . :|ft_1893|) (:documentation "US Survey Foot [1893]") #+OBJECT-ANNOTATION ;; ^ towards a concept similar to OWL annotation properites ;; in an application for annotation of Common Lisp objects, ;; ...towards something perhaps somewhat more specialized than ;; symbol plists, and onto "The Semantic Web" etc ;; ;; Here, just a small usage example, for denoting an exact "source ;; resource" from which a measurement conversion ratio has been ;; derived, manually, by the author: (:annotation ;; #i<IRI> reader macro (TBD) (:defined_by #i<http://physics.nist.gov/pubs/sp811/> B.6 42) ;; ^ specifically SP811 section B.6 (p. 42) )) (register-measurement-class (find-class 'us-survey-foot)) ;; (base-magnitude (make-measurement 1 :|ft_1893|)) ;; => 1200/3937 i.e meters (FIXME: Not returning that value, presently) ;; (base-convert-measurement (make-measurement 1 :|ft_1893|)) ;; => #<METER 1200/3937 m {1012630AC3}> ;; ;; (float 1200/3937 pi) ;; => 0.3048006096012192d0 ;; ^ 1 foot => "this many" meters (double float precision) ;; ^ approximately 0.30408 as per SP811 (less than single-float precision) ;; (find-conversion-factor :|ft_1893| :|m|) ;; (find-conversion-factor :|m| :|ft_1893|) ;; (make-measurement 1 :|ft_1893| 3) ;; ^ the illustrious kft ;; (make-measurement 1 :|ft_1893| -3) ;; ^ correspondingly, the larch millifoot (defclass us-survey-mile (measurement) () ;; FIXME: Denote as US Survey Mile [1893] - See previous (:metaclass derived-length) (:print-name . "mile [1893]") (:print-label . "mi [1893]") (:base-factor . #.(* 5280 1200/3937)) (:symbol . :|mi_1893|) (:documentation "US Survey Mile [1893]") #+OBJECT-ANNOTATION (:annotation (:defined_by #i<http://physics.nist.gov/pubs/sp811/>) )) (register-measurement-class (find-class 'us-survey-mile))
2,473
Common Lisp
.lisp
65
35.415385
75
0.685046
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
721ed002f9dbb2f0c73dfc67b029c9bc78a3eaf99ea4b0da045a939a1958bcae
24,828
[ -1 ]
24,829
linear-measure.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/derived/linear-measure.lisp
;; linear-measure.lisp - linear measurement units/expressions (in-package #:math) (defclass linear-derived-measurement-class (derived-measurement-class linear-measurement-class ) ()) ;; LINEAR-UNIT-EXPR : defined in measurement-base.lisp
287
Common Lisp
.lisp
6
38.666667
70
0.672662
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
39aedd563dd769171e37e2b9279f979e6fedc9615a83c6f78f411d0b034e30b2
24,829
[ -1 ]
24,830
geom-measure.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/derived/geom-measure.lisp
;; geom-measure.lisp - geometric measurement units/expressions (in-package #:math) (defclass geometric-measurement-class (derived-measurement-class) ((degree :initarg :degree :type fixnum :accessor measurement-degree))) (defclass geometric-unit-expr (linear-unit-expr) ((degree :initarg :degree :accessor unit-expr-degree :type fixnum)))
369
Common Lisp
.lisp
12
27.166667
65
0.745763
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
5387080c6b83ddcd9108ed7a0dbd26b20b9eb3b8183dcc9b6f380f5f904aa011
24,830
[ -1 ]
24,831
compound-measure.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/derived/compound-measure.lisp
;; compound-measure.lisp - object model for compound measurements (in-package #:math) (defgeneric measurement-unit-sequence (class)) (defgeneric measurement-degree-sequence (class)) (defgeneric measurement-normalized-expression (class)) ;; % Compound Measurements - Registry and Retrieval #| Notes * This system will define a registry specifically for compound measurement unit classes, effectively augmenting the registry of base and derived measurement unit classes comprised of `%MEASUREMENT-CLASSES%' and its corresponding `%MEASUREMENT-CLASSES-LOCK%' * At time of registering a componound measurement class, the class may be indexed within the compound measurement unit classes registry, according to three primary values: 0. The identity of the class, itself. Assuming that the Common Lisp implementation ensures that any class Cn named N (n > 1) will always be EQ to class C1 named N, the identity of the class Cn may be applied as an index key, such that the functions storing and accessing the index may use EQ as a :test function. 1. The MEASUREMENT-NORMALIZED-EXPRESSION defined to the measurement unit class. Although this may seem to denote a cosmetically appealing method for functional query onto the compound measurement unit classes registry, however it may not present the most optimal approach possible. 2. The set of the unit sequence and degree sequence for the normalized measurement unit expression defined to the measurement unit class. It may serve to permit for an optimized implementation in the functions for measurement query and unit conversion, when these values would be accessed seperately. * When searching for a measurement unit class, provided an arbitrary "normalized" base measurement unit expression, it may be assumed: * that the elements of the expresion may occur in any arbitrary order. * that a subset of the elements of the expression may effectively "match" the complete set of elements of a registered, compound measurement unit class * that the expression may contain elements in addition to any subset of elements effectively "matching" the normalized unit expression of any registered, compound measurement unit class |# ;; % Compound Measurements - Measurement Class Definition and Initialization (defclass compound-measurement-class (measurement-class) ((unit-sequence :initarg :unit-sequence :type (simple-array measurement-class (*)) :reader measurement-unit-sequence) (degree-sequence :initarg :degree-sequence :type (simple-array fixnum (*)) :reader measurement-degree-sequence) (normalized-expression :type (simple-array t (* 2)) :initarg :normalized-expression :reader measurement-normalized-expression ))) (defmethod shared-initialize :around ((instance compound-measurement-class) slots &rest initargs &key expression &allow-other-keys) (declare (type list expression)) (let (args-changed-p) (when expression (labels ((make-buffer (length element-type) (make-array length :element-type element-type)) (normalize (expr) ;; NOTE: It's assumed that the :EXPRESSION value ;; would be provided in base measurement units. ;; So, this function does not expressly normalize ;; to base measurement units. ;; ;; See also: `NORMALIZE-UNIT', `SIMPLIFY-UNIT' (declare (type list expr)) (let* ((%expr (coerce expr 'simple-vector)) (n (length (the simple-vector %expr))) (reslt (make-array (list n 2) :element-type t))) (dotimes (index n reslt) (let* ((elt (aref %expr index)) (s (etypecase elt (symbol elt) (cons (car elt)))) (c (find-measurement-class s)) (d (etypecase elt (symbol 1) (cons (cadr elt))))) (declare (type measurement-class c) (type fixnum d)) (setf (aref reslt index 0) c (aref reslt index 1) d))))) (unit-of (expr index) (declare (type (simple-array t (* 2)) expr)) (aref expr index 0)) (map-units (expr) (declare (type (simple-array t (* 2)) expr)) (let* ((n (array-dimension expr 0)) (buffer (make-buffer n 'measurement-class))) (dotimes (index n buffer) (let ((elt (unit-of expr index))) (declare (type measurement-class elt)) (setf (aref buffer index) elt))))) (degree-of (expr index) (declare (type (simple-array t (* 2)) expr)) (aref expr index 1)) (map-degrees (expr) (declare (type (simple-array t (* 2)) expr)) (let* ((n (array-dimension expr 0)) (buffer (make-buffer n 'fixnum))) (dotimes (index n buffer) (let ((elt (degree-of expr index))) (declare (type fixnum elt)) (setf (aref buffer index) elt)))))) (let ((nex (normalize expression))) (setq args-changed-p t) (setf (getf initargs :normalized-expression) nex (getf initargs :unit-sequence) (map-units nex) (getf initargs :degree-sequence) (map-degrees nex))))) (cond (args-changed-p (apply #'call-next-method instance slots initargs)) (t (call-next-method))))) ;; To Do: Develop prototypes for SIMPLIFY-UNIT / NORMALIZE-UNIT ;; with 'Newton' and 'N s' (momentum) as examples #+PROTOTYPE (defclass force (derived-measurement-class compound-measurement-class) () (:print-name . "force") (:print-label . "force") (:symbol . :force) (:metaclass measurement-domain) (:base-measure . newton)) #+PROTOTYPE (register-measurement-domain 'force) #+PROTOTYPE (defclass newton (measurement) () (:print-name . "newton") (:print-label . "N") (:symbol . :|N|) (:metaclass compound-measurement-class ;; FIXME: is not 'force' ) (:expression :|m| :|kg| (:|s| -2))) #+NIL ;; instance test (measurement-domain-base-measure (find-class 'force)) ;; => #<COMPOUND-MEASUREMENT-CLASS NEWTON> #+PROTOTYPE (register-measurement-class 'newton) #+PROTOTYPE (resister-compound-measurement-class 'newton) ;; (measurement-unit-sequence (find-class 'newton)) ;; => #(#<LENGTH METER> #<MASS KILOGRAM> #<TIME SECOND>) ;; (measurement-degree-sequence (find-class 'newton)) ;; => #(1 1 -2) ;; (measurement-normalized-expression (find-class 'newton)) ;; => #2A((#<LENGTH METER> 1) (#<MASS KILOGRAM> 1) (#<TIME SECOND> -2)) (defclass compound-unit-expr (unit-expr) ((elements :initarg :elements :accessor unit-expr-elements :type (simple-array t (* 2))))) ;; NORMALIZE-UNIT - Prototype (defun normalize-unit-expression (&rest exprs) (declare (values (simple-array t (* 2)))) (let* ((%exprs (coerce exprs 'simple-vector)) (n (length %exprs)) (buffer (make-array n :fill-pointer 0))) (declare (type simple-vector %exprs)) (dotimes (index n (make-array (list (length buffer) 2) :initial-contents buffer)) (let* ((elt (aref %exprs index)) (s (etypecase elt (symbol elt) (cons (car elt)))) (c (find-measurement-class s)) (d (etypecase elt (symbol 1) (cons (cadr elt))))) (declare (type measurement-class c) (type fixnum d)) (labels ((find-elt (s buffer) (do-vector (elt buffer (values nil nil)) (let ((elt-s (aref elt 0))) (when (eq s elt-s) (return (values (aref elt 1) elt)))))) (ensure-elt (c d buffer) (let ((s (measurement-symbol c))) (multiple-value-bind (%d elt) (find-elt s buffer) (cond (%d (setf (aref elt 1) (+ %d d))) (t (vector-push-extend (vector s d) buffer))))))) (etypecase c (base-measurement-class (ensure-elt c d buffer)) (linear-measurement-class ;; FIXME: To convert to base units from a non-base linear ;; measurement class will require a measurement conversion, ;; such that a measurement value must be available. ;; ;; Note that this would apply to all non-base measurements, ;; though it's rather kludged for now. (warn "Not converting non-base linear measurement ~A" c) (ensure-elt c d buffer)) (geometric-measurement-class (let ((%d (measurement-degree c))) (ensure-elt c (* d %d) buffer))) (compound-measurement-class (let ((nex (measurement-normalized-expression c))) (dotimes (%index (array-dimension nex 0)) (let ((%c (aref nex %index 0)) (%d (* d (aref nex %index 1)))) (ensure-elt %c %d buffer))))))))))) ;; NORMALIZE-UNIT / SIMPLIFY-UNIT - Usage cases ;; Prototype: Newtonian force / Weight / Acceleration due to gravity (Units) ;; ;; (normalize-unit-expression :|N|) ;; => #2A((:|m| 1) (:|kg| 1) (:|s| -2)) ;; ;; (normalize-unit-expression :|m| :|kg| '(:|s| -2)) ;; => #2A((:|m| 1) (:|kg| 1) (:|s| -2)) ;; ;; (normalize-unit-expression '(:|N| 2)) ;; => #2A((:|m| 2) (:|kg| 2) (:|s| -4)) ;; (FIXME: Verify) ;; (simplify-unit-expression :|m| :|kg| '(:|s| -2)) ;; Prototype: Momentum (Units) ;; ;; (normalize-unit-expression :|N| :|s|) ;; =initially=> #2A((:|m| 1) (:|kg| 1) (:|s| -2) (:|s| 1)) ;; =revised=> #2A((:|m| 1) (:|kg| 1) (:|s| -1)) ;; ;; (simplify-unit :|m| :|kg| (:|s| -2) :|s|) ;; (simplify-unit :|kg| :|m| (:|s| -1))
10,869
Common Lisp
.lisp
241
33.6639
76
0.561413
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a67cb75ed120fe926fa8c32d8d2dab80a2015557c2c74867accc2d4338733282
24,831
[ -1 ]
24,832
dimensionless.lisp
MetaCommunity_igneous-math/src/main/cltl/measure/derived/dimensionless.lisp
;; dimensionless.lisp - standard dimensionless measurements (in-package #:math) ;; % Class for Dimensionless Measurement Domains (defclass dimensionless-measurement-domain (measurement-domain) ;; FIXME: For formulas resulting in dimensionless measurements, it ;; may be possible to define a method to provide 'advice' for the ;; measurement being sought (?) ;; ;; Perhaps it may simply be accepted that the semantics of a ;; dimensionless measurement must be provided in documentation ;; seperate to any programmed expression of the measurement ()) ;;; % Angular Measure (defclass plane-angle (measurement-class) () (:metaclass dimensionless-measurement-domain) ;; FIXME: #I18N (:print-name . "angular measure") (:print-label . "angular measure") (:symbol . :plane-angle) (:base-measure . radian)) (register-measurement-domain (find-class 'plane-angle)) (defclass radian (measurement) ;; FIXME: Define as COMPOUND-MEASUREMENT-CLASS with units m m^-1 (?) ;; FIXME: Define corresponding STERADIAN class in measurement domain ;; SOLID-ANGLE (units m^2 m^-2 ?) () (:metaclass plane-angle) (:print-name . "radian") (:print-label . "rad") (:symbol . :|rad|)) (register-measurement-class (find-class 'radian)) ;; (object-print-name (measurement-domain-base-measure (find-class 'plane-angle))) ;; => "radian" (defclass degree (measurement) () (:metaclass plane-angle) (:base-factor . #.(/ (rational pi) 180) ) (:print-name . "degree") (:print-label . "deg") (:symbol . :|deg|)) (register-measurement-class (find-class 'degree)) ;; (scalar-magnitude (convert-measurement (make-measurement (rational pi) :|rad|) :|deg|)) ;; => 180 ;;; % Dimensionless Measure (Generic) (defclass dimensionless-measure (measurement-class) ;; FIXME: Consider undefining this class. It should be possible to ;; define any effectively dimensionless measure (e.g. for index of ;; refraction, per "Snell's Law") in terms of base units from which ;; it may be derived (e.g m s^-2 m^-1 s^2) () (:documentation "Informal domain for dimensionless measures") (:metaclass dimensionless-measurement-domain) ;; FIXME: #I18N (:print-name . "dimensionless measure") (:print-label . "dimensionless measure") (:symbol . :dimensionless-measure) (:base-measure . unity)) (register-measurement-domain (find-class 'dimensionless-measure)) (defclass unity (measurement) () (:documentation "Informal base measure of dimensionless measures") (:metaclass dimensionless-measure) ;; FIXME: Specialize print-object so as to not print the measurement ;; label for any instance of a DIMENSIONLESS-MEASURE class, ;; excepting those defined with conventional masurement labels (:print-name . "unity") (:print-label . "u") #+PROTOTYPE-M (:disable-print-label t) (:symbol . :|u|)) (register-measurement-class (find-class 'unity))
2,887
Common Lisp
.lisp
71
37.985915
90
0.727045
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a790b9b323ae9ef12c0bdffa04b2fc038f7c09cd7d018108cb089b505e0b648f
24,832
[ -1 ]
24,833
info.metacommunity.cltl.math.test.asd
MetaCommunity_igneous-math/src/test/cltl/info.metacommunity.cltl.math.test.asd
;; info.metacommunity.cltl.math.test.asd - math system tests -*- lisp -*- (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:math-system (:use #:asdf #:cl))) (in-package #:math-system) (defsystem #:info.metacommunity.cltl.math.test :depends-on (#:info.metacommunity.cltl.math #:info.metacommunity.cltl.test #:info.metacommunity.cltl.utils ) :components ((:file "math-test-package") (:file "measure-test" :depends-on ("math-test-package")) ))
528
Common Lisp
.asd
17
27.470588
74
0.684418
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
c5c10a7e68569658e142f1f7ac89c61a50e5214e6cc9c4bfdb6e92bbf9c22566
24,833
[ -1 ]
24,834
info.metacommunity.cltl.math.asd
MetaCommunity_igneous-math/src/main/cltl/info.metacommunity.cltl.math.asd
;; info.metacommunity.cltl.math.asd -*-lisp-*- (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:math-system (:use #:asdf #:cl))) (in-package #:math-system) #| Effective version history: 1.0: Initial prototype 1.1: Decimal scaling introduced 1.2: DEFOP defined with MOP extension 1.3: Definition of unit conversion formulas |# (defsystem #:info.metacommunity.cltl.math :description "A Mathematical Object System in Common Lisp" :version "1.3.2" :homepage "https://github.com/MetaCommunity/igneous-math" :license "https://github.com/MetaCommunity/igneous-math/blob/master/LICENSE" :depends-on (#:info.metacommunity.cltl.utils #:closer-mop #:bordeaux-threads #:info.metacommunity.cltl.utils.mop ) ;; :serial t :components ((:file "math-package") (:file "math-system-utils" :depends-on ("math-package")) (:file "defclass-star" ;; FIXME: move into .utils system :depends-on ("math-package")) (:file "monotonic-genf" ;; FIXME: move into .utils system :depends-on ("math-package")) (:file "math-ov" ;; NB: This file is essentially orthogonal to the ;; measurements subsystem :depends-on ("monotonic-genf" "math-package")) (:module "measure" :depends-on ("math-package" "defclass-star" "math-system-utils") :components ((:file "domain") (:file "decimal-scale") (:file "measurement-base" ;; :subsystem measure :depends-on ("domain" "decimal-scale" )) (:module "derived" :depends-on ("measurement-base") :components ((:file "linear-measure") (:file "geom-measure") (:file "compound-measure" :depends-on ("linear-measure" "geom-measure" )) (:file "dimensionless") (:file "derived-length"))) (:file "prefix" ;; :subsystem measure ;; nb. The prefix system is essentially orthogonal to MAKE-MEASUREMENT :depends-on ("measurement-base" )) (:file "mconv" :depends-on ("prefix" "measurement-base" "domain")) )) (:file "measure/measurement-ov" ;; measurements + math :depends-on ("measure" "math-ov")) (:file "geometry" :depends-on ("measure")) (:file "linear" :depends-on ("math-package")) ))
2,951
Common Lisp
.asd
82
23.670732
90
0.511307
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
462a5773d22c1f7b2274d988c6d81fa204460e0476f62605b0fd3ad2a0fca44d
24,834
[ -1 ]
24,846
floating-point-notes.diff
MetaCommunity_igneous-math/src/main/cltl/floating-point-notes.diff
diff --git a/src/main/cltl/decimal-scale.lisp b/src/main/cltl/decimal-scale.lisp index ad6727a..5936c7c 100644 --- a/src/main/cltl/decimal-scale.lisp +++ b/src/main/cltl/decimal-scale.lisp @@ -2,7 +2,29 @@ (in-package #:math) +#| + + (defun total-integer-part-digits (n) + (1+ (truncate (log n 10)))) + + (total-integer-part-digits 1020.1) + ;; => 4 + + (total-integer-part-digits 102.1) + ;; => 3 + +|# + (defun integer-shift-digits (d) + "Perform a decimal shift of D to the minimum significant digits of D, returning the scale and the shifted magnitude + +Example: + + (multiple-value-bind (scale magnitude) + (integer-shift-digits 1020) + (= (* magnitude (expt 10 scale)) 1020)) + => T +" (declare (type integer d) (values fixnum integer)) (cond @@ -40,28 +62,30 @@ ;; (frob-test 0) ;; => 0, 0, T ) - + + +;; FIXME: The syntax of INTEGER-SHIFT-DIGITS and FLOAT-SHIFT-DIGITS +;; is counterintuitive, namely in the ordering of the return values. +;; Both should => MAGNITUDE, SCALE (defun float-shift-digits (d) -"A floating point value, `d`, with a known number of significant -decimal digits, `n`, may be represented as a sequence of values -`(a, n)` for `a = d * 10^n`. +"A floating point value, `d`, with a known number of significant decimal digits, `n`, may be represented as a sequence of rational values + `(a, n)` for `a = d * 10^n`. - For example, with d=3.14, n=-2, d=314 +For example, with d=3.14, then n=-2, d=314 -For rhetorical purposes, `a` would be denoted as the _magnitude_ of -`d`, and `n` denoted as the _scale_ of `d`. +For rhetorical purposes, `a` may be denoted as the magnitude of +`d`, and `n` denoted as the scale of `d`. -When `n` is known, calculations evaluated on `d`, may instead be -evaluated on `(a, n)` -- `a` and `n` both being integer type -values. In implementing mathematical operations with this manner of -decimal scaling, it may serve to avoid floating point errors, in some -instances. +When `n` is known, then calculations evaluated on `d`, may instead be +evaluated on `(a, n)`, with `a` and `n` both being of type, rational. +In implementations of mathematical operations with this manner of +decimal scaling, it may serve to avoid some floating point errors, in +some implementations -- moreover, allowing for an implementation of +strictly rational calculations for mathematical operations. This funcdtion implements a calculation similar to a base-10 -calculation of the significand and exponent of `d`. However, this -function calculates the significant digits only in the decimal -portion of `d'" +calculation of the significand and exponent of `d`." (declare (type (or integer float) d) (values fixnum integer)) (let ((b d) @@ -124,9 +148,16 @@ portion of `d'" ;; (float-shift-digits 12.1) ;; => -1, 121 ;; -;; + +;; (float-shift-digits 120.1) +;; => -1, 1201 + ;; (float-shift-digits pi) ;; => -15, 3141592653589793 +;; ^ not all the same as (RATIONALIZE PI) + +;; (float-shift-digits 12000) +;; => 3, 12 ;; n.b: ;; (* 10 314.1592653589793d0) @@ -146,23 +177,25 @@ portion of `d'" ;; 0, 11 -;; n.b !!!! +;; n.b ;; (* 10 4.159265358979312d0) ;; => 41.592653589793116d0 ;; -;; so, until some further error filtering, there was an +;; thus, towards numerical filtering, i.e. float-to-rational conversion +;; ;; (float-shift-digits 4.159265358979312d0) ;; => -15, 4159265358979312 -;; previously => -15, 4159265358979311 +;; previously, without the filtering, would => -15, 4159265358979311 ;; -;; noticing: +;; for example: ;; (truncate (* 4.159265358979312d0 (expt 10 15))) ;; 4159265358979311, 0.5d0 ;; ^ thus the additional filtering is defined -;; (truncate (* 1.201 (expt 10 3))) +;; (float-shift-digits (rationalize 4.159265358979312d0)) +;; ^ N/A (FIXME) -;; sidebar: sb-impl::make-float +;; ... ;; (defstruct (decimal ;; (:constructor %make-decimal (magnitude scale))) @@ -189,9 +222,6 @@ portion of `d'" ;; => T -;; (float-shift-digits 12000) -;; => 3, 12 - (defun make-measurement (magnitude unit &optional (degree 0)) "Crate a MEAUREMENT object of the specified MAGNITUDE of a decimal scale denoted by DEGREE, representing a scalar measurement of
4,313
Common Lisp
.l
125
32.096
138
0.677008
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
443e3b94f8d82180d04a7363720f4096522a77bad27de2f930f090256d937afa
24,846
[ -1 ]
24,868
igm-guide.xml
MetaCommunity_igneous-math/doc/igm-guide.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE book [ <!ENTITY mdash "&#x2014;" > <!-- project metadata --> <!ENTITY project "<productname>Igneous Math</productname>" > <!ENTITY project.id "igm" > <!-- terms --> <!ENTITY cltl "<productname><acronym>ANSI</acronym> Common Lisp</productname>" > <!ENTITY asdf "<productname>ASDF</productname>" > <!-- terms --> <!ENTITY Ig1m "<productname>Ig<subscript>1</subscript><superscript>m</superscript></productname>" > <!ENTITY Ig2m "<productname>Ig<subscript>2</subscript><superscript>m</superscript></productname>" > <!ENTITY clim "<productname><acronym>CLIM</acronym></productname>" > <!ENTITY mcclim "<productname><acronym>McCLIM</acronym></productname>" > <!ENTITY clos "<productname><acronym>CLOS</acronym></productname>" > <!ENTITY mop "<productname><acronym>MOP</acronym></productname>" > ]> <book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="&project.id;.guide" version="5.0-extension metacommunity-1.0" > <info> <title>&project; &mdash; Guide</title> <author> <personname>Sean Champ</personname> </author> <pubdate>24 Dec 2014</pubdate> <revhistory> <revision> <date>24 Dec 2014</date> <revdescription> <formalpara> <title>Summary</title> <para> <simplelist> <member>Initial revision</member> <member> Comments (appendix) about design model applied in &project; &mdash; <glossterm>sprints</glossterm> as <foreignphrase>viz a viz</foreignphrase> <glossterm>scrum</glossterm> </member> <member> Comments about code alignment in &Ig1m;, &Ig2m; </member> <member> Comments about distinction of concepts of <emphasis>measurement numeric value</emphasis> and <emphasis>measurement magnitude, measurement degree</emphasis> </member> </simplelist> </para> </formalpara> </revdescription> </revision> </revhistory> </info> <preface xml:id="&project.id;.guide.ov"> <title>Overview</title> <remark>TBD - Develop a singular overview about this multi-module system. &project; is not formally a CAS, at &Ig2m;, but provides a small set of elementary <glossterm>modules</glossterm> ... etc.</remark> </preface> <appendix> <title>Software Design Model</title> <para> &project; is developed essentially in an <glossterm>agile</glossterm> model. At &Ig2m;, &project; has not adopted any formal <glossterm>process model</glossterm> for development<remark> <footnote> <para>and well, the &project; project does not have a large development team, at this revision</para> </footnote></remark>. In a broad sense, the development model &mdash; as developed, reflectively, in the development of &project; &mdash; may largely resemble a <productname>Scrum</productname> development model, if any other generic <productname>agile</productname> model. </para> <para> Similar to <productname>Scrum</productname>, &project; is developed in each of a momentary <glossterm>sprint</glossterm>. Unlike <productname>Scrum</productname>, however, the <glossterm>sprint</glossterm> duration is not preceded with any manner of a <emphasis>planning session</emphasis>, and is not followed with any manner of formal <glossterm>review</glossterm>, excepting &mdash; in the latter regards &mdash; a manner of a practical <emphasis>review by application</emphasis><remark> <footnote> <para> i.e. a certain manner of a <foreignphrase>Trial by Fire</foreignphrase> approach to <glossterm>bug hunting</glossterm> and <glossterm>design review</glossterm>, in software development. </para> </footnote> </remark>. Certainly, the <foreignphrase>ad hoc</foreignphrase> <glossterm>agile</glossterm> methodology developed in &project; may not be suitable for <emphasis>large scale</emphasis> projects. However, it appears to be sufficient for a manner of <emphasis>small scale</emphasis>, <glossterm>modular development</glossterm>, even at a <emphasis>scale</emphasis> of a <glossterm>developer team</glossterm> comprised essentially of an individual <glossterm>developer</glossterm>. </para> <section> <title>"Lessons from Camptown" &mdash; Concerning Alignment Between Design and Application in a Sprint-Oriented Development Model</title> <para>The &project; was begun essentially as a prototype for a system for mathematical computations. As a summary of the first set of goals addressed in the &project; project: The primary goal was to develop an <glossterm>object system</glossterm> for <glossterm>measurement</glossterm> values, in a model for <glossterm>dispatched</glossterm> application of <glossterm>monadic</glossterm>, <glossterm>diadic</glossterm>, and <glossterm>variadic</glossterm> mathematical <glossterm>operations</glossterm> &mdash; the latter, esentially as to extend of <glossterm>functions</glossterm> implemented for mathematical <glossterm>operations</glossterm> in &cltl;. </para> <para>As secondary goals, it was estimated that a graphical <glossterm>presentation</glossterm> model may be developed for such an <glossterm>object system</glossterm> as would be addressed in the previous goals. It was esimated that such a graphical <glossterm>presentation</glossterm> model may be developed specifically onto &clim;. By extension, it was a secondary goal: To develop a graphical model for <glossterm>phasor</glossterm> analysis and other <glossterm>signal domain</glossterm> analysis, such that could be applied &mdash; specifically &mdash; in an endeavor to clarify some concepts as with regards to qualities of <glossterm>electrodynamically reactive</glossterm> electrical circuit elements and their applications within circuits of <glossterm>alternating current</glossterm>. In this set of those goals, perhaps that much of the design of &project; may be subsequently revised as towards applications of technologies for <glossterm>pulse width modulation</glossterm> within <glossterm>digital signaling</glossterm> systems. Concerning a question of the essential <glossterm>geometry</glossterm> of <glossterm>electrodynamically reactive</glossterm> circuits within <glossterm>alternating current</glossterm> systems &mdash; perhaps that may remain to be addressed, as towards an application of this system, extensionally, for <glossterm>modeling</glossterm> of <glossterm>numeric systems</glossterm> in relation to <glossterm>components</glossterm> of <glossterm>electrical systems</glossterm>, as for purposes of electronic design and electrical system diagnostics. </para> <para> That secondary set of goals would prove to be largely orthogonal to the primary set of goals, as addressed in the development of the &project; <glossterm>codebase</glossterm>. </para> <section> <title>The First Sprints: &Ig1m;</title> <para> It might be estimated: That there cannot be a work developed of the sciences, except that it would be a work developed in extension of <emphasis>existing work</emphasis>, insofar as of theories and practices developed in domains of scientific discourse and the practical applications of scientific theory.<remark> <footnote> <para> This comment, itself, perhaps extends of Isaac Newton's original juxtaposition of <glossterm>geometry</glossterm> and <glossterm>mechanics</glossterm> &mdash; broadly, towards a contrast of <emphasis>ideal systems</emphasis> and <emphasis>material systems</emphasis>, in science and engineering. </para> </footnote></remark>. Likewise, the design of &project; was begun after a review of <emphasis>existing work</emphasis>, namely as with regards to repersentations of meaurement values within computational systems. This article will avoid any lengthy historic dissertation about the development of <productname><acronym>XML</acronym></productname> and its origins in <productname><acronym>SGML</acronym></productname>. Specifically as with regards to <productname><acronym>SGML</acronym></productname>, <remark>...</remark> <productname>HyTime</productname> <remark>Hypermedia - orthogonal to this article, relevant to the McCLIM fork, and not exclusively represented with MathML.</remark> <remark>(Existing work, in information sciences)</remark> <remark>(See also: SWEET Ontologies)</remark> </para> <para> <remark>Also a part of the existing work, namely in the domain of the material sciences: The BIPM's documentation about the SI system, itself, and that from the NIST.</remark> </para> <para> <remark>Existing work, in Common Lisp: {rmarren}'s <productname>Unit-Formula</productname> and the study referenced from the same &mdash; see also, bibliography &amp; bibliography tools...</remark> </para> <para> Subsequent to a review of <emphasis>existing work</emphasis> &mdash; insofar as noted, in this article, as with regards to systems of measurements, orthogonal to a system of vector mathematics &mdash; a number of corresponding <glossterm>object models</glossterm> were designed during the changesets now comprising &Ig1m;: <simplelist> <member>Measurement Domain</member> <member>Measurement Class</member> <member>Numeric Prefix Objects for Annotation of Measurement Values</member> </simplelist> </para> <sidebar> <para> Concerning any details of the design of that three-part object model for measurement systems in &project;, and its interfaces for application within extensional systems, the reader would kindly be referred to the source code of &project; &mdash; this <emphasis>guide</emphasis> book, itself, being presently in absence of any specific documentation for application of those object models. Certainly, those are documented thoroughly, in the project's source code. </para> <remark> This manual should be updated subsequently, to describe those object models as in a manner sufficient for their application. Also, there would be the revisions to be developed in &Ig2m;, as with regards to a <glossterm>reader</glossterm> <glossterm>syntax</glossterm> for input of numeric measurement values, etc. </remark> </sidebar> <para> Parallel to the development of the <glossterm>measurement</glossterm> model, during the development of &Ig1m;, an <glossterm>object model</glossterm> was defined also for definition and application of <glossterm>monadic</glossterm>, <glossterm>diadic</glossterm>, and <glossterm>variadic</glossterm> mathematical <glossterm>operations</glossterm>. That <glossterm>object model</glossterm> was defined as an extension of the <productname>Common Lisp Object System</productname> (&clos;) &mdash; insofas as the latter is standardized in &cltl; and may be extended in applciations of &clos; via the <productname>MetaObject Protocol</productname> (&mop;). The components of &Ig1m; as extending of &mop;, likewise extend of the &mop; <glossterm>model</glossterm> for implementation of <glossterm>funcallable</glossterm> <glossterm>standard objects</glossterm>. Essentially, this component of the &project; <glossterm>codebase</glossterm> implements a unique set of <glossterm>classes</glossterm> of &clos; <glossterm>method</glossterm> and <glossterm>generic function</glossterm> <glossterm>objects</glossterm>, such that the <glossterm>method</glossterm> <glossterm>dispatching</glossterm> within the latter is not a standard <glossterm>method</glossterm> <glossterm>dispatching</glossterm>. <remark>This componenent of &Ig1m; may be subject to some further revision. At the time of the writing of this remark, development of &Ig1m; is focusing primarily about refactoring of the <glossterm>measurement</glossterm> <glossterm>object model</glossterm>.</remark> </para> <para> As well as the development of those discrete <glossterm>object models</glossterm>, some simpler prototypes were created within the &project; codebase, during &Ig1m; development. Specifically, there was a prototype created &mdash; albeit, a trivial prototype &mdash; towards a development of a &clim; <glossterm>presentation model</glossterm> for <glossterm>objects</glossterm> of a system for <glossterm>linear mathematics</glossterm>, beginning namely at the <glossterm>presentation</glossterm> of a <glossterm>two dimensional</glossterm> <glossterm>matrix</glossterm> <glossterm>object</glossterm> onto a &clim; <glossterm>application pane</glossterm>. </para> <para> Fourthly, some intial prototypes were created for a definition of a formal <glossterm>object model</glossterm> for <glossterm>scalar</glossterm> and <glossterm>vector</glossterm> <glossterm>objects</glossterm> &mdash; pending revision, in extension of the mathematical <glossterm>operations</glossterm> <glossterm>object model</glossterm> defined originally in &Ig1m;. </para> <para> Lasly, &Ig1m; saw the development of a system for <glossterm>rational</glossterm> <glossterm>scaling</glossterm> of <glossterm>decimal</glossterm> <glossterm>numeric</glossterm> <glossterm>values</glossterm>. The implementaiton of this feature might corresponds conveniently with the system for <glossterm>measurement</glossterm> <glossterm>objects</glossterm>, as also begun in &Ig1m; </para> </section> <section> <title>Refactoring in &Ig2m;</title> <section> <title>Refactoring of the &Ig1m; Measurement Object Model</title> <remark>&Ig1m; - measurement domains; base measurement units; fundamental measurement units; linear measurement units</remark> <remark>&Ig2m; - derived measurement units; measurement units describing geometric qualities; measurement unit conversion</remark> <remark>Furthermore, &Ig2m; has seen the emergence of a concern with regards to <emphasis>code alignment</emphasis> and <emphasis>design alignment</emphasis> &mdash; thus, to the primary thesis orignally denoted of this article. Simply, it is the author's observation: That across the many <glossterm>sprints</glossterm> ultimately comprising the set of <glossterm>changesets</glossterm> developed in &Ig1m;, the <emphasis>system as developed</emphasis> became, in some ways, <glossterm>ambiguous</glossterm> within itself &mdash; furthermore, <glossterm>misaligned</glossterm>, within its own codebase. At this time, it appears that the primary concerns of that <glossterm>misalignment</glossterm> may be denoted as as with regards to: Concepts of function naming, function application, functional behaviors, and intended application. Insofar as the process of the discovery of this concern, it would also serve to denote an orthogonoal concern, as with regards to functional testing.</remark> </section> <section> <title>Design for Application of the revised &Ig2m; Measurement Object Model, in Extension of the &Ig1m; Object Model for Mathematical Applications</title> <remark>This may proceed not until after the program elements denoted in the previous section may be refactored to any condition of complete normalcy.</remark> </section> <section> <title>Development of the &Ig1m; Prototypes for Scalar and Vector Objects</title> <remark>There is some ambiguity with regards to the classes <classname>measurement</classname> and <classname>scalar</classname>, as towards a question of how the class <classname>scalar</classname> would finally be defined. Otherwise, this may be developed as towards a definition of a system for applications in linear mathematics. Infoar as the <classname>measurement</classname>/<classname>scalar</classname> ambiguity, that could possibly be revised with a definition of <classname>scalar</classname> as a <glossterm>container</glossterm> for a <glossterm>numeric value</glossterm>, but again there is the question of how the classes of <glossterm>numeric value</glossterm> would be defined or provided with an <glossterm>interface</glossterm> for mathematical procedures. Considering that a &cltl; implementation may provide a number of optimizations for mathematical functions, but that those optimizations would be contingent on whether the <glossterm>compiler</glossterm> would be able to determine an existing numeric type for the parameters to any single, optimized mathematical operation: It would be desirable to ensure that any application of the <classname>scalar</classname> class would not serve as to <emphasis>loose information</emphasis> with regards to the numeric type of any numeric value contained by a <classname>scalar</classname> <glossterm>object</glossterm>. Not insomuch a mere excerise in tedious application design, such considerations might serve towards an optimization of program systems, whether or not of any program systems that would require that procedures complete within a model of determinisic timing, even insofar as in mathematical operations within the Common Lisp programming environment. </remark> </section> </section> <!-- <section> --> <!-- <title>Further --> </section> </appendix> </book>
20,107
Common Lisp
.l
421
38.263658
84
0.664878
MetaCommunity/igneous-math
1
0
0
EPL-1.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
4857c85dd1054d1567d730bb32d10298c6a21e826e238ae65c9c1261f0d60804
24,868
[ -1 ]
24,883
build-with-ecl.lisp
csvitlik_build-with-ecl/build-with-ecl.lisp
(require 'cmp) (declaim (optimize (debug 0) (safety 0) (speed 3) (space 3))) (setq ext:*help-message* " build-with-ecl [--help | -?] out-filename Build a standalone executable using Embeddable Common-Lisp. If the name of the program you want to build is \"ls.lisp\", you would build it like this: $ build-with-ecl ls ") (defun build-program-wrapper (in-lisp in-o out) (compile-file in-lisp :system-p t) (c:build-program out :lisp-files in-o)) (defun main (args) (let ((in-file (first args))) (if (equalp in-file "-load") (setf in-file "build-with-ecl")) (let ((in-lisp (concatenate 'string in-file ".lisp")) (in-o (concatenate 'string in-file ".o")) (out in-file)) (build-program-wrapper in-lisp (list in-o) out)))) (defun usage (rc) (progn (princ ext:*help-message* *standard-output*) (ext:quit rc))) (defconstant +build-with-ecl-rules+ '(("--help" 0 (usage 0)) ("-h" 0 (usage 0)) ("-?" 0 (usage 0)) ("*DEFAULT*" 1 (main 1) :stop))) (let ((ext:*lisp-init-file-list* NIL)) ; No initialization files (handler-case (ext:process-command-args :rules +build-with-ecl-rules+) (error (c) (usage 1)))) (ext:quit 0)
1,212
Common Lisp
.lisp
33
32.545455
72
0.63613
csvitlik/build-with-ecl
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
7b521d7d6c3e9ca2c53cc1c6d2b3a1e1f3581f190f7cb5eac8657e14c0067336
24,883
[ -1 ]
24,884
test.lisp
csvitlik_build-with-ecl/test.lisp
(declaim (optimize (debug 0) (safety 0) (speed 3) (space 3))) (defun main () (princ "Hello, world! ")) (main) (ext:quit 0)
126
Common Lisp
.lisp
5
23.6
61
0.644068
csvitlik/build-with-ecl
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
cfc0ae5df9e6e269ca665cf9923d518f5c00821984059e1b73f2420c674f61c0
24,884
[ -1 ]
24,903
typechecker.lisp
jrharbin_cl-ocaml/typechecker.lisp
;; Basics of type handling in types.lisp (defun unify-types (constraints t1 t2) "Unify two types") (defun unify-expr "Unify two expressions" ())
158
Common Lisp
.lisp
6
23.166667
40
0.718121
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
795a69d402b377ce5f11e355e99392a0c9a87cb493893fb728eac1ac8769431b
24,903
[ -1 ]
24,904
parse-helpers.lisp
jrharbin_cl-ocaml/parse-helpers.lisp
(defun expr-list-p (l) (every #'(lambda (x) (typep x 'expr)) l)) (deftype expr-list () '(satisfies expr-list-p)) (defstruct expr (tag :E_Unit :type (member :E_Unit :E_Int :E_Float :E_Ident :E_Binop :E_Seq :E_Letbind :E_Letbind_in :E_Apply :E_Fun)) val (sub-exprs () :type list)) (defun mk-expr (&key tag val sub-exprs) "Expression maker which verifies the type" (check-type sub-exprs expr-list) (make-expr :tag tag :val val :sub-exprs sub-exprs)) (defun mk-parens (lp e rp) (declare (ignore lp rp)) e) (defun mk-int (i) (mk-expr :tag :E_Int :val i)) (defun mk-float (f) (mk-expr :tag :E_Float :val f)) (defun mk-ident (id) (mk-expr :tag :E_Ident :val id)) (defun mk-binop (e1 binop e2) (mk-expr :tag :E_Binop :val binop :sub-exprs (list e1 e2))) (defun mk-expr-seq (e1 s e2) (declare (ignore s)) (mk-expr :tag :E_Seq :val nil :sub-exprs (list e1 e2))) (defun mk-letbind (l id eq_ expr) (declare (ignore l eq_)) (mk-expr :tag :E_Letbind :val id :sub-exprs (list expr))) (defun mk-letbind-in (l id eq_ e1 in_ e2) (declare (ignore l eq_ in_)) (mk-expr :tag :E_Letbind_in :val id :sub-exprs (list e1 e2))) (defun mk-apply (e1 e2) (mk-expr :tag :E_Apply :val nil :sub-exprs (list e1 e2))) (defun mk-fun (fun id arrow_ e) (declare (ignore fun arrow_)) (mk-expr :tag :E_Fun :val id :sub-exprs (list e)))
1,419
Common Lisp
.lisp
45
27.822222
64
0.624082
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
435c843458ac5aa1efba552fb6d42b26883daf0fa7e4ec5c6e95121bab1b5788
24,904
[ -1 ]
24,905
test-parsing.lisp
jrharbin_cl-ocaml/test-parsing.lisp
(defparameter *parsing-test-expressions* '("1" "1+2" "(1+2)" "1;2;3" "1/.5" "fun x -> 1 + x" "let y = 3" "let square = fun x -> x * x" "(fun x -> x * x) 2")) (defun test-parsing-expressions () (mapcar (lambda (str) (format t "Expression = ~A: " str) (print (test-parse str)) (terpri)) *parsing-test-expressions*)) (test-parsing-expressions)
400
Common Lisp
.lisp
17
19.058824
41
0.546174
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
a25d409fd317ebe1fff76c5bccacd2a29c3369e4099090e95d8a0b5d28d07e8a
24,905
[ -1 ]
24,906
repl.lisp
jrharbin_cl-ocaml/repl.lisp
;; Needed processing sequence from string input: ;; Lexing/parsing of input into parse tree representation ;; Conversion to a typed tree representation ;; Unification of expression with known types ;; Handle conditions for errors in any of these ;; Backend(s): for now, 1) compile to CL code ;; 2) something more exciting (defun repl-on-streams (stdin stdout) (let ((continue t) (show-parse-tree t) (prompt "cl-ocaml REPL")) (loop while continue do (format stdout "~A>" prompt) (let1 str (read-line stdin) (cond ((equalp str "#exit") (setf continue nil)) (t (if show-parse-tree (print (test-parse str)))))) (terpri)))) (defun repl () (repl-on-streams *standard-input* *standard-output*))
760
Common Lisp
.lisp
20
34.45
57
0.67663
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
cb8e288c9f09df01f7007e45390d8fe43ceb7e123dab6a80c05f7046dd0d3448
24,906
[ -1 ]
24,907
types.lisp
jrharbin_cl-ocaml/types.lisp
;; Determine a type representation: location, level ;; Exceptions for unification failure (defclass type-info () ()) ;; Need the following - Look at Caml light for simplest implementation ;; Find the free type variables in a type ;; Generalise a type ;; Occurs checks - does a variable occur in a type? ;; Unification of two types ;; Lower the level of all generalisable vars in a type - what does this mean?
417
Common Lisp
.lisp
10
40
77
0.761194
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
dc644f885a52e9d1ce509d696888966f05869e38ac8db68fd16fb67cb2bd656f
24,907
[ -1 ]
24,908
lexing.lisp
jrharbin_cl-ocaml/lexing.lisp
(defparameter *str-keywords* (make-hash-table :test 'equal)) (defparameter *str-tokfuncs* (make-hash-table :test 'equal)) (defun add-to-hash (ht l) "Adds the given list l to the hashtable. Elements should be a 2-element list of string and result" (mapcar (lambda (tokstr-pair) (setf (gethash (car tokstr-pair) ht) (cadr tokstr-pair))) l)) (defun setup-keywords () "Initialises the global keyword hashtable" (add-to-hash *str-keywords* '(("and" AND) ("as" AS) ("assert" ASSERT) ("begin" BEGIN) ("class" CLASS) ("constraint" CONSTRAINT) ("do" DO) ("done" DONE) ("downto" DOWNTO) ("else" ELSE) ("end" END) ("exception" EXCEPTION) ("external" EXTERNAL) ("false" FALSE) ("for" FOR) ("fun" FUN) ("function" FUNCTION) ("functor" FUNCTOR) ("if" IF) ("in" IN) ("include" INCLUDE) ("inherit" INHERIT) ("initializer" INITIALIZER) ("lazy" LAZY) ("let" LET) ("match" MATCH) ("method" METHOD) ("module" MODULE) ("mutable" MUTABLE) ("new" NEW) ("nonrec" NONREC) ("object" OBJECT) ("of" OF) ("open" OPEN) ("or" OR) ("private" PRIVATE) ("rec" REC) ("sig" SIG) ("struct" STRUCT) ("then" THEN) ("to" TO) ("true" TRUE) ("try" TRY) ("type" TYPE) ("val" VAL) ("virtual" VIRTUAL) ("when" WHEN) ("while" WHILE) ("with" WITH)))) ;; These are actually tokens that for some reason are defined under the ;; keyword hashtable? ;;("mod" INFIXOP3("mod")) ;;("land" INFIXOP3("land")) ;;("lor" INFIXOP3("lor")) ;;("lxor" INFIXOP3("lxor")) ;;("lsl" INFIXOP4("lsl")) ;;("lsr" INFIXOP4("lsr")) ;;("asr" INFIXOP4("asr")) (defun lex-alpha-string (s) "Lexes an alphanumeric string" (let ((keytok (gethash s *str-keywords*))) (if keytok (values keytok keytok) (values 'Identifier s)))) (lexer:deflexer ocaml-lexer ("[0-9]+([.][0-9]+([Ee][0-9]+)?)" (return (values 'Float (lexer:num lexer:%0)))) ("[0-9]+" (return (values 'Int (lexer:int lexer:%0)))) ("=" (return (values 'Equals 'Equals))) ("#\Newline") ("_" (return (values 'Underscore 'Underscore))) ("~" (return (values 'Tilde 'Tilde))) (";" (return (values 'Semi 'Semi))) ("\\+" (return (values 'BinOp 'Plus))) ("\\/\\." (return (values 'BinOp 'FloatDiv))) ("\\*\\." (return (values 'BinOp 'FloatMul))) ("\\(" (return (values 'LParen 'LParen))) ("\\)" (return (values 'RParen 'RParen))) ("\\/" (return (values 'BinOp 'IntDiv))) ("\\*" (return (values 'BinOp 'IntMul))) ("\\-\\>" (return (values 'MinusGreater 'MinusGreater))) ("\\-" (return (values 'BinOp 'Minus))) (";;" (return (values 'SemiSemi 'SemiSemi))) ("[:alpha:][:alnum:]*" (return (lex-alpha-string lexer:%0))) ("[:space:]+") ("#\Newline")) (defun debug-print-lexing (str) (let ((l (ocaml-lexer str))) (loop while (funcall l)))) (defun test-lex () (ocaml-lexer "let x = 1 in x - 1")) (setup-keywords)
3,372
Common Lisp
.lisp
102
25.235294
82
0.51517
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
2de90a8f09e7345935af8a24c0592f8b443fabec263dc585189cfb8828455afe
24,908
[ -1 ]
24,909
customtypespec.lisp
jrharbin_cl-ocaml/customtypespec.lisp
(defun elements-are-of-type (seq type) (every #'(lambda (x) (typep x type)) seq)) (deftype list-of-type (type) (let ((predicate (gensym))) (format t "Defining predicate as gensym: ~A~%" predicate) (setf (symbol-function predicate) #'(lambda (seq) (elements-are-of-type seq type))) `(and list (satisfies ,predicate))))
341
Common Lisp
.lisp
8
38.75
61
0.662651
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
c2a85640f76cd71e403e77ca62167e24b5aed683b52a3dadb4ca4823f536a6f3
24,909
[ -1 ]
24,910
parsing.lisp
jrharbin_cl-ocaml/parsing.lisp
(defmacro define-parser-start-symbol (parser-name start-sym) `(yacc:define-parser ,parser-name (:start-symbol ,start-sym) (:terminals (Identifier Int Float Plus Minus Semi SemiSemi BinOp Equals MinusGreater Underscore Tilde Let Fun IN LParen RParen)) (:precedence ((:nonassoc IN LET FUN SemiSemi) (:right Equals MinusGreater Semi) (:left BinOp Equals) (:right simple_expr_list))) (implementation (expr SemiSemi #'car)) (expr (simple_expr #'identity) (simple_expr simple_expr_list #'mk-apply) (LET Identifier Equals expr IN expr #'mk-letbind-in) (LET Identifier Equals expr #'mk-letbind) (FUN Identifier MinusGreater expr #'mk-fun) (expr BinOp expr #'mk-binop) (expr Semi expr #'mk-expr-seq) ;; Fix the functions to generate here (expr Semi #'car)) (simple_expr (Int #'mk-int) (Float #'mk-float) (Identifier #'mk-ident) (LParen expr RParen #'mk-parens)) (simple_expr_list (simple_expr simple_expr_list #'list) (simple_expr #'identity)))) (define-parser-start-symbol *ocaml-parser* expr) (define-parser-start-symbol *impl-parser* implementation) (defun test-parse (str) "Tests parsing the given string" (debug-print-lexing str) (yacc:parse-with-lexer (ocaml-lexer str) *ocaml-parser*))
1,407
Common Lisp
.lisp
40
28.625
75
0.656761
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
873584ca8f454e77cbb8df652604e87c3705f742372bdc275d84e0c1350f9bbc
24,910
[ -1 ]
24,911
macros.lisp
jrharbin_cl-ocaml/macros.lisp
(defmacro let1 (name val &body body) "Let bind a single value" `(let ((,name ,val)) ,@body))
102
Common Lisp
.lisp
4
22.25
36
0.612245
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
f169ce833e5bcec405b31de1f0be3b33537c1f137606bae1e4d13108d1e56e17
24,911
[ -1 ]
24,912
cl-ocaml.asd
jrharbin_cl-ocaml/cl-ocaml.asd
;;;; cl-ocaml.asd (asdf:defsystem #:cl-ocaml :description "Toy implementation of OCaml in Common Lisp" :author "James Harbin <[email protected]>" :license "GPL2" :depends-on (#:yacc #:lexer) :serial t :components ((:file "customtypespec") (:file "package") (:file "macros") (:file "lexing") (:file "parse-helpers" :depends-on ("customtypespec")) (:file "parsing" :depends-on ("lexing" "parse-helpers")) (:file "repl" :depends-on ("parsing")) (:file "test-parsing" :depends-on ("parsing")) (:file "main")))
611
Common Lisp
.asd
17
29.058824
64
0.587838
jrharbin/cl-ocaml
1
0
0
GPL-2.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
6db9d76a421cd831f6a74c5124fa11d8cd18e39da6a1584dfa7be4436685cef1
24,912
[ -1 ]
24,938
ui.lisp
mparlaktuna_cl-cu2e/ui.lisp
(in-package :cl-cu2e) (defclass world2d-pane (basic-gadget) ((%background :initform (make-rgb-color 0.35 0.35 0.46) :reader background-color) (x :initform 0.0 :accessor x) (y :initform 0.0 :accessor y) (scene :initarg :scene :accessor world-scene) (scene-tf :initform (mat3 '(1 0 200 0 1 300 0 0 1)) :accessor scene-tf) (dragging :initform nil :accessor dragging))) (defun draw-world2d (pane) (format t "drawing 3d world")) (defmethod handle-repaint ((pane world2d-pane) region) (with-bounding-rectangle* (x0 y0 x1 y1) (sheet-region pane) (draw-rectangle* (sheet-medium pane) x0 y0 x1 y1 :ink +white+) (draw-grid pane x0 y0 x1 y1 50) (let ((scene (world-scene pane))) (mapcar (lambda (x) (draw-object pane x)) (scene-models scene)) ))) (defmethod draw-grid ((pane world2d-pane) x0 y0 x1 y1 step) (iter (for x from x0 to x1 by step) (draw-line* pane x y0 x y1)) (iter (for y from y0 to y1 by step) (draw-line* pane x0 y x1 y))) (defmethod draw-object ((pane world2d-pane) (object object)) (let* ((obj-vis (object-visual object)) (pos (model-pos obj-vis)) (shape (model-shape obj-vis)) (scene-tf (scene-tf pane)) (pos3d (m* scene-tf (v+ (vec 0 0 1) (vxy_ pos))))) (format t "~a" pos3d) (draw-shape pane pos shape))) (defmethod draw-shape ((pane world2d-pane) (pos vec2) (shape circle)) (draw-circle* pane (vx pos) (vy pos) (circle-radius shape) :filled nil)) (define-application-frame cl-cu2e-viewer () () (:menu-bar t) (:panes (world2d (make-pane 'world2d-pane :width 1600 :height 500 :scene (make-scene 'sample 1))) (interactor :interactor :text-style (make-text-style :sans-serif nil nil))) (:layouts (default (vertically () (7/10 (labelling (:label "2D World") world2d)) (3/10 interactor))))) (define-cl-cu2e-viewer-command (com-create-circle :name t) ((radius 'number)) (let* ((gadget (find-pane-named *application-frame* 'world2d)) (scene (world-scene gadget))) (add-object scene (make-object (make-physical-model (vec 50 50) (make-circle radius)) (make-visual-model (vec 100 50) (make-circle radius)))) (handle-repaint gadget (or (pane-viewport-region gadget) (sheet-region gadget))))) (define-cl-cu2e-viewer-command (com-start-scene :name t) () (let* ((gadget (find-pane-named *application-frame* 'world2d)) (scene (world-scene gadget))) (start-thread scene))) (define-cl-cu2e-viewer-command (com-stop-scene :name t) () (let* ((gadget (find-pane-named *application-frame* 'world2d)) (scene (world-scene gadget))) (stop-thread scene))) (define-cl-cu2e-viewer-command (com-clear-objects :name t) () (let* ((gadget (find-pane-named *application-frame* 'world2d)) (scene (world-scene gadget))) (clear-objects scene) (handle-repaint gadget (or (pane-viewport-region gadget) (sheet-region gadget))))) (defun run-cl-cu2e-viewer () (run-frame-top-level (clim:make-application-frame 'cl-cu2e-viewer)))
3,033
Common Lisp
.lisp
72
37.875
92
0.671312
mparlaktuna/cl-cu2e
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
555d054df605656e4ff606e5e729e16e57f288cfc3dcdf6198b3b783255c9d88
24,938
[ -1 ]
24,939
package.lisp
mparlaktuna_cl-cu2e/package.lisp
(cl:in-package #:cl-user) (defpackage #:cl-cu2e (:use #:clim-lisp :3d-vectors :3d-matrices :clim :hooks :iterate) (:export make-aabb make-circle make-vec2 aabbvsaabb circle-intersect-p run-cl-cu2e-viewer))
259
Common Lisp
.lisp
9
21.888889
67
0.610442
mparlaktuna/cl-cu2e
1
0
0
GPL-3.0
9/19/2024, 11:28:28 AM (Europe/Amsterdam)
9823495afe5cd4b8112f4610c4d8d2b202f86611ba037fa2cc60c4991ccac021
24,939
[ -1 ]