From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] srfi-64: fix unused variable warnings Date: Thu, 01 Apr 2021 13:37:26 +0200 Message-ID: <74a46c307dac2d9e2dbc4affdaa5c56a75fc2b1b.camel@telenet.be> References: <20210401061135.11914-1-aconchillo@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-yz3Kf5UXltmMLq4zr+50" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32522"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.34.2 To: Aleix Conchillo =?ISO-8859-1?Q?Flaqu=E9?= , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Apr 01 13:43:02 2021 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRvj3-0008K8-VP for guile-devel@m.gmane-mx.org; Thu, 01 Apr 2021 13:43:01 +0200 Original-Received: from localhost ([::1]:37520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvj2-00082d-Sn for guile-devel@m.gmane-mx.org; Thu, 01 Apr 2021 07:43:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvil-000813-5w for guile-devel@gnu.org; Thu, 01 Apr 2021 07:42:43 -0400 Original-Received: from baptiste.telenet-ops.be ([2a02:1800:120:4::f00:13]:51160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRvih-0001jL-KM for guile-devel@gnu.org; Thu, 01 Apr 2021 07:42:41 -0400 Original-Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by baptiste.telenet-ops.be with bizsmtp id nPdY2400H0mfAB401PdY6D; Thu, 01 Apr 2021 13:37:32 +0200 In-Reply-To: <20210401061135.11914-1-aconchillo@gmail.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1617277052; bh=4TZzE1fkafazs6BgqrP33RBIqjLbt6S8VqmcK9kCqUQ=; h=Subject:From:To:Date:In-Reply-To:References; b=bXWl60c66FJKRbjflwQg4bVCufitV3zyAn5sGC25qIiMIr6B9B/Q8GitbcVGdyQlA 3gJnLt5kY0ywklkVq7hKi9DgqJjofizBzFueT9xRkChnUXhu/1M2Us2Aip36guedDg q96NEWVQOJcXd+3aU4XogbHroxrwTA8p/hyrae1EiPBVFf0j6237PbjdW/5bFAwrVe VI82pHMoH+ew7rbrxXxdgMhDtjtu/jHk+PuipOGMRPPzAKDLDQ+hKTuzwUr+eUFe/7 102/Y06n/mbjAtIeto6WhMtYNCqSxkvsHGcr0mu9AdRcYKNdL6FWbya0tsrOkaDqzw WGhjS8gDMDvkA== Received-SPF: pass client-ip=2a02:1800:120:4::f00:13; envelope-from=maximedevos@telenet.be; helo=baptiste.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20721 Archived-At: --=-yz3Kf5UXltmMLq4zr+50 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2021-03-31 at 23:11 -0700, Aleix Conchillo Flaqu=C3=A9 wrote: > * module/srfi/srfi-64/testing.scm: remove unused name variable and use > let instead of let*. >=20 I don't think this is the correct approach with respect to side effects. For example, in: > (define (%test-comp2 comp x) > (syntax-case (list x (list (syntax quote) (%test-source-line2 x)) co= mp) () > (((mac tname expected expr) line comp) > (syntax > - (let* ((r (test-runner-get)) > - (name tname)) > + (let ((r (test-runner-get))) > (test-result-alist! r (cons (cons 'test-name tname) line)) > (%test-comp2body r comp expected expr)))) I would keep the let* (but reverse the binding order), but change 'tname' with 'name' in the call to 'test-result-alist!', such that 'test-X' macros behave somewhat more like procedure calls (except for installing exeption handlers and having access to the s-expression of the code that will be run= , of course). It's largely a matter of taste, though. In any case, it is good that 'tname' is now evaluated only once, as per SRFI-64 (notice ***It is evaluated only once.*** (markup mine)): (test-assert [test-name] expression) This evaluates the expression. The test passes if the result is true; if the result is false, a test failure is reported. The test also fails if an exception is raised, assuming the implementation has a way to catch exceptions. How the failure is reported depends on the test runner environ= ment. The test-name is a string that names the test case. (Though the test-name = is a string literal in the examples, it is an expression. ***It is evaluated = only once.***) It is used when reporting errors, and also when skipping tests, as describ= ed below. It is an error to invoke test-assert if there is no current test runner. (My suggestion would be to also evaluate 'test-name' at least once, even if= there is no test runner, which seems a bit stricter than SRFI-64 demands, but see= ms like a nice property to have and easy to achieve.) As this patch does not =E2=80=98merely=E2=80=99 fix a warnings, but fixes a= bug, could you change the patch message accordingly? Something like srfi-64: fix double evaluation of test-name. perhaps? Greetings, Maxime. --=-yz3Kf5UXltmMLq4zr+50 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYGWwdhccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7o8NAP9OU0/Wvq/refjv7RLGL+2gsKzD kWHvgOilVZ82B1aTFAD8C0zU2QVSznsTA/+ptyI/SeuQRUZ0dmqT3ZN1GHMqEwY= =mLjM -----END PGP SIGNATURE----- --=-yz3Kf5UXltmMLq4zr+50--