freenode/#lisp - IRC Chatlog
Search
16:25:29
White_Flame
no-defun-allowed: specifically, 32-bit ieee floats have 7.22 decimal digits of precision
22:40:33
emaczen
https://pastebin.com/zJVfpq0h -- I can't determine the inconsistent results here...
22:42:17
emaczen
I get a memory access error in local function get-family when evaluating the form (cffi:foreign-slot-value addr '(:struct sockaddr) 'sa-family)
22:44:46
|3b|
(and use cffi to allocate it rather than mixing in some other FFI and manual malloc/free)
22:55:00
|3b|
ACTION wouldn't expect it to work at all if that was the problem (or at least give nonsense results), but doesn't look right
22:55:25
russellw
when you don't specify in-package, your symbols are defined in :cl-user, aren't they?
22:57:27
|3b|
i think it was working by luck if it happened to have 0s in the right place after the pointer, since setf buf ... ifa-next would be same as above
22:57:49
|3b|
but that happens after first call to get-family, so would depend on what was in memory there
22:58:54
|3b|
so first time you were passing pointer to the pointer returned by getifaddrs to the other things
22:59:28
|3b|
and buf->ifa_next happens to be the same as *buf, so if it survives the first iteration, it works OK
23:00:25
|3b|
so you could think of it as struct ifaddrs* buf; getifaddrs(buf); too (minus any warnings from static typing)
23:00:47
|3b|
you pass a pointer to getifaddrs, it stores a pointer in the memory pointed to by the passed pointer
23:01:44
|3b|
cffi tends to have 1 extra layer of pointers than corresponding C code, which can be confusing to get used to :/
23:02:30
|3b|
ACTION supposes you should check for null pointer before that first dereference of buf too
23:04:02
emaczen
|3b|: I see the difference between my C code and my Lisp code but I don't quite see why cffi:mem-ref does the trick
23:05:12
emaczen
|3b|: but I thought I was missing a pointer... since the C code passes the address via & and in my lisp code I just passed the pointer
23:13:10
emaczen
so for cffi we have to get rid of an extra pointer because getifaddrs thinks it is a **
23:18:05
|3b|
in C we can make a local variable, and pass a pointer to it, in cl, we can't make a local, so have to allocate the "struct ifaddr*" explicitly
23:18:43
|3b|
in C, we can make a local temp pointer to the struct ifaddr*, but in lisp we would have to explicitly allocate that too
23:20:40
|3b|
but more so in lisp since you have 2 allocations (though you never freeifaddrs in lisp)
3:27:53
slightlycyborg
I wrote a todo list in lisp. I orignally saved all my completed todos into an sql db...I recently added a twitter backend though, so now all that info gets livetweeted. Most pointless twitter account ever
3:28:48
slightlycyborg
My next pointless twitter account driven by lisp will be a live video stream of myself broken up into 140 second video segments.
3:51:06
beach
If I were you, I would write an ASDF system definition so that you don't have to LOAD explicitly.
3:52:01
no-defun-allowed
yes, an asdf system would make it loadable via quicklisp and simplify dependencies considerably
3:52:13
slightlycyborg
Oh. I've never used ASDF explicitly before. OK. I will put some reading material on how to do that on my todo list
3:52:49
beach
Your indentation is off. It could be that you have TABs in your code so that the pastebin does not display it correctly. Or it could be that your indentation is off. :)
3:53:06
no-defun-allowed
[here's a simple single-layer ASDF system](https://gitlab.com/netfarm.gq/cl-decentralise/blob/master/decentralise.asd)
3:53:30
no-defun-allowed
[this one has directories/"modules"](https://gitlab.com/Theemacsshibe/cl-vep/blob/master/vep.asd)
3:56:07
beach
For an IF, either put each of the three arguments on a separate line, or put everything on one line.