libera/#commonlisp - IRC Chatlog
Search
17:47:47
pjb
well, airbus at least uses a Coq-validated C compiler: https://github.com/AbsInt/CompCert
17:48:44
pjb
Perhaps one day we'll have a formal specification of CL, and a Coq validated CL compiler?
20:22:50
coat
I am trying to make a small wrapper that can push a cons to alist. (defun add-key-value (key value alist) (push (cons key value) alist)) (defparameter *a* nil) (add-key-value "foo" "bar" *a*). But *a* remains as NIL after I execute this.
20:28:36
pjb
(define-modify-macro aconsf (key value) (lambda (alist key value) (acons key value alist))) (let ((alist '((a . 1) (b . 2)))) (aconsf alist 'c 3) alist) #| --> ((c . 3) (a . 1) (b . 2)) |#
20:29:13
pjb
coat: unfortunately, a lot of CL functions don't have their parameters in the right order for define-modify-macro… So you need to swap them, eg. with that lambda.
20:30:03
coat
pjb: Okay. Curious about another thing. Is creating a list and pushing cons to it not a popular way? Do people usually use acons instead?
20:30:27
pjb
(let ((alist '((a . 1) (b . 2)))) (let ((alist (acons 'c 3 alist))) alist)) #| --> ((c . 3) (a . 1) (b . 2)) |#
23:55:49
aeth
the way lists go, a push is a cons, so how can it not do that? there is no list, only cons pairs
23:56:36
aeth
pushes could only directly modify if the list data structure was actually one more pointer, a pointer to the first cons pair (or if it added to the end and was O(n))
23:57:47
moon-child
it could also add to the beginning destructively, moving down the elements of each successive cons cell. Still O(n) though
0:07:54
aeth
if I have a (with-open-file (stream #P"test42.txt" :direction :output :if-exists :append :if-does-not-exist :create) ...) for quite a few streams (42 would not be too many, since I'm talking about IRC logging), when do I hit limits?
0:09:17
moon-child
on modern unix, a file descriptor is a signed 32-bit integer between 0 and 2^31-1 or so
0:09:47
White_Flame
there are limits beyond running out of descriptors though. Don't recall where they are unfortunately
0:11:19
aeth
Very naive is just leave all of the streams open for all of the files and just keep appending, with periodic FORCE-OUTPUT. Less naive is to only leave it open for very active channels (e.g. here), while not leaving it open for very inactive channels (e.g. my own project channels) until necessary.
0:11:33
aeth
However, guessing "inactive" incorrectly is going to mean opening/closing a lot of files
0:12:03
aeth
I suppose it kind of has to guess it, though, once queries are taken into account, but those can just be special cased to time out, unlike channels, which are probably going to have some joins/parts/quits/nicks at the very least
0:12:59
aeth
I could also buffer it for an arbitrary amount of time, but the longer the buffer period is, the more likely that a system failure loses a lot of logs.
0:14:53
aeth
I guess with-open-file isn't the way to go since (1) there will be a lot of files and (2) files need to be able to "time out" if inactive until active again (at the very least, for queries)
0:43:24
pjb
aeth: note: the programs use already a good number of the available file descriptors for the shared libraries etc.
0:48:13
aeth
you can "easily" be in a few hundred channels (I'm constantly in anywhere from 16 to 35), which is already pushing into the limits assuming that the machine isn't being used solely for IRC
0:49:18
aeth
And yet, every single channel might be active if it logs joins/parts/quits. Most trivially, if you ping out and reconnect before your connection gets the ping timeout, since that ping out will show up in every channel you (re)join.
0:51:54
phadthai
shared lib fd are usually closed after reading+mapping, for irc there's the standard 3 (stdin/stdout/stderr) plus one socket per network/server, possibly a few for the display via curses etc... but yes if every channel is logged depending on client it may also mean one fd per channel. As for the 1024, it's probably the process limit more than the total system one
0:52:59
moon-child
you can split up your thing into a bunch of different processes, where each one only has a file or two open
0:54:18
aeth
White_Flame: for one thing, idk the no-power failure state of sqlite, while I know the no-power failure state of appending to a bunch of log files
0:55:22
aeth
also, IRC is pretty much designed for appending to plain text files since it's a text-and-line oriented protocol with no editing/deletion
0:55:53
White_Flame
quassel logs everything to sqlite, and I've not had a problem with recovering from system crashes and such
0:56:03
aeth
Afaik, some people lost their logs when they moved from freenode to libera because it wasn't just plain text files.
0:57:17
aeth
you'd only need a database to cache unsent messages in a bouncer (not client)... more for the reliability guarantees than anything else
0:57:43
White_Flame
also, since irc logs are often-written, seldom-read, you could just do a singular linear log, and grep for individual channels later
0:58:59
aeth
White_Flame: I mean, yes, that's what I do to display my bot's messages in SLIME (it's running in a background thread).
0:59:58
aeth
White_Flame: However, the stateless all-in-one-place log has a few issues. In particular, QUIT and NICK (and perhaps a few others) are global in IRC, which makes it unclear in which channels those are actually taking place.
1:01:56
aeth
Also it becomes unreadable without grep if I was in a bunch of channels, with one way noisier than the others. For instance, my SLIME is basically just a log of #lispcafe because cond is present there, but it is also present in other, quieter channels
1:11:16
waleee
what would be the likely reason for someones (not me) M-x slime-connect to fail with "Can't locate module: SWANK-IO-PACKAGE::SWANK-INDENTATION"?
3:22:34
lisp123
I want to add keys to slot-a in class B but not class A, i.e. in B it should look like (slot-a :accessor :get-slot-a :initform nil :MY-CUSTOM-KEY key-value) whereas in Class A it should be the same but without my-custom-key
3:24:01
lisp123
loke[m]: yes exactly, class b has a metaclass, and class a is the generic form of it without a metaclass
3:26:28
beach
lisp123: Your example is very strange with a GET- prefix and an access that is named with a keyword.
3:28:11
lisp123
beach - I did get instead of b-slot-a since I want the same accessor function across the two classes
3:29:25
lisp123
I want to use BKNR datastore to store objects (it uses a metaclass + requires some keys) but want a generic version of the class to also play around with when I don't want it ta automatically go to the datastore
3:29:26
loke[m]
lisp123: You are aware of the fact that accessor functions are independent from classes, right?
3:30:11
lisp123
yes, but if I name the accessor function class-name-slot-name, then it wouldn't work for 2 classes, since they have different class names
3:31:05
beach
lisp123: The name of the access or totally unrelated to the class names. You can name it whatever you want.
3:35:39
beach
Well, I haven't thought of a solution to your problem, but 1. The prefix GET- seems like an import from languages that don't have SETF and should be avoided. 2. The accessor should be named after some intrinsic property that you want to read or write, whereas a slot is an implementation detail the name of which is usually uninteresting.
3:42:18
beach
So, do I understand you correctly that you want to use the custom initarg in a slot option when you define class B using DEFCLASS, but you don't want it to be possible when you define class A using DEFCLASS?
3:43:49
lisp123
Yes (p.s. 'slot' in 'slot-name' was just for this example, now that I read your comment a second time - I don't use the word slot in my slot names. I haven't used GET so far, but having a think now on how to avoid it as much as possible)
3:44:38
lisp123
Also, Class B is a metaclass of bknr.datastore:persistent-class - whereas Class A is not - that's the main distinction
3:45:27
beach
Well, example: In Common Lisp it is more convenient to say (name <instance>) and (setf (name <instance>) <value>).
3:47:06
lisp123
Yeah I do the same style as you do it, but it's not a super strong view I have. For example, with database related functions I'm currently liking adding the verbs 'insert' 'create' etc in because it distinguishes them to some degree from a vanilla CL form
3:51:31
beach
lisp123: My immediate reaction is that you may need to intervene in some MOP stuff like COMPUTE-EFFECTIVE-SLOT-DEFINITION.
3:53:42
beach
Your direct slot definition classes are different in A and B since A does not have a special metaclass, but B does. So the metaclass of B has a different DIRECT-SLOT-DEFINITION-CLASS.
3:55:28
beach
So I presume COMPUTE-EFFECTIVE-SLOT-DEFINITION is defined by the bknr library so that it can handle the custom DIRECT-SLOT-DEFINITION-CLASS, and it may very well ask for the value of a slot in the direct slot-definition object that is not present in the direct slot from A.