[racket-dev] A few suggestions on indentation and DrRacket graphical syntax

From: Eli Barzilay (eli at barzilay.org)
Date: Fri May 11 18:49:08 EDT 2012

5 hours ago, Neil Toronto wrote:
> On 05/09/2012 02:18 AM, Laurent wrote:
> > From the guide: "Caveat 1: Until language specifications come with
> > fixed indentation rules, we need to use the default settings of
> > DrRacket’s indentation for this rule to make sense."
> >
> > Maybe a special submodule like drracket-indentation with
> > declarations like:
> > (module+ drracket-indentation
> >    (like-lambda my-lambda my-function ....)
> >    (like-begin my-begin ....)
> >    )
> > could be useful for user-specific indentation.
> >
> > As a submodule, Racket can read&load it only at appropriate
> > moments.  When indenting the file, DrRacket could first load the
> > drracket-indentation module of the file to know how to indent it.
> >
> > One could then create a whole language with its own indentation
> > rules.  It would also be easier to add good indentations for
> > for/fold and others.
> 
> That would be awesome for Typed Racket macros in particular. Its
> `for' macros are great examples of forms that should have fairly
> complex indentation rules. Optional type declarations make it
> difficult to classify them as "begin-like", "define-like" or
> "lambda-like".

That kind of indentation specification is more fitting in the language
info, together with coloring etc.

For specific macros in some random file something that I suggested in
the past could work better: have an ability to use "sub-namespaces"
where an identifier can have a number of related bindings -- so you
could define `foo' and some `foo at indent' (or whatever) which specifies
indentation.  The reason that this would work better is that any
context that receives the `foo' binding would also get its
indentation.  Eg, think about providing it as `bar' -- if the rules
are in a sub-module, then it won't work unless you construct your own
sub-module.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.