Re: Implicit unpacking of a map

2011-03-25 Thread Ken Wesson
On Fri, Mar 25, 2011 at 9:03 AM, Thorsten Wilms wrote: > On 03/25/2011 11:37 AM, Ken Wesson wrote: > >>> 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

Re: Implicit unpacking of a map

2011-03-25 Thread Thorsten Wilms
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 definitio

Re: Implicit unpacking of a map

2011-03-25 Thread Ken Wesson
On Fri, Mar 25, 2011 at 5:09 AM, Thorsten Wilms wrote: > On 03/25/2011 01:34 AM, Ken Wesson wrote: >> >> What about this? First, use :title and :body keywords instead of >> "title" and "body" strings as keys in form-params. Then define this >> utility function: >> >> (defn get-seq [m & kws] >>   (

Re: Implicit unpacking of a map

2011-03-25 Thread Meikel Brandmeyer
Hi, On 25 Mrz., 10:09, Thorsten Wilms 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 singl

Re: Implicit unpacking of a map

2011-03-25 Thread Thorsten Wilms
On 03/25/2011 01:34 AM, Ken Wesson wrote: What about this? First, use :title and :body keywords instead of "title" and "body" strings as keys in form-params. Then define this utility function: (defn get-seq [m& kws] ((apply juxt kws) m)) which takes a map and one or more keywords (cannot be

Re: Implicit unpacking of a map

2011-03-24 Thread Ken Wesson
What about this? First, use :title and :body keywords instead of "title" and "body" strings as keys in form-params. Then define this utility function: (defn get-seq [m & kws] ((apply juxt kws) m)) which takes a map and one or more keywords (cannot be other types of key) and returns a seq (actua

Re: Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms
On 03/24/2011 09:38 PM, Alan wrote: A macro should work fine if you use ~@ instead of just ~. (defmacro save-article [path form-params timestamp] `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp))) Thanks for the suggestion, but: Unknown location: error: java.lang.Illega

Re: Implicit unpacking of a map

2011-03-24 Thread Alan
I find it easier to write web apps if my users provide me with their inputs at compile time anyway. On Mar 24, 1:45 pm, Meikel Brandmeyer wrote: > Hi, > > Am 24.03.2011 um 21:38 schrieb Alan: > > > A macro should work fine if you use ~@ instead of just ~. > > > (defmacro save-article > >   [path

Re: Implicit unpacking of a map

2011-03-24 Thread Meikel Brandmeyer
Hi, Am 24.03.2011 um 21:38 schrieb Alan: > A macro should work fine if you use ~@ instead of just ~. > > (defmacro save-article > [path form-params timestamp] > `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp))) A macro works only with literal maps. Sincerely Meikel -- You rec

Re: Implicit unpacking of a map

2011-03-24 Thread Alan
A macro should work fine if you use ~@ instead of just ~. (defmacro save-article [path form-params timestamp] `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp))) On Mar 24, 1:28 pm, Thorsten Wilms wrote: > On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote: > > > The problem is the

Re: Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms
On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote: The problem is the constructor call. With plain old clojure functions you could use apply, but Java method and constructor calls must be hard-wired in the bytecode (and hence at compilation time) (if I understood this correctly). Guess that's wh

Re: Implicit unpacking of a map

2011-03-24 Thread Meikel Brandmeyer
Hi, On 24 Mrz., 16:16, Thorsten Wilms wrote: > > (defn save-article >    [path form-params timestamp] >    (ds/save! (Article. path (form-params "title") (form-params "body") >       timestamp > The problem is the constructor call. With plain old clojure functions you could use ap

Re: Implicit unpacking of a map

2011-03-24 Thread Tassilo Horn
Thorsten Wilms writes: Hi Thorsten, > The following simplified code works: > > (defn save-article > [path form-params timestamp] > (ds/save! (Article. path (form-params "title") (form-params "body") > timestamp > > > But I would like to not handle the content of form-param

Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms
Hi! The following simplified code works: (defn save-article [path form-params timestamp] (ds/save! (Article. path (form-params "title") (form-params "body") timestamp But I would like to not handle the content of form-params explicitly. My naive attempt that shows that I