From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Arne Babenhauserheide Newsgroups: gmane.lisp.guile.user Subject: Re: Python-style doctests in Guile (implemented, please comment) Date: Mon, 31 Jul 2017 19:23:36 +0200 Message-ID: <871sowmri4.fsf@web.de> References: <87379d7m66.fsf@web.de> <87ini8zs4w.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1501523047 17546 195.159.176.226 (31 Jul 2017 17:44:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 31 Jul 2017 17:44:07 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jul 31 19:44:03 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcEjZ-0004FQ-Cd for guile-user@m.gmane.org; Mon, 31 Jul 2017 19:44:01 +0200 Original-Received: from localhost ([::1]:60971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcEje-0003N7-NR for guile-user@m.gmane.org; Mon, 31 Jul 2017 13:44:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcEjG-0003Mo-MI for guile-user@gnu.org; Mon, 31 Jul 2017 13:43:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcEjD-00024e-Iq for guile-user@gnu.org; Mon, 31 Jul 2017 13:43:42 -0400 Original-Received: from mout.web.de ([217.72.192.78]:64265) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcEjD-00023i-6s for guile-user@gnu.org; Mon, 31 Jul 2017 13:43:39 -0400 Original-Received: from fluss ([85.212.2.4]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M2uao-1dsFhx2bPq-00scp3; Mon, 31 Jul 2017 19:43:36 +0200 In-reply-to: <87ini8zs4w.fsf@netris.org> X-Provags-ID: V03:K0:1Zt+XTiKt01UYl8Ny0kAJ3BJkrh53H75DKDhTyRUbkjBy2vu1wi FyZCbKUhDA+rhfghiO9VywZaYvaj0YyBrPF9WYN6tNHeJjNPbIZYJ63XpPfwKAifvokn0FI /8AfPInVOFHfRDpANoIgTsn/KGAA0t5SEV9L32ms+V1mwncsZKf2MFtIP42Mj6CUcyKPvR9 QwPCtazWNDF1GqCT/y2/w== X-UI-Out-Filterresults: notjunk:1;V01:K0:Zc0igwzSdEw=:4bnRNHfsACXiq/IUuR9ztm xurWh7HP7f44jHLiR8foNGi2ID8XQKyeF5pWewPuyU+abxdKKSDHe+lqKzULCVZKtnFqKIWTc jTyLT2c7NVZmQnRa87WAnYeDGtMIYxIOUgD+wZF6WNNliLzPA0XPQE4iVFpNibCDwzOOmF3fx KQgt11hnbuhBWHI6h26ViolJgeniqAoiz6VEziy6fNMXn+veWw7sw6glffTuzDsO61B6J1tIL diULcYqJokjpdcux5GhE8MC2QuobteovxUj5o4fvJ6JgWw6/c+eb0VlJca4TB8Vy93bma0KH4 YPPjfh+Vb/d6MkzJz0qR7cp+AP2lciQGv3mRxWiEUmFdNSyA01VjDxfLwYyn2EcZTQhVDnVBQ zCCO0FXBKKfTId3wyEgAl3axc/PZAAfYzAHupsKXtLExKnCC2rjpUNyYWIVuYpwNAZYTene7c kR4t8ALYrSyeWmjuk5l+eh+oveZFIw52ek8Fk2oyp7Oe5RQdJ5XN6EQQR/a3SU/CFe55DOra6 m7a9FGPmwSVk7/YgkExRCAXmUv7CrhiI/vpJq5BBud1wcnF5wmvWpVTfF1NYOUhKEHTjqAru0 UpywxXk+VfFVcZBJmhKNqnC4apsQ2T+S9cLpAVY3R5uiXAGTVjFroHuJcvC13PL88c9uBoALC gHmklHS5vdxmj7VhId3f4FULYM0fmhVwy6r30afGXXnTtDF5e6GJ6tDcU9UCHZqf9M+22Rbfw 2TVfsY3PLyu6QQ1j/+pcOZV6cwGU7/eVjRRMwl7Hk1vvWaHO4nZB1rYGQYKKnbweAWg4uHQ3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.78 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14002 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Mark, String-literals are a problem I did hit, and I=E2=80=99d be happy to lose t= hat problem without losing the ease of starting a procedure with tests which double as automatically verified documentation. Mark H Weaver writes: >> (import (examples doctests)) >>=20=20=20=20=20 >> (define (one) >> "(test 'foo >> (test-equal 1 (one)))" >> 1) > > While it may sometimes be beneficial to include a few > examples in the documentation, a full test suite does not, IMO, belong > in the doc string. I think there=E2=80=99s a misconception here: These doctests are not intend= ed to replace a full test suite. They provide simple tests which double as automatically verified documentation. This is why I asked whether what I implemented is too complex (by providing all of srfi-64 here). If you get clear benefits from editor-support, the test is typically too complex for a doctest. However editor-support could be provided as it is for org-mode: By editing the region in a specialized sub-buffer. The tests here are first-of-all intended for humans to read. Why does code in string-literals bring a loss of hygiene? I=E2=80=99s read = in the module as if it had been written directly in a lambda and read during parsing. Am I missing something or are you envisioning mutation of the string prior to reading and evaluating it? Panicz Maciej Godek writes: > I agree with Mark, that putting tests inside a string in Lisp is a > terrible idea, because Lisp doesn't have Python's shortcommings, =E2=80=A6 > There is no point in trading something better for something worse merely > because people from Python (or elsewhere) can't afford this "better". This doesn=E2=80=99t correctly represent the situation of Python. It is perfectly possible in Python to write tests in literal code =E2=80=94 for example by using attributes of a function to hold functions which run the tests. What doctests provide is a way to write example usage first and foremost for humans, directly at the top of the function definition, and have it checked automatically to ensure that these examples in auto-generated documentation actually work and keep working. Using a define-with-tests (or define-with-examples) does not allow writing for humans first, so it does not reach feature-parity. I could use pretty-print to create an examples section of the documentation, but I won=E2=80=99t know how it is going to be formatted while writing the code. (though this need not be a pure drawback) This is why I=E2=80=99m looking into doctests in the first place. If you ha= ve something which provides feature parity, I=E2=80=99m all for using that instead. Requirements: =2D Can be verified automatically. =2D Becomes part of auto-generated documentation. =2D Is "physically" close to the definition of the procedure (same file, no other definitions between the tests/examples and the procedure). Ideally it should look like what I=E2=80=99d run in the REPL to use the procedure, but I don=E2=80=99t think that this must be a hard requirement. Best wishes, Arne =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE801qEjXQSQPNItXAE++NRSQDw+sFAll/bEQACgkQE++NRSQD w+spuhAAkbFY88dO3Uk4Ex7/pRPEBRvXxHzl/mTGCf4q46djgpWPiaG9j4pCfJ6n IUfY/wCze+nJDDphhOENsYYOCSdbbICvdlaI6huwUSMp/26QCcFlw6o5SUHPgfjt vTCmoAWEwvqA6+WSQti9ewynG3WFUP+e2lhv/eghlaagvhjd1ve/6SqmywzCVZXQ /QptiCWh+dYAgtG5FYxVFkOPWm1IZvSx/HeT2UDOtHwrEtj0dVwA87iIuUEZupY4 Hkt8VqYc+Vs4JOTatRfQY0e4MFUzw0dyeO4uU+lHdi81qWE6Lkk68GUP77BisP6A gobffgitMH4ezwsc+DwgH37mSd77tElY/0uH5f2E87wZXYL/+Fdftok5RR+Zoqoz t+3KICSwEAEa3oDpY8YqMSuLf4SWl5PX+Vagyo0VHqE3q5qJlfDyGhWlbZ/l1i8F F9q+kHYa31L+KmCCOwXlDmhJI94ogpt/JwG91NO7p1GU6YPF7qm+dt83C7hxT1A2 RKNjyLDeg0Ypd3vi9G/mdk3WB5kw5OFdz5RiQ0AljWQetD5g5su74P6uAQofLr5J JjvNnXNab9r3OraLzRVpUMuCJoVUrNH+YuCfBVDmVTKIS2de2exbv0PYA2dhg7aW EwpO/Rr4okh6UWCilF6P61Ug1o056N21tD98eBcg99F1i+fbrBo= =7Dig -----END PGP SIGNATURE----- --=-=-=--