[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: making indentation marker &| implicit

This page is part of the web mail archives of SRFI 108 from before July 7th, 2015. The new archives for SRFI 108 contain all messages, not just those from before July 7th, 2015.



On Tue, May 28, 2013 at 10:09 AM, Per Bothner <per@xxxxxxxxxxx> wrote:
I hate to delay this even more, but ...

SRFI-10[789] uses &| as an indentation marker, which causes
any preceding whitespace to be skipped.  Scribble avoids this
in a way that seems nicer: Any indentation that is common to
each line (following a newline) is stripped.  Thus using SRFI-109
syntax:
(define str1 &{
  abc
    def
  ghi}
becomes: "abc\n  def\nhgi".

http://docs.racket-lang.org/scribbl/reader.html
(last section: 2.4.4 Spaces, Newlines, and Indentation.)

"Initial indentation" means indentation in the source port,
not the string returned by the reader.

This is the part that always bothered me, and why I didn't
implement indentation removal.  Many of the examples are
unintuitive, and the rule itself does not seem to be consistent.

For example, the docs have

@foo{bar

   baz

   bbb}

  reads as  

(foo "bar" "\n"
     "baz" "\n"
     "bbb")

Why?  The indentation of the leading bar is deeper in the
source port than the following lines, yet shallower in the
string.  How does it get the same result indentation?

Unsure of the right semantics, it seemed simpler to leave
this out since it's easy enough to specify arbitrary trimming
behavior separately:

@trim{@foo{
  ...
}}

Some tweaking of the Scribble rules might be appropriate.
For example, line-continuations markers @- seem worth keeping.
And the rules for initial and final lines needs some thought.

Tabs would have to be consistent: If a line starts with
T1 tabs followed by S1 spaces, and another line starts with
T2 tabs followed by S2 spaces, then it is an error if
(and (not (= T1 T2)) (> S1 0) (> S2 0)).

I presume you mean not an error, just not the same indentation?

  (define (indentation<? t1 s2 t2 s2)
    (or (< t1 t2) (and (= t1 t2) (< s1 s2))))

Or more simply, trimming would work only on string=? prefixes
of horizontal whitespace (tab or space).

... alternately just define a tab as 8 spaces.

-- 
Alex