libera/#commonlisp - IRC Chatlog
Search
1:13:59
mrcom
What's the appropriate channel on Liberia for navel-gazing "how does Lisp compare and contrast with other languages"?
4:06:28
asarch
I have this list: (defparameter *the-list* '((:id 343 :name "foo" :date 3852308297) (:id 212 :name "bar" :date 3852308297) (:id 583 :name "baz" :date 3852308297) …)
4:11:40
beach
asarch: Since you have two lists, I think you may have to use INTERSECTION with some appropriate :KEY and :TEST arguments.
4:12:45
moon-child
beach: I think intersection does not guarantee which of its inputs it uses to make the output
4:13:00
moon-child
'The result list may share cells with, or be eq to, either list-1 or list-2 if appropriate'
4:56:18
mfiano
Bike: Reading the spec for *-D-C, it doesn't seem to matter which parameter I specialize in a :AFTER method, PREVIOUS, CURRENT, or both. Is this correct?
4:58:51
Bike
if you care about updates from one class specifically to another class you need to specialize both. if you care about updates from one class to anything you only specialize on that.
4:59:39
mfiano
I thought one is just a copy of the other, a they would both always be instances of the same direct class
5:00:14
Bike
No, previous is the copy, and it is a direct instance of whatever class the instance being changed used to have
5:05:57
mfiano
Bike: Unfortunately, this seems to have the same bad behavior as SHARED-INITIALIZE for me.
5:09:20
mfiano
The method in the above gist, should _only_ SETF those slot values to the supplied initargs when CHANGE-CLASS's NEW-CLASS-NAME argument matches that of the class I'm specializing on. In the printout, the CAR of the list in the printed represenation is that class name.
5:10:01
mfiano
As you can see, the second invocation, called CHANGE-CLASS with 'SRGB as the new-class-name. I want to ensure that this method is not invoked then.
5:12:03
Bike
okay, so the mop stuff is not helping clarity here. im wondering if there isn't something weird going on such as the actual color-storage3 class object being used both times but its list of mixins changing.
5:14:45
mfiano
c0/c1/c2 initargs update the instance correctly when the first mixin is added with #'MIX, but after the second one, the instance has been reset to the default state.
5:14:57
Bike
like, what you're describing here is your implementation not dispatching correctly, which is a deep enough problem that it seems unlikely
5:21:48
mfiano
The problem is with the mixin system. I see the issue. Trying to find a solution is hard.
5:24:28
mfiano
Which makes sense. I want to change the class to be an anonymous class containing all the previous classes as superclasses, plus the additional new class.
6:43:06
mfiano
Hmm, for once I don't know if anything built-in can help me here, and I don't have any good ideas for how to do the plumbing myself.
7:07:00
moon-child
kathe: I do not know. I expect you would be more likely to get a response in a forum dedicated to X. I will note: the 'fn' key is usually handled in firmware or similar
7:22:40
mrcom
mfiano: update-instance-for-different-class is going to match as long as current is color-storage3 **or a subtype**, right?
7:24:08
mfiano
Yes. There is a bit of anonymous class MOP stuff going on that doesn't make what is going on very obvious, but yes.
7:25:03
mfiano
That isn't valid syntax. EQL value must be quoted, and I'm specifically looking for a class, not a value.
7:30:03
mfiano
I sometimes use Sharpsign number to refer to values here, but that's besides the point.
7:35:21
mfiano
The problem here is that the new-class argument passed to CHANGE-CLASS is always going to be a an anonymous class whose direct superclasses include the previous class plus one more additional class. I would have to disassemble the direct superclass list to see which class was just added.
7:36:03
mfiano
That information is not provided explicitly to UPDATE-INSTANCE-FOR-DIFFERENT-CLASS as in normal circumstances.
7:36:58
mfiano
Basically this mixin system is creating (and memoizing when new) anonymous classes containing a list of superclasses.
7:38:02
attila_lendvai
i wonder why i don't see many users of cffi/c2ffi... are people aware of how easy it is to generate FFI's with those tools?
7:39:18
mfiano
I would assume the answer has to do with the ultimate goal of a Lisp OS, or a pure Lisp stack for those less ambitious people.
7:40:05
Shinmera
I've written a lot of wrappers and I don't like the dependencies and style of code these autogenerators produce, so I just write them by hand.
7:40:21
phoe
attila_lendvai: oh? what are they using as alternatives to cffi? implementation-specific stuff?
7:41:15
attila_lendvai
phoe, cffi/c2ffi is a subsystem of cffi. this kinda answers my question... :) people are not aware of it
7:43:02
attila_lendvai
Shinmera, cffi/c2ffi generates pretty much the exact same names as they are in the C namespace (it generates into an empty package, and even retains the upper/lower case of symbols).
7:43:18
attila_lendvai
Shinmera, then you can add a foo/fancy package that lispifies it as you see fit
7:43:57
attila_lendvai
phoe, yes, like cl-autowrap, but c2ffi is using clang as a lib to parse the code and extract the metadata for the FFI
7:43:59
mfiano
mrcom: There's a few solutions, that being one of them. A couple others are, checking the supplied-p argument for the initargs supplied, and also doing a doing some set theoretical operations on the direct superclass list to see exactly which class was added.
7:46:10
attila_lendvai
phoe, didn't know about claw, it looks like something very similar. sadly, cffi/c2ffi predates it by several years, feels like duplicate effort.
7:46:38
mrcom
Custom combination that bases match against class equality rather than subtype matching
7:47:56
attila_lendvai
Shinmera, not sure, i never looked into wrapping C++ libs. it does deal with #define macros properly.
7:50:48
mrcom
Random question: Anybody familiar with J.A.R Williams? My wife knew a "Dr. JAR", but as an artist. Same person?
7:51:20
attila_lendvai
whatever can be done for wrapping C++, c2ffi and the cffi/c2ffi infrastructure is fully qualified to be a comfortable framework for it.
7:54:11
Shinmera
Idunno man I feel like if someone embarks on the journey of writing something like claw they'd have already checked c2ffi and deemed it not usable enough.
7:57:43
attila_lendvai
Shinmera, your imagination is rather constrained then. claw seems to be a fun project (looks like it does the c2ffi part also in CL). i can easily see myself embarking on that project 20 years ago, regardless of what else is available.
8:22:26
attila_lendvai
any ideas what else the CFFI readme should mention besides claw and cl-autowrap?
8:27:25
attila_lendvai
considering that each of us only has a limited time on earth, that is so much not true...
8:28:09
attila_lendvai
let alone when a project has no specification, and the only "API" is a binary blob...
8:35:06
mfiano
As Lisp programmers, we are paving the way for future generations to stand on our shoulders. Let's leave the footguns and bitrot where they belong.
8:49:19
borodust
phoe: in the beginning of times, :claw was using c2ffi and actually started as a fork of cl-autowrap with https://github.com/rpav/cl-autowrap/pull/83 merged (it was named bodge-autowrap at the time)
8:49:40
borodust
phoe: here i explain my reasoning switching to different solution: https://borodust.org/2020/06/12/claw-honing/#origins
8:52:14
borodust
once i was deep in wrapping C++, another feature bubbled up that required patching (or extending, i should say) of llvm/clang so i ended up with custom llvm/clang xD
8:53:00
borodust
but i dream someday i push that patch upstream, it's straightforward, just exposes more of C++ features through libclang C interface
8:53:41
borodust
attila_lendvai: my another dream is writing :claw documentation :D it's too early to mention or promote it anywhere
8:56:37
borodust
atm i'm working on super secret project that showcases in a useful way what can be done with alien-works (framework based on C/C++ foundation glued to lisp with :claw), then i'll go back to :claw release plans
9:00:07
borodust
for historians, previous claw repository is here: https://github.com/borodust/claw-legacy there you can see the rich history it has that goes back to cl-autowrap and c2ffi ;p
9:00:29
attila_lendvai
borodust, does that mean that i shouldn't mention claw in the CFFI readme? or with a word that it's beta?
9:18:02
lisp123w
phoe: Your suggestion on LW HUG is interesting. The downside is if things break on LW, people will invariably complain to LW and they may not want to deal with that
9:18:48
phoe
lisp123w: break on LW, what do you mean? if a library breaks on LW, then the first question is whether the library itself is OK
9:18:59
phoe
and if the library itself is OK, then the question is whether the LW CI edition is used correctly
9:19:16
lisp123w
They are already relatively hands off because they have limited time and spending on paid projects (I dare not ask them for help)
9:19:38
phoe
yes, I can imagine - that's why I asked about feasibility from the business point of view
9:19:41
lisp123w
Break in the sense, there is something in LW that isn't ANSI compliant / different to how other implementatiosn do it
9:20:07
phoe
well, they can mark it as WONTFIX in the worst case, and then compatibility libraries can try to work around this quirk
9:20:25
phoe
the real question is about discovering these quirks in the first place in LW as it is right now
9:22:22
lisp123w
It would be net beneficial for LW users to have better tested libraries for their implementation
9:23:25
lisp123w
unrelated, but we should do a crowd funding to get Clozure Associates to build a Cocoa Backend for CLIM...
9:24:23
lisp123w
(I think Clozure Associates did most of the GUI work for LW for Mac, they are the experts in that area)
9:26:49
phoe
lisp123w: that could be done, I guess - try contacting them about the idea and open a fundraiser somewhere if they're interested
9:46:59
phoe
minor announcement: CLISP installable via `ros install clisp-head` has working and somewhat tested package-local nicknames now
9:50:14
lisp123w
I reached out to Clozure, expect it to way too expensive (if they are interested at all), but you never know if you never ask :)
10:01:08
kathe
phoe: have you had time to give serious thought to a mop+clos book after you're through with the current one?
10:07:25
blacked
In defining like some default parameter for keyed function, why we give like this `((:c 10))`?
10:07:39
blacked
Like for this (defun foo (&key a b ((:c 10))) (format nil ": ~d\n :~d\n :~d " a b c) )
10:09:28
kathe
lisp123w: reason to ask about 'paip' is that's it's so huge and requires some knowledge of calculus (which i've forgotten).
10:09:59
phoe
blacked: &key ((foo bar)) means a different thing - it separates the keyword parameter that becomes the API from the variable name that is used internally
10:12:03
phoe
(&key (c 42 c-provided-p)) adds another boolean variable that is true only if :C is provided, and false otherwise
10:12:26
lisp123w
kathe: I'm reading PAIP now as my fingers hurt and I need to take a break. I think its a luxury in 2022, so would recommend working on actual projects & reading PCL if you need particular details on CL
10:13:08
lisp123w
One learns more from their own mistakes, so best not get caught in a 'paralysis by analysis' trap and get coding :)
10:14:03
phoe
blacked: in all of the above cases, C is both the variable name and the source for the name of the generated keyword, :C
10:14:39
phoe
and you can separate these by wrapping C in another pair of parenthesis and providing both the symbol that will name the keyword argument and the variable that's used internally
10:15:33
phoe
but you can do (&key ((:some-really-long-keyword c) ...)) to have a long API keyword and a shorter variable name for use in the function body
10:18:51
lisp123w
kathe: As an example, PAIP introduced the concept of data driven programming in Chapter 2, where the rules of an algorithm are separated out away from hardcoded conditional statements like COND and stored as data. A great idea, but one that I uncovered myself from trial and error so when I read it, it makes much more sense / sticks with me longer as I have gone through the pain of changing hardcoded functions in the past.
10:21:30
lisp123w
Ah he left. Was going to say: 'Dang' from Hacker News had a great quote, which I paraphrase: There's a natural balance between simple, ugly code and elegant, well abstracted code - start off by writing whatever comes to mind, and as you start repeating yourself, you will naturally start abstracting away, coming up with a better approach
10:22:10
lisp123w
I find that helped me a lot, because CL can have too much expressivity at times so one gets stuck trying to find the perfect solution. I'll shut up now :)
10:25:55
blacked
It feels weird in prefix notation. 😁 like i've to think from backward, unlike other languages
10:26:55
blacked
for eg (when (> (* i j) n).......) , first think what to compare , what value to multiply , what value to use....
10:30:35
phoe
also don't be scared of using lexical variables, even with names longer than one letter - Lisp code tends to be short even with that
10:31:33
splittist_
and putting the operator first allows multiple operands (* one-number another-number yet -another-number-without-repeating-the-operator)
10:31:48
phoe
the first difference you'll see compared to C++/Java/similar OOP systems is that classes don't have methods, generic functions have methods
10:34:21
phoe
blacked: sure; this channel can get busy at times, #clschool is a good place to ask more basic questions all the time though
11:35:33
artchad
borodust, I found a neat way to separate my own project, from projects I've pulled from the internet.
11:37:02
artchad
I just symlinked ~/Common-Lisp to ~/.local/share/common-lisp/source . There I put all the downloaded projects, which I load via asdf. In ~/quicklisp/localprojects I'll keep my own personal projects.