Re: [Readable-discuss] Using readable with clojure

2014-10-28 Thread David A. Wheeler
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


Re: [Readable-discuss] Using readable with clojure

2014-10-27 Thread John Cowan
David A. Wheeler scripsit:

 Not at all. The whole point is to have a syntax that is general, and
 not tied to a particular semantic. Clearly it needs to be useful for
 a given semantic, but not tied to it.

Well, indentation can model () or it can model []; it can't do both.
In CL or Scheme that doesn't matter, because [] is inessential.  In
Clojure it's essential.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
After fixing the Y2K bug in an application:
WELCOME TO censored
DATE: MONDAK, JANUARK 1, 1900

--
___
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss


Re: [Readable-discuss] Using readable with clojure

2014-10-27 Thread David A. Wheeler
On Mon, 27 Oct 2014 08:55:55 -0400, John Cowan co...@mercury.ccil.org wrote:
 Well, indentation can model () or it can model []; it can't do both.
 In CL or Scheme that doesn't matter, because [] is inessential.  In
 Clojure it's essential.

I've been assuming that it'd model ().  Interesting thought though.

You can model many other things by creating a macro that passes the parameters 
through it.

--- David A. Wheeler

--
___
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss


Re: [Readable-discuss] Using readable with clojure

2014-10-26 Thread David A. Wheeler
Not at all. The whole point is to have a syntax that is general, and not tied 
to a particular semantic. Clearly it needs to be useful for a given semantic, 
but not tied to it.

On October 26, 2014 10:43:17 PM EDT, John Cowan co...@mercury.ccil.org wrote:
David A. Wheeler scripsit:

 In Clojure, { is already taken for maps, and #{ for sets.  That
interferes with {...} for infix.

More importantly, [] is used to enclose lambda variables and in other
situations in which Lisps use () for something other than application.
I think that Readable would have to be substantially rethought, or at
least enhanced greatly to understand the syntax (not just lexical
syntax,
but keyword syntax) of Clojure in order to be usable at all.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
Nobody expects the RESTifarian Inquisition!  Our chief weapon is
surprise ... surprise and tedium  ... tedium and surprise 
Our two weapons are tedium and surprise ... and ruthless disregard
for unpleasant facts  Our three weapons are tedium, surprise, and
ruthless disregard ... and an almost fanatical devotion to Roy
Fielding

--- David A.Wheeler--
___
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss