From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ricardo Wurmus Newsgroups: gmane.lisp.guile.devel Subject: Re: rdelim: Add new procedure `for-line-in-file`. Date: Sun, 15 Dec 2024 17:57:51 +0100 Message-ID: <87ed28kho0.fsf@elephly.net> References: <68eef85f-611e-3245-fa5a-675dc3484def@disroot.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7738"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.12.7; emacs 29.4 Cc: guile-devel@gnu.org To: Adam Faiz Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Dec 15 17:58:42 2024 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 1tMrx3-0001sP-HS for guile-devel@m.gmane-mx.org; Sun, 15 Dec 2024 17:58:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMrwZ-0001Ey-Gn; Sun, 15 Dec 2024 11:58:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMrwT-0001Ee-Jh for guile-devel@gnu.org; Sun, 15 Dec 2024 11:58:06 -0500 Original-Received: from sender4-of-o51.zoho.com ([136.143.188.51]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMrwQ-00026j-JR for guile-devel@gnu.org; Sun, 15 Dec 2024 11:58:04 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1734281878; cv=none; d=zohomail.com; s=zohoarc; b=a3KyK+RvAcHvGyiRp2Szy2V29KRxjm878m9CYZFoJSoG92uvroB9m1TQcrq/fAy3BDXSogg5E/CqDJC9NCkB4B02kvPMpztCHz8T01yMBoqf40bEslYU6NcXtubYEnE0DqJ747ClqqJwvGgToxhmVM/Y9w6ivqP61j7PEQ3z7zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734281878; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=KzTc4Esq57nm+7+qukr3bP7qhwheGZfCgxsH/1R9yS8=; b=nCKBoriDNSvjOyGH807hnDvktoPn0QKlSOzznbi+NHpjSdOMuNsRUkWhPH+L5N6/0EK6oFE3SyhBm2C8qY3H5pS54Zh22BOFdx7NL6eCNSb1Tnb+K+eSpmndUT7+wrkZi12ZuqDEtFgIz3kn8mTaiirLFnv6bZzcSDNim7ymTuk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1734281878; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Subject:Subject:In-Reply-To:References:Date:Date:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To; bh=KzTc4Esq57nm+7+qukr3bP7qhwheGZfCgxsH/1R9yS8=; b=e5UrokHUHRgAnrVxIdzx+NPTvOGGVFWJ1lilMz5bmkkOU7JI5d6xfPdETtYAnruN yqGUly5JW1gwu7FqeiBq+Vnyj5jSI8pzJNLobFqD8bEm0ufyGdY0nSG5um6aaSZAf+F iinKi3nN2aUIbSniIFZT/uBEChz9hIbyaAJwqtDY= Original-Received: by mx.zohomail.com with SMTPS id 1734281874586529.4269008033087; Sun, 15 Dec 2024 08:57:54 -0800 (PST) In-Reply-To: <68eef85f-611e-3245-fa5a-675dc3484def@disroot.org> (Adam Faiz's message of "Mon, 16 Dec 2024 00:00:01 +0800") X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22813 Archived-At: Hi Adam, has this patch been discussed somewhere else? I'm asking because I have no context other than this patch. > From 18485a2b94595ae2239f5dcdeb06d3a80bb04bf1 Mon Sep 17 00:00:00 2001 > From: AwesomeAdam54321 > Date: Sun, 15 Dec 2024 23:48:30 +0800 > Subject: [PATCH] rdelim: Add new procedure `for-line-in-file`. > > * module/ice-9/rdelim.scm (for-line-in-file): Add it. > --- > module/ice-9/rdelim.scm | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/module/ice-9/rdelim.scm b/module/ice-9/rdelim.scm > index d2cd081d7..ffa38efad 100644 > --- a/module/ice-9/rdelim.scm > +++ b/module/ice-9/rdelim.scm > @@ -206,3 +206,15 @@ characters to read. By default, there is no limit." > line) > (else > (error "unexpected handle-delim value: " handle-delim))))) > + > +;;; for-line-in-file [PORT BODY] calls BODY (a procedure with the > +;;; line from PORT as it's argument) for every line until the > +;;; eof-object is reached. The line provided to BODY is guaranteed > +;;; to be a string. > + > +(define (for-line-in-file file body) > + (while #t > + (let ((line (read-line file))) > + (if (string? line) > + (body line) > + (break))))) It is preferrable to use a docstring instead of a comment. The choice of argument names is inconsistent, though. You're using PORT in the comment and FILE in the definition. BODY as a name for a procedure is also a rather "inspired" choice. Where is BREAK defined? -- Ricardo