On Sun, 21 Nov 2021, at 2:22 PM, dieter.v...@gmail.com wrote:
> repl> (mydata)
> ... (ArityException)...
> repl> ; instead i have to type eval
> 
> repl> ((eval mymap) :b)
>  -304538205
> 
> I know its only 4 letters and a space extra, but software composition is 
> supposed to avoid code duplication and perhaps the idea makes sense that 
> invoking a map without arguments evaluates it... Hence the question about the 
> choice made for the current behavior.

Evaluating a map is a fairly costly and uncommon use case. I don't believe I've 
ever had cause to eval an entire map, or if I have it can't have been more than 
a few times in the past 12 years of using Clojure. If I call a data structure 
with no arguments, it is most likely to be a mistake, so my expectation would 
be for the compiler or runtime to raise an error.

Syntax sugar is generally reserved for very common operations. Each piece of 
sugar that is introduced is something extra the reader needs to learn. 
Moreover, if they see (eval x) it is clear an evaluation is taking place; if 
they see (x), it is not obvious at all.

Not only is performing a lookup on a map a very common operation, treating a 
map as a function makes intuitive sense. A function is a mapping between two 
sets; a map is also a mapping between two sets. It's logical that they might 
share an interface.

-- 
James Reeves
booleanknot.com





-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/2e63a6d5-0136-4026-8f50-3643cf153d74%40www.fastmail.com.

Reply via email to