freenode/#lisp - IRC Chatlog
Search
16:15:18
dlowe
the json decoding doesn't leave distinguishing markers on whether something is a list or an object
16:16:49
jfrancis
Yeah. And I could actually live with that if I had a way to force cl-json to do what I want. I already have to do that with things like an empty list (you have to do (make-array 0) to force it to encode "[]" instead of "false").
16:16:56
_death
personally I recommend com.gigamonkeys.json that does roundtripping correctly without tweaking configuration
16:24:00
jfrancis
That does work. But the amount of effort required to convert three years of code from the cl-json way of doing things to the gigamonkeys way makes me sad.
16:24:07
jfrancis
(princ (com.gigamonkeys.json:json (com.gigamonkeys.json:parse-json "{\"sources\":{\"include\":[[{\"label\":{\"href\":\"/orgs/1/labels/41\"}}]],\"exclude\":[{\"ip_address\":{\"value\":\"10.1.0.27\"}}]}}")))
16:24:14
jfrancis
{"sources":{"include":[[{"label":{"href":"/orgs/1/labels/41"}}]],"exclude":[{"ip_address":{"value":"10.1.0.27"}}]}}
16:25:48
jfrancis
I was hoping there was a way to hack/coerce/force cl-json to do what I want. I build most of the objects in my code, anyway. I could just build them the way cl-json wants them to give me what I need.
16:26:21
sjl_
This is why the #1 most important feature for any JSON lib I use is "encodes and decodes unambiguously"
16:27:02
dlowe
json:set-decoder-simple-clos-semantics *seems* like it could work, but it barfs on your example json
16:28:31
_death
iirc there is a way to make cl-json work, but it will of course change the representation
16:28:32
jfrancis
It's much more straightforward to build lists, then convert them, than to build hashes and/or hashes and vectors.
16:29:14
jackdaniel
jfrancis: jsown is unambigous and fastest (according to benchmarks we did some time ago), though it is a little pita to use it with all `(:obj …) stuff
16:29:54
jackdaniel
yason otoh is the most convenient library (but I use it only for repl, production code works on jsown)
16:30:11
jfrancis
Oddly enough, performance is about #1045 on my list of priorities. The elapsed time of the REST API call dwarfs any compute time in my code.
16:32:08
pfdietz
I think you want an encoder/decoder that converts json boolean into something other than T/NIL. :true and :false, maybe.
16:32:23
sjl_
You can make hash/vector use less awkward with some greasy generic functions, e.g. https://github.com/sjl/cacl/blob/master/src/base.lisp#L77-L90
16:32:55
sjl_
It's still a little clumsy, but at least things will be unambiguous and actually work correctly.
16:34:32
sjl_
And you can always go full Clojure and define a #{} reader macro to wrap alexandria:alish-hash-table
16:35:02
jfrancis
I can work around the :true/:false t/nil issue, given how rigorously the API is defined (ie, I can guess correctly 100% of the time). The issue I can't work around is that cl-json improperly converts my data into an array instead of a key/value.
17:06:08
fiddlerwoaroof
jfrancis: you could probably also use these special variables to make decoding unambiguous: https://common-lisp.net/project/cl-json/cl-json.html#DECODER-CUSTOMIZATION
17:13:11
jmercouris
I'm hesitant to iterate over the hashtable keys and do remhash because I have a feeling it won't like that
17:15:16
jackdaniel
(let ((to-remove nil)) (maphash #'(lambda (k v) (when (pred v) (push v to-remove))) ht) (mapc #'remhash* to-remove))
17:17:00
_death
jmercouris: the standard guarantees that you should be able to do that for the entry currently being passed
17:18:53
sjl_
yeah, (maphash (lambda (k v) (when (funcall predicate k v) (remhash foo k)) foo) should be portable
17:23:16
_death
yep.. that would save you from errors like pushing value instead of key, or rotating the arguments to remhash ;)
17:24:39
sjl_
ugh, yet another instance of *hash functions having the opposite arg order to what I expect
17:30:08
_death
same argument for MAPCAR taking lists after the function.. while it could make sense for (single) sequence functions to take the sequence first, I guess
17:32:05
sjl_
I'd still probably lean toward taking the predicate first, because (curry #'mapcar #'pred) to make map-pred seems more useful than (curry #'mapcar somelist), which would be... map-over-some-particular-list
17:46:28
ogamita
The nth element of the list (nth n list); Let's reference the array a with the indices i j k (aref a i j k).
17:49:14
ogamita
(defun at-indices-of-array (&rest arguments) (apply (function aref) (first (last arguments)) (butlast arguments))) (at-indices-of-array 1 0 #2A((a b) (c d))) #| --> c |#
19:18:31
jcowan
It shouldn't be that hard to hack an interface to <good JSON package> that mimics <bad JSON package>.
19:48:25
jackdaniel
Greenspun's eleventh rule: there is never enough JSON packages and lisp implementations. :-)
19:51:48
dim
what about channeling this fabulous energy to McCLIM and a pure-CL dev environment (listener, editor, debugger, etc etc) that would compare favorably to DrRacket and its tutorial with images?
19:52:16
dim
so that next time a newcomer to CL asks questions about getting started, they just use thing new thing instead of having to learn SLIME or some derivatives
19:52:56
malice
jackdaniel: Hi! You're maintainer of both McClim and ECL projects, right? I suggest that you take a look at Google Summer of Code: https://opensource.googleblog.com/2018/11/google-summer-of-code-15-years-strong.html
19:52:57
sjl_
I've successfully resisted the temptation to write my own test framework and/or JSON library so far. I'm fighting the good fight.
19:53:16
dim
jackdaniel: I know you do, and I'd like to help, I don't have enough time to reproduce and fix pgloader issues already, unfortunately, though
19:53:21
malice
The registration for organizations starts in january, so there's still some time to familiarize yourself with the project if you were interested.
19:53:50
jasom
Google SoC might get you future contributors, but it's rare that useful contributions come out of it.
19:54:22
malice
Well, if you manage to prepare that, I believe it might be beneficial (or maybe someone can do it for you?)
19:55:21
malice
jasom: I think it would be beneficial because (1) people would browse GSoC to find projects. Some of those people could get familiar with Lisp and its projects by seeing those there
19:56:11
malice
I agree. This is best thought of as a way of easing a person into the project and/or its ecosystem
19:56:53
jasom
speaking of which, what's a current need for McClim that isn't getting some TLC (other than non-X11 backends; I don't use any non x-11 guis regularly so wouldn't be uesful for me)
19:59:35
jackdaniel
jasom: this ticket would be a big step in good direction: https://github.com/McCLIM/McCLIM/issues/35
20:00:02
jackdaniel
this would make life easier when using the Listener: https://github.com/McCLIM/McCLIM/issues/307
20:03:27
jasom
jackdaniel: what extensions can the X11 backend assume the server will have (or more generally which X servers do you wish to support)?
20:06:25
jackdaniel
right now it supports very old x11, but we are slowly moving towards xrender model
20:17:15
jcowan
Unlike CLICC CL1 and stand-alone CL0 it will be based on ANS CL and will not restrict the language of macros, since I assume the compiler will be written in full CL.
20:41:48
jcowan
I think so, but I'm open to arguments against. It seems only trivially different from symbol-function at first glance
21:00:25
dim
kinlo: the new file https://github.com/dimitri/pgloader/blob/master/bundle/save.lisp should help you build pgloader from the bundle distribution, you just need to prepare a version.sexp file containing "3.5.2" with the quotes and then either sbcl --no-userinit --load ./save.lisp or ccl -l save.lisp
22:08:22
pjb
I'm trying to use asdf:make-build, but I get errors "An error occurred during initialization: Component "<my-system>" not found.", even if I quickload successfully "<my-system>" before asdf:make-build. What would be the problem?
22:28:29
dim
pjb: could it be that you're using QL facilities to find your projects that are unknown to ASDF itself? ql:*local-project-directories* comes to mind
22:30:32
pjb
I've set asdf:*central-registry* with the paths to the directories where all my asd are.
22:31:54
dim
(asdf:initialize-source-registry) might be necessary after setting the central registry
22:37:37
pjb
Nope, same result with all the directories containing asd in the project and in ~/quicklisp in asdf:*central-registry*, and with (asdf:initialize-source-registry)…
22:41:13
pjb
Ok, it's an asdf problem with this setup. (asdf:oos 'asdf:load-op "<my-system>") fails too. Not specific to asdf:make-build. I'll debug that tomorrow.
0:04:22
White_Flame
thoughts on another stupid hack of mine: To READ multiple terms from a single string, encase the string with paren characters, and READ once into a list.
0:05:04
White_Flame
I think the only difference is that if there's an unclosed paren in the string, the location of the error would be different?
0:05:32
noobly
in the little schemere, there is a function as such: (define even? (lambda (n) (= (* (/ n 2) 2) n))). SO, because (* (/ n 2) 2) alwasy equals n, I've come to the conclusion that this either errata, a quirk of a specific scheme dialect. I'm using guile.. any help here?
0:06:25
White_Flame
this channel is about CL, not scheme. try #scheme. However, / might be an integer division or a divmod or something
0:12:14
noobly
and I'll try finding the specs, not quite sure how though (in emacs using guile, fwiw)
0:14:34
jmercouris
so if I make a program with asdf:make, right, it has an entry point, how can I keep that program running without doing a while true loop?
0:16:25
jmercouris
Bike: so the thing is, all events come from s-xml-rpc, invoked by xml-rpc from the client program
0:18:00
jmercouris
what if I used BT threads to run a loop that is sleeping 99% of the time to avoid the program closing
0:18:04
sjl
Is there some built-in function that takes a list and an element and appends that element to the list? I realize this will be slow.
0:18:30
pillton
jmercouris: You should wait for the thread which controls the event loop to terminate.
0:19:30
jmercouris
pillton: wait for the thread which controls the event loop...? how could I possibly know what thread s-xml-rpc is running on, or are you suggesting I make an event loop thread?
0:25:47
pillton
jmercouris: Have the main thread wait on a mutex which a s-xml-rpc handler sets upon termination.
0:26:45
jmercouris
are mutexs native to common lisp? or will I have to use a library or some bool or something?
0:51:39
no-defun-allowed
if you can chase the last cons in the list you can append to the end very quickly
0:52:03
no-defun-allowed
eg the results of (macroexpand '(loop for n from 1 to 10 collect n)) might involve such cons chasing
0:52:19
sjl
Sure. I could also use the queue implementation I wrote a while ago... I'm looking for a portable built-in or one-liner equivalent
0:55:36
sjl
starting with a vector and v-p-e would work, but v-p-e's args are in the wrong order and CL doesn't have flip
0:56:49
sjl
well, if I had flip and could live with reversed output it could be (flip #'cons) I guess
1:21:36
sjl
exactly. if append doesn't solve the problem, nconc will only not solve the problem faster and more dangerously
3:53:11
beach
What is your intended use for CL-R? It is hard to give advice unless the purpose is clear. Like, why would you want to give up reflection?
3:56:48
beach
jcowan: Another way of asking the same question, I guess: What problem with full Common Lisp is CL-R meant to solve?
3:57:56
pfdietz
Perhaps it's intended for more minimal, static compiled apps? Sort of a scheme-like CL?
3:59:13
beach
I am not saying there is anything wrong with wanting such a thing. I am just curious about the goal.