On Mon, Nov 18, 2013 at 7:48 PM, Jeremy Heiler <jeremyhei...@gmail.com>wrote:

> I am interested in what you think about generating functions at compile
> time (with a macro) from data. The specific use case I am thinking about
> pertains to libraries for large web services with a lot of endpoints. A
> cost-benefit analysis could probably be done for what size is appropriate,
> but lets just assume the number of endpoints is large enough for you to
> start thinking about this.
>
> Potential advantages include:
>
> - Less boilerplate. It would be less annoying to maintain data that
> represents each endpoint and generate the boilerplate than it is to
> maintain a lot of repetitive code.
>
> - Shareable. The work done to maintain the endpoint data could be used by
> multiple libraries for multiple languages. In fact, it could be maintained
> by the web service itself.
>
> Potential disadvantages include:
>
> - Limited discoverability. If the code is generated at compile time, there
> is no direct source for it, which may hinder the ability to view or
> generate documentation with your favorite tool(s).
>
> - Complicated edge cases. Endpoints that require extra code are usually
> edge cases, but not always. Regardless, breaking from the template may
> complicate the code further. (I don't think this is a difficult problem to
> solve, though.)
>
> One way to alleviate the "limited discoverability" problem is to generate
> source code at build time. This is what you would do in langauges like
> Java, and that has always left me frustrated, so I am not inclined to think
> it's a good idea. However, feel free to make the case!
>
> A language like Clojure makes doing this relatively easy, but is it simple?
>

Another consequence of this that I forgot to mention in the mail above is
that there will either need to be way for the library to self-execute the
macro or require the user to initialize the library. The latter might not
be too bad considering global (immutable) configuration such as
authentication credentials and URLs are necessary.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to