Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The clearest way into the Universe is through a forest wilderness. -- John Muir


devel / comp.lang.lisp / Re: Long Docstrings

SubjectAuthor
* Long DocstringsLawrence D'Oliveiro
+* Re: Long DocstringsMadhu
|`* Re: Long DocstringsLawrence D'Oliveiro
| `* Re: Long DocstringsMadhu
|  `- Re: Long DocstringsLawrence D'Oliveiro
`* Re: Long DocstringsKaz Kylheku
 `* Re: Long DocstringsDavid De La Harpe Golden
  `* Re: Long DocstringsLawrence D'Oliveiro
   `* Re: Long DocstringsKaz Kylheku
    `* Re: Long DocstringsDavid De La Harpe Golden
     `- Re: Long DocstringsKaz Kylheku

1
Long Docstrings

<uoalc1$2gjnk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17860&group=comp.lang.lisp#17860

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Long Docstrings
Date: Thu, 18 Jan 2024 07:52:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <uoalc1$2gjnk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Jan 2024 07:52:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7b7eb05269adaf47ad0e7a8103a3b8bb";
logging-data="2641652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PcA6CD5K6dE3K+N8Ef2Y1"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:aybZgGItz89vSzcsrshUGNZOuyc=
 by: Lawrence D'Oliv - Thu, 18 Jan 2024 07:52 UTC

I often write long docstrings (not sure whether Lisp has its own name
for these). In Python, if the body of a class or function begins with
a string literal, then this becomes the docstring. And a REPL will
display this as help text if you type “help(«object»)”. E.g.

class Matrix :
"representation of a 3-by-2 affine homogeneous matrix. This does not" \
" actually use any Cairo routines to implement its calculations; these" \
" are done entirely using Python numerics. The from_cairo and to_cairo" \
" methods provide conversion to/from cairo_matrix_t structs. Routines" \
" elsewhere expect this Matrix type where the underlying Cairo routine" \
" wants a cairo_matrix_t, and return this type where the Cairo routine" \
" returns a cairo_matrix_t."

...

#end Matrix

This takes advantage of the fact that, like C and some C-derivatives,
Python supports implicit concatenation of adjacent string literals.
This allows me to construct very long string literals without messing
up the layout of my code.

Lisp doesn’t have such an implicit-concatenation convention. But it
has macros. And it easy enough to define a macro which does string
concatenation at macro-invocation time, e.g.

(defmacro mstr (&rest strs)
"lets me define a long string literal in pieces across lines, useful for docstrings."
(apply 'concat strs)
) ; defmacro mstr

And using this macro is equally easy:

(defun cur-line (ensure-newline)
(mstr
"returns list of two character positions, representing the"
" beginning and end of the selection if there is one, else"
" the beginning and end of the current line. ensure-newline"
" => ensures there is a newline at the end of the line."
)
...
) ; defun

Re: Long Docstrings

<m3il3rugas.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17862&group=comp.lang.lisp#17862

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Thu, 18 Jan 2024 15:14:27 +0530
Organization: Motzarella
Lines: 69
Message-ID: <m3il3rugas.fsf@leonis4.robolove.meer.net>
References: <uoalc1$2gjnk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="91ef3727482b5d42508e52eb72b8e6e9";
logging-data="2674189"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bFgefgPLVEjmcXI/CqbhOLN499FZw8FQ="
Cancel-Lock: sha1:nPBQlWv0KuY2S8mN2z9vStJjdFc=
sha1:i4dleifaMMT4SCbV20zxNXUvZfM=
 by: Madhu - Thu, 18 Jan 2024 09:44 UTC

* Lawrence D'Oliveiro <uoalc1$2gjnk$1 @dont-email.me> :
Wrote on Thu, 18 Jan 2024 07:52:34 -0000 (UTC):

> I often write long docstrings (not sure whether Lisp has its own name
> for these). In Python, if the body of a class or function begins with
> a string literal, then this becomes the docstring. And a REPL will
> display this as help text if you type “help(«object»)”. E.g.
>
> class Matrix :
> "representation of a 3-by-2 affine homogeneous matrix. This does not" \
> " actually use any Cairo routines to implement its calculations; these" \
> " are done entirely using Python numerics. The from_cairo and to_cairo" \
> " methods provide conversion to/from cairo_matrix_t structs. Routines" \
> " elsewhere expect this Matrix type where the underlying Cairo routine" \
> " wants a cairo_matrix_t, and return this type where the Cairo routine" \
> " returns a cairo_matrix_t."
>
> ...
>
> #end Matrix
>
> This takes advantage of the fact that, like C and some C-derivatives,
> Python supports implicit concatenation of adjacent string literals.
> This allows me to construct very long string literals without messing
> up the layout of my code.

Why do you want to split strings?

in python can't you just put the documentation in a string with embedded
newlines?
the length of each line will be under screenwidth.

""" representation of a 3-by-2 affine homogeneous matrix. This does not
actually use any Cairo routines to implement its calculations;
these[...] """

> Lisp doesn’t have such an implicit-concatenation convention. But it
> has macros. And it easy enough to define a macro which does string
> concatenation at macro-invocation time, e.g.

lisp strings (the ~ quoting convention) embed newlines by default.

>
> (defmacro mstr (&rest strs)
> "lets me define a long string literal in pieces across lines, useful for docstrings."
> (apply 'concat strs)
> ) ; defmacro mstr
>
> And using this macro is equally easy:
>
> (defun cur-line (ensure-newline)
> (mstr
> "returns list of two character positions, representing the"
> " beginning and end of the selection if there is one, else"
> " the beginning and end of the current line. ensure-newline"
> " => ensures there is a newline at the end of the line."
> )
> ...
> ) ; defun

You could just have said

(defun cur-line (ensure-newline)
"returns list of two character positions, representing the
beginning and end of the selection if there is one, else
the beginning and end of the current line. ensure-newline
ensures there is a newline at the end of the line."
)

Re: Long Docstrings

<uoc2sg$2oa3u$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17864&group=comp.lang.lisp#17864

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Thu, 18 Jan 2024 20:49:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uoc2sg$2oa3u$3@dont-email.me>
References: <uoalc1$2gjnk$1@dont-email.me>
<m3il3rugas.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Jan 2024 20:49:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f05da8d0375bd152ab59cb890d40489a";
logging-data="2893950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pvjGiziv+Wei2tqMmu0zg"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:jPreMb50wVIzB1xYd9tDtfziCqY=
 by: Lawrence D'Oliv - Thu, 18 Jan 2024 20:49 UTC

On Thu, 18 Jan 2024 15:14:27 +0530, Madhu wrote:

> in python can't you just put the documentation in a string with embedded
> newlines?

You mean triple-quoted strings? And having to add extra blanks at the
start of each line, throwing the formatting off?

> You could just have said

Which is why I said “without messing up the layout of my code.”

Re: Long Docstrings

<20240118140321.208@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17865&group=comp.lang.lisp#17865

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Thu, 18 Jan 2024 22:39:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <20240118140321.208@kylheku.com>
References: <uoalc1$2gjnk$1@dont-email.me>
Injection-Date: Thu, 18 Jan 2024 22:39:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d2d938dda3e1a6a4011b6cb72d132af7";
logging-data="2931235"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kuOa4srZ2t3jrpijeKbc/Cx/VFUYy3Cs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:DYtFYCeq9RAZGV1kp/SZGXPf0Cs=
 by: Kaz Kylheku - Thu, 18 Jan 2024 22:39 UTC

On 2024-01-18, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> I often write long docstrings (not sure whether Lisp has its own name
> for these).

Lis has its own name: docstrings. It is Python that doesn't have its own name.

> (defmacro mstr (&rest strs)
> "lets me define a long string literal in pieces across lines, useful for docstrings."
> (apply 'concat strs)

What is concat?

> ) ; defmacro mstr

Another solution would be to make the macro take a format argument.
Common Lisp has a mechanism inside format strings for removing a newline
and eating the whitespace which follows: tilde before a newline.

(format nil "this is a ~
multi-line ~
print job that ~
becomes one line.")

But ...

> And using this macro is equally easy:
>
> (defun cur-line (ensure-newline)
> (mstr
> "returns list of two character positions, representing the"
> " beginning and end of the selection if there is one, else"
> " the beginning and end of the current line. ensure-newline"
> " => ensures there is a newline at the end of the line."
> )

I am concerned whether this is actually valid syntax for specifying
a docstring.

Note that according to ANSI CL, the syntax of defun is:

defun function-name lambda-list [[declaration* | documentation]] form*

You see how "declaration" and "form" are distinct? Further, the
specification says:

documentation---a string; not evaluated.

It's not evaluated, because it's not a form. The documentation
must be a string literal element in the defun syntax.

Your (mstr ...) therefore doesn't correspond to the "documentation"
element, it is a form.

Nowhere does the spec say that the forms enclosed in defun are
macroexpanded in order to look for docstrings.

It's indeed not working for me in CLISP.

If I define this:

(defun fn () "abc" 42)

the function has "abc" documentation. If I use this:

(defun fn () (mstr "abc") 42)

then it has NIL documentation.

[1]> (defmacro mstr () "abc")
MSTR
[2]> (mstr)
"abc"
[3]> (defun fn () (mstr) 42)
FN
[4]> (documentation 'fn 'function)
NIL
[5]> (defun fn () "abc" 42)
FN
[6]> (documentation 'fn 'function)
"abc"

You need to make your own defun-doc macro to make this work, or else
(yuck) rely on read-time #. evaluation.

;; using your concat

(defmacro defun-doc (name args docstring-list &body body)
`(defun ,name ,args ,(apply #'concat docstring-list) ,@body))

This macro sidesteps the problem by generating a defun which
a string object in the docstring position. defun nevers sees
anything but a string object there.

I would make the macro smart so that it checks for the missing
docstring-list, without which the first argument of the body will
be taken for that position. Like checking that docstring-list is
a proper list, all of whose elements are strings.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Long Docstrings

<uoci6v$2qn07$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17866&group=comp.lang.lisp#17866

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david@harpegolden.net (David De La Harpe Golden)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Fri, 19 Jan 2024 01:10:54 +0000
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <uoci6v$2qn07$1@dont-email.me>
References: <uoalc1$2gjnk$1@dont-email.me> <20240118140321.208@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 19 Jan 2024 01:10:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3ba6e6c45ed9229ccd66b4687288c212";
logging-data="2972679"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DcN8qctgXSz3Jm0+ECB/UKUW3oOYtAj6XLhJn1H5sKg=="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:q+aXKkDhaM+G7ZZ/VKlZwT6Umlc=
Content-Language: en-US
In-Reply-To: <20240118140321.208@kylheku.com>
 by: David De La Harpe Go - Fri, 19 Jan 2024 01:10 UTC

On 18/01/2024 22:39, Kaz Kylheku wrote:
> On 2024-01-18, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>> I often write long docstrings (not sure whether Lisp has its own name
>> for these).
>
> Lis has its own name: docstrings. It is Python that doesn't have its own name.
>

They're certainly normally called docstrings or documentation strings in
python. I expect python got the idea from lisp in the first place.

peps.python.org/pep-0257/#what-is-a-docstring
peps.python.org/pep-0008/#documentation-strings

Normal (and stated in the relevant PEPs!) python convention IS to use
python's triple-double-quoted """multiline-string""" literals for them
uniformly, though.

It's not idiomatic to use python's single-line-restricted
"double-quoted string" literals for them. Not made syntactically
illegal, but odd.

Common python documentation processors using python docstrings as input
do just expect the bit of excess whitespace that ends up embedded in the
docstrings, and generally just trim it away. There's, like, functions in
the stdlib for it

docs.python.org/3/library/inspect.html#inspect.cleandoc

It's also very common to write python docstrings in
Sphinx/reStructuredText syntax specifically (has the advantage of still
remaining fairly readable when viewed as plaintext) on the assumption
they'll also be pulled into the project's generated Sphinx documentation.

www.sphinx-doc.org/en/master/usage/quickstart.html#autodoc

Anyway.

Re: Long Docstrings

<m3o7dit8tn.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17867&group=comp.lang.lisp#17867

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Fri, 19 Jan 2024 06:53:32 +0530
Organization: Motzarella
Lines: 39
Message-ID: <m3o7dit8tn.fsf@leonis4.robolove.meer.net>
References: <uoalc1$2gjnk$1@dont-email.me>
<m3il3rugas.fsf@leonis4.robolove.meer.net>
<uoc2sg$2oa3u$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="85f3fb399de18b079832b71548459811";
logging-data="2975325"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Qy8vFWZYCwcexB+EhEANGX/UyQHkNxr8="
Cancel-Lock: sha1:reWZl5KJJrAsclxXo8yHtLfwY3w=
sha1:PHW0/ZAx9tsvq1eXkR6RU1n1Nts=
 by: Madhu - Fri, 19 Jan 2024 01:23 UTC

* Lawrence D'Oliveiro <uoc2sg$2oa3u$3 @dont-email.me> :
Wrote on Thu, 18 Jan 2024 20:49:20 -0000 (UTC):
> On Thu, 18 Jan 2024 15:14:27 +0530, Madhu wrote:
>> in python can't you just put the documentation in a string with embedded
>> newlines?
> You mean triple-quoted strings? And having to add extra blanks at the
> start of each line, throwing the formatting off?
>> You could just have said
> Which is why I said “without messing up the layout of my code.”

Sorry I misunderstood, I thought you wanted (documentation function) to
yield formatted text and not a single line.

What Kaz said applies for emacs lisp too (`concat' gives it away) -- the
docstring has to be a string.

try add a declaration "(declare (speed 0))" for elisp
or "(declare (optimize (speed 0)))" after the docstring to see the
problem.

elisp will both complain
- Warning: docstring wider than 80
- diagnose a Warning: Stray ‘declare’ form: (declare (speed 0))

common lisp should blow up on compilation.
```
While compiling CUR-LINE :
The DECLARE expression (DECLARE
(OPTIMIZE
(SPEED 0))) is being treated as a form,
possibly because it's the result of macroexpansion. DECLARE expressions
can only appear in specified contexts and must be actual subexpressions
of the containing forms.
```

But you can get around it by using #.(mstr .... ) for the docstring
and evaluate it at read time.

Re: Long Docstrings

<uoesoe$3audo$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17874&group=comp.lang.lisp#17874

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Fri, 19 Jan 2024 22:23:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <uoesoe$3audo$3@dont-email.me>
References: <uoalc1$2gjnk$1@dont-email.me>
<m3il3rugas.fsf@leonis4.robolove.meer.net> <uoc2sg$2oa3u$3@dont-email.me>
<m3o7dit8tn.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 19 Jan 2024 22:23:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a99d1106c5a63aadcf4a9426eaf9b9d4";
logging-data="3504568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QnIc1h0MQsqDBpDHc0wpV"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:RX/sZIbCRrpLZ0lS0AhNm0gXQ1c=
 by: Lawrence D'Oliv - Fri, 19 Jan 2024 22:23 UTC

On Fri, 19 Jan 2024 06:53:32 +0530, Madhu wrote:

> elisp will both complain ...

I have used this successfully in elisp.

Re: Long Docstrings

<uoesuu$3audo$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17875&group=comp.lang.lisp#17875

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Fri, 19 Jan 2024 22:26:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uoesuu$3audo$4@dont-email.me>
References: <uoalc1$2gjnk$1@dont-email.me> <20240118140321.208@kylheku.com>
<uoci6v$2qn07$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 19 Jan 2024 22:26:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a99d1106c5a63aadcf4a9426eaf9b9d4";
logging-data="3504568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5rmb6INDOi0Yueq7ceSAD"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:dYMaDtBKT2fvtHUbmoxaKvf4EDg=
 by: Lawrence D'Oliv - Fri, 19 Jan 2024 22:26 UTC

On Fri, 19 Jan 2024 01:10:54 +0000, David De La Harpe Golden wrote:

> It's not idiomatic to use python's single-line-restricted "double-quoted
> string" literals for them. Not made syntactically illegal, but odd.

I have no idea why people design a language one way, then expect you to
use it a different way.

> Common python documentation processors using python docstrings as input
> do just expect the bit of excess whitespace that ends up embedded in the
> docstrings, and generally just trim it away. There's, like, functions in
> the stdlib for it

I wonder why you need to use them ...

Re: Long Docstrings

<20240119163144.931@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17876&group=comp.lang.lisp#17876

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Sat, 20 Jan 2024 00:32:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20240119163144.931@kylheku.com>
References: <uoalc1$2gjnk$1@dont-email.me> <20240118140321.208@kylheku.com>
<uoci6v$2qn07$1@dont-email.me> <uoesuu$3audo$4@dont-email.me>
Injection-Date: Sat, 20 Jan 2024 00:32:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7af8e8f05916c27f985dd122d5796d12";
logging-data="3543263"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RUFsdey/NQI6TD3XgxYZP+f0gd6QARcw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:tA/6FhcrCDnRTAwYbYhLcei5XKE=
 by: Kaz Kylheku - Sat, 20 Jan 2024 00:32 UTC

On 2024-01-19, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Fri, 19 Jan 2024 01:10:54 +0000, David De La Harpe Golden wrote:
>
>> It's not idiomatic to use python's single-line-restricted "double-quoted
>> string" literals for them. Not made syntactically illegal, but odd.
>
> I have no idea why people design a language one way, then expect you to
> use it a different way.
>
>> Common python documentation processors using python docstrings as input
>> do just expect the bit of excess whitespace that ends up embedded in the
>> docstrings, and generally just trim it away. There's, like, functions in
>> the stdlib for it
>
> I wonder why you need to use them ...

And why doesn't the Python compiler use them to sanitize the docstring
when the function definition is processed, to spare the tooling from
having to do it.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Long Docstrings

<uogicp$3mj90$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17883&group=comp.lang.lisp#17883

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david@harpegolden.net (David De La Harpe Golden)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Sat, 20 Jan 2024 13:38:32 +0000
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uogicp$3mj90$1@dont-email.me>
References: <uoalc1$2gjnk$1@dont-email.me> <20240118140321.208@kylheku.com>
<uoci6v$2qn07$1@dont-email.me> <uoesuu$3audo$4@dont-email.me>
<20240119163144.931@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 20 Jan 2024 13:38:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3afa2fb95a5b397995d5cb918d2eb3fa";
logging-data="3886368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zxUMaBR9+7XNoeOuIne5jMpxIifKcRXKb8+zpRJWdrQ=="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kD0g8CEYEhLrGg7MZmKTgJGKR4Y=
In-Reply-To: <20240119163144.931@kylheku.com>
Content-Language: en-US
 by: David De La Harpe Go - Sat, 20 Jan 2024 13:38 UTC

On 20/01/2024 00:32, Kaz Kylheku wrote:

>> I wonder why you need to use them ...
>
> And why doesn't the Python compiler use them to sanitize the docstring
> when the function definition is processed, to spare the tooling from
> having to do it.
>

Well, sounds like they may well be about to do something like that for
Python 3.13 shortly (at least for compiled files) - pre-release notes -

docs.python.org/3.13/whatsnew/3.13.html

> Compiler now strip indents from docstrings. This will reduce the size
of bytecode cache (e.g. .pyc file). For example, cache file size for
sqlalchemy.orm.session in SQLAlchemy 2.0 is reduced by about 5%. This
change will affect tools using docstrings, like doctest.

Not sure about backward compat though, seems like it would necessarily
be quite a breaking change (seeing as docstrings have in fact preserved
line-leading whitespace all along, if only to be later typically but not
necessarily stripped)

Was debate ongoing 2 weeks ago whether they roll back on the change or not:

github.com/python/cpython/issues/81283#issuecomment-1878628233

Shrug. Not my circus not my monkeys etc.

Re: Long Docstrings

<20240120205725.844@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17907&group=comp.lang.lisp#17907

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Long Docstrings
Date: Sun, 21 Jan 2024 05:01:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <20240120205725.844@kylheku.com>
References: <uoalc1$2gjnk$1@dont-email.me> <20240118140321.208@kylheku.com>
<uoci6v$2qn07$1@dont-email.me> <uoesuu$3audo$4@dont-email.me>
<20240119163144.931@kylheku.com> <uogicp$3mj90$1@dont-email.me>
Injection-Date: Sun, 21 Jan 2024 05:01:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33c09ed4842a7f81f4877f94e0219235";
logging-data="77754"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mrbGQDwbNYQRQjB4piN3PaYDuL4Uu3nk="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Jz99H0g4YABZ9JuCA4Jb3HGy+Hs=
 by: Kaz Kylheku - Sun, 21 Jan 2024 05:01 UTC

On 2024-01-20, David De La Harpe Golden <david@harpegolden.net> wrote:
> On 20/01/2024 00:32, Kaz Kylheku wrote:
>
>>> I wonder why you need to use them ...
>>
>> And why doesn't the Python compiler use them to sanitize the docstring
>> when the function definition is processed, to spare the tooling from
>> having to do it.
>>
> Well, sounds like they may well be about to do something like that for
> Python 3.13 shortly (at least for compiled files) - pre-release notes -
>
> docs.python.org/3.13/whatsnew/3.13.html
>
> > Compiler now strip indents from docstrings. This will reduce the size
> of bytecode cache (e.g. .pyc file). For example, cache file size for
> sqlalchemy.orm.session in SQLAlchemy 2.0 is reduced by about 5%. This
> change will affect tools using docstrings, like doctest.

Under my watch, this obvious thing would have been done 20 years ago.

(Well, if I didn't hate docstrings.)

The Python people are slow on the uptake.

> Not sure about backward compat though, seems like it would necessarily
> be quite a breaking change (seeing as docstrings have in fact preserved
> line-leading whitespace all along, if only to be later typically but not
> necessarily stripped)
>
> Was debate ongoing 2 weeks ago whether they roll back on the change or not:
>
> github.com/python/cpython/issues/81283#issuecomment-1878628233

Undoubtedly, some of these nincompoops have managed to stow away
textual Python source inside docstrings, whose semantics is destroyed
by the stripping.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor