freenode/lisp - IRC Chatlog
Search
0:41:49
sjl
I think I'll probably end up using flexi-streams. My next question is how to check whether a stream supports binary i/o.
0:42:20
sjl
(subtypep (stream-external-format s) 'integer) is close, but doesn't pick up e.g. SBCL's bivalent streams
0:58:58
Xach
fwiw: binary adj. 1. (of a stream) being a stream that has an element type that is a subtype of type integer.
0:59:44
Xach
i agree that sbcl bivalent streams don't look like they can be sussed out by the element-type
1:03:35
jasom
suggestions for wall-clock profiling of sbcl? I am getting about a 1:4 ratio of CPU to wall-clock time, and assume it's I/O bound in foreign libraries, but am not sure if there's a better way than manually instrumenting my code.
1:41:01
jasom
blargh. So sb-sprof has a :mode :time option, which should do what I want. However, I have 8s of wall-clock time and only ~2s worth of samples. If I add a (sleep 2) to the main body of my with-profiling, I get ~4s worth of samples. Anybody know what sorts of thing(s) sb-sprof can't discover runtime from?
1:53:54
sjl
my goal is to have a function users can call which takes a stream and reads the image from it, and returns a Lisp array with the pixel data
1:57:06
Xach
sjl: when i am faced with problems like that, i deal only with binary streams but make it easy to express the ascii codes as characters to be translated to code for parsing.
1:58:09
sjl
which brings me back to my request: how do I detect that they've given me what I've asked for, so I can fail with a nice error message if they don't
1:58:43
Xach
so, a character, a bare code, or a symbolic thingy could match, but obviously only against an integer underneath
1:58:49
sjl
I could live with (assert (stream-supports-binary-ops-p ...) ...) at the beginning of the function
1:59:13
sjl
but I don't want someone to pass a character input stream and get a stack trace from wherever the hell my first `read-byte` function call happens to be
2:00:04
sjl
I was hoping either flexi-streams or trivial-gray-streams might have something, but couldn't find anything
2:01:16
Xach
it's basically a way to get rainer joswig to dig into it, or sam steingold, or a handful of other prolific commenters who aren't usually here.
2:03:02
Xach
sjl: i like the noble goal of a nice direct error like "use a binary stream" but it feels somewhat out of reach to me in this situation
2:03:16
sjl
Streams are used all over the place in CL -- I don't want to have to force users to figure out how to use some weird byte-reading interface
2:04:06
pjb
sjl: this is idiotic. Will you be able to parse the image if the stream is a binary stream of (unsigned-byte 3)?
2:05:37
Xach
sjl: one thought is you could try to read the magic with a read-byte and if it fails, try a read-char, and if that succeeds signal a nice error of some sort.
2:05:59
dmiles
well one thing that is possible (thinking about what pjb is saying) is that you might be able to create a small sanity test for the stream type you get provided and test if certain bytes come back accurate based on a file that you know what should be therer
2:07:05
pjb
sjl: the point is that it's not up to your client to choose the stream type! You must open the file yourself using the kind of stream you want!
2:07:17
Xach
there are a handful of reasons read-byte could fail, so it would be speculative to mention non-binary-ness
2:08:18
pjb
sjl: alternatively, you could parse a in-memory string (or byte vector), and let the client do the I/O.
2:08:59
dmiles
ahah, what pjb said is really agood idea.. copy the stream data to a stream you know the details of
2:09:09
pjb
It's always a good idea to separate the concerns and avoid doing the I/O in the processing code.
2:09:21
sjl
sure, I could provide alternative interfaces. But it should also be able to take an input stream. What if they've implemented their own kind of stream (via trivial-gray-streams) and want to use its functionality?
2:10:39
sjl
I can't avoid interleaving the processing and the reading -- I need to know how much data to read, which is encoded partway through the file header
2:10:54
dmiles
(though i guess is just getting the stream copied correctly is the basic underlying problem)
2:10:56
sjl
I'm not just gonna copy the entire stream contents into a buffer or something. There could be more things in the stream after the file
2:12:39
dmiles
*not* what i am wondering is if you wanted to copy the data out of the stream is even really possible
2:13:16
sjl
Xach: I read an article somewhere that mentioned them, and they seem like a simple way to get graphics in/out, using e.g. imagemagic to reencode at the boundaries
2:13:40
Zhivago
sjl: Presumably you don't care about streams -- just about reading the next N bytes -- so why not just provide a function which does that?
2:14:31
sjl
Zhivago: I care about providing a simple interface to the user, not working around the streams problem by making them provide a function
2:14:42
dmiles
Zhivago: i assume slj is wanting to be able to in most cases be able to extract which accessor will make sense
2:14:58
sjl
I want them to say (read-ppm-from *standard-input*) not (read-ppm-with (alexandria:curry #'read-byte *standard-input*))
2:18:21
Zhivago
sjl: You have stream-element-type which should allow you to automatically select an appropriate accessor, no?
2:19:28
sjl
Zhivago: I want to ensure binary streams, but not exclude bivalent streams like sbcl's standard-input
2:19:33
Xach
it did give me some lemonodor-fame over 10 years ago though! http://lemonodor.com/archives/2004/06/flashy.html
2:22:29
dmiles
actualy what almost sounds reasonable is for the user to &key stream-type for bivaliant streams
2:23:12
sjl
I think Xach's idea of trying to read the magic byte with read-byte first is a good compromise
2:32:12
dmiles
i would have expected the user to use the wrong type of stream even out of no choices so reading for a magic would be required most cases
2:47:59
dmiles
in a program i work with, a user supplies concatenated ascii and binary mixed from FASLs over a socket opened as either ascii or binary .. so in most transmitions i must change the element types based on some headers and even then they tend to lie
3:03:05
Zhivago
dmiles: Just imagine how much simpler it would have been if they couldn't do that. :)
7:19:59
fiddlerwoaroof
So, I've noticed there's been a lot of talk about abandoned libraries and libraries that are about to be abandoned.
7:20:40
fiddlerwoaroof
I'd love to be able to be able to help maintain some libraries, but I don't have much spare time these days
7:56:33
Fare
so no big breakage expected. Actually, Xach and stassats will probably be relieved that I'm not there anymore... unless someone even more radical than I replaces me, of course.
8:35:36
jackdaniel
code doesn't belong to "self-documenting" type either, so maintaining it would require some motivation and time
12:09:30
dmiles
if someone use LABELS at the toplevel of a file, are these declared in the global environment?
12:13:35
jackdaniel
so if you define functions A and B in labels and you call B from A, it will call this B you have defined
12:14:11
jackdaniel
if you define them in flet, then it will call B from the environment in which you put flet/labels
12:15:12
jackdaniel
try (defun a () (pring "hi!")) ; (labels ((a () (print "hi from labels!")) (b () (a))) (b)) ; (flet ((a () (print "hi from flet!")) (b () (a))) (b))
12:21:57
elonopea
anyone know how to turn off auto-repeat-mode in CLX for the duration the program is running, and then ensure it's turned back on before gracefully exiting? I currently have the auto-repeat-mode turned off globally before the loop, and turn it back on on a key-release event, but this doesn't work unless I return nil from the key-release clause. if I close/destroy the window/display within the key-release clause, auto-repeat-mode gets
12:23:14
elonopea
I then issue Abort and get back to REPL with key repeat back on, but how to do this cleanly?
12:24:03
elonopea
sorry, auto-repeat-mode gets turned ON if I destroy the screen/display within the clause
12:25:43
elonopea
I thought I could just add the call to turn auto-repeat-mode off into the key-release event clause (within event-case) as that would return T, but although the program exits auto-repeat-mode stays off
12:28:57
elonopea
I'm not sure how to go about this. yes, key repeat remains off globally in X after the program exits.