Hi Gabriel,

> That being said it is absolutely possible to read, edit and write
> Scheme files from within Scheme, and I think this could be a cool
> addition—GNU Guix itself prominently lacks interactive/frontend/GUI
> tooling for the less geeky.

> I doubt editing toml or yaml or other not-fully-structured text-file
> formats are easier than s-expressions.

I disagree. There are two distinct difficulties:
1. it is hard to programmatically edit S-expressions while preserving
comments and formatting
2. it is impossible to reliably edit arbitrary scheme code without doing
serious static analysis or maybe even executing the code

1. Editing S-expressions

It is very hard to programmatically edit S-expressions while still
preserving comments and whitespace correctly. A while back, I tried to
write a CLI utility that can add a new key to a .guix-authorizations
file. I started out with the assumption that it was simply a matter of
using `read` and `pretty-print`. But, no: `read` discards all comments
and whitespace. Then, `pretty-print` prints it out in a way that may be
very different from the way the user had originally formatted the file.
Here's a small excerpt from our .guix-authorizations file just to prove
my point:
```
 (;; primary: "D963 A5A3 8A80 3D52 4461  F914 7483 0A27 6C32 8EC2"
  ("2841 9AC6 5038 7440 C7E9  2FFA 2208 D209 58C1 DEB0"
   (name "abcdw"))
  ("AD17 A21E F8AE D8F1 CC02  DBD9 F7D5 C9BF 765C 61E3"
   (name "andreas"))
  ("27D5 86A4 F890 0854 329F  F09F 1260 E464 82E6 3562"
   (name "apteryx"))
  ("7F73 0343 F2F0 9F3C 77BF  79D3 2E25 EE8B 6180 2BB3"
   (name "arunisaac"))
  ( ;; primary: "D0C2 EAC1 3310 822D 98DE  B57C E9C5 A2D9 0898 A02F"
   "01FD 85F4 1A7B 7F82 0583  06A5 935E BE07 36DC 857E"
   (name "avp"))
  ("5D54 CF25 57B2 38E8 8DC1  80A2 2D22 3241 0AB7 4043"
   (name "baleine"))
```
This problem can be solved if we have a special version of `read` that
does not throw away the comments and whitespace information. But, on to
the next more serious problem.

2. Editing arbitrary scheme code

> Writing a program that parses a manifest and adds or removes single
> entries should not be *that* hard to craft.

Consider the manifest file from earlier:
```
(specifications->manifest '("pkg1" "pkg2" "pkg3"))
```
This is not the only way to write this manifest file. I could also write
the following:
```
(specifications->manifest (list "pkg1" "pkg2" "pkg3"))
```
Or the following:
```
(define deps
  (specifications->manifest (list "pkg1" "pkg2" "pkg3")))

deps
```
Or the following:
```
(define deps
  (specifications->manifest '("pkg1" "pkg2" "pkg3")))

deps
```
You get the idea. I could express exactly the same manifest in
infinitely many ways, and you couldn't easily write a program that would
work on all of these correctly.

> but I can see how people thrilled with 4-space-indentations and
> top-down declarations are provoked by parens.

And, none of this is about parentheses. Wisp won't help.

Cheers,
Arun

Reply via email to