ns attr-map

42 views
Skip to first unread message

James Reeves

unread,
Oct 11, 2009, 11:03:01 AM10/11/09
to Clojure Dev
Hi folks,

The defn, defmacro and defmulti forms all allow an attr-map to be
specified, as a way of more neatly specifying metadata.

Would it be a good idea to allow the ns macro this same syntax sugar?
For example:

(ns example
"This is an example"
{:author "John Doe"
:email "jd...@example.com"}
(:use clojure.contrib.def)
(:require [clojure.core.set :as set]))

This looks a little neater than when the metadata is placed before the
namespace name, as is currently required:

(ns #^{:author "John Doe"
:email "jd...@example.com"}
example
"This is an example"
(:use clojure.contrib.def)
(:require [clojure.core.set :as set]))

- James

Stephen C. Gilardi

unread,
Oct 12, 2009, 12:52:27 PM10/12/09
to cloju...@googlegroups.com

On Oct 11, 2009, at 11:03 AM, James Reeves wrote:

Would it be a good idea to allow the ns macro this same syntax sugar?
For example:

(ns example
 "This is an example"
 {:author "John Doe"
  :email "jd...@example.com"}
 (:use clojure.contrib.def)
 (:require [clojure.core.set :as set]))

This looks a little neater than when the metadata is placed before the
namespace name, as is currently required:

I like it.

--Steve

Dimitry Gashinsky

unread,
Oct 12, 2009, 1:44:14 PM10/12/09
to cloju...@googlegroups.com
Hi,

I think everywhere there is a docstring? parameter there should be
attr-map? parameter.

Regards,
DiG

Konrad Hinsen

unread,
Oct 13, 2009, 2:46:59 AM10/13/09
to cloju...@googlegroups.com
On 12 Oct 2009, at 19:44, Dimitry Gashinsky wrote:

> I think everywhere there is a docstring? parameter there should be
> attr-map? parameter.

Me too - and that's why I wrote clojure.contrib.def/name-with-
attributes a while ago, which makes it simple to implement such a
convention in macros:

http://richhickey.github.com/clojure-contrib/def-api.html#def/name-
with-attributes

For a usage example, see clojure.contrib.types/deftype:

http://github.com/richhickey/clojure-contrib/blob/bdc813a0d39cb3c6184c4e123d847458e9c77711/src/clojure/contrib/types.clj#L53

Konrad.

James Reeves

unread,
Oct 14, 2009, 2:42:27 PM10/14/09
to Clojure Dev
Should I open up a Assembla ticket for this, then? I've just started
watching the Clojure assembla space, so I guess I'd need access to
open up a ticket.

- James

On Oct 13, 7:46 am, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
> On 12 Oct 2009, at 19:44, Dimitry Gashinsky wrote:
>
> > I think everywhere there is a docstring? parameter there should be
> > attr-map? parameter.
>
> Me too - and that's why I wrote clojure.contrib.def/name-with-
> attributes a while ago, which makes it simple to implement such a  
> convention in macros:
>
>        http://richhickey.github.com/clojure-contrib/def-api.html#def/name-
> with-attributes
>
> For a usage example, see clojure.contrib.types/deftype:
>
>        http://github.com/richhickey/clojure-contrib/blob/bdc813a0d39cb3c6184...
>
> Konrad.
Reply all
Reply to author
Forward
0 new messages