I was developing this project of mine, which has an intricate business
logic, and I wrote a macro that makes programming this kind of stuff
more comfortable. It's called "ilet", which stands for "implicit let".
The name is probably no longer appropriate, since I added more
features to it, but I can't make up anything better right now.

I'd really appreciate it if you could dissuade (or persuade) me from
posting this to clojure-dev for inclusion in contrib. I need to know
if this could be useful to someone besides me.


Here's the rationale of the ilet macro. (Warning: the examples are
silly. See below for a real world example.)

We have "->" in Clojure because it lets you do dataflow-programming-
like manipulations. The first version of ilet was used in a similar
way, but it simply bound a symbol ($). It works like "->" but it's
more flexible, because you can put the value of the previous
expression wherever you want (e.g., see http://pastebin.com/g7k8wK4a).

This is nice, but it's often useful to bind symbols explicitly. Using
a "let" inside an "ilet" is clunky, so I added this capability inside
"ilet" itself. If you write [symbol] [expression], ilet interprets
that as an explicit binding (see http://pastebin.com/2VJ8D738).

Finally, I wanted to be able to interrupt this kind of calculations.
Unfortunately, Clojure doesn't provide any return-like constructs:
you'd need to use if's and cond's. So I added a new syntax to ilet:
"<" [condition] [expression]
where if [condition] is true, the value of the whole ilet expression
is just [expression] (see http://pastebin.com/np2M9kZr).


I hope my explanation was clear, in spite of my poor English.

This is the definition of the ilet macro: http://pastebin.com/nHLifsu3

And this is a real world example, straight from my repository:
http://pastebin.com/xGQT1c5h


Thank you all for your input!

-- 
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

Reply via email to