changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: fix dns, rename lql->dql

changeset 502: a2fe095379f9
parent 501: dc4dfb4d71d0
child 503: 03c2017b1405
author: Richard Westhaver <ellis@rwest.io>
date: Tue, 02 Jul 2024 19:30:24 -0400
files: lisp/ffi/gstreamer/element.lisp lisp/lib/net/proto/dns.lisp lisp/lib/q/dql.lisp lisp/lib/q/lql.lisp lisp/lib/q/pkg.lisp lisp/lib/q/q.asd lisp/lib/q/sql.lisp lisp/lib/q/tests.lisp
description: fix dns, rename lql->dql
     1.1--- a/lisp/ffi/gstreamer/element.lisp	Tue Jul 02 17:30:44 2024 -0400
     1.2+++ b/lisp/ffi/gstreamer/element.lisp	Tue Jul 02 19:30:24 2024 -0400
     1.3@@ -68,7 +68,6 @@
     1.4           (contexts (* glist))
     1.5           (%gst-reserved (array gpointer #.(- +gst-padding+ 1)))))
     1.6 
     1.7-
     1.8 (define-opaque gst-element-class)
     1.9 
    1.10 (define-alien-routine gst-element-get-type gtype)
     2.1--- a/lisp/lib/net/proto/dns.lisp	Tue Jul 02 17:30:44 2024 -0400
     2.2+++ b/lisp/lib/net/proto/dns.lisp	Tue Jul 02 19:30:24 2024 -0400
     2.3@@ -26,27 +26,27 @@
     2.4   '("9.9.9.9" "149.112.112.112"))
     2.5 
     2.6 (defvar *dns-servers*
     2.7-  (list* "127.0.0.1"
     2.8-         (append *dnswatch-servers* *quad9-servers*
     2.9-                 *cloudflare-servers* *opendns-servers*
    2.10-                 *google-servers*)))
    2.11+  (cons "127.0.0.1"
    2.12+        (append *dnswatch-servers* *quad9-servers*
    2.13+                *cloudflare-servers* *opendns-servers*
    2.14+                *google-servers*)))
    2.15 
    2.16 (defun try-server (server send send-length recv recv-length &key (attempts 1) (timeout 1))
    2.17   (handler-case
    2.18       (let ((socket (sb-bsd-sockets:socket-connect
    2.19                      (make-instance 'inet-socket
    2.20                        :type :datagram :protocol :udp)
    2.21-                     (cons server +dns-port+))))
    2.22+                     (make-inet-address server) +dns-port+)))
    2.23         (unwind-protect
    2.24              (loop repeat attempts
    2.25-                   do (usocket:socket-send socket send send-length)
    2.26-                      (when (usocket:wait-for-input socket :timeout timeout :ready-only T)
    2.27-                        (let ((received (nth-value 1 (usocket:socket-receive socket recv recv-length))))
    2.28+                   do (sb-bsd-sockets:socket-send socket send send-length)
    2.29+                      (sb-ext:with-timeout timeout
    2.30+                        (let ((received (nth-value 1 (socket-receive socket recv recv-length))))
    2.31                           (when (and received (< 0 received))
    2.32                             (return received)))))
    2.33           (socket-close socket)))
    2.34     (socket-error (e)
    2.35-      (values NIL e))))
    2.36+      (values nil e))))
    2.37 
    2.38 (defmacro with-query-buffer ((send pos hostname type &rest header-args) &body body)
    2.39   `(let* ((,send (make-array 512 :element-type '(unsigned-byte 8) :initial-element 0))
     3.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2+++ b/lisp/lib/q/dql.lisp	Tue Jul 02 19:30:24 2024 -0400
     3.3@@ -0,0 +1,45 @@
     3.4+;;; dql.lisp --- Deductive Query Langs
     3.5+
     3.6+;; Query Engine for Inference-based query langs.
     3.7+
     3.8+;;; Commentary:
     3.9+
    3.10+;; Prolog, Datalog, etc.
    3.11+
    3.12+;;;; Why bother with this when we have SQL?
    3.13+
    3.14+;; My current understanding is that Prolog and SQL-derived langs share much in
    3.15+;; common. You can certainly do deductive logic in SQL and you can do
    3.16+;; relational table-based logic in Prolog.
    3.17+
    3.18+;; It is interesting to note that they were both discovered around the same
    3.19+;; time in the 60s-70s, but in very different contexts. Prolog was intended
    3.20+;; for NLP and SQL (relational-algebra/RA) was the foundation for
    3.21+;; RDBMS. Prolog never really found the same sort of success had by SQL, but
    3.22+;; with the AI summer in full bloom and NLP being a hot-topic, perhaps we will
    3.23+;; see the scales shift.
    3.24+
    3.25+;;;; Design
    3.26+
    3.27+;; The WAM compiler is a bit too much to understand let alone implement at
    3.28+;; this stage. The design of this package will be much simpler and optimized
    3.29+;; for compatibility with Lisp.
    3.30+
    3.31+;; I think we can get quite far 
    3.32+
    3.33+;;; Code:
    3.34+(in-package :q/dql)
    3.35+
    3.36+;;; Conditions
    3.37+(define-condition dql-error (error) ())
    3.38+
    3.39+(deferror simple-dql-error (dql-error simple-error) ())
    3.40+
    3.41+(defun simple-dql-error (ctrl &rest args)
    3.42+  (error 'simpl-dql-error :format-control ctrl :format-arguments args))
    3.43+
    3.44+(defclass dql-query (query) ())
    3.45+
    3.46+(defclass dql-data-source (data-source) ()
    3.47+  (:documentation "Data source which can be used withing DQL expressions."))
    3.48+
     4.1--- a/lisp/lib/q/lql.lisp	Tue Jul 02 17:30:44 2024 -0400
     4.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3@@ -1,7 +0,0 @@
     4.4-;;; l.lisp --- Logical Query Langs
     4.5-
     4.6-;; Query Engine for Logical Query Languages
     4.7-
     4.8-;;; Code:
     4.9-(in-package :q/lql)
    4.10-
     5.1--- a/lisp/lib/q/pkg.lisp	Tue Jul 02 17:30:44 2024 -0400
     5.2+++ b/lisp/lib/q/pkg.lisp	Tue Jul 02 19:30:24 2024 -0400
     5.3@@ -8,16 +8,27 @@
     5.4   (:export))
     5.5            
     5.6 (defpackage :q/sql
     5.7+  (:nicknames :sql)
     5.8   (:use :cl :std :q/engine :parse/pratt :obj/query :obj/id)
     5.9   (:export
    5.10+   :sql-error
    5.11+   :read-sql-string
    5.12+   :read-sql-stream
    5.13+   :parse-expression
    5.14    :sql-tokens
    5.15    :sql-parser))
    5.16 
    5.17-(defpackage :q/lql
    5.18-  (:use :cl :std :q/engine))
    5.19+(defpackage :q/dql
    5.20+  (:nicknames :dql)
    5.21+  (:use :cl :std :q/engine :obj/query :obj/id :dat/sxp :dat/proto)
    5.22+  (:export
    5.23+   :dql-error
    5.24+   :dql-data-source
    5.25+   :dql-query
    5.26+   :dql-expression))
    5.27 
    5.28 ;; (defpackage :q/e)
    5.29 
    5.30 (in-package :std-user)
    5.31 (defpkg :q
    5.32-  (:use-reexport :q/sql :q/lql))
    5.33+  (:use-reexport :q/sql :q/dql))
     6.1--- a/lisp/lib/q/q.asd	Tue Jul 02 17:30:44 2024 -0400
     6.2+++ b/lisp/lib/q/q.asd	Tue Jul 02 19:30:24 2024 -0400
     6.3@@ -4,7 +4,7 @@
     6.4   :depends-on (:std :obj :log :dat :parse)
     6.5   :components ((:file "pkg")
     6.6                (:file "sql" :depends-on ("pkg"))
     6.7-               (:file "lql" :depends-on ("pkg")))
     6.8+               (:file "dql" :depends-on ("pkg")))
     6.9   :in-order-to ((test-op (test-op "q/tests"))))
    6.10 
    6.11 (defsystem :q/tests
     7.1--- a/lisp/lib/q/sql.lisp	Tue Jul 02 17:30:44 2024 -0400
     7.2+++ b/lisp/lib/q/sql.lisp	Tue Jul 02 19:30:24 2024 -0400
     7.3@@ -13,6 +13,7 @@
     7.4 
     7.5 (declaim (optimize (speed 3)))
     7.6 
     7.7+;;; Conditions
     7.8 (define-condition sql-error (error) ())
     7.9 
    7.10 (deferror simple-sql-error (sql-error simple-error) ())
    7.11@@ -36,6 +37,7 @@
    7.12 (defun illegal-sql-state (state)
    7.13   (error 'illegal-sql-state :state state))
    7.14 
    7.15+;;; Objects
    7.16 (defclass sql-query (query) ())
    7.17 
    7.18 (defclass sql-data-source (data-source) ()
     8.1--- a/lisp/lib/q/tests.lisp	Tue Jul 02 17:30:44 2024 -0400
     8.2+++ b/lisp/lib/q/tests.lisp	Tue Jul 02 19:30:24 2024 -0400
     8.3@@ -17,7 +17,7 @@
     8.4 (deftest sql ())
     8.5 
     8.6 ;; https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html
     8.7-(deftest lql ()
     8.8+(deftest dql ()
     8.9   (adjacent 1 2)
    8.10   (adjacent 2 1) 
    8.11   (adjacent 1 3)