For what it's worth, I see two things intertwined here, one being the desire to embed text in an arbitrary format and interpret it, the other being the mechanism in which you're doing it. To me, it seems you can do the kinds of things you have shown as examples by using just functions, macros, and strings, without having to resort to arbitrary reader extension. If you embed things as strings, say, similarly to how instaparse works, then you can still read in CSV text, code in other languages, etc. For example, rewriting your csv example using macros/functions/string:
(def parse-csv (insta/parser " file = record (line-break record)* <_> = <\" \"+> <CR> = '\u000D' <LF> = <'\u000A'> <CRLF> = CR LF <line-break> = CRLF | CR | LF <field-sep> = <#\" *, *\"> <field> = unquoted-field | quoted-field unquoted-field = #\"[a-zA-Z0-9]*\" quoted-field = <'\"'> #\"[^\\\"\\n\\r]*\" <'\"'> record = _? field (field-sep field)* _?")) (defmacro parse-csv! [csv] (parse-csv csv)) (parse-csv! " foo , \"bar man ccc\", boo fred , fox ") Now, while going through and quoting text is inconvenient, it's just that. It doesn't limit one from still using existing mechanisms to interpret text at run-time or compile-time via functions and macros respectively. To get around the inconvenience of quoting, having here docs, or triple-quoted strings ala Python, as a first-class construct in Clojure could address that. It's a smaller change that would seem to address making convenient what you're doing, but without the bigger costs that would occur with arbitrary reader extension. At least with this, the rest of the Clojure language remains the same (homoiconicity, commas as white space, indenting is insignificant, etc.). The only change that ripples out to users and tooling is that a string has a new way of being defined. (To note, alternate string quoting has been proposed at [1], which includes a link to an implementation of triple-quote reading, but this design page seems to have been around a while...) [1] - http://dev.clojure.org/display/design/Alternate+string+quote+syntaxes On Wednesday, February 11, 2015 at 3:59:45 AM UTC-5, Henrik Heine wrote: > > Hi, > > Am Dienstag, 10. Februar 2015 21:07:50 UTC+1 schrieb Gary Verhaegen: >> >> For the sake of completeness, in this context "other users" is not >> limited to humans: what about IDE support? Refactoring tools? Code analysis? > > > I agree. You lock out "others" and that takes away a lot. For me that's > the main argument against my proposal. > > I was not thinking to copy&paste huge CSV data in to Clojure files. I'm > thinking more about in-line configuration that you can copy&paste to/from > other sources, test data, maybe literate programming (haven't worked that > out though). But not only "data stuff" could be in-lined: prolog code, SQL > statements compiled to the corresponding Clojure libs. OK - the indirection > through an external file does not cost that much. > > You could even use it to try out new Clojure features (like reader > conditionals) without touching one line of Clojure core - just make it a > #[CLJxxx ...] form and play around with it before you move it over to the > Clojure core code. And you could back-port things just by supplying a > lib/function. In this case the "embedded syntax" would still be Clojure. > > I still feel like being "new to Clojure", so thanks for all the replies > and the insights into "The Clojure Way". > > Henrik > > -- 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.