Re: When to use metadata

2015-01-30 Thread adrian . medina
To be clear, I actually agree with Stuart. I would really like to dig into 
this topic and hear everyones thoughts on this; it's such a large piece of 
Clojure's private and public API. 

On Friday, January 30, 2015 at 1:53:37 PM UTC-5, adrian...@mail.yu.edu 
wrote:

 Metadata fields proliferate throughout the standard Clojure value and 
 reference types. It seems odd that one would suggest that this seemingly 
 well supported feature should not be taken advantage of except in very 
 narrow circumstances. What is the rationale for such robust support for 
 runtime metadata if their usage should be restricted primarily to 
 compile-time or metaprogramming tasks? If that was the primary purpose, 
 certainly a Common Lisp proclaim/declaim/declare-esque expression would be 
 preferable since then the compiler and macros can take advantage of this 
 information when reading forms without having to extract data out of 
 symbols on an ad-hoc basis. It makes me think maybe we're missing the point 
 here. Rich Hickey clearly carefully designed Clojure to support varied uses 
 of runtime metadata on Clojure objects. 

 On Friday, January 30, 2015 at 1:28:04 PM UTC-5, Stuart Sierra wrote:

 Almost never.

 Seriously, anything important enough to be included in your program's 
 input or output is almost certainly important enough to be *data*, not 
 metadata. And the non-equality-checking semantics of metadata are confusing.

 About the only place I've found metadata to be worthwhile is 
 meta-programming namespaces and Vars, e.g. what clojure.test does.

 My personal rule of thumb is: if you strip all the metadata from your 
 program it should still work, thought maybe less efficiently.

 –S


 On Thursday, January 29, 2015 at 10:10:34 AM UTC-5, Jonathon McKitrick 
 wrote:

 Is there a rule of thumb or set of use cases when metadata is a more 
 elegant solution than simply adding more entries to a map or record?



-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When to use metadata

2015-01-30 Thread Stuart Sierra
Almost never.

Seriously, anything important enough to be included in your program's input 
or output is almost certainly important enough to be *data*, not metadata. 
And the non-equality-checking semantics of metadata are confusing.

About the only place I've found metadata to be worthwhile is 
meta-programming namespaces and Vars, e.g. what clojure.test does.

My personal rule of thumb is: if you strip all the metadata from your 
program it should still work, thought maybe less efficiently.

–S


On Thursday, January 29, 2015 at 10:10:34 AM UTC-5, Jonathon McKitrick 
wrote:

 Is there a rule of thumb or set of use cases when metadata is a more 
 elegant solution than simply adding more entries to a map or record?


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When to use metadata

2015-01-30 Thread adrian . medina
Metadata fields proliferate throughout the standard Clojure value and 
reference types. It seems odd that one would suggest that this seemingly 
well supported feature should not be taken advantage of except in very 
narrow circumstances. What is the rationale for such robust support for 
runtime metadata if their usage should be restricted primarily to 
compile-time or metaprogramming tasks? If that was the primary purpose, 
certainly a Common Lisp proclaim/declaim/declare-esque expression would be 
preferable since then the compiler and macros can take advantage of this 
information when reading forms without having to extract data out of 
symbols on an ad-hoc basis. It makes me think maybe we're missing the point 
here. Rich Hickey clearly carefully designed Clojure to support varied uses 
of runtime metadata on Clojure objects. 

On Friday, January 30, 2015 at 1:28:04 PM UTC-5, Stuart Sierra wrote:

 Almost never.

 Seriously, anything important enough to be included in your program's 
 input or output is almost certainly important enough to be *data*, not 
 metadata. And the non-equality-checking semantics of metadata are confusing.

 About the only place I've found metadata to be worthwhile is 
 meta-programming namespaces and Vars, e.g. what clojure.test does.

 My personal rule of thumb is: if you strip all the metadata from your 
 program it should still work, thought maybe less efficiently.

 –S


 On Thursday, January 29, 2015 at 10:10:34 AM UTC-5, Jonathon McKitrick 
 wrote:

 Is there a rule of thumb or set of use cases when metadata is a more 
 elegant solution than simply adding more entries to a map or record?



-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When to use metadata

2015-01-29 Thread Jan Herich
Solussd is absolutely correct, but maybe even more simplistic (or easier to 
grasp) explanation would be to use metadata if you don't want the 
additional (meta)data to change the equality semantics of the map, for 
example:

(def test-desc1 {:number-of-threads 10})
(def test-desc2 ^{:integration true} {:number-of-threads 10})
(def test-desc3 {:number-of-threads 10 :integration true})

(= test-desc1 test-desc2) ;; returns true
(= test-desc1 test-desc2 test-desc3) ;; returns false, because while the 
first two vars reference equal values, the third one doesn't


Dňa štvrtok, 29. januára 2015 16:10:34 UTC+1 Jonathon McKitrick napísal(-a):

 Is there a rule of thumb or set of use cases when metadata is a more 
 elegant solution than simply adding more entries to a map or record?


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


When to use metadata

2015-01-29 Thread Jonathon McKitrick
Is there a rule of thumb or set of use cases when metadata is a more 
elegant solution than simply adding more entries to a map or record?

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When to use metadata

2015-01-29 Thread Joseph Smith
Yes- when the data you want to add shouldn't affect the value of the map. 

---
Joe R. Smith
@solussd


 On Jan 29, 2015, at 9:10 AM, Jonathon McKitrick jmckitr...@gmail.com wrote:
 
 Is there a rule of thumb or set of use cases when metadata is a more elegant 
 solution than simply adding more entries to a map or record?
 -- 
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.