freenode/#lisp - IRC Chatlog
Search
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.
3:56:29
beach
Not the condition and the `then' branch on one line and the `else' branch on a separate line.
3:57:21
beach
For good indentation of LOOP clauses, I recommend you use the slime-indentation contribution.
3:58:40
beach
You either put everything on one line, or else you put the test on the same line as the IF, and you align the `then' and the `else' with the test.
4:00:13
beach
You have some code duplication in there. todo-select and todo-complete are almost identical.
4:00:48
beach
You could make a single function that takes an additional argument. Either 'complete or 'select.
4:02:00
beach
It is a bit strange to have (IF (NOT ...) rather than removing the NOT and reversing the arguments. Especially since INTEGERP seems to be the "special case", and you want to handle special cases first.
4:04:12
slightlycyborg
Ok. Do you mean the file name for top level comments. I just put those in there for pastebin
4:06:49
beach
(IF (not (null...)) <only-a-then-branch>) is better expressed as (when (null...) <only-a-then-branch>)
4:07:44
beach
This should keep you busy for a while. I'll review your next version if you like. Now I am off for a break. Back in 30 minutes or so.
4:32:17
beach
(IF (NOT (NULL ...)) ...) is the same as (WHEN (NOT (NULL ...)) ...) which is the same as (UNLESS (NULL...) ...) as you pointed out.
4:54:28
montxero
hi guys, given the following sinppet: https://pastebin.com/tT5vjapJ, is it possible to call func3 in func1 and vice versa?
8:46:08
myrmidon
Hi! I'm trying to make a macro produce a backtick list with some ,@(when ...) forms in it, but all I can get is ,(when ...) forms: https://ptpb.pw/PVsQ/lisp -- any advice?
8:54:39
no-defun-allowed
double backquotes aren't my strong point but i think you'd need to backquote-splice twice
8:59:01
jackdaniel
you may splice it shallow or deep and even CL implementations are not consistent here