A portable implementation for srfi-159 Duy Nguyen (14 Feb 2020 12:39 UTC)
Re: A portable implementation for srfi-159 Lassi Kortela (14 Feb 2020 13:08 UTC)
Re: A portable implementation for srfi-159 Duy Nguyen (14 Feb 2020 13:13 UTC)
Re: A portable implementation for srfi-159 Lassi Kortela (14 Feb 2020 13:23 UTC)
Re: A portable implementation for srfi-159 Duy Nguyen (14 Feb 2020 13:26 UTC)
Standardizing some feature identifiers Lassi Kortela (14 Feb 2020 13:36 UTC)
Re: Standardizing some feature identifiers Lassi Kortela (14 Feb 2020 13:38 UTC)
Re: Standardizing some feature identifiers John Cowan (14 Feb 2020 13:40 UTC)
Re: Standardizing some feature identifiers Duy Nguyen (14 Feb 2020 13:43 UTC)
Re: Standardizing some feature identifiers Lassi Kortela (14 Feb 2020 13:51 UTC)
cond-expand portability Lassi Kortela (14 Feb 2020 13:45 UTC)
Re: cond-expand portability John Cowan (14 Feb 2020 14:29 UTC)
Re: cond-expand portability Lassi Kortela (14 Feb 2020 14:54 UTC)
Re: A portable implementation for srfi-159 Marc Nieper-Wißkirchen (14 Feb 2020 13:24 UTC)
Re: A portable implementation for srfi-159 Duy Nguyen (14 Feb 2020 13:28 UTC)
Re: A portable implementation for srfi-159 Marc Nieper-Wißkirchen (14 Feb 2020 13:33 UTC)
Pretty-printing and auto-formatting Scheme code Lassi Kortela (14 Feb 2020 13:34 UTC)
Re: Pretty-printing and auto-formatting Scheme code Duy Nguyen (14 Feb 2020 13:41 UTC)
Re: Pretty-printing and auto-formatting Scheme code Marc Feeley (14 Feb 2020 13:51 UTC)
Re: Pretty-printing and auto-formatting Scheme code Lassi Kortela (14 Feb 2020 14:02 UTC)
Re: Pretty-printing and auto-formatting Scheme code John Cowan (14 Feb 2020 14:07 UTC)
Re: Pretty-printing and auto-formatting Scheme code Lassi Kortela (14 Feb 2020 14:19 UTC)
Re: Pretty-printing and auto-formatting Scheme code Arthur A. Gleckler (14 Feb 2020 16:28 UTC)
Re: Pretty-printing and auto-formatting Scheme code Lassi Kortela (14 Feb 2020 17:05 UTC)
Re: Pretty-printing and auto-formatting Scheme code Arthur A. Gleckler (14 Feb 2020 20:02 UTC)
Re: Pretty-printing and auto-formatting Scheme code John Cowan (14 Feb 2020 21:59 UTC)
Re: Pretty-printing and auto-formatting Scheme code Lassi Kortela (14 Feb 2020 22:37 UTC)
Re: Pretty-printing and auto-formatting Scheme code John Cowan (15 Feb 2020 07:44 UTC)
Re: Pretty-printing and auto-formatting Scheme code Vladimir Nikishkin (15 Feb 2020 10:15 UTC)
More conventional syntax Lassi Kortela (15 Feb 2020 20:05 UTC)
Re: More conventional syntax John Cowan (15 Feb 2020 20:12 UTC)
Re: Pretty-printing and auto-formatting Scheme code Arthur A. Gleckler (15 Feb 2020 17:44 UTC)
Re: Pretty-printing and auto-formatting Scheme code John Cowan (15 Feb 2020 18:33 UTC)
Re: Pretty-printing and auto-formatting Scheme code Arthur A. Gleckler (15 Feb 2020 18:58 UTC)
Re: Pretty-printing and auto-formatting Scheme code Lassi Kortela (15 Feb 2020 19:47 UTC)
Re: A portable implementation for srfi-159 Arthur A. Gleckler (14 Feb 2020 16:20 UTC)
Re: A portable implementation for srfi-159 Duy Nguyen (15 Feb 2020 00:59 UTC)
Re: A portable implementation for srfi-159 Arthur A. Gleckler (15 Feb 2020 02:26 UTC)
Re: A portable implementation for srfi-159 Duy Nguyen (22 Feb 2020 12:50 UTC)
Re: A portable implementation for srfi-159 Arthur A. Gleckler (23 Feb 2020 07:52 UTC)

Pretty-printing and auto-formatting Scheme code Lassi Kortela 14 Feb 2020 13:34 UTC

> It's basically the pretty printer that hasn't been implemented yet.

How complex is the behavior of the pretty-printer?

It would be nice to have a SRFI that specifies a standard coding style
for Scheme. It could have quite rigid rules about indentation and line
breaking, specified so that an auto-formatter can enforce them without
human effort. Lots of people in the Go community love their "gofmt"
tool, which formats everything to the same rigid standard and has no
configuration options. That saves time for other debates :)

Scheme (and Lisp generally) are blessed in the coding style department
because people already agree about indenting with 2 spaces, where to put
the parentheses, etc. It would be quite a simple effort to write an
auto-formatter that applies the rules most people are already using anyway.

It would need a few special cases for things like indenting `define`,
`call-with-input-string`, R6RS `library` and R7RS `define-library`, etc.
There are not many of those exceptions and they are quite simple to
handle. For much of the other stuff we could simply copy the current
behavior of Emacs scheme-mode and add some heuristic line breaking to
avoid long lines.

If your pretty-printer is sophisticated, it could serve as a good
foundation for implementing such a formatter.

There are also projects to implement an auto-formatter using the Chez
Scheme pretty-printer: <https://github.com/iZarif/scmfmt>

And another more from-the-ground-up thing, which I inherited and am
ashamed to be procrastinating on:
<https://github.com/lispunion/code-formatter>

Papers about pretty-printing have been written for decades, so automatic
line-breaking should be a tractable problem. The guy who wrote the Dart
auto-formatter (dartfmt) says it was very hard to do well:
<http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/>.