clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
john 2019-05-02T19:35:52.062900Z

Proposal: read single characters of : as whitespace, ala ,, so that json files can be directly read into Clojure maps, without having to clean the colons out.

john 2019-05-02T19:40:44.063400Z

You can't def a : anyway, so it's pretty much useless as a single character otherwise

alexmiller 2019-05-02T19:41:24.063700Z

there actually is a very old proposal for this in jira

alexmiller 2019-05-02T19:42:02.063900Z

https://dev.clojure.org/jira/browse/CLJ-899

alexmiller 2019-05-02T19:42:30.064300Z

I'd say at this point that it's unlikely we're ever going to do this

john 2019-05-02T19:47:39.064900Z

hmmm, a lot of "boo" votes on that ticket... Thanks for the context, @alexmiller

alexmiller 2019-05-02T19:58:11.065400Z

I think if you look at the details, there are a lot of subtle points about reader ambiguity being made that are well-founded

slipset 2019-05-02T20:26:17.066200Z

Very nicely written, Alex https://clojure.org/community/contributing

alexmiller 2019-05-02T20:37:49.068700Z

thx, still needs some review from Rich and Stu so might go through some changes :)

john 2019-05-02T20:38:11.069100Z

lol and some not so subtle 😉 I don't know, I don't find them very convincing. JSON keys are strings, so I don't think you'd have such ambiguity.

john 2019-05-02T20:40:08.070Z

But it seems like adding another white space char would be perceived as extra "pollution" to the syntax.

john 2019-05-02T20:40:37.070400Z

Admittedly, I dislike the noise of commas

2019-05-02T20:46:52.070700Z

json allows not quoting keys

john 2019-05-02T20:48:18.071400Z

Some parsers do I guess

2019-05-02T20:48:23.071600Z

all do

2019-05-02T20:49:19.072100Z

oh, huh, I guess not

2019-05-02T20:49:28.072300Z

wild

john 2019-05-02T20:49:50.072500Z

maybe json-ld doesn't

john 2019-05-02T20:50:03.072700Z

or allows them rather

2019-05-02T20:51:00.073900Z

that must be the difference between literal objects in js and json

2019-05-02T20:51:35.074300Z

because come to think of it, the only place I have every seen it done is actually in js

dominicm 2019-05-02T20:54:21.075200Z

Yeah, js allows it, json doesn't.

john 2019-05-02T20:56:05.076500Z

Anyway, even if they did accept unquoted keys, I still don't think that'd be a sufficient objection on it's own. If some json accidentally has unquoted keys with colons beside them, with no space between them, you'd get a symbol with a colon at the end.

john 2019-05-02T20:57:30.077800Z

I do wonder though if the extra logic branch to accept and then ignore : would slow down reads on keywords at all

2019-05-02T21:01:36.079Z

map keys are not always keywords

2019-05-02T21:02:22.079900Z

automatically turning json string keys in to keywords instead of leaving them as strings would be another thing

john 2019-05-02T21:03:52.081300Z

Well, this would imply that you could read a syntactically correct JSON map and the reader wouldn't even know it's not a map already

2019-05-02T21:04:03.081600Z

sure

2019-05-02T21:04:18.082100Z

but you are are talking about dealing with ":" in the reading of keywords

john 2019-05-02T21:04:29.082500Z

nah just ignore them

2019-05-02T21:04:32.082800Z

and keywords can be read anywhere, not just inside maps

john 2019-05-02T21:04:35.082900Z

when they're a single char

2019-05-02T21:05:01.083300Z

you just said "I do wonder though if the extra logic branch to accept and then ignore : would slow down reads on keywords at all"

john 2019-05-02T21:05:39.083900Z

Well, hitting : is going to trigger the keyword-read function

john 2019-05-02T21:05:45.084200Z

Then fail

2019-05-02T21:06:35.084900Z

it may or may not

2019-05-02T21:06:56.085400Z

it depends a lot on the implementation

john 2019-05-02T21:07:24.086300Z

If : is read as a singular token, I think it'll fail. And you can't def it as a symbol

2019-05-02T21:07:26.086500Z

the reader is not a parser combinator thing where you can read and fail and try something else

john 2019-05-02T21:08:51.087300Z

AFAICT, : is not currently usable as a token by itself anywhere

2019-05-02T21:09:27.087700Z

I don't know if anyone is keeping a formal analysis, but the reader is, if I recall generally LL(1)

seancorfield 2019-05-02T21:10:27.088400Z

{"a":true} seems to be the killer counter-argument to this whole discussion.

john 2019-05-02T21:11:04.088700Z

ah, I missed that one 😕

seancorfield 2019-05-02T21:11:13.088900Z

It's right there in the ticket.

john 2019-05-02T21:11:32.089200Z

Yeah, I just didn't process that part

john 2019-05-02T21:12:12.089600Z

and {"a":123}

john 2019-05-02T21:12:59.090600Z

Yeah, false alarm. Bad idea... Pretend I didn't say any of what I just said 😉

seancorfield 2019-05-02T21:13:00.090700Z

Well, yeah, but I wanted to lead with a well-defined, valid keyword example 🙂 :123 works but... 🙂

seancorfield 2019-05-02T21:13:19.091200Z

Feel free to delete all your messages above (and we'll delete ours) 🙂

2019-05-02T21:13:35.091500Z

or just wait for slack to delete them for us

1
john 2019-05-02T21:13:41.091800Z

right

seancorfield 2019-05-02T21:13:55.092200Z

It doesn't. It just makes them unsearchable. If we paid for a month, they'd all still be there.

seancorfield 2019-05-02T21:14:28.093Z

Mind you, at this point, they're all enshrined in the ClojureVerse log archive and in Zulip's infinite searchable archive 🙃

john 2019-05-02T21:15:30.093600Z

I'll just suffice to apologize for all the noise in the dev channel. Interesting thoughts though. Thanks folks.

alexmiller 2019-05-02T21:39:59.093800Z

no worries