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: [PATCH] Document R7RS bytevector functions Date: Sun, 15 Jan 2023 23:06:09 +0100 Message-ID: References: <4ACA94E8-9A54-448E-86F1-DA1D3B6A044C@sarc.name> <87bkn19ncf.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=_4A69F0E9-468A-40CF-AFA2-3712AB4CC47F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34381"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" To: =?utf-8?Q?Ludovic_Court=C3=A8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Jan 15 23:06:51 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 1pHB9O-0008oI-Sj for guile-devel@m.gmane-mx.org; Sun, 15 Jan 2023 23:06:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHB99-0001mD-7C; Sun, 15 Jan 2023 17:06:35 -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 1pHB97-0001lj-GO for guile-devel@gnu.org; Sun, 15 Jan 2023 17:06:33 -0500 Original-Received: from mta-13-4.privateemail.com ([198.54.127.109]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHB95-00005l-MH; Sun, 15 Jan 2023 17:06:33 -0500 Original-Received: from mta-13.privateemail.com (localhost [127.0.0.1]) by mta-13.privateemail.com (Postfix) with ESMTP id 0FB7618000A0; Sun, 15 Jan 2023 17:06:14 -0500 (EST) Original-Received: from [192.168.1.105] (unknown [51.154.167.214]) by mta-13.privateemail.com (Postfix) with ESMTPA id 2316118000A2; Sun, 15 Jan 2023 17:06:11 -0500 (EST) In-Reply-To: <87bkn19ncf.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass client-ip=198.54.127.109; envelope-from=lloda@sarc.name; helo=MTA-13-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, 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:21590 Archived-At: --Apple-Mail=_4A69F0E9-468A-40CF-AFA2-3712AB4CC47F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Ludovic,=20 thanks for the review. Second version attached. > We should keep the manual in sync with docstrings in bytevectors.c. >=20 > Thus, my suggestion would be to not insert comments and footnotes = about > R7RS in the existing sections, but instead to do that in the new = section. Following this, I've removed the footnotes & references to R7RS in the = main section. Patch aside: I still think the links are useful, so I'd like to find a way to put = them back. I think someone who finds their way into the doc for r6rs = bytevector-copy should be told that there are in fact different versions = of this procedure. Just in general, I think there should be many more = links in the doc. Regards Daniel --Apple-Mail=_4A69F0E9-468A-40CF-AFA2-3712AB4CC47F Content-Disposition: attachment; filename=0001-Document-R7RS-functions-related-to-bytevectors.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Document-R7RS-functions-related-to-bytevectors.patch" Content-Transfer-Encoding: quoted-printable =46rom=20547bd47887d7096e5568c31edb0b1661b1ac23ec=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0ADate:=20= Sun,=2015=20Jan=202023=2022:41:48=20+0100=0ASubject:=20[PATCH]=20= Document=20R7RS=20functions=20related=20to=20bytevectors=0A=0A*=20= doc/ref/api-data.texi=20(Bytevectors):=20Document=20R7RS=20bytevector,=0A= =20=20bytevector-copy,=20bytevector-copy!,=20bytevector-append.=0A=20=20= Fix=20typo=20in=20(r6:bytevector-copy),=20index=20need=20not=20be=20= positive.=0A=20=20Fix=20typos=20in=20bytevector-length,=20bytevector=3D,=20= bytevector-fill!.=0A*=20doc/ref/api-io.texi=20(Binary=20I/O):=20Document=20= R7RS=0A=20=20open-output-bytevector,=20write-u8,=20read-u8,=20peek-u8,=0A= =20=20get-output-bytevector,=20open-input-bytevector,=20= read-bytevector!,=0A=20=20read-bytevector,=20write-bytevector.=0A---=0A=20= doc/ref/api-data.texi=20|=20102=20++++++++++++++++++++++++++++++++---=0A=20= doc/ref/api-io.texi=20=20=20|=20121=20= ++++++++++++++++++++++++++++++++++++++++++=0A=202=20files=20changed,=20= 216=20insertions(+),=207=20deletions(-)=0A=0Adiff=20--git=20= a/doc/ref/api-data.texi=20b/doc/ref/api-data.texi=0Aindex=20= d332aa997..e4f3978b4=20100644=0A---=20a/doc/ref/api-data.texi=0A+++=20= b/doc/ref/api-data.texi=0A@@=20-6635,7=20+6635,7=20@@=20and=20writing.=0A= =20@cindex=20bytevector=0A=20@cindex=20R6RS=0A=20=0A-A=20= @dfn{bytevector}=20is=20a=20raw=20bit=20string.=20=20The=20@code{(rnrs=20= bytevectors)}=0A+A=20@dfn{bytevector}=20is=20a=20raw=20byte=20string.=20=20= The=20@code{(rnrs=20bytevectors)}=0A=20module=20provides=20the=20= programming=20interface=20specified=20by=20the=0A=20= @uref{http://www.r6rs.org/,=20Revised^6=20Report=20on=20the=20= Algorithmic=20Language=0A=20Scheme=20(R6RS)}.=20=20It=20contains=20= procedures=20to=20manipulate=20bytevectors=20and=0A@@=20-6722,6=20= +6722,7=20@@=20The=20objects=20denoting=20big-=20and=20= little-endianness,=20respectively.=0A=20Bytevectors=20can=20be=20= created,=20copied,=20and=20analyzed=20with=20the=20following=0A=20= procedures=20and=20C=20functions.=0A=20=0A+@anchor{x-make-bytevector}=0A=20= @deffn=20{Scheme=20Procedure}=20make-bytevector=20len=20[fill]=0A=20= @deffnx=20{C=20Function}=20scm_make_bytevector=20(len,=20fill)=0A=20= @deffnx=20{C=20Function}=20scm_c_make_bytevector=20(size_t=20len)=0A@@=20= -6730,6=20+6731,7=20@@=20is=20given,=20fill=20it=20with=20@var{fill};=20= @var{fill}=20must=20be=20in=20the=20range=0A=20[-128,255].=0A=20@end=20= deffn=0A=20=0A+@anchor{x-bytevector?}=0A=20@deffn=20{Scheme=20Procedure}=20= bytevector?=20obj=0A=20@deffnx=20{C=20Function}=20scm_bytevector_p=20= (obj)=0A=20Return=20true=20if=20@var{obj}=20is=20a=20bytevector.=0A@@=20= -6739,6=20+6741,7=20@@=20Return=20true=20if=20@var{obj}=20is=20a=20= bytevector.=0A=20Equivalent=20to=20@code{scm_is_true=20(scm_bytevector_p=20= (obj))}.=0A=20@end=20deftypefn=0A=20=0A+@anchor{x-bytevector-length}=0A=20= @deffn=20{Scheme=20Procedure}=20bytevector-length=20bv=0A=20@deffnx=20{C=20= Function}=20scm_bytevector_length=20(bv)=0A=20Return=20the=20length=20in=20= bytes=20of=20bytevector=20@var{bv}.=0A@@=20-6750,31=20+6753,33=20@@=20= Likewise,=20return=20the=20length=20in=20bytes=20of=20bytevector=20= @var{bv}.=0A=20=0A=20@deffn=20{Scheme=20Procedure}=20bytevector=3D?=20= bv1=20bv2=0A=20@deffnx=20{C=20Function}=20scm_bytevector_eq_p=20(bv1,=20= bv2)=0A-Return=20is=20@var{bv1}=20equals=20to=20@var{bv2}---i.e.,=20if=20= they=20have=20the=20same=0A+Return=20@code{#t}=20if=20@var{bv1}=20equals=20= @var{bv2}---i.e.,=20if=20they=20have=20the=20same=0A=20length=20and=20= contents.=0A=20@end=20deffn=0A=20=0A=20@deffn=20{Scheme=20Procedure}=20= bytevector-fill!=20bv=20fill=20[start=20[end]]=0A=20@deffnx=20{C=20= Function}=20scm_bytevector_fill_x=20(bv,=20fill)=0A=20Fill=20positions=20= [@var{start}=20...=20@var{end})=20of=20bytevector=20@var{bv}=20with=0A= -byte=20@var{fill}.=20@var{start}=20defaults=20to=200=20and=20@var{end}=20= defaults=20to=20the=0A-length=20of=20@var{bv}.@footnote{R6RS=20defines=20= @code{(bytevector-fill!=20bv=0A-fill)}.=20Arguments=20@var{start}=20and=20= @var{end}=20are=20a=20Guile=20extension=0A+byte=20@var{fill}.=20=20= @var{start}=20defaults=20to=200=20and=20@var{end}=20defaults=20to=20the=0A= +length=20of=20@var{bv}.@footnote{R6RS=20only=20defines=20= @code{(bytevector-fill!=20bv=0A+fill)}.=20=20Arguments=20@var{start}=20= and=20@var{end}=20are=20a=20Guile=20extension=0A=20(cf.=20= @ref{x-vector-fill!,@code{vector-fill!}},=0A=20= @ref{x-string-fill!,@code{string-fill!}}).}=0A=20@end=20deffn=0A=20=0A= +@anchor{x-r6:bytevector-copy!}=0A=20@deffn=20{Scheme=20Procedure}=20= bytevector-copy!=20source=20source-start=20target=20target-start=20len=0A= =20@deffnx=20{C=20Function}=20scm_bytevector_copy_x=20(source,=20= source_start,=20target,=20target_start,=20len)=0A=20Copy=20@var{len}=20= bytes=20from=20@var{source}=20into=20@var{target},=20starting=0A-reading=20= from=20@var{source-start}=20(a=20positive=20index=20within=20= @var{source})=0A+reading=20from=20@var{source-start}=20(an=20index=20= index=20within=20@var{source})=0A=20and=20writing=20at=20= @var{target-start}.=0A=20=0A=20It=20is=20permitted=20for=20the=20= @var{source}=20and=20@var{target}=20regions=20to=0A-overlap.=20In=20that=20= case,=20copying=20takes=20place=20as=20if=20the=20source=20is=20first=0A= +overlap.=20=20In=20that=20case,=20copying=20takes=20place=20as=20if=20= the=20source=20is=20first=0A=20copied=20into=20a=20temporary=20= bytevector=20and=20then=20into=20the=20destination.=0A=20@end=20deffn=0A=20= =0A+@anchor{x-r6:bytevector-copy}=0A=20@deffn=20{Scheme=20Procedure}=20= bytevector-copy=20bv=0A=20@deffnx=20{C=20Function}=20scm_bytevector_copy=20= (bv)=0A=20Return=20a=20newly=20allocated=20copy=20of=20@var{bv}.=0A@@=20= -6799,6=20+6804,86=20@@=20Return=20the=20length=20in=20bytes=20of=20= bytevector=20@var{bv}.=0A=20Return=20a=20pointer=20to=20the=20contents=20= of=20bytevector=20@var{bv}.=0A=20@end=20deftypefn=0A=20=0A= +@subsubheading=20Bytevector=20Procedures=20in=20R7RS=0A+=0A+@ref{R7RS=20= Standard=20Libraries,R7RS}=20defines=20a=20set=20of=20bytevector=0A= +manipulation=20procedures,=20accessible=20with=0A+=0A+@example=0A= +(use-modules=20(scheme=20base))=0A+@end=20example=0A+=0A+Of=20these,=20= @ref{x-make-bytevector,@code{make-bytevector}},=0A= +@ref{x-bytevector?,@code{bytevector?}},=0A= +@ref{x-bytevector-length,@code{bytevector-length}},=0A= +@ref{x-bytevector-u8-ref,@code{bytevector-u8-ref}}=20and=0A= +@ref{x-bytevector-u8-set!,@code{bytevector-u8-set!}}=20have=20the=20= same=0A+definition=20as=20in=20R6RS.=20=20The=20procedures=20listed=20= below=20either=20have=20a=0A+different=20definition=20in=20R7RS=20and=20= R6RS,=20or=20are=20not=20defined=20in=20R6RS.=0A+=0A+@deffn=20{Scheme=20= Procedure}=20bytevector=20arg=20@dots{}=0A+Return=20a=20newly=20= allocated=20bytevector=20composed=20of=20the=20given=20arguments.=0A= +Analogous=20to=20@code{list}.=0A+=0A+@lisp=0A+(bytevector=202=203=204)=20= @result{}=20#vu8(2=203=204)=0A+@end=20lisp=0A+=0A+See=20also=20= @ref{x-u8-list->bytevector,@code{u8-list->bytevector}}.=0A+@end=20deffn=0A= +=0A+@anchor{x-r7:bytevector-copy}=0A+@deffn=20{Scheme=20Procedure}=20= bytevector-copy=20bv=20[start=20[end]]=0A+Returns=20a=20newly=20= allocated=20bytevector=20containing=20the=20elements=20of=20@var{bv}=0A= +in=20the=20range=20[@var{start}=20...=20@var{end}).=20=20@var{start}=20= defaults=20to=200=20and=0A+@var{end}=20defaults=20to=20the=20length=20of=20= @var{bv}.=0A+=0A+@lisp=0A+(define=20bv=20#vu8(0=201=202=203=204=205))=0A= +(bytevector-copy=20bv)=20@result{}=20#vu8(0=201=202=203=204=205)=0A= +(bytevector-copy=20bv=202)=20@result{}=20#vu8(2=203=204=205)=0A= +(bytevector-copy=20bv=202=204)=20@result{}=20#vu8(2=203)=0A+@end=20lisp=0A= +=0A+See=20also=20@ref{x-r6:bytevector-copy,the=20R6RS=20version}.=0A= +@end=20deffn=0A+=0A+@anchor{x-r7:bytevector-copy!}=0A+@deffn=20{Scheme=20= Procedure}=20bytevector-copy!=20dst=20at=20src=20[start=20[end]]=0A+Copy=20= the=20block=20of=20elements=20from=20bytevector=20@var{src}=20in=20the=20= range=0A+[@var{start}=20...=20@var{end})=20into=20bytevector=20= @var{dst},=20starting=20at=0A+position=20@var{at}.=20=20@var{start}=20= defaults=20to=200=20and=20@var{end}=20defaults=20to=0A+the=20length=20of=20= @var{src}.=20=20It=20is=20an=20error=20for=20@var{dst}=0A+to=20have=20a=20= length=20less=20than=20@var{at}=20+=20(@var{end}=20-=20@var{start}).=0A+=0A= +See=20also=20@ref{x-r6:bytevector-copy!,the=20R6RS=20version}.=20=20= With=0A+=0A+@lisp=0A+(use-modules=20((rnrs=20bytevectors)=20#:prefix=20= r6:)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20((scheme=20base)=20= #:prefix=20r7:))=0A+@end=20lisp=0A+=0A+the=20following=20calls=20are=20= equivalent:=0A+=0A+@lisp=0A+(r6:bytevector-copy!=20source=20source-start=20= target=20target-start=20len)=0A+(r7:bytevector-copy!=20target=20= target-start=20source=20source-start=20(+=20source-start=20len))=0A+@end=20= lisp=0A+=0A+@end=20deffn=0A+=0A+@rnindex=20bytevector-append=0A+@deffn=20= {Scheme=20Procedure}=20bytevector-append=20arg=20@dots{}=0A+Return=20a=20= newly=20allocated=20bytevector=20whose=20characters=20form=20the=0A= +concatenation=20of=20the=20given=20bytevectors=20@var{arg}=20@enddots{}=0A= +=0A+@lisp=0A+(bytevector-append=20#vu8(0=201=202)=20#vu8(3=204=205))=0A= +@result{}=20#vu8(0=201=202=203=204=205)=0A+@end=20lisp=0A+@end=20deffn=0A= +=0A+=0A=20=0A=20@node=20Bytevectors=20as=20Integers=0A=20@subsubsection=20= Interpreting=20Bytevector=20Contents=20as=20Integers=0A@@=20-6852,6=20= +6937,7=20@@=20Set=20the=20@var{size}-byte=20long=20signed=20integer=20= at=20@var{index}=20to=0A=20The=20following=20procedures=20are=20similar=20= to=20the=20ones=20above,=20but=20specialized=0A=20to=20a=20given=20= integer=20size:=0A=20=0A+@anchor{x-bytevector-u8-ref}=0A=20@deffn=20= {Scheme=20Procedure}=20bytevector-u8-ref=20bv=20index=0A=20@deffnx=20= {Scheme=20Procedure}=20bytevector-s8-ref=20bv=20index=0A=20@deffnx=20= {Scheme=20Procedure}=20bytevector-u16-ref=20bv=20index=20endianness=0A@@=20= -6873,6=20+6959,7=20@@=20Return=20the=20unsigned=20@var{n}-bit=20= (signed)=20integer=20(where=20@var{n}=20is=208,=0A=20@var{endianness}.=0A= =20@end=20deffn=0A=20=0A+@anchor{x-bytevector-u8-set!}=0A=20@deffn=20= {Scheme=20Procedure}=20bytevector-u8-set!=20bv=20index=20value=0A=20= @deffnx=20{Scheme=20Procedure}=20bytevector-s8-set!=20bv=20index=20value=0A= =20@deffnx=20{Scheme=20Procedure}=20bytevector-u16-set!=20bv=20index=20= value=20endianness=0A@@=20-6952,6=20+7039,7=20@@=20Return=20a=20newly=20= allocated=20list=20of=20unsigned=208-bit=20integers=20from=20the=0A=20= contents=20of=20@var{bv}.=0A=20@end=20deffn=0A=20=0A= +@anchor{x-u8-list->bytevector}=0A=20@deffn=20{Scheme=20Procedure}=20= u8-list->bytevector=20lst=0A=20@deffnx=20{C=20Function}=20= scm_u8_list_to_bytevector=20(lst)=0A=20Return=20a=20newly=20allocated=20= bytevector=20consisting=20of=20the=20unsigned=208-bit=0Adiff=20--git=20= a/doc/ref/api-io.texi=20b/doc/ref/api-io.texi=0Aindex=20= a0be2dd57..86f83e85e=20100644=0A---=20a/doc/ref/api-io.texi=0A+++=20= b/doc/ref/api-io.texi=0A@@=20-150,12=20+150,14=20@@=20some=20different=20= kind=20of=20port,=20that's=20not=20the=20case:=20all=20ports=20in=20= Guile=20are=0A=20both=20binary=20and=20textual=20ports.=0A=20=0A=20= @cindex=20binary=20input=0A+@anchor{x-get-u8}=0A=20@deffn=20{Scheme=20= Procedure}=20get-u8=20port=0A=20@deffnx=20{C=20Function}=20scm_get_u8=20= (port)=0A=20Return=20an=20octet=20read=20from=20@var{port},=20an=20input=20= port,=20blocking=20as=0A=20necessary,=20or=20the=20end-of-file=20object.=0A= =20@end=20deffn=0A=20=0A+@anchor{x-lookahead-u8}=0A=20@deffn=20{Scheme=20= Procedure}=20lookahead-u8=20port=0A=20@deffnx=20{C=20Function}=20= scm_lookahead_u8=20(port)=0A=20Like=20@code{get-u8}=20but=20does=20not=20= update=20@var{port}'s=20position=20to=20point=0A@@=20-227,6=20+229,7=20= @@=20will=20be=20read=20again=20in=20last-in=20first-out=20order.=0A=20= To=20perform=20binary=20output=20on=20a=20port,=20use=20@code{put-u8}=20= or=0A=20@code{put-bytevector}.=0A=20=0A+@anchor{x-put-u8}=0A=20@deffn=20= {Scheme=20Procedure}=20put-u8=20port=20octet=0A=20@deffnx=20{C=20= Function}=20scm_put_u8=20(port,=20octet)=0A=20Write=20@var{octet},=20an=20= integer=20in=20the=200--255=20range,=20to=20@var{port},=20a=0A@@=20= -239,6=20+242,124=20@@=20Write=20the=20contents=20of=20@var{bv}=20to=20= @var{port},=20optionally=20starting=20at=0A=20index=20@var{start}=20and=20= limiting=20to=20@var{count}=20octets.=0A=20@end=20deffn=0A=20=0A= +@subsubheading=20Binary=20I/O=20in=20R7RS=0A+=0A+@ref{R7RS=20Standard=20= Libraries,R7RS}=20defines=20the=20following=20binary=20I/O=0A= +procedures.=20=20Access=20them=20with=0A+=0A+@example=0A+(use-modules=20= (scheme=20base))=0A+@end=20example=0A+=0A= +@anchor{x-open-output-bytevector}=0A+@deffn=20{Scheme=20Procedure}=20= open-output-bytevector=0A+Returns=20a=20binary=20output=20port=20that=20= will=20accumulate=20bytes=0A+for=20retrieval=20by=20= @ref{x-get-output-bytevector,@code{get-output-bytevector}}.=0A+@end=20= deffn=0A+=0A+@deffn=20{Scheme=20Procedure}=20write-u8=20byte=20[out]=0A= +Writes=20@var{byte}=20to=20the=20given=20binary=20output=20port=20= @var{out}=20and=20returns=0A+an=20unspecified=20value.=20=20@var{out}=20= defaults=20to=20@code{(current-output-port)}.=0A+=0A+See=20also=20= @ref{x-put-u8,@code{put-u8}}.=0A+@end=20deffn=0A+=0A+@deffn=20{Scheme=20= Procedure}=20read-u8=20[in]=0A+Returns=20the=20next=20byte=20available=20= from=20the=20binary=20input=20port=20@var{in},=0A+updating=20the=20port=20= to=20point=20to=20the=20following=20byte.=20=20If=20no=20more=20bytes=20= are=0A+available,=20an=20end-of-file=20object=20is=20returned.=20=20= @var{in}=20defaults=20to=0A+@code{(current-input-port)}.=0A+=0A+See=20= also=20@ref{x-get-u8,@code{get-u8}}.=0A+@end=20deffn=0A+=0A+@deffn=20= {Scheme=20Procedure}=20peek-u8=20[in]=0A+Returns=20the=20next=20byte=20= available=20from=20the=20binary=20input=20port=20@var{in},=0A+but=20= without=20updating=20the=20port=20to=20point=20to=20the=20following=0A= +byte.=20=20If=20no=20more=20bytes=20are=20available,=20an=20end-of-file=20= object=0A+is=20returned.=20=20@var{in}=20defaults=20to=20= @code{(current-input-port)}.=0A+=0A+See=20also=20= @ref{x-lookahead-u8,@code{lookahead-u8}}.=0A+@end=20deffn=0A+=0A= +@anchor{x-get-output-bytevector}=0A+@deffn=20{Scheme=20Procedure}=20= get-output-bytevector=20port=0A+Returns=20a=20bytevector=20consisting=20= of=20the=20bytes=20that=20have=20been=20output=20to=0A+@var{port}=20so=20= far=20in=20the=20order=20they=20were=20output.=20=20It=20is=20an=20error=20= if=0A+@var{port}=20was=20not=20created=20with=0A= +@ref{x-open-output-bytevector,@code{open-output-bytevector}}.=0A+=0A= +@example=0A+(define=20out=20(open-output-bytevector))=0A+(write-u8=201=20= out)=0A+(write-u8=202=20out)=0A+(write-u8=203=20out)=0A= +(get-output-bytevector=20out)=20@result{}=20#vu8(1=202=203)=0A+@end=20= example=0A+@end=20deffn=0A+=0A+@deffn=20{Scheme=20Procedure}=20= open-input-bytevector=20bv=0A+Takes=20a=20bytevector=20@var{bv}=20and=20= returns=20a=20binary=20input=20port=20that=0A+delivers=20bytes=20from=20= @var{bv}.=0A+=0A+@example=0A+(define=20in=20(open-input-bytevector=20= #vu8(1=202=203)))=0A+(read-u8=20in)=20@result{}=201=0A+(peek-u8=20in)=20= @result{}=202=0A+(read-u8=20in)=20@result{}=202=0A+(read-u8=20in)=20= @result{}=203=0A+(read-u8=20in)=20@result{}=20#=0A+@end=20example=0A= +@end=20deffn=0A+=0A+@deffn=20{Scheme=20Procedure}=20read-bytevector!=20= bv=20[port=20[start=20[end]]]=0A+Reads=20the=20next=20@var{end}=20-=20= @var{start}=20bytes,=20or=20as=20many=20as=20are=0A+available=20before=20= the=20end=20of=20file,=20from=20the=20binary=20input=20port=20into=20the=0A= +bytevector=20@var{bv}=20in=20left-to-right=20order=20beginning=20at=20= the=20@var{start}=0A+position.=20=20If=20@var{end}=20is=20not=20= supplied,=20reads=20until=20the=20end=20of=20@var{bv}=0A+has=20been=20= reached.=20=20If=20@var{start}=20is=20not=20supplied,=20reads=20= beginning=20at=0A+position=200.=0A+=0A+Returns=20the=20number=20of=20= bytes=20read.=20=20If=20no=20bytes=20are=20available,=20an=0A= +end-of-file=20object=20is=20returned.=0A+=0A+@example=0A+(define=20in=20= (open-input-bytevector=20#vu8(1=202=203)))=0A+(define=20bv=20= (make-bytevector=205=200))=0A+(read-bytevector!=20bv=20in=201=203)=20= @result{}=202=0A+bv=20@result{}=20#vu8(0=201=202=200=200=200)=0A+@end=20= example=0A+=0A+@end=20deffn=0A+=0A+@deffn=20{Scheme=20Procedure}=20= read-bytevector=20k=20in=0A+Reads=20the=20next=20@var{k}=20bytes,=20or=20= as=20many=20as=20are=20available=20before=20the=20end=0A+of=20file=20if=20= that=20is=20less=20than=20@var{k},=20from=20the=20binary=20input=20port=0A= +@var{in}=20into=20a=20newly=20allocated=20bytevector=20in=20= left-to-right=20order,=20and=0A+returns=20the=20bytevector.=20=20If=20no=20= bytes=20are=20available=20before=20the=20end=20of=0A+file,=20an=20= end-of-file=20object=20is=20returned.=0A+=0A+@example=0A+(define=20bv=20= #vu8(1=202=203))=0A+(read-bytevector=202=20(open-input-bytevector=20bv))=20= @result{}=20#vu8(1=202)=0A+(read-bytevector=2010=20= (open-input-bytevector=20bv))=20@result{}=20#vu8(1=202=203)=0A+@end=20= example=0A+=0A+@end=20deffn=0A+=0A+@deffn=20{Scheme=20Procedure}=20= write-bytevector=20bv=20[port=20[start=20[end]]]=0A+Writes=20the=20bytes=20= of=20bytevector=20@var{bv}=20from=20@var{start}=20to=20@var{end}=20in=0A= +left-to-right=20order=20to=20the=20binary=20output=20@var{port}.=20=20= @var{start}=0A+defaults=20to=200=20and=20@var{end}=20defaults=20to=20the=20= length=20of=20@var{bv}.=0A+=0A+@example=0A+(define=20out=20= (open-output-bytevector))=0A+(write-bytevector=20#vu8(0=201=202=203=204)=20= out=202=204)=0A+(get-output-bytevector=20out)=20@result{}=20#vu8(2=203)=0A= +@end=20example=0A+=0A+@end=20deffn=0A+=0A=20@node=20Encoding=0A=20= @subsection=20Encoding=0A=20=0A--=20=0A2.39.0=0A=0A= --Apple-Mail=_4A69F0E9-468A-40CF-AFA2-3712AB4CC47F--