michael.ballantyne
2017-10-12 15:29:00

@michael.ballantyne has joined the channel


notjack
2017-10-12 17:30:31

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


blerner
2017-10-12 17:36:04

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


notjack
2017-10-12 17:36:42

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


notjack
2017-10-12 17:36:53

because if not you’re in for a fun surprise


blerner
2017-10-12 17:37:07

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


leif
2017-10-12 17:40:17

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


leif
2017-10-12 17:41:04

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))


leif
2017-10-12 17:42:03

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))))


mflatt
2017-10-12 17:59:35

@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!)?


stamourv
2017-10-12 18:00:33

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


royall
2017-10-12 18:01:52

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


stamourv
2017-10-12 18:02:37

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


royall
2017-10-12 18:03:03

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


royall
2017-10-12 18:03:40

Oh wait, I totally misread that


royall
2017-10-12 18:03:46

maybe that does print to stdout


notjack
2017-10-12 18:04:39

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?


notjack
2017-10-12 18:05:13

stamourv
2017-10-12 18:06:30

@royall: PRs definitely welcome!


stamourv
2017-10-12 18:06:46

And I think it should indeed be printing to stdout.


royall
2017-10-12 18:07:28

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


stamourv
2017-10-12 18:07:28

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.


notjack
2017-10-12 18:08:35

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


royall
2017-10-12 18:09:07

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?


royall
2017-10-12 18:09:29

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


notjack
2017-10-12 18:09:33

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


greg
2017-10-12 18:14:00

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


greg
2017-10-12 18:14:21

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


leif
2017-10-12 18:14:30

@mflatt That is correct.


leif
2017-10-12 18:14:48

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


leif
2017-10-12 18:14:56

They are (for the moment) a memory leak.


leif
2017-10-12 18:15:55

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


greg
2017-10-12 18:16:48

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


greg
2017-10-12 18:17:30

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


greg
2017-10-12 18:17:59

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


greg
2017-10-12 18:18:16

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


mflatt
2017-10-12 18:18:27

@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.


greg
2017-10-12 18:19:25

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


royall
2017-10-12 18:19:29

Thanks, I’ll add these to my notes


leif
2017-10-12 18:19:51

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


greg
2017-10-12 18:19:53

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


leif
2017-10-12 18:20:15

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


mflatt
2017-10-12 18:20:33

I guess the interesting part is: what calls racket_log_callback?


leif
2017-10-12 18:21:09

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); } }


leif
2017-10-12 18:22:26

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.


leif
2017-10-12 18:22:32

And then it calls the racket callback and returns.


mflatt
2017-10-12 18:23:00

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


leif
2017-10-12 18:23:04

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


leif
2017-10-12 18:23:21

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


leif
2017-10-12 18:23:53
  (av-log-set-callback ffmpeg-log-callback)

leif
2017-10-12 18:24:33

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


leif
2017-10-12 18:25:14

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


leif
2017-10-12 18:25:26

So I would imagine _fpointer is good enough for that.


leif
2017-10-12 18:25:38

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


leif
2017-10-12 18:35:19

@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


leif
2017-10-12 18:35:47

Which seems like a suspiciously low address to me…


leif
2017-10-12 19:35:02

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



leif
2017-10-12 19:36:25

lol…thanks.


apg
2017-10-12 20:09:08

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


apg
2017-10-12 20:10:50

@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)


apg
2017-10-12 20:12:06

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.


jbclements
2017-10-12 21:12:00

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:.


apg
2017-10-12 22:27:35

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


apg
2017-10-12 22:27:57

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


apg
2017-10-12 22:29:41

ah. it’s in plt-index.js


lexi.lambda
2017-10-12 22:33:57

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


mflatt
2017-10-12 22:34:16

@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
2017-10-13 01:23:09

@zafar.huma has joined the channel


drdeeglaze
2017-10-13 05:44:27

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


drdeeglaze
2017-10-13 05:44:39