hectometrocuadrado
2021-1-22 08:22:31

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
2021-1-22 09:04:37

@zengmor has joined the channel


laurent.orseau
2021-1-22 09:06:10

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.


hectometrocuadrado
2021-1-22 09:16:28

Nice, thank you!


alexharsanyi
2021-1-22 09:21:40

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?


bmitchell33
2021-1-22 15:00:21

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.


bmitchell33
2021-1-22 21:26:54

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.


bmitchell33
2021-1-22 21:27:07

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


ben.knoble
2021-1-22 22:19:23

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


notjack
2021-1-22 22:20:12

Write an #%app macro



notjack
2021-1-22 22:21:18

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


notjack
2021-1-22 22:22:00

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


ben.knoble
2021-1-22 22:23:32

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)


sorawee
2021-1-22 22:23:49

How accurate does it need to be?


ben.knoble
2021-1-22 22:26:00

Not perfect; it’s for checking students code.


laurent.orseau
2021-1-22 22:29:05

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


laurent.orseau
2021-1-22 22:30:21

Do they use full racket ot some more limited language?


ben.knoble
2021-1-22 22:33:41

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


laurent.orseau
2021-1-22 22:34:15

Then the sandbox sounds like a good idea indeed


bmitchell33
2021-1-23 01:06:15

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.