unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lynn Winebarger <owinebar@gmail.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [NonGNU ELPA] New package: sqlite3
Date: Wed, 22 Mar 2023 20:07:27 -0400	[thread overview]
Message-ID: <CAM=F=bDikC+An-AXEJ=OpTvxXh80FKjGfvkUvWcf30Dr_3gWaA@mail.gmail.com> (raw)
In-Reply-To: <CAM=F=bBQjAo9nABxJ9uvGHH2NtyKD59Qt9PWgABaAp4u+VFLaQ@mail.gmail.com>

On Wed, Mar 22, 2023 at 11:05 AM Lynn Winebarger <owinebar@gmail.com> wrote:
>
> On Wed, Mar 22, 2023, 4:10 AM Philip Kaludercic <philipk@posteo.net> wrote:
>>
>> Lynn Winebarger <owinebar@gmail.com> writes:
>>
>> > On Tue, Mar 21, 2023 at 12:53 PM Philip Kaludercic <philipk@posteo.net> wrote:
>> >> I really, really have no idea what you are getting at.  As in "ok, but
>> >> what is your intent in explaining this?".
>> >>
>> >> Are you trying to propose that Emacs circumvents the SQLite API (that as
>> >> far as I see uses strings) by constructing statement objects manually?
>> >
>> > Not at all.  I don't think I can communicate via email the power of
>> > generative programming techniques, and why basing them on simple
>> > string concatenation is a bad idea, so I'm going to stop trying.
>>
>> I get that, and I am not advocating for string concatenation.  Perhaps
>> that is what is confusing me?
>>
>> > I don't think "? ? table values ( 1.0, 'Foo' )" can be supplied with
>> > 'insert and 'into as parameters.
>>
>> Nor do I, but I doubt the necessity.  SQL is a very brittle language,
>> and replacing one keyword with another will usually require other
>> changes to be made as well.
>
>
> Exactly the point of a DSL that compiles to a query.
>
> Whether emacsql is the best DSL or not, I don't know.  I really haven't used it.  It has the distinct advantage of existing and providing a syntax tree of the query, which are strong points.
>

I gave this some more thought after starting to sketch a sql sexpr ->
string compiler.  SQL is non-compositional (as you put it, "brittle"),
so just encoding SQL syntax trees as sexprs is not particularly
empowering.

A lot of the ugliness (non-compositionality) arises from embedding
properties of the expected instantiation of tables (e.g. keys,
indexing) as part of the query.  To get a compositional querying DSL,
it's probably better to have three orthogonal but mutually recursive
types of expressions, one for specifying the table schema, which may
incorporate queries in its formation, which specify the shape of a
table, and another for specifying "queries" (select - or just "from"
as an operator, join, where, let ["with", as etc], labels ["with
recursive"], etc) that will instantiate the data set in one form or
another, and the third for "commands" that perform side-effects on the
database.  There's probably a set of these operators that can be
cleanly composed in mostly arbitrary ways with clear semantics.  Then
those expressions could be compiled to SQL, letting the compiler
handle optimization as dictated by experience.

There's also the matter of how to store lisp data transparently in
data tables.  Storing pointers directly will mean the garbage
collector will have to know which entries have LispObjects as values
and how to trace them.  And you wouldn't want to do that unless the
database was in memory.

I'm not going to put that before my other projects though, so I may
just be using some fixed string queries to get things going with
unboxed, which has fairly modest needs in terms of table schemas.

Lynn



  reply	other threads:[~2023-03-23  0:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 10:17 [NonGNU ELPA] New package: sqlite3 Jonas Bernoulli
2023-03-04 11:39 ` Philip Kaludercic
2023-03-06 18:43   ` Jonas Bernoulli
2023-03-14 16:16     ` Philip Kaludercic
2023-03-14 22:46       ` Jonas Bernoulli
2023-03-15  8:05         ` Philip Kaludercic
2023-03-21  6:51       ` Jean Louis
2023-03-21 10:55         ` Lynn Winebarger
2023-03-21 11:08           ` Philip Kaludercic
2023-03-21 11:56             ` Lynn Winebarger
2023-03-21 12:18               ` Philip Kaludercic
2023-03-21 13:04                 ` Lynn Winebarger
2023-03-21 16:53                   ` Philip Kaludercic
2023-03-21 21:00                     ` Tomas Hlavaty
2023-04-07  4:53                       ` Jean Louis
2023-03-21 23:58                     ` Lynn Winebarger
2023-03-22  8:10                       ` Philip Kaludercic
2023-03-22 15:05                         ` Lynn Winebarger
2023-03-23  0:07                           ` Lynn Winebarger [this message]
2023-03-21 20:42             ` Tomas Hlavaty
     [not found]               ` <875yatn70c.fsf@posteo.net>
2023-03-21 22:46                 ` Tomas Hlavaty
2023-03-22  8:00                   ` Philip Kaludercic
2023-03-21 20:36         ` Tomas Hlavaty
2023-04-07  5:17           ` Jean Louis
2023-03-06  5:08 ` Richard Stallman
2023-03-14 14:36   ` Jonas Bernoulli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM=F=bDikC+An-AXEJ=OpTvxXh80FKjGfvkUvWcf30Dr_3gWaA@mail.gmail.com' \
    --to=owinebar@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).