markus.pfeiffer
2021-4-20 17:58:17

waves


markus.pfeiffer
2021-4-20 17:59:52

probably an easy question: I have today wrapped something that implements gen:graph in a struct (so, essentially (struct wrap (graph))

is there a convenient way for my wrap to “inherit” (or forward the calls to) gen:graph ?


markus.pfeiffer
2021-4-20 18:00:14

or is this somehow naughty and I should rethink my life (design of the program I mean)


capfredf
2021-4-20 18:11:34

I don’t think there is a built-in way to do this for a proxy structure. But you could do it through substructuring


capfredf
2021-4-20 18:13:28

which you probably won’t like it, since the meaning becomes is-a from has-a from an OO’s perspective.


josh803
2021-4-20 18:27:09

Hi! I’m trying to use rsound library on 8.0-bc (rsound doesn’t work on Chez Scheme version) on Windows 10. rsound implicitly requires the portsound libraries, which get installed as dependencies when you install the rsound package. I can get it to work from the IDE, but when I compile the portaudio.dll and callbacks.dll files are not included in the package and the executable crashes immediately. Even if I copy the files manually and rename them to be what the executable seems to be expecting, it still dies. Any idea what’s going on? I’ve tried “stand-alone” and “distribution” for compiling, with and without “Embed DLL’s in executable?” checked. Thanks in advance!


capfredf
2021-4-20 18:30:18

@mflatt For creating a struct-info , what’s the benefit of making a struct-info list over using make-struct-info given that I should make the thunk for the latter return a list?


markus.pfeiffer
2021-4-20 18:59:00

I wonder whether I could cook up some reasonably horrible macro magic that lets me forward generics (and whether I´ll need this often enough to warrant it)



samdphillips
2021-4-20 20:35:56

I’ve definitely thought about wrapping and proxying generic methods, but I’m not sure if I made a macro to make it easier.


samdphillips
2021-4-20 20:44:20

This seems short enough to paste: #lang racket/base (require racket/generic) (define-generics foo [do-foo foo]) (struct bar () #:methods gen:foo [(define (do-foo foo) 'in-a-bar)]) (struct baz (inner-foo) #:methods gen:foo [(define-syntax-rule (define-via-proxy method inner) (begin (define/generic inner-method method) (define (method a . args) (apply inner-method (inner a) args)))) (define-via-proxy do-foo baz-inner-foo)])


samdphillips
2021-4-20 20:44:45

It’s wordy for one method but for a bunch it could help.


markus.pfeiffer
2021-4-20 20:47:35

that looks a bit like what I had cooked up today; I think I had defined the syntax rule outside of the struct and it didn´t expand;


samdphillips
2021-4-20 20:47:39

Oh, define-via-proxy can be lifted to the top level so it is reusable too.


markus.pfeiffer
2021-4-20 20:47:52

extra points for just being able to export all methods :wink:


samdphillips
2021-4-20 20:48:13

I think that requires generics introspection that isn’t in the public api


markus.pfeiffer
2021-4-20 20:49:08

it most certaily would, how else would you know what to proxy :wink:


markus.pfeiffer
2021-4-20 20:49:51

cheers all, this at least makes it at least feel sligthly less copy-and-pasty


cris2000.espinoza677
2021-4-20 23:19:58

question, how do I programmatically move a panel scroll?


zhuravok96
2021-4-20 23:22:58

@zhuravok96 has joined the channel


a.nastaev
2021-4-21 00:54:48

I am going through HTDP 2, specifically I am here https://htdp.org/2020-8-1/Book/part_three.html#%28part._sec~3afunc-similarities%29 When I am just copying this code from the book and running it in DrRacket: (define (extract R l t) (cond [(empty? l) '()] [else (cond [(R (first l) t) (cons (first l) (extract R (rest l) t))] [else (extract R (rest l) t)])])) I am getting an error: Welcome to DrRacket, version 7.9 [3m]. Language: Beginning Student; memory limit: 128 MB. function call: expected a function after the open parenthesis, but found a variable > Couldn’t figure out what is going on :disappointed: Is it a typo in the book? I would appreciate any possible help here! Thanks a lot in adavnce!


sorawee
2021-4-21 01:01:48

You should switch the language to “Intermediate Student Language”


sorawee
2021-4-21 01:02:25

a.nastaev
2021-4-21 01:13:22

Aaaaaaa, yes! Thank you so much @sorawee! I really appreciate it!


mflatt
2021-4-21 01:37:28

I don’t know of a benefit for making it a list. There are two options just because a list was the original, and the thunk option was added for more flexibility.


mflatt
2021-4-21 01:45:17

It looks like rsound and portaudio are not set up for raco exe, at least not for the normal way. The normal approach is to use define-runtime-path so that raco exe and raco dist know to pull the libraries along.

The portaudio package seems to look for libraries via the portaudio/lib collection directory. It’s possible that you could arrange for the portaudio/lib directory to be found relative to the executable though raco exec flags like --collects-path, but it’s probably not easy to get all the right flags and directories in place.


josh803
2021-4-21 03:31:46

You’ve got that right! I spent several hours diving down various rabbit holes with that. With what I know now about how raco is collecting things (or not), I might be able to make it work, but I wound up using sdl2 Mixer instead. Thanks very much for taking a look!