freenode/#lisp - IRC Chatlog
Search
16:29:02
emaczen
I want to use cffi:defcstruct to just get 4 fields out of a struct with many fields and nested structs.
18:36:18
_death
hmm.. (defmacro frogn (&body forms) (cond ((null forms) nil) ((null (cdr forms)) (car forms)) (t (let ((whatever (gensym))) `((lambda (,whatever) (declare (ignore ,whatever)) (frogn ,@(cdr forms))) ,(car forms))))))
18:36:40
_death
I thought http://www.pipeline.com/~hbaker1/MetaCircular.html might show something similar, but apparently not
18:43:56
Bike
(defmacro progn (&body forms) `(tagbody ,@(loop for form in forms when (symbolp form) collect `(identity ,form) else collect form))) "makes you think"
18:47:11
Shinmera
I mean if we're doing implicit progns: (defmacro progn (&body forms) `((lambda()NIL,@forms)))
18:52:49
Shinmera
The string might stick around longer as the docstring instead of being eliminated. Terrifying.
18:53:24
_death
yes Shinmera.. that's why I mentioned.. but I also seem to recall some issue besides that.. lemme check
18:53:45
Shinmera
It's specified that if the only form in the body of a lambda is a string, it is not treated as the docstring.
18:54:06
Shinmera
So the thing that would cause people to trip up in terms of semantics is not the issue.
18:58:22
_death
Shinmera: yes, I knew about that, but I'm still looking for why I feel there was another issue
19:08:02
_death
meanwhile found an interesting KMP message.. apparently the syntax for bit vectors was once #"..."
19:10:47
_death
anyway, the issue was http://www.lispworks.com/documentation/HyperSpec/Body/03_dk.htm .. but this is about interaction with declarations
20:15:59
jmercouris
I honestly think just a re-theme of the CLHS would do wonders for making it feel modern
20:16:20
Shinmera
Yeah, well, the best shot at that is CLUS. The HTML is so unstructured you'd have to style every page manually.
20:18:06
whoman
i would have imagined that CLHS could be dumped from any CL-comforming code base. would be nice
20:19:52
jackdaniel
jmercouris: see http://cvberry.com/tech_writings/notes/common_lisp_standard_draft.html
20:20:48
whoman
like if we just move the doc strings from the html into the code, with implementation specific notes kept in tact, or... at least to seperate the core guts of CLHS from html if it is not already. isnt it generated from a less noisy format ?
20:47:52
jmercouris
Alright, so I have an interesting problem, let's say I have two lisp files, they provide the exact same functions, but sometimes I want to compile with file A, and sometimes with file B. I don't want to have to change any of the other code in my codebase as the functions will have the same name. How should I do this?
20:49:57
pjb
jmercouris: then the second simpliest way is to push a specific feature in *features* and test for it to select one file or the other with #+/#- in a single asd file.
20:49:59
jmercouris
the only issue then is whenever I add a single dependnecy, I must add it to both files
20:50:18
pjb
jmercouris: it's better to have features in one of your own package to avoid collision.
20:51:17
pjb
Or you could use :jmercouris-file-selector as feature, it should be unique enough I'd guess.
20:52:17
jmercouris
I could also manually edit the asd file when compiling for one system or the other
20:53:04
pjb
also, having multiform asd definitions may be a problem in itself, since reading the asd file, and processing the definition is independent.
20:53:44
pjb
jmercouris: you may have two asd files to select your files, and both can depend on a common system (defined in a third asd file) that wouldn't depend on them.
20:54:13
pjb
But of course, all the files that depend on those alternative files will have to be in the duplicate systems.
20:56:44
emaczen
so I'm able to cffi:define-foreign-library and cffi:use-foreign-library and my defcfun evaluates without a problem, but when I go to call the defcfun I get a "Can't resolve foreign symbol" condition
20:57:39
pjb
(defpackage "JMERCOURIS-FEATURES" (:use) (:export "FOO")) (pushnew 'jmercouris-features:foo *features*) (quote (#+jmercouris-features:foo a #-jmercouris-features:foo b)) #| --> (a) |#
20:58:34
pjb
jmercouris: your question is meaningless: variables don't have package. Only symbols have packages. And symbols may or may not name a variable.
20:58:55
pjb
Eg. global variables are named by a symbol, but lexical variables have no name (once compiled).
20:59:39
pjb
Symbols are only used to name global variables, and to refer to lexical variables in the source.
21:00:17
pjb
Once compiled, there's only the lexical variable, no symbol anymore. This is why you cannot use EVAL with a form refering a lexical variable!
21:00:51
pjb
Because the foo naming the lexical variable doesn't exist anymore once the compiler did its work.
21:03:34
pjb
You have strange notions in your brains. Perhaps you've learned some other language before lisp? You'd better forget them first!
21:04:12
jmercouris
The only definitions that I can maybe sometimes perhaps understand, underneath full moons are those from practical common lisp
21:06:24
jmercouris
I'm reareading: http://www.gigamonkeys.com/book/variables.html maybe it will make sense this time around
21:07:51
emaczen
my question definitely got lost... What do I do with CFFI when I can define and use a foreign library but my defcstruct when evaluated says "Can't resolve foreign symbol"?
21:08:43
pjb
emaczen: notice that you need to load it when defining the function, AND when calling the function.
21:10:02
emaczen
pjb: I have this working on OSX, and I don't know what you mean by load? I just have two toplevel forms: cffi:define-foreign-library and cffi:use-foreign-library
21:11:23
oleo
https://common-lisp.net/project/cffi/manual/html_node/Tutorial_002dLoading.html#Tutorial_002dLoading
21:13:35
pjb
toplevel forms are executed at :load-toplevel and at :execute time; :load-toplevel is when you load the .fasl file (or in the case of ecl, when you load the executable). :execute time is when you load the source file, so usually not that time, if you compile.
21:14:09
pjb
If you don't use ecl, but an image saving implementation, then the load-toplevel time is when you load your system before saving the image. So it's too early.
21:14:32
pjb
You have to have a initialize function that you call at run-time, after booting the lisp image! where you can load the shared libraries.
21:15:38
pjb
Even with ecl, it's better to put all that kind of toplevel code in an initialize function, and call it explicitely when it's needed.
21:16:28
pjb
Don't do toplevel forms, put everything in a initialize function and call it before (or at the begining of) your main function.
21:16:58
emaczen
pjb: got it, I wonder if I did this early on on OSX and something is cached and that is why it still works, and I just don't remember
21:19:21
pjb
Now, there may also be differences in the set of functions available in libraries on linux and on osx.
21:31:32
emaczen
pjb: this should work for .so files too? nm -g libopencv_core.so.3.1.0 when evaluted just tells me "no symbols"
21:34:46
emaczen
No link, I'm just trying to capture video frames. There are mostly C libraries to do this, so I've been fooling around with CFFI
21:35:13
emaczen
I also got ABCL to do what I want, but there was a significant lag, so I'm trying to do it in CCL
21:37:27
pjb
on linux so files may be indirect: they contain text telling where to find the actual so file.
21:38:10
pjb
cffi used to be unable to load them, I provided a patch a few years ago, I hope it's included now. Check that you're actually able to load them.
21:41:52
oleo
do you have your package manager open and can check the packages associated with that name ?
22:05:53
pjb
well, if it's binary, then it's the library. if nm doesn't show any external symbol, perhaps it has none…
23:00:36
emaczen
oleo: with nm -D I found a bunch of symbols of the form cvCreate but not the one I am looking for
23:07:42
pjb
emaczen: look, what I'm trying to say, is do not use the fucking C libraries! Write the library in Lisp and use a lisp library!
23:10:40
aeth
pjb: Except at some point libraries are necessary, such as OpenGL+SDL if you're doing (OS-portable) 3D.
23:17:22
emaczen
I tried ABCL with all of this and got it to work but I have a 5 second lag, I'm not sure whose fault that lag is, but I'm blaming ABCL right now which is why I am trying this
23:52:12
pierpa
the CLs times look plausible. I'm surprised only at swi being twice as fast as clisp :)
0:57:49
pierpa
dmiles: do you know about optimization declarations in CL? you are using each implementation default I guess?
0:59:32
dmiles
i recall it seting optikiaion flags.. but i dont know if they are what every impl listens to
1:03:20
dmiles
but i am not settign the optimizations and i am sure if i was making a lisp when the user enters the repl i'd make safety first
1:04:27
dmiles
the differnce between safety speed and not in 4x-8x diference for wam-cl (comparity when i add typechecking)
1:12:42
pierpa
you could try adding at top level (declaim (optimize (speed 3) (debug 0) (safety X)) ;; for X in 0..3
1:14:06
dmiles
and test with (defun fib (n)(declare (optimize speed (safety 0) (debug 0)) (fixnum n)) (if (<= (1- n) 0) n (the fixnum (+ (fib (- n 1)) (fib (- n 2)))))) (fib 38)
1:17:06
Bike
safety 0 and 3 vary too. certain things have to happen in safe code, but it's hardly a complete specification
1:17:42
pierpa
safety 3 means safe as mandated by the spec, safety 0 means as unsafe as the implementation allow
1:23:06
dmiles
ok it stayed the same with and without (as at least my cpu is not fluxuating as much as my last irc message might have made us htink)
1:31:58
dmiles
SBCL varries quite a bit and so do ccl.. i know ABCL really pays attention to these directivers but its not paying off
1:37:49
dmiles
(declaim (optimize (speed 3) (debug 0) (safety 0)))(defun fib (n)(declare (optimize speed (safety 0) (debug 0)) (fixnum n)) (if (<= (1- n) 0) n (the fixnum (+ (fib (- n 1)) (fib (- n 2)))))) (time (fib 41))
1:38:06
dmiles
(declaim (optimize (speed 0) (debug 3) (safety 3)))(defun fib (n)(declare (optimize (safety 3) (debug 0)) (fixnum n)) (if (<= (1- n) 0) n (the fixnum (+ (fib (- n 1)) (fib (- n 2)))))) (time (fib 41))
1:49:05
dmiles
its hard to know the differnce between the meaning of balls to the wall with type information vs what the anyhting else would mean
1:56:16
dmiles
and (ftype (function (fixnum) fixnum) fib) means.. but the lack of ftype and different numbers than the above.. also this sometimes only is meaningfull for compilation
3:16:48
stylewarning
I have some exciting news. We have some scientific simulation code in Lisp that beats C++, where the C++ code has non-standard Intel ISA SIMD intrinsics.