Account Options

  1. Sign in
Google Groups Home
« Groups Home
Message from discussion Clojure reader macros
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rich Hickey  
View profile  
 More options Mar 14 2008, 9:12 am
From: Rich Hickey <richhic...@gmail.com>
Date: Fri, 14 Mar 2008 06:12:36 -0700 (PDT)
Local: Fri, Mar 14 2008 9:12 am
Subject: Re: Clojure reader macros

On Mar 13, 9:21 pm, "Darshan Shaligram" <scinti...@gmail.com> wrote:

> On Wed, Mar 12, 2008 at 9:35 PM, Rich Hickey <richhic...@gmail.com> wrote:

> [...]

> >  As time goes by I become more entrenched in my decision not to
> >  support reader macros. While reader macros afford a lot
> >  of power, they come at a price in lack of interoperability, much more
> >  so than ordinary macros, which can be placed in namespaces.

> I believe Clojure can provide reader macros that do not affect
> interoperability at all. Reader macros cause problems when a
> read-table modification performed in one source file affects other
> source files that did not expect such a modification. I'd suggest
> preventing such read-table damage as follows:
> ...
> Other potential issues:

> * Two different libraries may use the same dispatch characters by
> default,

That's what I mean by interoperability.

> but this can be solved easily if the libraries allow the
> client code to specify the dispatch characters they should attach
> their reader macros to. For instance:

> (enable-interpolate-syntax \I) ; Uses #I"" for interpolating strings.

I would dread having to read code in libraries that did this.

> If the libraries do not allow choosing the dispatch character, they
> cannot be used together in the same source file, but that can be
> easily fixed (presuming you have the source, or don't mind
> re-modifying the read-table after the library has done its thing), and
> that little inconvenience is preferable to not having any reader macro
> support. :-)

I wouldn't want to encourage that either.

> As you note, reader macros provide a lot of power, and while most code
> will never need reader macros, some code can benefit powerfully from
> them. It is possible to fake reader macros in very roundabout ways
> (provide custom definitions of load and read that check characters
> against a dispatch table, and call the underlying read for characters
> not in the custom dispatch table), but life would be a lot easier if
> the language supports them directly.

> What do you think of this proposal? If there's no interest in (safe)
> reader macros at all, I'll drop this discussion, but if there is
> interest, I'd be delighted to put together a prototype.

I am unconvinced that reader macros are needed in Clojure at this
time. They greatly reduce the readability of code that uses them (by
people who otherwise know Clojure), encourage incompatible custom mini-
languages and dialects (vs namespace-partitioned macros), and
complicate loading and evaluation.

To the extent I'm willing to accommodate common needs different from
my own (e.g. regexes), I think many things that would otherwise have
forced people to reader macros may end up in Clojure, where everyone
can benefit from a common approach.

Clojure is arguably a very simple language, and in that simplicity
lies a different kind of power.

I'm going to pass on pursuing this for now,

Rich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.