Yes, that’s what I meant. But beware! This is a quasi OO style. — Matthias
p.s. In plain Racket, structs serve as an opaque carrier of values. > On Apr 24, 2016, at 1:56 PM, Benjamin Greenman <[email protected]> > wrote: > > > On Sun, Apr 24, 2016 at 1:47 PM, Daniel Karch <[email protected] > <mailto:[email protected]>> wrote: > how this could be done with structures > > One way is to consider the struct definition as an interface. Then different > values can implements the same interface & be used in a uniform way. > > Here's a struct that I used as an interface for web scrapers. (Scraping > definitions of English words from dictionary web sites) > https://github.com/bennn/iPoe/blob/master/ipoe/private/scrape/scrape-words.rkt#L42 > > <https://github.com/bennn/iPoe/blob/master/ipoe/private/scrape/scrape-words.rkt#L42> > > With that definition (and `prop:procedure` to make instances of the struct > callable), it's easy to write a function that queries a bunch of web scrapers > in order and returns as soon as one scraper finds a result. > https://github.com/bennn/iPoe/blob/master/ipoe/private/scrape/scrape-words.rkt#L32 > > <https://github.com/bennn/iPoe/blob/master/ipoe/private/scrape/scrape-words.rkt#L32> > > The above code is untyped, but should work in Typed Racket. If you want I can > port an example. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

