Am Mo., 28. Juni 2021 um 10:38 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:
> I think you are missing the point. There is no universal s-expression
> format. A priori, you just have text, which you have to interpret.
> Different Scheme implementations use different formats (e.g. for
> bytevector literals in R6RS and R7RS; other Schemes may have more
> complex reader macros, etc.).

Of course. The key is to decide what level of compatibility to go for,
and then write the code in the common subset of those standards /
implementations. Increasing portability usually adds some pain.
cond-expand adds pain, and a lexical-syntax-cond-expand would add even
more pain. If the latter is desired, it would be better to standardize
in the language than in a bundle file format, but I think it's
overengineering.

I have thought that you want to have maximum applicability of the proposed script format. If you want to restrict everything to a common denominator, you cannot, for example, use identifiers like `..1' (as used by some match-like macros) because they are not supported by R6RS even if you want to target an R7RS.

A "lexical-syntax-cond-expand" wouldn't make any sense as an s-expression.
 
> There is a distinction to be made between the representation and the
> actual structure.
>
> The crucial principle is that a program should never try to parse
> another program's representation for data. This principle is much more
> important than any aesthetic considerations. It forbids that a script
> consists *solely* of s-expressions.

I find the aesthetic consideration much more important. Aesthetic
mistakes cannot be rectified later; it puts the "ecosystem" on a
downward spiral of getting more and more messy over the years.

???

In any case, we are not discussing a clear case with respect to aesthetics.

But if something is not logically sound, filling and serving it in nice-looking bottles doesn't help.
 
In the case of embedding (declare-file ...) in Scheme or Lisp syntax, we
don't parse another program's representation; instead, the script writer
promises to use a syntax (in the relevant part of the file) that is
compatible with both the target Lisp standards/implementations, as well
as the (declare-file ...) spec which specifies its own lenient version
of S-expressions. Note that you need to do the same with magic comments
and the like.

If `scheme-script-ce' stops parsing after 4096 characters that is fine (but also rules out that it interprets any `cond-expand').

And as you like aesthetics, forcing a Scheme top-level program to define a dummy `declare-file' is anything but aesthetic.

You could specify that the launcher always rewrites the file, removing
the (declare-file ...), but that adds the complexity of temp files,
messes up line numbers in stack traces, etc. Nothing is gained.

It *must* do some rewriting if library definitions are included or if you want to have a cross-platform R5RS/R6RS/R7RS script. So this is the general case.