libera/#commonlisp - IRC Chatlog
Search
18:00:35
jcowan
phoe: You can write a very short function to do "1st"-style formatting for you: take the number mod 10, then convert the number to a string. if the modulo result is {1,2,3}, append {st,nd,rd}, otherwise append "th'.
18:03:19
jcowan
and 12th and 13th, yes. So it may be simpler to work with mod 100 and a vector of strings.
18:24:41
pjb
(format nil "~{~D~:*~[th~;st~;nd~;rd~:;th~]~^, ~}" (iota 10)) #| --> "0th, 1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th" |#
18:26:26
pjb
(format nil "~:{~D~[th~;st~;nd~;rd~:;th~], ~}" (mapcar (lambda (n) (list n (if (< 10 n 20) 5 (mod n 10)))) (iota 35))) #| --> "0th, 1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th, 11th, 12th, 13th, 14th, 15th, 16th, 17th, 18th, 19th, 20th, 21st, 22nd, 23rd, 24th, 25th, 26th, 27th, 28th, 29th, 30th, 31st, 32nd, 33rd, 34th, " |#
19:45:14
pjb
(defvar xyz t "the tomato symbol") (documentation xyz 'variable) ; implementation specific.
21:22:58
drmeister
Does anyone remember what bordeaux threads :initial-bindings argument looks like? The updated documentation doesn't describe it.
22:23:10
drmeister
I kind of remember the Bordeaux threads documentation being more complete. It looks like it was spruced up, which I appreciate - but it's not very complete. (grumble grumble)
22:24:35
drmeister
How does one kill a thread? I remember that it was difficult (impossible?) to implement destroy-thread because signals and C++ exception handling don't talk to each other properly.
22:25:47
drmeister
Do implementations put something in to poll if a signal has been sent to a thread? I'm off my threaded programming game.
22:27:27
drmeister
And I freakin' implemented clasp's Bordeaux threads support - I should be answering the questions.
22:29:28
MichaelRaskin
But if you use what POSIX considers threads inside the same process, you cannot send a signal to a thread, it is handled by a process
22:29:56
drmeister
Ok - one less thing to deal with. What I do know is that a signal handler can set a global flag and a thread can poll that flag and then decide what to do with it.
22:31:27
drmeister
In Bordeaux threads there's destroy-thread. https://sionescu.github.io/bordeaux-threads/threads/destroy-thread/
22:37:01
yitzi
drmeister: Answered your bordeaux-threads question over in chat. I'll restate: those docs are for v2 and the v1 docs appear gone. Here is an archived copy. https://web.archive.org/web/20190921043635/http://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation
22:38:06
drmeister
MichaelRaskin: Thanks - I'm flailing a bit trying to figure out how this stuff is supposed to work and looking at my implementation to figure out what I did when I better understood how this works. I see what I did now. I implemented the underlying code of destroy-thread so that it registers an interrupt with the thread you want to destroy and when that checks its list of pending interrupts it unwinds the stack and shuts
22:39:15
drmeister
yitzi: Ah - so I'm not going crazy. I thought I remembered the documentation being more complete.
22:40:03
drmeister
And there's a v2 for bordeaux threads - that's welcome - I guess. It would be nice to keep a link to the old documentation in the meantime while the new documentation is populated with "TODO"
22:40:09
yitzi
Yeah, it's kind of irritating. I just downloaded a copy on my machine cause I am always needing them.
22:42:44
drmeister
Ok, thanks MichaelRaskin - sorry to sound a little clueless. It's been a few years since I implemented clasp's low level multithreading code and I was a little thrown off by the change in the state of the BT documentation.
23:00:09
drmeister
https://usercontent.irccloud-cdn.com/file/GONNByVH/Screen%20Recording%202021-06-12%20at%206.57.52%20PM.mov
23:55:35
pjb
drmeister: I use (list-threads) and (kill-thread) ;-) in https://github.com/informatimago/lisp/blob/master/tools/thread.lisp
1:57:55
drmeister
pjb: What does that bring to the table? It's built on bordeaux thread destroy-thread?
2:31:44
pjb
drmeister: indeed. They're repl "commands", ie, functions intended to be called interactively from the REPL. list-threads displays the list of threads. kill-thread calls list-threads, and let the user select a thread to kill it.
2:32:16
pjb
drmeister: this way, I don't have to remember how one kills a thread (when all I want to do is to kill blocked threads I forked from slime).
2:34:04
pjb
drmeister: of course, when you run slime/swank, there's also M-x slime-list-threads RET and k (slime-thread-kill) …
2:37:25
pjb
drmeister: sometimes, a what a function brings, is only its name. You didn't ask "How does one destroy a thread?", but "How does one kill a thread?", as any normal person woul do. So naturally, what is needed is a kill-thread function, not a destroy-thread function. Try (apropos "KILL") !
2:38:33
pjb
drmeister: that's also what my tools/quicklisp.lisp provides, with a bunch of (quick-…) quicklisp commands. Most are just renaming or thin layers on quicklisp stuff. Some people have really twisted naming minds…
3:36:10
drmeister
I have multiple of these workers running in parallel and I'm monitoring them and occasionally I have to stop them and make changes and then restart them.