Namespaced keywords in metadata

2011-12-28 Thread JuanManuel Gimeno Illa
I've been writing some code which adds some keywords in metadata associated 
to vars. Initially I used namespaces keywords to not collide with other 
keywords. The problem is that having to namespace these keywords makes the 
code, at least, ugly. Is it any consensus in the use of keywords in 
metadata? I've done some search of examples and, most of them, does not use 
namespaced keywords, but I am not sure.

Thanks,

Juan Manuel

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

Re: Namespaced keywords in metadata

2011-12-28 Thread Ambrose Bonnaire-Sergeant
I would recommend sticking with namespaced keywords to avoid clashes with
var metadata keys.

Remember qualified keywords respect namespace aliasing and ::keyword is
qualified in the current namespace.
These can help making the code more readable.

You could store keywords in vars if namespaced keywords really bothered you.

(def mykey ::mykey)

Thanks,
Ambrose

On Wed, Dec 28, 2011 at 5:54 PM, JuanManuel Gimeno Illa
jmgim...@gmail.comwrote:

 I've been writing some code which adds some keywords in metadata
 associated to vars. Initially I used namespaces keywords to not collide
 with other keywords. The problem is that having to namespace these keywords
 makes the code, at least, ugly. Is it any consensus in the use of keywords
 in metadata? I've done some search of examples and, most of them, does not
 use namespaced keywords, but I am not sure.

 Thanks,

 Juan Manuel

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

Re: Namespaced keywords in metadata

2011-12-28 Thread JuanManuel Gimeno Illa


El miércoles 28 de diciembre de 2011 11:01:16 UTC+1, Ambrose 
Bonnaire-Sergeant escribió:

 I would recommend sticking with namespaced keywords to avoid clashes with 
 var metadata keys.

 Remember qualified keywords respect namespace aliasing and ::keyword is 
 qualified in the current namespace.
 These can help making the code more readable.


OK 

You could store keywords in vars if namespaced keywords really bothered you.

 (def mykey ::mykey)


My main concern is that when using reader macros for metadata I have to 
fully qualify it. For instance, I must write:

 (defdatatype
::Streams
Nil
   (^:ml.datatypes/lazy Cons elem stream))

instead of

 (defdatatype
::Streams
Nil
   (^:lazy Cons elem stream))

But I suppose the benefits of namespacing outweight these inconveniences.

Thanks,

Juan Manuel


 Thanks,
 Ambrose

 On Wed, Dec 28, 2011 at 5:54 PM, JuanManuel Gimeno Illa jmgi...@gmail.com
  wrote:

 I've been writing some code which adds some keywords in metadata 
 associated to vars. Initially I used namespaces keywords to not collide 
 with other keywords. The problem is that having to namespace these keywords 
 makes the code, at least, ugly. Is it any consensus in the use of keywords 
 in metadata? I've done some search of examples and, most of them, does not 
 use namespaced keywords, but I am not sure.

 Thanks,

 Juan Manuel

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@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 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

Re: Namespaced keywords in metadata

2011-12-28 Thread Meikel Brandmeyer
Hi,

Am 28.12.2011 um 11:09 schrieb JuanManuel Gimeno Illa:

 My main concern is that when using reader macros for metadata I have to fully 
 qualify it. For instance, I must write:
 
  (defdatatype
 ::Streams
 Nil
(^:ml.datatypes/lazy Cons elem stream))
 
 instead of
 
  (defdatatype
 ::Streams
 Nil
(^:lazy Cons elem stream))
 
 But I suppose the benefits of namespacing outweight these inconveniences.

Please consider the alternatives outlined by Ambrose:

user= (require '[clojure.string :as str])
nil
user= (meta ^:foo [])
{:foo true}
user= (meta ^::foo [])
{:user/foo true}
user= (meta ^::str/foo [])
{:clojure.string/foo true}

Sincerely
Meikel

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


Re: Namespaced keywords in metadata

2011-12-28 Thread JuanManuel Gimeno Illa
Finally I have considered your advice and namespaced the keywords.

Thanks,

Juan Manuel


El miércoles 28 de diciembre de 2011 12:33:22 UTC+1, Meikel Brandmeyer 
(kotarak) escribió:

 Hi,

 Am 28.12.2011 um 11:09 schrieb JuanManuel Gimeno Illa:

  My main concern is that when using reader macros for metadata I have to 
 fully qualify it. For instance, I must write:
  
   (defdatatype
  ::Streams
  Nil
 (^:ml.datatypes/lazy Cons elem stream))
  
  instead of
  
   (defdatatype
  ::Streams
  Nil
 (^:lazy Cons elem stream))
  
  But I suppose the benefits of namespacing outweight these inconveniences.

 Please consider the alternatives outlined by Ambrose:

 user= (require '[clojure.string :as str])
 nil
 user= (meta ^:foo [])
 {:foo true}
 user= (meta ^::foo [])
 {:user/foo true}
 user= (meta ^::str/foo [])
 {:clojure.string/foo true}

 Sincerely
 Meikel



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