freenode/#lisp - IRC Chatlog
Search
19:31:02
seok
why does pomo reference have an example with (create-database) when it is not defined?
0:00:41
Oladon
Anyone around with experience in parser combinators? I'm trying to do two things with bbcode-tag (L90): 1) make it work, and 2) make it recursive. https://pastebin.com/an96mFSK
0:00:45
Oladon
I'm pretty new to the concept of parser combinators, so I suspect I'm missing something fairly obvious.
0:09:41
iissaacc
trying to insert a dao with a nil in one of the slots, getting the following error. I can't find anythng in the manual about how nils in daos are treated
3:55:09
aeth
stylewarning: Also, I noticed your repository has that annoying NewLisp false positive that the Linguist (written in Ruby) library has, and it's used by both Github and Gitlab. You can fix that by manually telling it that all .lisp files are Common Lisp in .gitattributes like this: https://gitlab.com/zombie-raptor/zombie-raptor/-/blob/9a520eb8a41751cd377ad334446f222522322647/.gitattributes
3:55:54
aeth
1 false positive file: library.lisp: https://github.com/stylewarning/coalton/search?l=newlisp
3:57:01
aeth
Ah, I see why... it uses a heuristic system, and any "define" with no "defun" (or I guess not enough "defun"s since you have one) is seen as NewLisp... which leads to quite a few false positives even without custom macros since sometimes people have files with only DEFINE-CONDITIONs in them.
3:57:33
aeth
The file in question: https://github.com/stylewarning/coalton/blob/b2fe9d9103bdf8af2796e2caf40d6513d4c6f074/src/library.lisp
3:58:32
aeth
Alternatively, they do recognize emacs modes in the header (well, I know Gitlab does) so you could just add ";;;; -*- mode: common-lisp; -*-" to the top of that file.
4:09:42
stylewarning
aeth: is LOOP a different language that compiles to CL? If yes, then yes Coalton is
4:12:25
stylewarning
aeth: my hope is that Coalton can be compiled and type checked at macro time and expand into efficient Common Lisp code
4:16:46
stylewarning
I’m just not sure I’ll be able to do everything properly at macroexpansion time. Coalton is having issues currently with side effects happening at macro time
4:18:43
aeth
stylewarning: Well, if you do make it a language that compiles to Common Lisp with almost-but-not-quite-identical syntax to CL then you need to solve the same problem that my Airship Scheme is working on solving, which is why I asked about the distinction.
4:19:23
aeth
stylewarning: One of the trickiest parts seems to be ASDF integration since it's not obvious at all where to intercept the ASDF file compiler to tell it to use a custom reader but otherwise treat it as a Common Lisp file.
4:23:03
stylewarning
This file is an example https://github.com/stylewarning/coalton/blob/master/src/library.lisp#L3
4:24:22
aeth
stylewarning: What exactly are the issues with side effects at macro time? The only way I can think around that is if you do side effects in a way that multiple (almost always just double) evaluation doesn't impact the macro. "No side effects in macros" is only a rule of thumb, after all. e.g. a global INCFed variable is afaik fine, since it should only go up.
4:24:44
aeth
Also INTERNing is the most notable exception to the no-side-effects-in-macro rule, since INTERNing twice isn't problematic.
4:26:26
stylewarning
aeth: I modify and query a global database at macro time and it causes all sorts of funky stuff, esp. since those side effects aren’t put into a FASL
4:31:32
stylewarning
Here: https://github.com/stylewarning/coalton/blob/master/src/global-environment.lisp#L15
4:32:05
aeth
What if instead of using one hash table you defined functions in a different package namespace? So you'd look up with function calls.
4:34:28
stylewarning
The difficult part is setting and querying still. I think I’d have to EVAL or SETF FDEF to get that to work
4:34:37
aeth
I was thinking along the lines of generating `(defun coalton.type:foo () 'whatever-you-use-for-types)
4:35:38
aeth
As long as you only use 'coalton.type:foo and (coalton.type:foo) without using any #'coalton.type:foo in your code, then it will always query the fresh value and not go stale (the #' could go stale)
4:37:13
stylewarning
All of this hacking does lead me to believe I ought to have special ASDF support so I can do stuff before and after the compilation unit
4:37:21
aeth
I think defining and redefining functions is an acceptable side effect in macros. If it's not, you can add a versioning system of always-incrementing version numbers for each function, since always-incrementing afaik is safe.
4:38:01
stylewarning
aeth: consider this function which gets executed as a part of a macroexpansion https://github.com/stylewarning/coalton/blob/master/src/toplevel-declare.lisp#L35
4:38:15
aeth
Please lobby for that special ASDF support because I know that you're doing it for types and not a custom reader, but Airship Scheme needs the exact same thing (telling it to use a custom reader before the compilation unit and then restoring it after, or something along those lines).
4:39:12
aeth
I've been looking through ASDF off and on over the past few years and have found some possible candidates for interception (if I wrote it down somewhere...) but it would really just be a hack and not something official afaik like it should be.
4:39:51
stylewarning
Is it possible to define a new component type? We do that for compiling C libraries
4:40:38
aeth
The problem is that you'd want the least possible work, since you want it to otherwise use the CL compiler just with some before/after stuff.
4:40:56
stylewarning
aeth: https://github.com/rigetti/magicl/blob/master/magicl-transcendental.asd#L56
4:40:59
aeth
If you just copy and paste the implementation of the .lisp stuff (through quite a few files) I think it would work
4:42:09
aeth
Does that use its own file extension, distinct from .lisp? Coalton might need its own extension.
4:42:59
aeth
It's not as bad as it sounds since most tools should respect ";;;; -*- mode: common-lisp; -*-" so it would just add one line of boilerplate to every file
4:44:49
stylewarning
aeth that’s controlled by https://github.com/rigetti/magicl/blob/master/magicl-transcendental.asd#L9
4:46:22
aeth
ouch, that file uses way more lines than I thought that the solution would take, and since that just calls a foreign compiler, that's probably fewer lines than reimplementing ASDF's CL compiler logic
4:46:45
aeth
Ideally, a custom extension in ASDF with before/after stuff would just produce .FASLs and reuse almost all of ASDF's CL machinery.
4:48:45
aeth
stylewarning: Yes, Airship Scheme is written in Common Lisp + R7RS Scheme and will compile to Common Lisp, and interoperate with Common Lisp using the hack of case inversion so Scheme's case-sensitive "foo" is really "FOO"... https://gitlab.com/mbabich/airship-scheme
4:49:04
aeth
stylewarning: I got like 90% of the way to a version 0.0.1 in April and then it stalled out a bit and I needed to take a break from it
4:50:27
aeth
Airship Scheme even has a minimal "runtime" since it adds continuation passing style to everything. What I'm going to do is add it at the exposed-to-CL entrypoints, but also have internal Scheme procedure definitions that don't add the runtime
4:50:59
aeth
Afaik, continuation passing style + thunks + trampoline will solve that, not that much boilerplate, and almost all of it handled by macros
4:52:13
aeth
stylewarning: Airship Scheme will probably also support optional static typing, since I already do some static typing in CL with my DEFINE-FUNCTION macro... https://gitlab.com/zombie-raptor/zr-utils/-/blob/24f747564418f65b91df186028655c408fe18244/util.lisp#L66
4:53:06
aeth
I've just added a few tests so you can see the massive amounts of boilerplate DEFINE-FUNCTION can save: https://gitlab.com/zombie-raptor/zr-utils/-/blob/24f747564418f65b91df186028655c408fe18244/tests/all.lisp#L68-178
4:53:26
aeth
Well, the test cases are simple so it's not entirely apparent, but see e.g. line 166 for one of the more elaborate examples.
4:55:05
aeth
stylewarning: I might add some extensibility to DEFINE-FUNCTION and the other macros in the collection to support some other libraries that deal with types, e.g. specialization-store (a type-based generic dispatch, rather than class-based... useful for numbers/sequences) https://github.com/markcox80/specialization-store/
4:57:16
aeth
(If I do, I'd do it through optional ASDF systems in subdirectories so zr-utils doesn't suddenly depend on half a dozen type-system-expanding CL libraries... or just through exposing an API for those libraries to use)
4:59:12
aeth
stylewarning: I'm also considering (when Airship Scheme is more complete) moving some code out of airship-scheme and/or zr-utils to serve as a sort of embedding-languages-in-CL framework...
4:59:45
aeth
One of the things that's delaying Airship Scheme is that I'm overengineering the reader in Airship Scheme so it can be upstreamed to the language framework
5:01:22
aeth
I'd really love if Airship Scheme could interoperate in every language that's embedded into CL, not just CL itself. (I know of several: Shen, Clojure (two?), Python, JavaScript, etc.)
5:01:58
aeth
I am also considering writing a Lua implementation as a test of this framework, since Lua is a tiny, but notable language.
5:02:32
aeth
The idea being that any language that doesn't use s-expressions would first be parsed into a high-level s-expression representation
5:04:04
aeth
stylewarning: If your emphasis is on types, then that overlaps quite a bit with Airship Scheme. Scheme is portably only "predecately" typed, e.g. a list is just something that satisfies "list?" which could naively (and inefficiently) just be CL SATISFIES types
5:04:34
aeth
But another way to do it would be to generate a CL DEFTYPE and a type predicate at the same time, and maybe even use the ?s at the end of the name for the type since Scheme is a Lisp-1
5:06:23
stylewarning
aeth the focus for me is being able to define parametric types (a list-of T) and have them all statically type checked before code is executed (allowing me, in turn, to put safe DECLARES that will never be violated)
5:08:56
aeth
Well, statically typed and/or immutable sequences are coming to Airship Scheme at some point, hopefully before milestone 1.0, but if not, then at least for 2.0.
5:09:10
aeth
Of course, they'd also be exposed to the CL, via something like https://github.com/Shinmera/trivial-extensible-sequences/
5:10:41
aeth
I have a prototype, inconvenient-to-use typed-list/typed-cons using structs here, which I use in a handful of places in my game engine: https://gitlab.com/zombie-raptor/zr-utils/-/blob/24f747564418f65b91df186028655c408fe18244/data-structures.lisp#L48
5:16:39
stylewarning
Coalton doesn’t need such checks because all functions capable of constructing lists in the first place are also verified
5:17:34
aeth
Airship Scheme can't do that because then any use of CLFFI could (and probably would) break the type system
5:18:29
stylewarning
Right. In Coalton you have to tell Coalton what type your lisp ffi is. If you lie you die and Coalton automatically rm -rf /
5:21:33
stylewarning
Lisp ffi example https://github.com/stylewarning/coalton/blob/master/src/library.lisp#L77
5:24:05
aeth
stylewarning: here's mine at the moment: https://gitlab.com/mbabich/airship-scheme/-/blob/cbc61ba6390d4c955cc1f7175ae94933387e7490/standard-procedures.lisp
5:24:56
aeth
Several things. First, I didn't add the optional static types there yet. I'd probably use pretty similar syntax to DEFINE-FUNCTION... except, of course it would be (define-scheme-procedure (foo (x integer)) ...) instead of (define-function foo ((x integer)) ...) since the idea is to use almost Scheme-like syntax
5:25:47
aeth
And second, I'm not quite settled on how to handle arbitrary-length procedures... At the moment, I just use APPLY because if the function's inline, SBCL knows what to do and optimizes it away.
5:26:29
aeth
Oh, I suppose the third thing to note is that I do it in CL, not in Scheme, while you seem to do yours in Colton... although in principle I should be able to have parallel macros in Scheme for most things I'm doing in CL.
5:43:32
contrapunctus
stylewarning: "Right. In Coalton you have to tell Coalton what type your lisp ffi is. If you lie you die and Coalton automatically rm -rf /" lmao
6:04:29
fbmnds
jackdaniel: (in case you'll see this later) - ECL appears not to have a compare-and-swap implementation (ref. https://github.com/lmj/lparallel/blob/master/src/thread-util.lisp#L113). Is there a known workaround?