libera/commonlisp - IRC Chatlog
Search
17:02:21
skin
I have a question regarding unicode support. I know SBCL has it; e.g. `(code-char some-character)` will return that character's unicode code point.
17:10:35
beach
My guess is "not very well". But there is a cl-unicode library by Edi Weitz that some might use.
17:25:01
Shinmera
most implementations use utf-8 for the external format when writing characters to file.
17:25:09
skin
Good to hear. I wondered if that were true, after reading https://github.com/sabracrolleton/uax-15/blob/master/src/trivial-utf-16.lisp
19:02:13
aeth
unfortunately, last I checked, most unicode-specific functionality seems to be available in SBCL as sb-unicode and not available portably, while most "unicode" libraries are more about various encodings rather than things like sb-unicode:casefold... perhaps other implementations have similar functionality, in which case a portability library is needed
19:21:43
Bubblegumdrop
Oh man, I always mix up char-code and code-char. Is there a better way to remember which is which?
19:31:11
aeth
in fact, those names would be better so I could imagine an alternate universe where those were the names
19:32:31
Bubblegumdrop
I usually carry around my own toolkit.lisp from project to project. That's going in there for sure.
19:36:49
aeth
if you're just going to rename something, don't forget to inline it... there are also other ways to rename something, such as e.g. (setf (fdefinition 'add) #'+) but that seems hackier than having a one-line inline function, where the main disadvantage is that e.g. SBCL by default has an *inline-expansion-limit* of 50 and you can definitely hit that because it's 50 for an entire function
19:45:25
_death
using your own names for CL operators is digging an esoteric hole for yourself, and perhaps later on asking everyone who reads your code to come along.. similar to having your own similar-but-different operators.. basically inventing a private language. it's a rite of passage, every lisper goes through it, but abstractions have a cost, so maybe it's better to limit the language invention to your actual application's domain
19:46:46
mfiano
I was bored today, so I decided to really study the simple and classic Norvig cons-based queue algorithm. I've been using it for a while in various codes, but haven't sat down to study how it works in detail in some years. I figured out the symmetric analog of storing the tail in the car of the cons, and discovered that it costs an extra traversal for deletion and obtaining the queued elements,
19:46:48
mfiano
and removes a traversal from insertion. I'm not too sure if I care. It was just a fun 10 minute experiment. Though interesting that insertion becomes less expensive.
19:55:16
mfiano
I suppose I should read the subject matter more fully instead of going by my notes and comments.
19:56:40
mfiano
He explored this as well, in his last example of removing the boundary test, and noticed the extra traversal. If the cons queue is reversed, that extra traversal is removed and put in another place, deletion.
20:00:24
mfiano
it should be noted that insertion and deletion have to be measured for your domain. That is, if you can't afford a vector implementation. It should also be noted that his queue-elements and dequeue functions both increased in traversal with the reverse, but insertion decreases.
20:01:26
Bubblegumdrop
I think I did try using vectors but had some esoteric use case that they didn't support, I don't remember why I chose to use plain cons instead
20:01:37
Bubblegumdrop
I think I tried arrays too? I actually think I just literally did not understand them at the time.
20:05:14
mfiano
,(let* ((l (list nil)) (q (cons l l))) (setf (cdr q) (setf (cddr q) (list 1))) (setf (cdr q) (setf (cddr q) (list 2))) (setf (car q) (cdar q)) (setf (cdr q) (setf (cddr q) (list 3))) (cdar q))
20:05:21
mfiano
,(let* ((l (list nil)) (q (cons l l))) (setf (car q) (setf (cdar q) (list 1))) (setf (car q) (setf (cdar q) (list 2))) (setf (cdr q) (cddr q)) (setf (car q) (setf (cdar q) (list 3))) (cddr q))
20:06:06
mfiano
The latter would just be the inverse of his "removing the boundaries" implementation, with the noted advantage/disadvantages
20:11:27
mfiano
Yes, it's just that not all arrays are vectors, and not all vectors are simple-arrays, and not all non-simple-array vectors are not simple-vectors....
20:13:02
Bubblegumdrop
https://github.com/Lisp-Stat/ oh this is cool. So many incredible resources for lisp.
20:54:44
Kingsy
Is anyone around that can give me tips on how to handle errors properly in hunchentoot?
21:19:36
Kingsy
skin: I have looked over this a few times, but it still doesnt really answer my question. for example. I want to return JSON objects not templates. I also want to be able to specify the object that is returned based on the condition that is raised. I don't see how that is done with the items listed here.
21:22:15
Kingsy
the docs are vague. I can see there is a hunchentoot-error class but there is absoutely no information on how it works. What can be overriden and how? etc etc.
21:43:48
Bubblegumdrop
Kingsy if you want to return json you may need to set the content type or something, caveman has this
21:44:08
Bubblegumdrop
https://github.com/fukamachi/caveman/blob/master/v2/skeleton/src/view.lisp#L33
21:44:24
Bubblegumdrop
hunchentoot-error is the base class and you can make your own conditions like so"
21:44:59
Bubblegumdrop
(hunchentoot:define-easy-handler (say-yo :uri "/yo") (name) (setf (hunchentoot:content-type*) "text/plain") (format nil "Hey~@[ ~A~]!" name))
21:46:44
Bubblegumdrop
Kingsy I struggled with the condition system at first too, it's not specific to hunchentoot although hunchentoot may hook into it specifically
21:47:09
Bubblegumdrop
Yeah you were trying to do something like "catch the error and return json if so"
21:47:18
Kingsy
if something goes wrong, in general, it returns an error template for the 500.. I want to change that. so it never returns HTML. ever
21:47:23
Bubblegumdrop
If you're able to explain what you want/are trying to acheive in english it's helpful as well
21:48:21
Kingsy
so lets start with the simple example. I want to. catch ANY error that is thrown during the execution of a route, and return a custom json object, set the content type as you showed. but also log the stack trace to the repl
21:48:45
Kingsy
yeah this is just a learning exercise. I know there are things out there that would make this a lot easier
21:48:47
Bubblegumdrop
mm yeah so you'll have to wrap all that in a progn if you're using your lambda thingy with ,@body
21:49:35
Bubblegumdrop
You should be able to just add (log-whatever ..) in the progn and it should just work
21:51:11
Kingsy
Bubblegumdrop: no I got that working. but it meant it stopped logging to REPL, which didnt help. it meant I didnt know what was going on
21:51:39
Kingsy
it also got me thinking about what happens when it is deployed. we probably want different error handling based on production and not. so I was just looking for general advice.
21:53:05
Bubblegumdrop
Kingsy I actually ended up using Shinmera's VERBOSE library because it's so amazing and versatile. This is what I followed to integrate it into my multithreaded web app: https://www.darkchestnut.com/2021/set-up-verbose-multi-threaded-standalone-applications/
21:54:04
Bubblegumdrop
https://git.lain.church/Bubblegumdrop/cl-deck-builder2/src/branch/master/src/main.lisp#L90
21:55:46
Kingsy
no this is fune, but it doesnt answer the hunchentoot question. I don't know how to properly catch and return different custom objects based on conditions whilst controlling the REPL. the way I am doing it right now feels wrong
21:59:15
Bubblegumdrop
Derived acceptor classes can implement methods for the ACCEPTOR-LOG-MESSAGE and ACCEPTOR-LOG-ACCESS generic functions
21:59:36
Bubblegumdrop
So I think what you'll want to do is have your own acceptor class that subclasses ACCEPETOR: (defclass my-acceptor (hunchentoot:acceptor) ...)
21:59:45
Bubblegumdrop
Then pass that to the thingy instead of the default acceptor or whatever you're using now.
22:00:09
Bubblegumdrop
You'll want to specialize on ACCEPTOR-LOG-MESSAGE and etc for that class like so: (defmethod acceptor-log-message :after ((obj my-acceptor) ..) ..)
22:01:47
Bubblegumdrop
You can do things like open a log file and save it with defparameter or defvar, (defparameter *my-log-file* (open ...))
22:02:23
Bubblegumdrop
I'm not sure if hunchentoot uses threads, but threads make this a whole lot more fun.
22:03:58
Bubblegumdrop
and by that I mean, *standard-output* of your REPL is *not* *standard-output* of the thread hunchentoot is executing on
22:15:32
Kingsy
well I wrote a simple logger and just outputs with format. so I am going to try and use that. will see how it goes.
22:16:40
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/ I learned a lot from this repository
22:17:06
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/-/blob/master/run.lisp?ref_type=heads
22:17:37
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/-/blob/master/src/web/web.lisp?ref_type=heads#L29
22:18:28
Bubblegumdrop
If you find any other programs using hunchentoot I'm interested in knowing more as well. I primarily use woo.
22:18:47
Bubblegumdrop
I'm actually not sure what the differences between clack/lack/hunchentoot/woo/etc are
22:19:03
Bubblegumdrop
like superficially I understand they're different projects with different goals
0:25:06
paulapatience
Shinmera: It is perfectly harmless, but I assume the asterisk is de trop here: https://github.com/Shirakumo/trial/blob/b5e95f859e82faac2db4eb6eba5be26dd1ec80c9/asset.lisp#L48
2:24:26
Bubblegumdrop
paulapatience I'm not certain but I think that's an idiom, like LIST and LIST*
2:25:09
Bubblegumdrop
https://github.com/Shirakumo/trial/blob/b5e95f859e82faac2db4eb6eba5be26dd1ec80c9/asset.lisp#L128
2:45:35
holycow
that video points to a direction in which lisp programmers might look to find full time positions
2:46:03
holycow
it could get interesting, nano tech is coming soon and it will merge with the the LLM stuff happening now
3:07:04
Bubblegumdrop
Clasp is an implementation of Common Lisp primarily designed for compatibility with C++-language programs and libraries.
3:15:53
Bubblegumdrop
Hah, watching this video is a kick. You went from Smalltalk to lisp. I'm doing the opposite! This is so cool. Thanks for all your hard work drmeister_.
3:21:53
holycow
no probs. i don't know what the rules are here but maybe announce it here and on reddit?
3:27:38
hayley
Bubblegumdrop: To misquote Steele, I am now trying to take Lisp programmers halfway to Newspeak.
3:29:51
hayley
Bubblegumdrop: Gilad Bracha in turn took Smalltalk programmers halfway to BETA and E.
3:30:52
Bubblegumdrop
Totally off topic for this channel. I've been studying Smalltalk. Currently looking at GT and Pharo.