freenode/#lisp - IRC Chatlog
Search
2:28:06
no-defun-allowed
If you want to argue that, the threading implementation in SBCL could be broken too. And then you'd have to fix up all your code to work on another implementation.
2:28:06
nij
I should only say that it's tested and designed for sbcl.. it might behave unexpectedly for other impls.
2:30:48
nij
Is there any system-level timer abstraction? For sbcl we have its timer.. but while sb-threads are abstracted by bd-threads, sb-timers do not seem to be.
2:31:28
no-defun-allowed
Of course SB-THREAD would only work on SBCL, but (as I understand it) the Bordeaux thread protocol is derived from B.2 and B.3 of the CLIM specification (Multi-processing and Locks respectively).
2:32:26
nij
Bike, does trivial-timer call system timer? Or it's an abstraction over bd-threads? Based on its dependency, I don't see how it calls system timers.
2:32:37
no-defun-allowed
I recall that handled ERROR strangely on Clozure, because it would fall back to creating a new thread which has none of the condition handlers set up.
2:35:59
no-defun-allowed
nij: It uses SBCL's timers on SBCL, but falls back to a portable thread implementation.
2:36:38
nij
Hmm.. for common lisp to "grow", we cannot alter the standard (ie those described by CLHS). Instead, we should implement them in new implementations. But then after a period of time, someone should come out and unify them, like bd-threads for threads.. right?
2:37:25
nij
no-defun-allowed: If trivial-timer is portable, then what timers does it call on other implementations?
2:39:02
nij
Oh.. so on sbcl it's sbcl's.. but on other implementations it abstracts over threads to make a timer.
2:44:36
nij
Hmm.. suppose I have a function (lambda () ...), how do I call it with all outputs redirected to some file?
2:46:42
no-defun-allowed
(with-open-file (*standard-output* pathname :direction :output ...) (funcall function))
2:58:42
Bike
of course if you output to some other stream that won't be redirected, but *standard-output* is the default output stream
3:23:55
muyinliu_
cl-disruptor, a high performance inter-thread messaging library, a port of LMAX Disruptor in Common Lisp, https://github.com/muyinliu/cl-disruptor
6:10:21
beach
Today I'll try to figure out whether the problems with my sound have to do with the microphone or with OBS.
6:57:41
beach
phoe: There is nothing wrong with my microphone. I just used Audacity to record my voice and the sound is quite good. So the problem is with OBS then.
7:01:00
easye
Morning all. Is there a pure ANSI CL library someone might recommend to convert JSON to YAML?
7:22:03
easye
MichaelRaskin: moments ago I just learned this from p_l Still digesting the various libraries.
7:22:34
easye
My ultimate need is a JSON Schema validator in pure ANSI that works well for recursively defined schemas.
7:25:13
easye
What I mean by ANSI CL is sort of a shorthand for saying "portable across contemporary ANSI CL implementations)
7:25:38
easye
Lycurgus: the full twitch stream is available, for which you have to seek to the right spot.
7:26:04
easye
The ad-hoc ELS tech crew will be editing it into bite-sized YouTube chunks as time permits.
8:07:55
asarch
How would you remove entirely a SBCL that has been compiled/installed using the tarball from the project site?
9:57:23
Shinmera
Our first Lisp game is now available for purchase on Steam! https://store.steampowered.com/app/1605720/Eternia_Pet_Whisperer/?beta=0
10:13:54
nij
Hello! I hope to launch a thread that should run indefinitely. It doesn't seem that there would be an unhandled case. But no one can be 100% on this, I think. So, what should I do for it to move on if it happens to have any conditions, and log every thing in the same time?
10:15:07
phoe
(loop (tagbody :continue (handler-bind ((error (lambda (c) (log-error c) (go :continue))) (do-thing)))
10:18:52
flip214
wouldn't be a problem with tail calls... lifetime of the universe will stop most things eventually
10:23:52
nij
The point is that I want them to run indefinitely, without my paying attention to it constantly.
10:25:11
phoe
if a condition is passed to the ERROR function, which does SIGNAL and then INVOKE-DEBUGGER
10:25:21
nij
Uh.. I must misunderstand something. Aren't errors in CL yet another condition, which is some object people can create?
10:26:28
phoe
unless someone does silly stuff like calling SIGNAL with an error condition that should not proceed with execution
10:27:11
phoe
so: yes, only unhandled errors can cause the thread to enter the debugger unless the code explicitly does something extraordinary
10:27:58
nij
Maybe this is what I want - I want to suppress all debuggers and just let it logged. Is that possible?
10:29:26
nij
However, when a debugger is supposed to be on, usually it will present a list of options. Which option should I let my thread choose automatically in order to proceed?
10:31:40
phoe
if you tell your *debugger-hook* to perform a jump then you'll never enter the proper debugger
10:33:03
nij
Before doing that, I just want to make sure it's not obviously done yet.. as I think it should be there already..
10:33:38
nij
So a service is just a wrapped function, which will be fired as a thread. But after it's fired, it must log every output to some file, and does the error handling stuff I say above.
10:41:47
nij
Is there a "safe" thread, meaning a thread that completely logs all output, and skip (but log) any errors when it's running?
10:43:22
nij
By a "safe" thread I mean a thread that does (1) all logging (2) all things I asked above automatically.
10:45:32
nij
This ==> (loop (tagbody :continue (handler-bind ((error (lambda (c) (log-error c) (go :continue))) (do-thing)))
10:49:00
phoe
there's a variant of handler-case that I described in one of the TCLCS appendices that executes the handler and only then unwinds, but it's not standard
12:28:44
beach
jnewton: Here is the link to the document about a Lisp OS that I mentioned on the phone: http://metamodular.com/closos.pdf
12:48:10
pjb
nij: if log error doesn't use implementation specific API to collect and report the backtrace, then you can use handler-case instead of handler-bind. (loop (handler-case (do-thing) ((error (c) (log-error c)))))
12:54:29
nij
Is there a tiny project that uses CFFI? I'm new to it and hope to see it working in action. Thanks :)
12:55:32
pjb
nij: https://github.com/informatimago/lisp/tree/master/clext/pkcs11 might be an example.
12:56:21
pjb
nij: it wraps a pkcs11 library in a low-level lisp package and a high-level lisp package, which is rather a classic way to do it.
12:57:36
pjb
nij: and pcks11.lisp wraps the low-level C function calls in lisp calls, processing error handling and parameter conversions, etc.
12:59:09
pjb
nij: notably, when you have a library with a consistent API, you can write macros to perform the work in a consistent way, so wrapping over is easy: https://github.com/informatimago/lisp/blob/master/clext/pkcs11/pkcs11.lisp#L2011
13:00:12
pjb
nij: an example of usage of this library is in https://github.com/informatimago/scquery (sources-cl, not sources, which contains the C version).
13:01:49
pjb
nij: I guess we could give a hello world example, but this wouldn't teach you anything more than the cffi manual.
13:03:02
nij
semz you mean this? https://common-lisp.net/project/cffi/manual/cffi-manual.html#Tutorial
13:03:24
beach
kali123: Like: /nick my-new-nick and be sure the slash is the first character on the line.
13:04:10
beach
nij: I strongly recommend you use Common Lisp exclusively if you possibly can. Using FFI makes everything much harder.
13:05:01
splittist
nij: how is asking questions about it on irc going to help you? I usually find trying things out - and with lisp that's usually very easy - much more likely to illuminate the particular areas of ignorance I want to address.
13:07:17
nij
splittist: I never know. Sometimes on some topics there will be super helpful advises. Sometimes no..
13:07:49
pjb
nij: for example, there's a clock() -> long (actually clock_t but it's a long) function in libc. (cffi:defcfun (clock "clock") :long) #| --> clock |# (clock) #| --> 147584979 |# (- (clock) (progn (sleep 1) (clock))) #| --> -110 |#
13:10:15
pjb
nij: another example, always in libc, there's a int chmod(const char*path,int mode) function: (cffi:defcfun (change-file-mode "chmod") :int (path :string) (mode :int)) (change-file-mode "/tmp/foo.c" #o444) #| --> 0 |# ls -l /tmp/foo.c # --> -r--r--r-- 1 pjb wheel 29 May 4 05:08 /tmp/foo.c
13:11:28
pjb
So you would have to read the C header file, or write a little C function to get it: #include <time.h> long clocks_per_sec(){return CLOCKS_PER_SEC;} and use cffi to call it.
13:12:18
pjb
nij: C APIs are often not designed to be used in foreign code, so they use things like C macros and other stuff that goes thru difficultly. You may have to write some C portability code sometimes.
13:13:09
pjb
nij: of course, there are more complex cases, eg. out or inout parameters. Then you may have to allocate temporary storage for them, and convert the data. See the pcks11 example for that.
13:13:58
nij
In the first example you gave, the output was an integer, which is easy to translate to Lisp.
13:14:20
pjb
nij: but there are special cases. For example, macOS uses some structures with #pragma packed , and cffi doesn't deal with that.
13:14:36
nij
I see. Say I'm using a function in some C library, I need to translate the structures defined in that C library by myself?
13:14:43
pjb
nij: so I find it easier and safer, to refer structures are mere memory blocks, and specify the offsets to the fields myself.
13:16:03
pjb
nij: an example with defcstruct forms: https://gitlab.com/patchwork/CoreMIDI/-/blob/master/coremidi-cffi.lisp
13:17:42
nij
Nilby: yeah. but most of the time I must translate the structures in to Lisp by using defcstruct, right?
13:20:22
Nilby
nij: You don't have to translate. But it depends how you want to use them. If you want to use them conveniently in Lisp code that doesn't use CFFI, then yes. Usually one would provide a higher level interface to C code.
13:23:09
pjb
It depends on the C API really. Sometimes, they use complex structures to be created by the client code, then it's more convenient to do that in lisp, and provide code to convert between lisp an C structures. Sometimes they use function calls to manipulate an internal state, and then it is easier, you just have to deal with the functions.
13:23:58
pjb
void* make_point(); void point_set_x(void* pt,int x); void point_set_y(void* pt,int y); int point_x(void* pt); int point_y(void* pt);
13:24:46
pjb
vs. typedef struct point {int x,y; } point_t; point_t* make_point(); void use_point(point_t* pt);
13:25:22
pjb
using point_set_x is simplier from a FFI point of view than having to know how the struct point is laid out, and how to store or read it.
13:26:23
pjb
Also, in terms of API, when the structure point evolves (they may add fields, or want to reorder them), code using point_set_x will always work, while code setting directly a structure may become incompatible.
14:10:21
jmercouris
however, this forces recompilation of systems on disk which are in NOT writable directories
14:15:14
jackdaniel
you may want to try harder to provide a reproducible test case; ("foo" "bar") is indeed an illegal function call
14:16:01
jackdaniel
asdf claims that it does some magic parsing of asd files, but it in reality reads them
14:19:26
Nilby
I've been living with the same problem for years. It's especially trouble when your not in control of the filesystem or quicklisp setup for the resulting images, and the REPL user may _want_ to reload some systems. I figured someday I would force asdf to do what I want.