Re: Feedback on idiomatic API design

2016-03-28 Thread Johan Haleby
Thanks everyone for your input. I just wanted to say that I have an initial version of the library available at my github page if anyone is interested. On Sat, Mar 12, 2016 at 3:43 PM, Timothy Baldridge wrote: > "Idiomatic" is

Re: Feedback on idiomatic API design

2016-03-12 Thread Timothy Baldridge
"Idiomatic" is always a hard word to define, and I think some of the points made here are good, but let me also provide a few guidelines I try to abide by when writing an API: Start with data, preferably hash maps. At some point your API will be consumed by someone else's program. Macros make it

Re: Feedback on idiomatic API design

2016-03-12 Thread Johan Haleby
Thanks a lot for your support and insights. I'm going to rewrite it to use "with-open" as we speak. On Sat, Mar 12, 2016 at 2:37 PM, Marc Limotte wrote: > Look at the source for the clojure.core with-open macro. In the repl: > `(source with-open)`. > > I think Gary is

Re: Feedback on idiomatic API design

2016-03-12 Thread Marc Limotte
Look at the source for the clojure.core with-open macro. In the repl: `(source with-open)`. I think Gary is right. with-open does exactly what you need, I should have thought of that, and you should probably use it. But if you want to get your version working, trying to understand what the

Re: Feedback on idiomatic API design

2016-03-11 Thread Johan Haleby
On Wed, Mar 9, 2016 at 7:32 PM, Marc Limotte wrote: > With the macro approach, they don't need to escape it. > Do you know of any resources of where I can read up on this? I have the macro working with an implicit "uri" generated but I don't know how to make it explicit

Re: Feedback on idiomatic API design

2016-03-10 Thread Johan Haleby
Very interesting approach indeed. I'm going to finish up the previous approach first then I'll look more closely into this. I like it, and its simple! Thanks! On Thu, Mar 10, 2016 at 10:51 AM, Gary Verhaegen wrote: > I would suggest a slightly different approach.

Re: Feedback on idiomatic API design

2016-03-10 Thread Gary Verhaegen
I would suggest a slightly different approach. First, define a record for your fake server, which implements Closeable; put your current "shutdown" code in the close method. This will allow you to use the existing with-open macro, instead of having to redefine your own, while leaving the option

Re: Feedback on idiomatic API design

2016-03-09 Thread Marc Limotte
With the macro approach, they don't need to escape it. On Wed, Mar 9, 2016 at 12:52 PM, Johan Haleby wrote: > Thanks a lot for your support Marc, really appreciated. > > On Wed, Mar 9, 2016 at 5:33 PM, Marc Limotte wrote: > >> Yes, I was assuming

Re: Feedback on idiomatic API design

2016-03-09 Thread Johan Haleby
Thanks a lot for your support Marc, really appreciated. On Wed, Mar 9, 2016 at 5:33 PM, Marc Limotte wrote: > Yes, I was assuming the HTTP calls happen inside the with-fake-routes! block. > > I missed the part about the random port. I se 3 options for that: > > *Assign a

Re: Feedback on idiomatic API design

2016-03-09 Thread Marc Limotte
Yes, I was assuming the HTTP calls happen inside the with-fake-routes! block. I missed the part about the random port. I se 3 options for that: *Assign a port, rather than random* (with-fake-routes! ...) But then, of course, you have to worry about port already in use. *An atom* (def

Re: Feedback on idiomatic API design

2016-03-08 Thread Johan Haleby
On Wed, Mar 9, 2016 at 6:20 AM, Johan Haleby wrote: > Thanks for your feedback, exactly what I wanted. > > On Tuesday, March 8, 2016 at 3:16:02 PM UTC+1, mlimotte wrote: >> >> I don't think you need a macro here. In any case, I'd avoid using a >> macro as late as

Re: Feedback on idiomatic API design

2016-03-08 Thread Johan Haleby
Thanks for your feedback, exactly what I wanted. On Tuesday, March 8, 2016 at 3:16:02 PM UTC+1, mlimotte wrote: > > I don't think you need a macro here. In any case, I'd avoid using a macro > as late as possible. See how far you get with just functions, and then > maybe at the end, add one

Re: Feedback on idiomatic API design

2016-03-08 Thread Marc Limotte
I don't think you need a macro here. In any case, I'd avoid using a macro as late as possible. See how far you get with just functions, and then maybe at the end, add one macro if you absolutely need it to add just a touch of syntactic sugar. routes should clearly be some sort of

Feedback on idiomatic API design

2016-03-08 Thread Johan Haleby
Hi, I've just committed an embryo of an open source project to fake http requests by starting an actual (programmable) HTTP server. Currently the API looks like this (which in my eyes doesn't look very Clojure idiomatic): (let [fake-server