freenode/#lisp - IRC Chatlog
Search
4:52:28
pillton
CFFI works from ECL. CFFI allows you to load a shared object library and invoke functions inside it.
4:56:20
pillton
black_13: I have used CFFI on windows to invoke foreign functions. The only thing that I haven't done is tried cffi:load-foreign-library on windows.
5:00:48
pillton
The user manual is there. Start here https://common-lisp.net/project/cffi/manual/html_node/defcfun.html#defcfun
5:36:34
duncan_bayne
Possibly stupid question: is there an idiomatic way of accessing data in lists that are neither alists nor plists? Specifically, in the form: '(("Name" ("first" "Duncan" "last" "Bayne")) ("Phone" ("area" "01" "number" "123456")))
5:42:18
White_Flame
you can generally use FIND for custom cases, but many of these functions have :key or :test style optional parameters to configure what you want
5:45:50
White_Flame
the Alexandria library has WHEN-LET* which allows you to cascade multiple forms, continuing if each step yields non-NIL
5:46:20
duncan_bayne
White_Flame: thanks - that was the sanity-check I needed, I'm new to CL and was afraid I was missing something. Happy to roll my own here
5:47:32
White_Flame
yes, for ("Name" ("first" "Duncan" "last" "Bayne")), the CAR is "Name" and the CDR is (("first" "Duncan" "last" "Bayne"))
5:48:10
White_Flame
also, to be more idiomatic, you should probably use symbols, like (:first "Duncan" :last "Bayne") or something
5:51:11
duncan_bayne
Right I'll head off to #clnoobs, because my attempts to use a-list functions on that structure have so far been failures
5:55:53
duncan_bayne
beach: Sorry, didn't mean to be ignoring you, have been looking into your example
5:56:10
pillton
Maybe lisp is like coffee baristas. You need to find the really old and grumpy baristas to get a good coffee.
5:57:18
jackdaniel
black_13: like any other foreign function. I'd use cffi, but ffi interfaces are documented too (ECL's FFI has an API defined in UFFI)
6:06:18
duncan_bayne
beach: Yep, (assoc "Phone" the-list :test #'string-equal) => ("Phone" ("area" "01" "number" "123456"))
6:09:26
duncan_bayne
White_Flame: yes; this list is being returned by a library that is deserializing it from JSON
6:10:20
White_Flame
the library might also have transforms that it can apply to object keys, where you could intern the strings into symbols, preferrably changing their case to Lisp default
6:12:17
duncan_bayne
flip214: yes, because the assoc example provided by beach returns a list of strings, which doesn't play nice with getf
6:22:53
duncan_bayne
Yeah, that's what I mean; getf is no help with the data structure returned by the library, because (eq "foo" "foo") => NIL
7:16:42
flip214
If I have a JAR file created via ABCL, is there already something to decompile that back to CL sources?
7:29:33
White_Flame
unless the source code is literally included, reversing the process is not really programmatically reliable
7:30:53
flip214
I also have a few __loader__._ files -- these include the function names and docstrings in many (SYSTEM:FSET ...) calls
7:31:22
easye
flip214: How'd you create the JAR? If via ASDF-JAR there should still be Lisp source along with the fasls.
7:34:33
knobo
Could I get some feedback on my first package using cffi, please? https://github.com/knobo/cl-sysinfo
7:48:02
shka
usually, i would suggest to signal error instead of returning nil in scenarios like this
7:49:03
shka
if you remove redundant functions, you will be left with just one function to document :-)
7:51:19
knobo
shka: unless I also keep the decode-loads funtion. But maybe I should not decode the loads.
8:10:22
knobo
Maybe I could define a variable that keeps a c-sysinfo struc, and reuse it in the function call.
12:15:00
jackdaniel
if you are curious about ECL's FFI implementation, then you can read about it here: https://common-lisp.net/project/ecl/static/ecldoc/Extensions.html#Foreign-Function-Interface
12:15:46
jackdaniel
generally it follows UFFI API, which reference manual is included here: https://common-lisp.net/project/ecl/static/manual/pt04.html
12:17:58
black_13
if had a function "void foo(void);" defined in a .dll and had normal exports and this was built using visual studio how would i call
12:19:21
jackdaniel
first you load the library (see cffi's doc) then you call defcfun (see cffi doc)
12:19:48
jackdaniel
(defcfun "foo" :void) ; should create function foo which could be called like CL-REPL> (foo)
12:28:30
jackdaniel
while I understand that reading documentation may be a demanding task for various reason, that's why documentation is written - so a person who wrote it doesn't have to explain things over and over again
12:52:24
dlowe
people come to help on IRC because a) they want to know something they can't find in the manual, b) they don't want to read the manual, c) they need emotional support while trying to use your thing