libera/#commonlisp - IRC Chatlog
Search
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.
12:00:48
artchad
Oh, actually I can just quickload them, because quicklisp seems to use asdf:*central-registry*
12:01:22
artchad
I came up with thise solution. I just call this function whenever I want the downloaded projects to be visible.
12:02:40
artchad
Is there a smarter way of managing your local projects and downloaded projects separately?
12:14:39
artchad
Could you help me with that. I would love to have a nicer interface for scanimage. Currently I'm using shell scripts, which is kinda meh.
14:04:42
artchad
interesting is that asdf:*central-registry* doesn't include ~/.local/share/common-lisp/source nor ~/common-lisp by default.
14:06:38
Bike
the asdf central registry is only a backwards compatibility thing. you're supposed to use the newer config mechanism now, and that's what asdf uses for those directories probably
14:53:29
White_Flame
artchad: most people use quicklisp nowadays, and symlink their project trees from ~/quicklisp/local-projects/ to make them visible
14:54:09
White_Flame
(well most people use quicklisp. not that necessarily most people use its local-projects dir over asdf)
14:54:45
White_Flame
but it uses that filesystem artifact to maintain their default visibly loadable projects
14:58:05
artchad
it's a waste to time to try and figure out why something failed, just to realize that a system in local-projects contains a system with the same name, as the one pulled from quicklisp prior.
14:58:25
artchad
that's why I'm making sure all the things I clone go into a separate directory, which is not visible by default
14:58:55
artchad
only when I start a repl and explicitly want to play around with someone elses code, then I make sure quicklisp can find it.
15:00:02
frgo
Hi guys. I have been away a bit - so please excuse me jumping right to an issue I couldn't resolve for the last couple of days: c2ffi on ARM64. I am trying to build cl-sdl2 and it fails misrably on my NVIDIA Jetson Xavier NX (being an ARM64 6-core CPU). Anybody here with experience c2ffi on ARM64?
15:03:46
White_Flame
artchad: ah, ok. I have some loader scripts in my .sbclrc as well, for pulling in things with their own static libraries
15:06:30
frgo
If anyone wants to see the issue: https://gist.github.com/dg1sbg/2f997df6bd4183578aae24b02663bd73#file-c2ffi-failing-on-arm64-when-building-cl-sdl2
15:21:58
phoe
like, the real error seems to be in /usr/lib/llvm-12/lib/clang/12.0.0/include/arm_neon.h:1730:47 and not anything that includes that file
15:54:15
_death
frgo: I don't use this architecture, but vector operations table at https://clang.llvm.org/docs/LanguageExtensions.html seems to suggest that clang does not support C-style cast for neon vector types
15:57:26
SAL9000
phoe: regarding l-t-v and static-let ( https://github.com/phoe/articles/blob/main/2022-01-30-load-time-value/README.md ) -- could you fall back to implementing load-time-value via let-over-lambda in implementations where eval semantics != compile semantics?
15:58:35
phoe
SAL9000: I can't, the LET would need to be hoisted all the way up and above the LAMBDA
15:59:06
phoe
one way to fix it would be to make an external hashtable from some sorta symbols to values, but that would be kinda ugly
16:01:28
SAL9000
what if, at macroexpand time, (let ((v (make-thing))) (lambda () v)) and pass the return value of that into the macroexpansion?
16:02:37
_death
frgo: SDL includes this header in SDL_cpuinfo.h .. you can try to define SDL_DISABLE_ARM_NEON_H and see what happens
16:20:19
Bike
i don't think dumping functions works on any implementation. i would be interested if one could do it
16:20:42
phoe
again, you could try to (load-time-value (lambda () v)) to work around this problem, but, sike, we are using load-time-value
16:23:17
Bike
phoe: translating a runtime function object into a description of a function object is nontrivial
16:25:22
SAL9000
but hey at least we aren't in bizarro C++ land, where const doesn't always mean constant (i.e. const qualifier on pointers)
16:26:04
Bike
constants could also influence dumpability in weird ways. like, if you have (lambda () (if t 0 #.(non-externalizable-object))), whether that could hypothetically be dumped depends on how much optimization the compiler does.
16:30:01
scymtym
http://web.archive.org/web/20170331132917/http://www.discontinuity.info/~pkhuong/common-cold/ may be interesting in this context
16:47:20
Bike
yes. symbol-value is sort of orthogonal to whether a variable has been proclaimed/declared special.
16:56:28
jasom
You could use #. instead of load-time-value; that should only get evaluated at read time, right?
16:59:06
jasom
I was thinking #.(let ((x gensym)) (setf symbol-value x 0) x) and then using the result in a macrolet
16:59:50
phoe
the symbol-value is only set in the compiler environment, it won't get dumped into the FASL
17:02:39
borodust
frgo: if you are fine with sdl2 bindings only and don't care about c2ffi working you can steal bindings from https://github.com/borodust/aw-sdl/blob/master/bindings/aarch64-linux-android.lisp
17:03:21
borodust
frgo: generally speaking though, most of SDL2 is fairly portable, so you can take any bindings and use them
17:05:03
borodust
so, what i mean, you can take cl-sdl2, rename one of the .json (linux one to be more or less safe) to the architecture of yours and be done with it
17:08:46
frgo
So, for the record: _death 's advice worked. I will compare results with the android output.
17:11:48
borodust
ahh, i guess, i need to read better next time, i thought there's a problem with c2ffi
17:34:04
jasom
biggest downside is you can't declare the type of it; some magic with cl:the might let you get around it
17:40:26
sm2n
alpine doesn't make all the dependencies for ecl necessary for building as necessary dependencies by default
17:41:56
sm2n
(Also, the only reason I used ecl is because I was running it on a very old raspberry pi short on ram, feel free to try another implementation, everything but the build scripts should be portable, and I developed on sbcl)