
Racket is optimized for using functional programming but C is not. Using ffi, what I should to prioritize? Assigments like ptr-set!
or array-set!
, or is preferable to generate new pointer or arrays?

@zengmor has joined the channel

I’d say try to do as much as possible in Racket, in particular GC, unless you know precisely what’s wrong with Racket in your circumstances that you could fix with C—which should be rather rare.

Nice, thank you!

the editor-snip%
has margins which default to 5 and insets which default to 1. Perhaps you want to create the editor snip with all these set to zero?

Yea, those are all set to zero in the code that generated that picture (it’s the same code as before just with the addition of setting those initialization properties and adding in the super draw). I’m confused where the border and margins are coming from. It’s almost like the pasteboard editor that’s given to the editor-snip has some margin and border and “snaps” to the snip.

Nevermind, I’m an idiot. Haha. I didn’t notice that I pasted those properties into my custom init
method rather than super-new
. I had tried those methods but because they weren’t passed to the super, they didn’t take affect, hence my confusion since I thought I had passed them in.

Anyway, thank you for the help on the editor-snip% draw method.

If I had a set of racket-code as an s-expression (e.g., (define code '(…))
, what’s the best way to find everything in “operator position” and avoid finding the parts of bindings like let
? (example: in (let ([e (+ 1 2)]) (* e 3))
, I only care about +
and *
and possibly let
, though e
is in a head-position). I suspect that either • there’s a library for that (@notjack? maybe you know a way to do this with your refactoring code?) • I’m going to have write a large match
and add by hand any expressions that we want to treat specially

Write an #%app
macro


Oh I missed the part of your question where you have an s-expression, not actual code

I think a large match
is the best to can do there

Hm, could I define the #%app
in a submodule and eval
the S-expression? it’s not trusted code, but I know how to use a sandbox (doing that already for rackunit
checks)

How accurate does it need to be?

Not perfect; it’s for checking students code.

Don’t you just need (random max-grade)
then?

Do they use full racket ot some more limited language?

Full-racket atm. I wanted to use racket/base, but was told we should use full-racket :slightly_smiling_face:

Then the sandbox sounds like a good idea indeed

Looks like I finally figured out how to get what I wanted, but still figuring out why and if it’s the best way.
It seems that one needs to both override on-paint
for the pasteboard%
that’s given to the editor-snip%
AND override draw
for the editor-snip%
itself. In this case, I just used the exact same drawing procedure for both. It seems weird to me, but at least I get what I wanted, for now. Still working on why there’s weird drag behavior.