freenode/#lisp - IRC Chatlog
Search
4:34:41
edgar-rft
ealfonso, you can FMAKUNBOUND the LDB function in your Lisp code before you're dumping the image.
4:43:18
phoe
edgar-rft: I do not think he means #'LDB but rather he means SBCL's low level debugger.
6:14:24
phoe
Do I want to treat my RDBMS as plain old data store, and therefore have all logic on the Lisp side
6:15:43
phoe
I'll learn PL/PGSQL that way, and then end up writing the same in Lisp nonetheless because hell, I prefer to debug Lisp rather than to debug procedural SQL.
6:17:53
phoe
I was initially thinking about performance, but then remembered that premature optimization is the sqrt of all evil and it's easy to speculate about something that does not yet exist.
7:09:57
phoe
I need a Common Lisp utility that, given some kind of lambda list with annotated types, and a function's return value, will give me a valid DECLAIM FTYPE form.
7:11:14
phoe
Something like ((foo string) bar (baz (or symbol number))) (values t boolean) as input, and (function (string t (or symbol number)) (values t boolean)) as output.
10:35:30
elderK
Hey guys, I was wondering how people parse binary formats in CL. I've seen read-sequence?
10:39:19
pjb
elderK: notice that you can also specify the element-type, so you can read files bit by bit, or 3-bit by 3-bit, etc.
10:39:52
pjb
(but other than 8-bit by 8-bit and possibly bit-by-bit on current hardware, it's probably implementation dependent how the bytes are mapped to the files).
10:42:48
elderK
pjb: I just figure you'd need to create functions so that you could say, read-u32 from some arbitrary position in the blob that you've loaded.
10:43:55
phoe
you could read the code for https://github.com/rpav/fast-io to learn how it works - it has functions for {read,write}[u]{8,16,32,64,128}{-be,-le}
10:44:03
pjb
yeah, bit is not portable or useful. clall -r '(with-open-file (out (format nil "/tmp/foo-~A" (lisp-implementation-type)) :direction :output :if-exists :supersede :if-does-not-exist :create :element-type (quote bit)) (write-sequence #(1 0 1 1 0 1 0 0 1 1) out) (file-length out))' ; ls -l /tmp/foo-* ; for f in /tmp/foo-* ; do od -t x1 "$f" ; done
10:44:31
pjb
clisp writes bit by bit, but writes first a 32-bit little endian file-length (in number of bits). the other implementations write one bit per octet, which is useless.
10:45:06
pjb
This is why the usual advice is to use (unsigned-byte 8) as element-type, and format the binary file yourself, octet-by-octet.
10:46:57
phoe
AFAIR it's pjb's script that calls the following code with all CL implementations available on the machine
11:33:34
random9899
found some good youtube vids about lisp too https://www.youtube.com/channel/UCufkSSu1trzm9nB-jYOPuvw and http://www.uio.no/studier/emner/matnat/ifi/INF4820/h17/timeplan/index.html#2-2
15:58:29
jmercouris
here's the top of the makefile: https://gist.github.com/4de76bd2e6250b5a8d54588e50c60a45
15:59:04
pjb
jmercouris: http://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful
15:59:18
phenoble
I'm currently learning CL. Any recommended resources on learning CL debugging techniques? I finished Seibel's "Practical Common Lisp" today. Nothing about debugging in there.
16:01:03
pjb
You may have extensions on directory names, when they're "file packages", as implemented on NeXTSTEP/OpenStep/MacOSX/iOS.
16:01:06
beach
phenoble: Unfortunately, the debugging tools available for free Common Lisp implementations are not so great.
16:01:46
pjb
phenoble: I have a little tutorial for clisp debugging. https://www.cliki.net/TutorialClispDebugger
16:01:54
beach
phenoble: Start by putting (proclaim '(optimize (debug 3) (speed 0) (safety 3) (compilation=speed 0))) in your start-up file.
16:02:06
phenoble
beach, jmercouris: that's unfortunate. Though I got the impression that some "trace" functionality would be a thing in CL debugging?
16:02:42
pjb
phenoble: not all implementation implement the STEP operator, or starting a trace from the debugger. For this, have a look at my conforming cl-stepper.
16:03:04
beach
phenoble: Otherwise, you need to stick a (break) in the place where you want to stop, then C-c C-c to compile that function, then run your program.
16:03:48
beach
phenoble: From the backtrace, you can then find local variables, and you can use the SLIME inspector to inspect them.
16:04:56
beach
phenoble: Most of the time, though, you run the program until it fails, look at the backtrace. Figure out why things were called the way they were. Hit SPACE in front of your stack frames, look at variables, inspect, etc.
16:05:22
pjb
phenoble: the thing is that since we can easily just redefine a function while running the program, lisp debugging techniques are often source-based. You just edit the source of your function, adding print and break and other forms to help you debug it, re-evaluate the function, and go on executing.
16:06:22
phenoble
beach: Yes, the standard is to be expected. Though I would not've been surprised if CL offered something extra-nice in conjunction with e.g. slime.
16:06:30
pjb
The only case where it's not possible, is when your function is on the call stack (it's being executed), such as a main loop, or when its calls are optimized (it's inlined), notably when it's called from other functions in the same file. For this, you have to declare it notinline and recompile the file.
16:06:53
pjb
(Probably a (debug 3) would make all functions notinline, check your implementation documentation).
16:06:55
beach
phenoble: It probably does, but you would have to pay for a commercial implementation.
16:07:32
beach
phenoble: There has not been enough manpower for the free implementations to become excellent when it comes to debugging techniques.
16:07:47
phenoble
pjb: I see. Yes. That's how I am increasingly working with elisp. Though my implementations are not all that nested, or dependent on each other. I could well imagine that even this rather comfortable style can get to its limits. So more sophisticated tools might become necessary.
16:08:27
MichaelRaskin
Also, Common Lisp has macros, so you can quickly add some interesting tracing where needed. Like writing a special trace-let macro that shows all the bindings as they are made
16:09:13
phenoble
MichaelRaskin: showing all the bindings as they are made... does that count as a modification of the compiler?
16:09:54
beach
phenoble: Yes, one way of looking at macros is as a means of programming the compiler.
16:11:04
phenoble
beach: I can imagine. I have a bit of a background in C++ metaprogramming, so I'm not all too new to the rationale behind it. Though this in particular, changing the way bindings are done or the like, intrigues me very much.
16:11:33
pjb
phenoble: have a look at OpenC++ https://www.informatimago.com/articles/life-saver.html
16:12:30
phoe
with Lisp macros, you simply accept some S-expressions and then output some S-expressions
16:12:40
beach
MichaelRaskin: For debugging, I would prefer not to modify the source. For one thing, it takes time to insert the code, and then I often forget to take it out. And I certainly don't want my "production" code to have debugging information in it. But it is also sometimes the case that the problem disappears when the code is modified that way.