Re: [racket-users] How to handle circular 'requires'

2018-05-15 Thread David Storrs
Incidentally, sorry for the mangled formatting / narrow margins that my emails keep having. I'm not doing that, it's coming from GMail. On Tue, May 15, 2018 at 10:06 AM, David Storrs wrote: > On Tue, May 15, 2018 at 1:28 AM, Matthew Butterick wrote: >> To add to your pile of options, because yo

Re: [racket-users] How to handle circular 'requires'

2018-05-15 Thread David Storrs
On Tue, May 15, 2018 at 1:28 AM, Matthew Butterick wrote: > To add to your pile of options, because you said "certain error conditions": > perhaps you might `raise` an exception in the db code that gets caught by > the network code (using `with-handlers`). In this way the dependency only > runs on

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Matthew Butterick
To add to your pile of options, because you said "certain error conditions": perhaps you might `raise` an exception in the db code that gets caught by the network code (using `with-handlers`). In this way the dependency only runs one direction (network module imports db module) but the db module

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread David Storrs
On Mon, May 14, 2018 at 10:07 PM, Greg Hendershott wrote: > David you wrote "both" so I just wanted to point out I read three ways: Good point; I misspoke. (Mistyped?) > 4. It doesn't sound like this is your case, but: If there are many > function calls where you pass the extra parameter, and t

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Greg Hendershott
David you wrote "both" so I just wanted to point out I read three ways: 1. Units 2. Callbacks (pass the function as a parameter). 3. Lazy-requires In a simple case (maybe yours?) I'd suggest trying 2 (callbacks) first, and see how that works for you in practice. Also: 4. It doesn't sound like t

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread David Storrs
Brilliant. I knew there had to be a clean way and both of these sound good. Thanks. Dave On Mon, May 14, 2018 at 4:56 PM, Alexis King wrote: > In addition to what Matthias says, you can also sometimes break these > kinds of cycles using lazy-require, which defers the requiring the other > modu

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Alexis King
In addition to what Matthias says, you can also sometimes break these kinds of cycles using lazy-require, which defers the requiring the other module until it is first needed. This is simpler than using units and provides stronger guarantees than using callbacks, but it is a bit more ad-hoc than bo

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Matthias Felleisen
> On May 14, 2018, at 4:28 PM, David Storrs wrote: > > My application retrieves chunks of files from the network and writes > them to disk, as well as writing certain data about them to the > database (e.g. where they are on disk and where they came from on the > network). > > I've split these

[racket-users] How to handle circular 'requires'

2018-05-14 Thread David Storrs
My application retrieves chunks of files from the network and writes them to disk, as well as writing certain data about them to the database (e.g. where they are on disk and where they came from on the network). I've split these functions into separate files: app/network/chunks.rkt app/lib/db/ch