freenode/#lisp - IRC Chatlog
Search
13:30:03
jmercouris
Here's my question then, if the ABI, is so awesome, why aren't there other stable ABIs?
13:32:03
jmercouris
can I in SBCL write a program that exposes functions via this ABI to a C program on a Unix system?
13:32:07
Bike
i think with ECL that works because the lisp is compiled into a c program, not because of matching the ABI
13:32:28
Bike
(i mean, compiling into a C program means it gets to match the ABI, you know what i mean)
13:32:44
dlowe
so you can't suck sbcl into a C program, but you could pass a lisp function to a C function as an argument
13:33:04
jackdaniel
there is additional perk of that: if we compile ECL with CXX then we match C++ ABI of the default compiler ,)
13:33:45
Bike
sbcl has its own internal calling conventions that aren't stable or exported, but also to call a lisp function you need to have the lisp runtime, which is generally larger than libc, and i think only ecl makes it available as a shared object anyway
13:34:45
jackdaniel
Bike: but this is not a coincidence that functions are compiled to C functions (it would be in fact easier to have some things as state machines -- i.e flet functions); it was designed this way in KCL to have a common runtime for numerous languages in the same ABI as C (prolog was one of them)
13:35:58
dlowe
maybe just read the wikipedia page? https://en.wikipedia.org/wiki/Application_binary_interface
13:35:59
Xach
jmercouris: "binaries" implies multiple independent processes to me. but the ABI is about how, within a single process, to set up the registers and such to invoke functionality that is part of a single binary, provided by the OS (as a syscall), or linked in via a shared library
13:36:21
Xach
jmercouris: it is a protocol, but it's a protocol in the sense of an orderly and formal series of steps
13:36:29
Bike
it's just letting functions compiled with one thing call functions compiled with another thing, in the same process
13:36:49
jmercouris
Maybe I spent too long in Java world, but that's what protocol means to me when I think about it
13:37:07
Bike
an ABI is also why you can link a library to your C program without worrying so much about what compiled the library
13:37:10
jmercouris
why doesn't everyone implement this ABI for all sorts of FFI from any lang to any lang?
13:37:34
jmercouris
Bike: that's why my first question was about the shared library with one compiler, and the other program with another compiler
13:37:40
jackdaniel
jmercouris: C ABI has some limitations. one obvious one is that it is the caller who "owns" the callee arguments
13:40:08
Bike
like you can have more than one function with the same name but different parameter types
13:41:38
shka__
Bike: every compiler has it's own mangling rules so it is not even possible to know how it works
13:41:48
_death
there is an old book about C++ object model (Lippman) but in general the language is so complex that there is a lot of room for disagreements, and though there are multiple ABI standards, none is king
13:42:29
_death
it does not help that the C++ crowd decided to come up with a new standard every couple of years
13:42:58
Bike
you can drop by #clasp and ask drmeister stuff if he's not busy with another grant proposal
13:44:18
_death
jackdaniel: no one really cares about those.. people either care about the old standards or their implementation-specific extensions
13:44:19
jackdaniel
correct me if I'm wrong, but I think that languages which target llvm (given it is the same llvm version) may interop with each other
13:45:31
jmercouris
is there a way to avoid the segfault or somehow make that part of the memory not interfere?
13:46:06
jmercouris
dlowe: that's what I'm doing at the moment in Next, but one of our developers wishes to move to using CFFI
13:47:31
jackdaniel
if you want to invent memory protection on top of memory protection then I will leave that without comment
13:50:39
phoe
one way I think of is to mprotect() all of your Lisp pages each time you dive into C and unprotect them on your way back to Lisp
13:53:28
phoe
yep - you'd actually need to measure what is faster, doing actual IPC or spamming mprotect() inside a single process
13:53:55
phoe
the trick is, you have no idea if your Lisp implementation actually uses mprotect itself
13:54:10
jmercouris
jackdaniel: cs200 is a beginner CS class, one of the first things we learn about with C is all the types of ways a program crashes and what they mean
13:54:47
jackdaniel
jmercouris: it is hard to assume what you know and what you don't know (based on some of your questions)
13:54:52
phoe
_death: I don't think shared memory is going to work in that use case - you basically want Lisp to drive a lot of foreign code
13:55:07
jmercouris
jackdaniel: well, CS is a very wide breadth, and my knowledge is in a very specialized domain...
13:56:02
jmercouris
phoe: yes, basically, a lot of IPC, we have a very strict, limited protocol defined in remote.lisp
13:56:27
jmercouris
jackdaniel: yes, my specialty is in data ingestion, sanitation, and semantic analysis of documents
13:56:32
jackdaniel
either way, using mprotect or other ways to protect memory will save you from some crashes and will make it easier to hide bugs in your usage of the library
13:57:24
jackdaniel
jmercouris: then I can't assume you know what segfault is? I'm confused, but I won't investigate ,)
13:59:04
jmercouris
it's something Akin to smoke using gobject introspection to make bindings for languages
14:01:08
jmercouris
in terms of performance, I thought unix domain sockets typically used shared memory for IPC?
14:01:53
phoe
stackoverflow tells me https://stackoverflow.com/questions/2101671/unix-domain-sockets-vs-shared-memory-mapped-file
14:02:26
_death
phoe: I did not necessarily meant it this way.. it's also possible to have a shared memory area for storing large blobs and a message queue, perhaps using a different transport
14:07:46
dlowe
there's quite a lot. IPC means having to serialize and de-serialize your data structures
14:12:28
jmercouris
Indeed, that is extra work, on both sides, we use D-Bus which supports some primitives
14:12:42
jmercouris
and fortunately most of the information is contained within Lisp data structures that the foreign code not be knowledgable of
14:13:35
phoe
jmercouris: Second Question of Optimization: do you know where exactly in your system the bottleneck exists?
14:13:50
phoe
if it's not the IPC between Lisp and C, then you won't gain much from optimizing this place
14:14:30
phoe
otherwise you won't gain as much as you can from spending your time on speeding up the wrong thing
14:14:55
jmercouris
Yeah, the biggest argument in favor of moving to FFI is that we won't have to maintain a separate C and C++ codebase for the Webkit and Webengine ports
14:15:41
jmercouris
and that we'll be able to access more of GTK and QT without having to expand the protocol
14:15:57
jmercouris
for example, we want to add split window functionality, it means updating the C program, and the C++ program, and the Lisp program and then coordinating a release
17:12:11
fiddlerwoaroof
jmercouris: minion doesn't seem to have remembered, but it's possible to have dyld on a mac automatically find a library relative to your application's bundle
17:13:20
fiddlerwoaroof
I've recently been experimenting with configuring ASDF to dump all its compilation results into my application bundle, so I can use this to find annoying things like osicat.dylib
18:12:31
kapitanfind-us
Question I have: say I have a system and I run sbcl and want to load a system from my local my-package.asd
18:14:53
mfiano2
It has to be located in a path asdf looks for, unless you call asdf:load-asd before asdf:load-system
18:16:01
mfiano2
IIRC it also needs to have a filename the same as the system name, sans file extension
18:19:36
mfiano2
`sly` on the asd file? That just starts up an image and sets the current working path to that of the file. sly doesn't load an asd
18:20:41
mfiano2
By the way, it is common practice to use Quicklisp rather than asdf directly in most situations
18:23:05
kapitanfind-us
fiddlerwoaroof: so do I understand right, you "compile" first then use a package manager to load it back in memory
18:25:26
kapitanfind-us
ok so my next question would be, is there a way to set this up every time I launch sbcl (via sly)
18:26:01
fiddlerwoaroof
There's probably a hook you can setup, but I don't really find this worth automating
20:58:25
no-defun-allowed
Are there any libraries or any code for writing out a ratio as a decimal number?
21:02:58
no-defun-allowed
(Looking at that stupid pidigits benchmark) I have a lot more precision than what a float can provide.
21:04:06
Shinmera
When printing a ratio with ~f your implementation may or may not use a more precise method to print it
22:21:53
pfdietz
Specifically, it would get into a mode where it ignored interrupts. If I then caused an error, it would throw an interrupt condition instead of the intended error.
0:42:23
phoe
Implementors of #lisp: do we have anyone proficient with debugging ANSI LOOP? I am trying to fix ANSI-TEST failures on CCL.
0:42:48
phoe
One of them is the infamous (loop for x of-type (integer 1 5) from 1 to 5 collect x) that fails on safe code because (setq x 6) is happening behind the scenes.
0:48:12
White_Flame
"the loop terminates when the variable var passes the value of form2" Sounds like the bug is with the test. The actual variable is supposed to breach past the "to" value
0:51:21
White_Flame
hmm, no I think I might be wrong. That's from downto/upto. "to" specifically flags an ending value, not a threshold
1:04:24
phoe
I asked specifically about ANSI LOOP because this implementation of LOOP is what is used inside CCL.
1:10:43
phoe
pjb: dead code per se isn't invalid, it just won't be reached and a sufficiently smart compiler will optimize it away
1:15:55
White_Flame
I still think the test itself is badly written. Its declaration mislabes what ranges it asks LOOP to calculate for X
1:16:25
White_Flame
from CLHS: (let ((x 1)) (loop for i from x by (incf x) to 10 collect i)) => (1 3 5 7 9)
1:17:16
pjb
The value 6 is not of the expected type (integer 1 5). on "Version 1.12-dev (v1.12-dev.4-4-gd9740256) Darwinx8664"
1:18:21
White_Flame
in http://www.lispworks.com/documentation/HyperSpec/Body/06_abaa.htm is "stepped[1]" supposed to refer to the glossary with that [1]?
1:18:42
phoe
I ask because ECL also uses a modified ANSI LOOP and maybe it has fixed this issue already.
1:19:10
White_Flame
"step v.t., n. 1. v.t. (an iteration variable) to assign the variable a new value at the end of an iteration, in preparation for a new iteration."