From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: lloda Newsgroups: gmane.lisp.guile.devel Subject: Re: Add internal definitions to derived forms Date: Tue, 24 Jan 2023 18:59:12 +0100 Message-ID: <52FED4FA-CDCD-4DDE-B915-DD9002332D9B@sarc.name> References: <2f38c5ea-0cb6-494e-b680-70b39c3291fb@app.fastmail.com> <38A58B58-3E5C-48EA-A108-1255982789DF@sarc.name> <39109fe3-4f7f-8d07-51ba-f9f993ab5c0d@lassi.io> <8187541f-a4e0-2f26-e8b7-df7fb82bb9f0@lassi.io> <2ffeb6fa-87eb-4008-9881-91b3e71a1fc3@app.fastmail.com> <87h6wgzyqb.fsf@gnu.org> <588FD427-B3C2-4946-83E9-74978E2D3C62@sarc.name> <87mt68wbip.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_9E04327A-32C5-47CA-8A00-58C750BF9224" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38895"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" , =?utf-8?Q?Linus_Bj=C3=B6rnstam?= , Lassi Kortela To: =?utf-8?Q?Ludovic_Court=C3=A8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Jan 24 18:59:56 2023 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 1pKNaO-0009uM-Er for guile-devel@m.gmane-mx.org; Tue, 24 Jan 2023 18:59:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKNZv-0000rp-G4; Tue, 24 Jan 2023 12:59:27 -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 1pKNZt-0000rI-Em for guile-devel@gnu.org; Tue, 24 Jan 2023 12:59:25 -0500 Original-Received: from mta-07-4.privateemail.com ([68.65.122.27]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKNZq-0005Zl-NO; Tue, 24 Jan 2023 12:59:25 -0500 Original-Received: from mta-07.privateemail.com (localhost [127.0.0.1]) by mta-07.privateemail.com (Postfix) with ESMTP id AAEE518000A9; Tue, 24 Jan 2023 12:59:18 -0500 (EST) Original-Received: from [192.168.1.105] (unknown [51.154.167.214]) by mta-07.privateemail.com (Postfix) with ESMTPA id 5042A18000A4; Tue, 24 Jan 2023 12:59:14 -0500 (EST) In-Reply-To: <87mt68wbip.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass client-ip=68.65.122.27; envelope-from=lloda@sarc.name; helo=MTA-07-4.privateemail.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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:21627 Archived-At: --Apple-Mail=_9E04327A-32C5-47CA-8A00-58C750BF9224 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 24 Jan 2023, at 10:02, Ludovic Court=C3=A8s wrote: >=20 > Hi! >=20 > lloda skribis: >=20 >>>> @lisp >>>> -(@var{test} @var{body} @dots{}) >>>> +(@var{test} @var{body}) >>>=20 >>> I think removing dots is incorrect here because it suggests, = according >>> to the typographic conventions used in the document, that there can = only >>> be a single expression. >=20 > [...] >=20 >> This was actually the main thing I wanted to fix in this patch. = Linus' patch had =E2=80=98body ...=E2=80=99 but that clearly means = =E2=80=98zero or more bodies=E2=80=99, which doesn't work because = there's exactly one =E2=80=98body=E2=80=99. I.e. =E2=80=98body=E2=80=99 = isn't an expression that is tagged =E2=80=98body=E2=80=99, it's, well, a = =E2=80=98body=E2=80=99. >=20 > Yeah, =E2=80=98body=E2=80=99 is a bit confusing here; in the example = above, I=E2=80=99d have > written: >=20 > (@var{test} @var{exp} @dots{}) >=20 > because that=E2=80=99s what the =E2=80=9Cbody=E2=80=9D is: one or more = expressions. Hmm, it would seem so, but the way the Scheme reports use = =E2=80=98expression=E2=80=99, it's not. I've added an explicit definition of what the let-expression body is in = the updated patch, I hope that reads better. Also tried to address your = other comments. =20 Thanks Daniel >> The Scheme reports use one =E2=80=98=E2=80=99 and no dots in = all these definitions. See also the definition of let in the linked = section =E2=80=98Local Bindings=E2=80=99, which again uses =E2=80=98body=E2= =80=99 and no dots. I hoped that section would count as definition of = =E2=80=98body=E2=80=99, and the section on =E2=80=98Internal = Definitions=E2=80=99 explains precisely what can go into =E2=80=98body=E2=80= =99, so I linked to that as well. I see that isn't clear enough. Maybe = =E2=80=98body=E2=80=99 should be explicitly defined in one of these = sections? >=20 > Damn it, I hadn=E2=80=99t realized this was a widespread convention, = but yeah, > R5RS and parts of the Guile manual follow this convention. So hmm, = the > change you propose makes a lot of sense to me now. >=20 > So yeah overall I guess we should always write one of: >=20 > (something @var{body}) >=20 > or: >=20 > (something @var{exp} @dots{}) >=20 > Using @var{body} like you do in this patch is consistent with other > parts of the manual, so it LGTM. >=20 > Thanks, > Ludo=E2=80=99. --Apple-Mail=_9E04327A-32C5-47CA-8A00-58C750BF9224 Content-Disposition: attachment; filename=0002-Document-multiple-value-returns-in-forms-taking-a-le.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-Document-multiple-value-returns-in-forms-taking-a-le.patch" Content-Transfer-Encoding: quoted-printable =46rom=2070ce7174a43ba17f2db0c3a6b7eeeb191a332663=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0ADate:=20= Tue,=2024=20Jan=202023=2011:26:44=20+0100=0ASubject:=20[PATCH=202/2]=20= Document=20multiple-value=20returns=20in=20forms=20taking=20a=0A=20= let-expression=20body=0A=0A*=20doc/ref/api-binding.texi=20(Local=20= Bindings):=20Document=20multiple-value=0A=20=20returns=20for=20let.=0A*=20= doc/ref/api-control.texi=20(begin):=20Document=20multiple-value=20= returns=20for=0A=20=20begin.=0A=20=20(Conditionals):=20Document=20= multiple-value=20returns=20and=20use=20'body'=20in=20the=0A=20=20syntax=20= description=20of=20when,=20unless,=20cond,=20case.=0A=20=20(Multiple=20= values):=20Document=20multiple-value=20returns=20and=20use=20'body'=20in=0A= =20=20the=20syntax=20description=20of=20SRFI-8=20receive.=0A---=0A=20= doc/ref/api-binding.texi=20|=2011=20++++++---=0A=20= doc/ref/api-control.texi=20|=2051=20= +++++++++++++++++++---------------------=0A=202=20files=20changed,=2032=20= insertions(+),=2030=20deletions(-)=0A=0Adiff=20--git=20= a/doc/ref/api-binding.texi=20b/doc/ref/api-binding.texi=0Aindex=20= 60f034a0e..a0cf8f0d8=20100644=0A---=20a/doc/ref/api-binding.texi=0A+++=20= b/doc/ref/api-binding.texi=0A@@=20-138,6=20+138,11=20@@=20The=20most=20= basic=20local=20binding=20construct=20is=20@code{let}.=0A=20that=20is=20= zero=20or=20more=20two-element=20lists=20of=20a=20variable=20and=20an=20= arbitrary=0A=20expression=20each.=20=20All=20@var{variable}=20names=20= must=20be=20distinct.=0A=20=0A+@cindex=20body,=20of=20a=20@code{let}=20= expression=0A+=0A+@var{body}=20is=20a=20sequence=20of=20expressions=20= and=20definitions,=20ending=20in=20an=0A+expression.=20=0A+=0A=20A=20= @code{let}=20expression=20is=20evaluated=20as=20follows.=0A=20=0A=20= @itemize=20@bullet=0A@@=20-151,9=20+156,9=20@@=20New=20storage=20is=20= allocated=20for=20the=20@var{variables}.=0A=20The=20values=20of=20the=20= @var{init}=20expressions=20are=20stored=20into=20the=20variables.=0A=20=0A= =20@item=0A-The=20expressions=20in=20@var{body}=20are=20evaluated=20in=20= order,=20and=20the=20value=20of=0A-the=20last=20expression=20is=20= returned=20as=20the=20value=20of=20the=20@code{let}=0A-expression.=0A= +The=20expressions=20and=20definitions=20in=20@var{body}=20are=20= evaluated=20in=20order=0A+(@pxref{Internal=20Definitions}),=20and=20the=20= values=20of=20the=20last=20expression=0A+are=20returned=20as=20the=20= result=20of=20the=20@code{let}=20expression.=0A=20@end=20itemize=0A=20=0A= =20The=20@var{init}=20expressions=20are=20not=20allowed=20to=20refer=20= to=20any=20of=20the=0Adiff=20--git=20a/doc/ref/api-control.texi=20= b/doc/ref/api-control.texi=0Aindex=20ece6a6020..24356a273=20100644=0A---=20= a/doc/ref/api-control.texi=0A+++=20b/doc/ref/api-control.texi=0A@@=20= -47,8=20+47,8=20@@=20output=20port,=20then=20display=20a=20newline.=20=20= We=20use=20@code{begin}=20to=20form=20a=0A=20compound=20expression=20out=20= of=20this=20sequence=20of=20sub-expressions.=0A=20=0A=20@deffn=20syntax=20= begin=20expr=20@dots{}=0A-The=20expression(s)=20are=20evaluated=20in=20= left-to-right=20order=20and=20the=20value=20of=0A-the=20last=20= expression=20is=20returned=20as=20the=20value=20of=20the=0A+The=20= expression(s)=20are=20evaluated=20in=20left-to-right=20order=20and=20the=20= values=20of=0A+the=20last=20expression=20are=20returned=20as=20the=20= result=20of=20the=0A=20@code{begin}-expression.=20=20This=20expression=20= type=20is=20used=20when=20the=0A=20expressions=20before=20the=20last=20= one=20are=20evaluated=20for=20their=20side=20effects.=0A=20@end=20deffn=0A= @@=20-117,7=20+117,7=20@@=20abuses=20the=20@code{begin}=20form=20for=20= these=20two=20tasks.=0A=20=0A=20Guile=20provides=20three=20syntactic=20= constructs=20for=20conditional=20evaluation.=0A=20@code{if}=20is=20the=20= normal=20if-then-else=20expression=20(with=20an=20optional=20else=0A= -branch),=20@code{cond}=20is=20a=20conditional=20expression=20with=20= multiple=20branches=0A+branch),=20@code{cond}=20is=20a=20conditional=20= expression=20with=20multiple=20branches,=0A=20and=20@code{case}=20= branches=20if=20an=20expression=20has=20one=20of=20a=20set=20of=20= constant=0A=20values.=0A=20=0A@@=20-141,14=20+141,14=20@@=20expression.=20= =20(By=20convention,=20we=20use=20the=20word=20@dfn{statement}=20to=20= refer=20to=0A=20an=20expression=20that=20is=20evaluated=20for=20effect,=20= not=20for=20value).=0A=20=0A=20In=20such=20a=20case,=20it=20is=20= considered=20more=20clear=20to=20express=20these=20intentions=0A-with=20= these=20special=20forms,=20@code{when}=20and=20@code{unless}.=20=20As=20= an=20added=0A-bonus,=20these=20forms=20accept=20multiple=20statements=20= to=20evaluate,=20which=20are=0A-implicitly=20wrapped=20in=20a=20= @code{begin}.=0A+with=20the=20special=20forms=20@code{when}=20and=20= @code{unless}.=20=20As=20an=20added=0A+bonus,=20these=20forms=20take=20a=20= @emph{body}=20like=20in=20a=20@code{let}=20expression,=0A+which=20can=20= contain=20internal=20definitions=20and=20multiple=20statements=20to=0A= +evaluate=20(@pxref{Local=20Bindings}).=0A=20=0A-@deffn=20{Scheme=20= Syntax}=20when=20test=20statement1=20statement2=20...=0A-@deffnx=20= {Scheme=20Syntax}=20unless=20test=20statement1=20statement2=20...=0A-The=20= actual=20definitions=20of=20these=20forms=20are=20in=20many=20ways=20= their=20most=20clear=0A-documentation:=0A+@deffn=20{Scheme=20Syntax}=20= when=20test=20body=0A+@deffnx=20{Scheme=20Syntax}=20unless=20test=20body=0A= +The=20actual=20definitions=20of=20these=20forms=20may=20be=20their=20= most=20clear=20documentation:=0A=20=0A=20@example=0A=20= (define-syntax-rule=20(when=20test=20stmt=20stmt*=20...)=0A@@=20-167,11=20= +167,10=20@@=20statements=20if=20@var{test}=20is=20false.=0A=20Each=20= @code{cond}-clause=20must=20look=20like=20this:=0A=20=0A=20@lisp=0A= -(@var{test}=20@var{body}=20@dots{})=0A+(@var{test}=20@var{body})=0A=20= @end=20lisp=0A=20=0A-where=20@var{test}=20is=20an=20arbitrary=20= expression=20and=20@var{body}=20is=20a=0A-lambda-like=20body,=20or=20= like=20this=0A+where=20@var{test}=20is=20an=20arbitrary=20expression,=20= or=20like=20this=0A=20=0A=20@lisp=0A=20(@var{test}=20=3D>=20= @var{expression})=0A@@=20-180,9=20+179,9=20@@=20lambda-like=20body,=20or=20= like=20this=0A=20where=20@var{expression}=20must=20evaluate=20to=20a=20= procedure.=0A=20=0A=20The=20@var{test}s=20of=20the=20clauses=20are=20= evaluated=20in=20order=20and=20as=20soon=20as=20one=0A-of=20them=20= evaluates=20to=20a=20true=20value,=20the=20corresponding=20= @var{expression}s=0A-are=20evaluated=20in=20order=20and=20the=20last=20= value=20is=20returned=20as=20the=20value=20of=0A-the=20= @code{cond}-expression.=20=20For=20the=20@code{=3D>}=20clause=20type,=0A= +of=20them=20evaluates=20to=20a=20true=20value,=20the=20corresponding=20= @var{body}=20is=0A+evaluated=20to=20produce=20the=20result=20of=20the=20= @code{cond}-expression.=20=20For=20the=0A+@code{=3D>}=20clause=20type,=0A= =20@var{expression}=20is=20evaluated=20and=20the=20resulting=20procedure=20= is=20applied=20to=0A=20the=20value=20of=20@var{test}.=20=20The=20result=20= of=20this=20procedure=20application=20is=0A=20then=20the=20result=20of=20= the=20@code{cond}-expression.=0A@@=20-209,7=20+208,7=20@@=20procedure=20= to=20the=20value(s)=20of=20@var{test},=20in=20the=20same=20manner=20as=20= the=0A=20=0A=20The=20@var{test}=20of=20the=20last=20@var{clause}=20may=20= be=20the=20symbol=20@code{else}.=0A=20Then,=20if=20none=20of=20the=20= preceding=20@var{test}s=20is=20true,=20the=0A-@var{expression}s=20= following=20the=20@code{else}=20are=20evaluated=20to=20produce=20the=0A= +@var{body}=20following=20the=20@code{else}=20is=20evaluated=20to=20= produce=20the=0A=20result=20of=20the=20@code{cond}-expression.=0A=20@end=20= deffn=0A=20=0A@@=20-217,7=20+216,7=20@@=20result=20of=20the=20= @code{cond}-expression.=0A=20@var{key}=20may=20be=20any=20expression,=20= and=20the=20@var{clause}s=20must=20have=20the=20form=0A=20=0A=20@lisp=0A= -((@var{datum1}=20@dots{})=20@var{body}=20@dots{})=0A+((@var{datum1}=20= @dots{})=20@var{body})=0A=20@end=20lisp=0A=20=0A=20or=0A@@=20-229,7=20= +228,7=20@@=20or=0A=20and=20the=20last=20@var{clause}=20may=20have=20the=20= form=0A=20=0A=20@lisp=0A-(else=20@var{expr1}=20@var{body}=20@dots{})=0A= +(else=20@var{body})=0A=20@end=20lisp=0A=20=0A=20or=0A@@=20-241,14=20= +240,13=20@@=20or=0A=20All=20@var{datum}s=20must=20be=20distinct.=20=20= First,=20@var{key}=20is=20evaluated.=20=20The=0A=20result=20of=20this=20= evaluation=20is=20compared=20against=20all=20@var{datum}=20values=0A=20= using=20@code{eqv?}.=20=20When=20this=20comparison=20succeeds,=20the=20= @var{body}=0A-following=20the=20@var{datum}=20is=20evaluated=20like=20= the=20body=20of=20a=20lambda,=0A-returning=20the=20value=20of=20the=20= last=20expression=20as=20the=20result=20of=20the=0A+following=20the=20= @var{datum}=20is=20evaluated=20to=20produce=20the=20result=20of=20the=0A=20= @code{case}=20expression.=0A=20=0A=20If=20the=20@var{key}=20matches=20no=20= @var{datum}=20and=20there=20is=20an=0A=20@code{else}-clause,=20the=20= @var{body}=20following=20the=20@code{else}=20is=0A-evaluated.=20=20If=20= there=20is=20no=20such=20clause,=20the=20result=20of=20the=20expression=20= is=0A-unspecified.=0A+evaluated=20to=20produce=20the=20result=20of=20the=20= @code{case}=20expression.=20=20If=20there=0A+is=20no=20such=20clause,=20= the=20result=20of=20the=20expression=20is=20unspecified.=0A=20=0A=20For=20= the=20@code{=3D>}=20clause=20types,=20@var{expression}=20is=20evaluated=20= and=20the=0A=20resulting=20procedure=20is=20applied=20to=20the=20value=20= of=20@var{key}.=20=20The=20result=20of=0A@@=20-970,13=20+968,12=20@@=20= same=20as=20specified=20by=20SRFI-8=20(@pxref{SRFI-8}).=0A=20= (use-modules=20(ice-9=20receive))=0A=20@end=20lisp=0A=20=0A-@deffn=20= {library=20syntax}=20receive=20formals=20expr=20body=20@dots{}=0A+@deffn=20= {library=20syntax}=20receive=20formals=20expr=20body=0A=20Evaluate=20the=20= expression=20@var{expr},=20and=20bind=20the=20result=20values=20(zero=0A=20= or=20more)=20to=20the=20formal=20arguments=20in=20@var{formals}.=20=20= @var{formals}=20is=20a=0A=20list=20of=20symbols,=20like=20the=20argument=20= list=20in=20a=20@code{lambda}=0A-(@pxref{Lambda}).=20=20After=20binding=20= the=20variables,=20the=20expressions=20in=0A-@var{body}=20@dots{}=20are=20= evaluated=20in=20order,=20the=20return=20value=20is=20the=0A-result=20= from=20the=20last=20expression.=0A+(@pxref{Lambda}).=20=20After=20= binding=20the=20variables,=20the=20@var{body}=20is=0A+evaluated=20to=20= produce=20the=20result=20of=20the=20@code{receive}=20expression.=0A=20=0A= =20For=20example=20getting=20results=20from=20@code{partition}=20in=20= SRFI-1=0A=20(@pxref{SRFI-1}),=0A--=20=0A2.30.2=0A=0A= --Apple-Mail=_9E04327A-32C5-47CA-8A00-58C750BF9224 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_9E04327A-32C5-47CA-8A00-58C750BF9224--