On Sat, Aug 4, 2012 at 11:05 PM, Baishampayan Ghose <b.gh...@gmail.com>wrote:

> To add my two cents, IMHO the literal notation for sets, vectors &
> maps are just that---they are the "literal" representations of those
> data-structures and are not semantically equivalent to constructor
> functions. As such, the literal notation should really be used with
> constants; in every other case, you should use the constructor
> functions.
>

My jaw is dropping here.  I can't believe anyone would seriously propose
that the only things that go between [], {}, or #{} should be constants.

BTW, I'm well aware that literal representations are not equivalent to the
constructor function.  This is precisely why it is *better* to use the
literal representation -- it chooses intelligently among the appropriate
constructor functions.

For example, compare:
(type {1 2})
(type (hash-map 1 2))

Note that the {} notation intelligently chose array map as the underlying
representation because it is more appropriate for small maps.

In any case, Clojure is already able to detect when x and y are equal in
something like #{x y} and report it as an error.  I fail to see how it's
better for Clojure to crash my program in such an event rather than to do
the intuitive thing and just make the intended set.

And if for some reason, the behavior absolutely has to be the way it is,
I'd much rather the *compiler* warn for any use of a non-constant in a set
literal or in the key position of a map.  Why allow variables if such use
is prone to error?

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

Reply via email to