On Mon, 27 Oct 2014 02:04:42 +0100, martijn brekelmans tijntj...@msn.com
wrote:
Hello everybody,
I'm fiddling around with clojure, and I'd like to use readable with clojure.
I've looked a little more at implementing readable (at least some tiers) in
Clojure, beyond http://clojure.org/reader.
Without changing the core code you could implement basic curly infix with a
somewhat different syntax and Clojure's tagged literals. Tagged literals let
you do #my/tag element - the reader then reads element, and passes through
my/tag. Reader tags without namespace qualifiers are reserved for Clojure,
however, so the tag will be multiple characters. So the best you could do
without changing the reader, as far as I can tell, would be something like
#n/fx (i = 0), where #n/fx is an infix processor for curly-infix. That's
ugly, especially if they are embedded: #n/fx (i = #n/fx (a + b)).
Clojure has nothing user-accessible like the Common Lisp readtable.
Implementing any of the readable tiers with a nicer-looking syntax will require
modifying the Clojure reader's source code. I took a quick peek at
src/jvm/clojure/lang/LispReader.java - that appears to be where the key reader
functionality is implemented. It doesn't look like it'd be hard to add a
variation of curly-infix or neoteric expressions, but getting those changes
*accepted* might be another matter.
I'm sure backwards-compatibility is critical for them, so using #[...] instead
of {...} is probably the only practical approach for them.
It might be sensible to start simple, just try to get #[...] accepted for as a
notation for basic curly-infix (with NO neoteric support). That has NO
possibility of conflict with existing code. We could warn users to NOT include
syntax in there of the form a(b) with the assumption that it would be
interpreted as a (b). The next step would be to get neoteric supported
inside #[...], at least in the sense of supporting a() as a synonym for (a
...). Maybe that version of neoteric could be supported at all times; the
problem is not writing the code, it's getting such a change *accepted*. It
would be possible to also interpret x[y...] as (x #[y...]), which would be
full neoteric with a slightly different syntax. Note that unprefixed [...]
would continue to have its current meaning.
Any indentation-sensitive syntax would be a much bigger step - again, not
because it's hard to implement, but because it has to be *accepted*.
Example of infix notation in this situation:
#[#[a + b] #[c * d]]
That is not as nice as {{a + b} {c * d}}, but I don't see a nicer alternative
unless they're willing to use non-ASCII pairing characters (!).
In Clojure [...] and (...) have a different meaning, but it seems to me that we
should just leave [...] as-is. Parens are way more common for enclosing larger
scopes, as far as I can tell.
--- David A. Wheeler
--
___
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss