As you point out, symbols in edn have no inherent meaning; it's entirely up
to how you interpret them. However, if you saw the symbol
"clojure.core/conj" in an edn file, then the chances are that it's intended
to refer to a Clojure function. Similarly, the symbol "PI" likely refers to
the mathematical constant.
A good litmus test is to replace the symbol with the thing it identifies,
and then see if the data still makes sense. So if we take your example:
{:angle PI}
We can substitute the symbol for the data it identifies:
{:angle 3.141592653589793}
And the edn file still makes sense. It's lost no significant semantic
meaning. However, if we return to your earlier example:
{username "vasya"}
What external identity does the symbol "username" have? If we say that it's
"vasya", then the substitution test fails:
{"vasya" "vasya"}
Since "username" has no meaning beyond itself, it should ideally be a
keyword:
{:username "vasya"}
On Fri, 25 Oct 2019 at 15:30, Anton Vodonosov <[email protected]> wrote:
> Thank you for responses.
>
> The last two arguments do not resolve the doubt, however:
>
> 1. symbols also implement IFn:
>
> (require 'clojure.edn)
> ('a (clojure.edn/read-string "{a 1 b 2}"))
> => 1
>
> 2. EDN does not specify any evaluation model, so how can a symbol
> designate something "in isolation"?
> For example, clojure.core/conj in the context of EDN does not
> designate a function - EDN is not Clojure.
>
>>
> One way I can imagine symbols to designate something is by agreement
> of particular EDN config file format.
> Maybe a user can specify {:angle PI}, and this specific config file
> format declares that the PI symbol
> can be used to refer the 3.14... constant.
>
> Still, I'm not sure such interpretation implies symbols in map keys
> should be resolved by the config file parser
> to some values....
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/68a3fce8-b63a-420b-9fbd-904f911a746b%40googlegroups.com
> <https://groups.google.com/d/msgid/clojure/68a3fce8-b63a-420b-9fbd-904f911a746b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/clojure/CALg24jRx4vrEv8R7POX5XpT90BCpA57sxO-AeWrJnPV1oBARRQ%40mail.gmail.com.