waves
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 ?
or is this somehow naughty and I should rethink my life (design of the program I mean)
I don’t think there is a built-in way to do this for a proxy structure. But you could do it through substructuring
which you probably won’t like it, since the meaning becomes is-a from has-a from an OO’s perspective.
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!
@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?
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)
I think that you can use define/generic (doc: https://docs.racket-lang.org/reference/struct-generics.html?q=define%2Fgeneric#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29\|https://docs.racket-lang.org/reference/struct-generics.html?q=define%2Fgeneric#%28form._%28%28lib._racket%2Fgene[…]c..rkt%29._define%2Fgeneric%29%29) in the #:methods part of the struct definition to forward the calls to generic functions.
I’ve definitely thought about wrapping and proxying generic methods, but I’m not sure if I made a macro to make it easier.
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)])
It’s wordy for one method but for a bunch it could help.
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;
Oh, define-via-proxy can be lifted to the top level so it is reusable too.
extra points for just being able to export all methods :wink:
I think that requires generics introspection that isn’t in the public api
it most certaily would, how else would you know what to proxy :wink:
cheers all, this at least makes it at least feel sligthly less copy-and-pasty
question, how do I programmatically move a panel scroll?
@zhuravok96 has joined the channel
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!
You should switch the language to “Intermediate Student Language”
An earlier section instructs you to do that: https://htdp.org/2020-8-1/Book/part_three.html#%28part._ch~3add-similarities%29
Aaaaaaa, yes! Thank you so much @sorawee! I really appreciate it!
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.
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.
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!