
@michael.ballantyne has joined the channel

TIL tonyg has a package for sending and receiving raw Ethernet frames in Racket https://github.com/tonyg/racket-packet-socket

Not quite sure why, but the name of that packet reminds me of this gem: http://web.mit.edu/adorai/www/seuss-technical-writing.html

@blerner you did read the README poem right? :p

because if not you’re in for a fun surprise

no, but I’m glad Tony and I thought along the same vein…

@mflatt Welp, looks like I had the segfault solved, but its still there.

Possibly a different thing, as it does seem like this will make the callback last indefinitely: (define-libvid set-racket-log-callback
(_fun (_fun #:async-apply (λ (x) (let loop () (displayln "NO") (loop)) (x))
#:keep malloc-immobile-cell
_bytes _av-log-constant _int _bytes
-> _void) -> _void))

I kind of wonder if I’m doing something in atomic mode that is not allowed. Namely, these two functions which are in atomic mode: (define (callback-proc name level len msg)
(define name* (or name #"???"))
(set! ffmpeg-log-list (cons (ffmpeg-msg name* level msg) ffmpeg-log-list)))
(define (flush-ffmpeg-log-list!)
(call-as-atomic
(λ ()
(define ret ffmpeg-log-list)
(set! ffmpeg-log-list '())
(reverse ret))))

@leif The callbacks look ok to run in atomic mode, but I’m unclear on the lifetime of the arguments pass to the callback installed by set-racket-log-callback
– given that callback-proc
keeps the arguments for use later and returns. Are those arguments things that live beyond the dynamic extent of the call to the callback (and they’re eventually freed by whatever calls flush-ffmpeg-log-list!
)?

@royall: Yes. There’s a (not very friendly) command-line interface: racket -l optimization-coach/report my-file.rkt

Friendly or not, sounds like a good starting point for integration with other editors or CI tools

Ah, if that’s the goal, then it may not be so bad. Its output is mostly machine readable.

If you’re willing to accept PRs for other output modes (like stdout) then that may be my next Racket experiment

Oh wait, I totally misread that

maybe that does print to stdout

at racketcon office hours there was mention of some work on getting racket to cooperate with some “editor server” protocol used by things like eclipse and visual studio, maybe the optimization coach could be part of that?


@royall: PRs definitely welcome!

And I think it should indeed be printing to stdout.

I’m thinking Emacs integration myself. Does anyone edit Racket with a tool that supports this protocol?

A raco optimization-coach
command would be nice (and I have half the plumbing for that sitting around), but that would need a more human-friendly output.

@royall re emacs integration: would that be built on top of racket-mode
or would it be something completely separate?

I don’t understand it well enough to say. racket-mode
seems like a fine candidate, but maybe it would be more appropriate to integrate with Flycheck?

I only just adopted full-time emacs a few weeks ago after using Jetbrains tools for many years

I don’t use emacs at all so I know virtually nothing about its ecosystem

wrt to emacs I’d suggest step 0 is simply make sure any command-line tool prints error-like messages in a standard way

like /full/path/to/file:line:col some message here

@mflatt That is correct.

Although, I should mention that at the moment, those objects never get freed.

They are (for the moment) a memory leak.

(I will fix that later, for now keeping them takes relatively little space, and helps with debugging things.)

Then you can use various emacs things to run the tool (a shell, or async-shell-command
), and next-error
will work on the output

A counter-example, that’s kind of awkward, is when Racket elides paths in messages with <pkgs>/some/path/to/file
and then next-error can’t work

For the racket-mode REPL, specifically, I set an error display handler to not do those special prefixes

But for command-line tools in general, try to just do the full path in the first place :slightly_smiling_face:

@leif What is the C-level function that corresponds to set-racket-log-callback
? I think a callback installed with av_log_set_callback
will not necessarily get values for the first (likely, but probably not guaranteed) or fourth (definitely not) arguments that live beyond the callback.

Anyway, with that, even if you want to wrap async-shell-command
and next-error
in some convenience stuff, it’s just a thin wrapper and there’s no wheel re-inventing

Thanks, I’ll add these to my notes

@mflatt Here it is: void set_racket_log_callback(void (*callback)(RACKET_CALLBACK_TYPES)){
racket_log_callback = callback;
}

Just my suggestion for step 0. Not necessarily trying to discourage steps 1 … ¯_(ツ)_/¯

Where racket_log_callback
is: void (*racket_log_callback)(RACKET_CALLBACK_TYPES) = NULL;

I guess the interesting part is: what calls racket_log_callback
?

That would be ffmeg_log_callback
, whose implementation is: void ffmpeg_log_callback(void * avcl,
int level,
const char * fmt,
va_list vl) {
int buffsize;
char find_size_buf[FIND_BUFF_SIZE];
char *buff;
va_list size_vl;
size_t namesize;
const char *tmp;
char *name = NULL;
if(avcl) {
tmp = ((AVClass*)(*(void**)avcl))->class_name;
namesize = strlen(tmp);
name = malloc((1 + namesize)*sizeof(char));
strncpy(name, tmp, (1 + namesize));
}
if(racket_log_callback) {
va_copy(size_vl, vl);
buffsize = vsnprintf(find_size_buf, FIND_BUFF_SIZE, fmt, size_vl);
buff = malloc((buffsize + 1) * sizeof(char));
vsnprintf(buff, buffsize + 1, fmt, vl);
va_end(size_vl);
racket_log_callback(name, level, buffsize, buff);
} else {
vsnprintf(find_size_buf, FIND_BUFF_SIZE, fmt, vl);
}
}

More or less it takes the va_list, duplicates it, calls vsnprintf
once to get the buffer size, calls vsnprintf
again (on the now duplicated list) again to fill in the actual buffer.

And then it calls the racket callback and returns.

Ok, that makes sense. I’m out of ideas just by looking at the definitions.

From the racket side, that call is defined as: (define-libvid ffmpeg-log-callback _fpointer)

And the reason its called that way is because its used in this context:

(av-log-set-callback ffmpeg-log-callback)

Where the type of av-log-set-callback
is: (define-avutil av-log-set-callback (_fun _fpointer -> _void))

And _fpointer
is used because the type includes a va_list, and so Racket is just plugging the one c function into the other.

So I would imagine _fpointer
is good enough for that.

@mflatt Ah, okay. Thanks anyway. :confused:

@mflatt hmm…you know, I wonder if I can start this up in gdb and get interesting results. (BTW, the error I am getting is): racket(29704,0x7fff76471000) malloc: *** error for object 0xd01: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1] 29704 abort racket -W debug -l raco video mosaic.rkt

Which seems like a suspiciously low address to me…

And of course running racket in a debugger makes the segfault go away. :disappointed:


lol…thanks.

I’d be interesting to integrate this into say, racket-mode or something.

@royall @notjack it might actually be best to start with a something even smaller — a simple minor-mode in the likes of go-lint-mode
(https://github.com/golang/lint/blob/master/misc/emacs/golint.el)

but, to @greg’s point, that’s probably step 1. step 0 is making sure you can easily jump to the error with the output matching something emacs can understand.

doc search question: how do I tag my rsound docs so that they show up for users searching in the lang/htdp-beginner context? I’m not even sure whether this information goes in the .scrbl file or in my info.rkt. I’ve spent my obligatory 10 minutes searching, so now I’m asking for help :slightly_smiling_face:.

@jbclements more basic question: how does doc search even work?

where’s the index data? It’s gotta be local since I don’t see any network requests to search…

ah. it’s in plt-index.js

the racket-index
package is what actually renders the documentation index, IIUC https://github.com/racket/racket/tree/master/pkgs/racket-index

@jbclements It looks like the set of places to search is hardwired into the language: https://github.com/racket/htdp/blob/master/htdp-lib/lang/htdp-langs.rkt#L600

@zafar.huma has joined the channel

I’m working out a definition for a standard-cat pict. Haven’t played with whiskers yet. Here’s the gist https://gist.github.com/deeglaze/31bc02c325acdef4d67daec8c3af06e1
