On 03/25/2011 11:37 AM, Ken Wesson wrote:
Interesting, but you just listed title and body twice, where the goal was to
not list them at all (except in the definition of Article and in the html
form, of course, though theoretically, the form could be generated from a a
bit richer single definition, I suppose).
I extracted them from save-article to what's basically a
Clojure-friendlier constructor for Article. Is there a reason for you
to consider this goal supremely important?
Yes, it was the whole reason to not be satisfied with just destructuring
in the signature. To be concise, avoiding any repetition. While perhaps
enlightening, anything that makes me end up writing more, not less, is
not practical.
By now I'm rather sure this would trigger an error, as nothing but an
immediate call of Article. seems acceptable for ds/save!.
Why do you say that? Either your ds-save! is a function that accepts
Article objects, and that apply expression returns one; or else your
ds-save! is a macro that accepts an s-expression that will become part
of its expansion and which works if it evaluates to an Article object
at run-time, which the apply expression does.
I say that because of what Meikel said at
http://groups.google.com/group/clojure/msg/2f2b97b627da2d1d?hl=en
and because my experiments suggest so.
If for some reason you've made it a macro that accepts an
s-expression, but parses it itself and expects it to be a constructor
invocation, then I suggest you rewrite it to accept any s-expression.
Otherwise, the style should be separate parameters, e.g. (defmacro
ds-save! [classname& ctor-args]) to make it simpler to implement and
to make it clear to its users that it cannot take general-purpose
sexps that return the appropriate Java type.
But really, it should accept pure function invocations happening in
its context, at least -- and the only possibly-impure thing in the
apply/getseq/new-article chain there is the Article constructor
invocation itself, which would be there anyway.
I didn't write it, it's part of appengine-magic. It appears in a
defprotocol and if I get this right, is mapped to a save!-helper
function in a defprotocol. So at my current level, I really couldn't
have written that :)
https://github.com/gcv/appengine-magic/blob/v0.4.0/src/appengine_magic/services/datastore.clj
--
Thorsten Wilms
thorwil's design for free software:
http://thorwil.wordpress.com/
--
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