freenode/#lisp - IRC Chatlog
Search
22:34:56
nihil
though I was thinking of something that's probably not directly relevant to CL but program design in general...
22:41:03
save-lisp-or-die
what issues are you bumping up against? Or are you just sort of... feeling uncertain?
22:42:37
nihil
I guess it's a question of style, whether it makes sense to make a class to save in slot definitions
22:44:17
nihil
but then I also thought "what about elements that won't require a name and a description?"
22:45:28
save-lisp-or-die
My personal taste is to not give in to the temptation of "factoring out" classes unless that class will actually serve a different role in the running application.
22:45:53
ane
uh, if I have a cffi function like this: void foobar(size_t *blah);, which in C I would call like this size_t blah; foobar(&blah); ... how would I do that using cffi? something like (with-foreign-object (blah :uint) (let ((ptr (foreign-alloc :uint))) (setf (mem-aref ptr :uint) blah) (foreign-funcall "foobar" :pointer ptr :void))
22:45:57
save-lisp-or-die
But using "mix -ins" for augmenting "main classes" is a useful strategy for some application domains.
22:46:40
save-lisp-or-die
nihil without seeing your application, its hard to say what you should do. I see your concern. I say go with your gut and come back when things get hairy
22:47:30
phoe
but then again, what exactly should your set of superclasses be depends on your application logic
22:48:23
phoe
and that's a question of what you want your inheritance graph to look like, how do you want to apply the Liskov substitution principle, and which classes of your graph are meant to be protocol classes (not meant to be instantiated directly).
22:48:53
save-lisp-or-die
nihil like. I wrote a (fairly crappy, just-for-friends) matrix bot framework a while back. It used a mixin approach. I made a main client - then each bot had "components" that I could mix in to customize the behavior of the particular bot in question.
22:49:16
save-lisp-or-die
I could even install new behaviors in old bots (while they were running) by adding in a new class to the list of superclasses for the bot in question.
22:49:42
save-lisp-or-die
so. It can be a good idea, but it can also get icky. Like people are suggesting. It depends on the specifics of your application.
22:51:32
phoe
if some place in your code accepts something of class X, it should also accept all subclasses of X
22:57:40
save-lisp-or-die
Gnuxie[m] not really intended for human consumption. Just something that a friend and I were using last summer to play around.
23:14:52
Gnuxie[m]
save-lisp-or-die: that's quite nice, I have some ideas in the pipeline to make writing this sort of thing easier in the future, I've not really talked about them too much publicly
23:16:18
Gnuxie[m]
if you looked at cl-matrix, you'll notice there's a sort of generator, but i was a bit naive and didn't generalize it at the time but I did start fixing that https://gitlab.com/Gnuxie/rest-api-description
23:17:05
Gnuxie[m]
some people have wrote generators for swagger apis but the problem with that is that if the thing you're trying to wrap is not expressed in swagger than you're sorta stuck
23:18:04
Gnuxie[m]
so i started trying to make a model for it all in CLOS, but it's a bit of a big task tbh, hopefully you'd be able to do things for webservers from this library too
23:19:20
Gnuxie[m]
https://gitlab.com/Gnuxie/invidious-api-description/-/blob/master/description.lisp here's an example of something I made that uses it
4:13:22
drmeister
beach: I'm using the call-history for dispatching as clasp boots up - it works pretty well. It's faster than the cache and mutex that I stole from ECL.
4:14:40
drmeister
I didn't think an alist would be fast enough - but it was. So an alist updated with CAS is faster than a fancy cache with a mutex.