libera/commonlisp - IRC Chatlog
Search
5:53:30
nij-
For example, after I `(ql:quickload :rutils) (in-package :rtl-user) (named-readtables:in-readtable rutils-readtable)`,
6:05:22
beach
Functions like COMPILE-FILE and LOAD bind *READTABLE*, so during compilation or loading, even if you alter the readtable, its old value is restored after compilation or loading.
6:06:32
beach
And, no, there is no mechanism to change the readtable according to the current package. There are two different variables: *PACKAGE* and *READTABLE*.
6:10:31
nij-
I see. Yeah after playing it more, I almost came to the conclusion that it's not meant to be used interactively.
6:12:10
nij-
I just add (setq *readtable* my-readtable) in the beginning of the file, and (setq *readtable* *old-readtable*) in the end of the file?
6:13:02
beach
You don't have to set it back. Like I said, COMPILE-FILE and LOAD do (LET ((*READTABLE* *READTABLE*)) ...) around the reading of your file.
6:14:54
nij-
beach, sorry, do you mean (let ((*readtable* *my-readtable*)) <insert the codes in the file>)?
6:16:01
beach
Check this example: (defparameter *x* 10) then (let ((*x* *x*)) (setf *x* 20)) then *x*
6:16:48
beach
That is what COMPILE-FILE and LOAD do, so you can safely assign to *READTABLE* in the file.
6:17:50
nij-
so do you mean (let ((*readtable* *readtable*)) (mutate *readtable*) <insert the codes in the file>)?
6:19:08
nij-
I use asdf without touching compile-file and load. But lemme do a quick experiment. Thanks :D
6:19:10
beach
Therefore, it is safe to assign to *READTABLE* in the file, just like you do (IN-PACKAGE...) in the beginning of the file.
10:14:01
minion
Josh_2: please look at universal greeting time: It is always morning when a person enters a channel, and late night when they leave. You may want to read http://www.total-knowledge.com/~ilya/mips/ugt.html for further information
12:16:26
Equill
Good point with the cake analogy: maybe what this thing needs is some brandy. I mean, what's the worst that can happen?
12:18:54
hayley
"By now, my remaining readers are wondering what I’ve been smoking. Well, I don’t smoke, but red wine is good for you."
12:18:55
Equill
Oh man, I've had that moment. Reading through some old code and thinking "was I *drunk* when I wrote thi... oh crap, now I remember. Yes, I was."
12:35:35
nij-
I heard the following: C is a lingua franca, so being able to FFI with C makes CL able to communicate with almost all langs.
12:37:06
nij-
That makes C an "inferior", in the sense that C has not much freedom to do whatever it wants, including talk to the third language X.
12:37:51
nij-
In the case where the thid language X is embedded in C (e.g. X = Python), it is easier to let CL and X communicate.
12:37:53
jackdaniel
usually a ffi has two aspects: calling foreign functions and creating callbacks that may be called by foreign functions
12:38:13
nij-
But other languages do not necessarily embed in C. I thus wonder how we can use CFFI to do FFI with other langs.
12:38:16
jackdaniel
when you want for some c function to call your cl function, you define a ffi callback and pass it to the foreign world
12:39:24
jackdaniel
C ABI is omnipresent, that's why having FFI allows you to interact with other programs exposing C ABI (be it a program written in C or in Python) - ABI is mostly about how to call things and retrieve values
12:40:59
nij-
But for C to work in CL, it basically got embedded as a process in CL. In this case, even if lang X has a nice CFFI, it cannot embed the same C process in itself.
12:41:53
jackdaniel
you may compile CL to a shared library (be it ecl or sbcl recently) and export an interface following the C ABI convention
12:42:22
jackdaniel
then some program (i.e written in FOOLANG) may load that shared library and call functions exported using that interface as if these were C functions
12:42:36
nij-
Oh I see. So first have CL load a C shared library. And compile this into another shared library to be loaded by X?
12:43:47
jackdaniel
I don't know what you want to achieve, but it may be that you have compiled CL library to a shared object, you dlopen it from FOOLANG program and call the function cl_load_ffi, and then that CL library dlopen's libraries it uses itself
12:45:57
nij-
With this method, to let CL and FOOLANG interopt, one needs to write many C wrappers, and the CL objects and X objects should be translated via the semantics of C.