12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623 |
- @node Streams, Printer, Files, Top
- @chapter Streams
- @menu
- * Stream Concepts::
- * Streams Dictionary::
- @end menu
- @node Stream Concepts, Streams Dictionary, Streams, Streams
- @section Stream Concepts
- @c including concept-streams
- @menu
- * Introduction to Streams::
- * Stream Variables::
- * Stream Arguments to Standardized Functions::
- * Restrictions on Composite Streams::
- @end menu
- @node Introduction to Streams, Stream Variables, Stream Concepts, Stream Concepts
- @subsection Introduction to Streams
- A @i{stream}
- @IGindex{stream}
- is an @i{object} that can be used with an input or output
- function to identify an appropriate source or sink of @i{characters} or
- @i{bytes} for that operation.
- A @i{character}
- @IGindex{character}
- @i{stream}
- @IGindex{stream}
- is a source or sink of @i{characters}.
- A @i{binary}
- @IGindex{binary}
- @i{stream}
- @IGindex{stream}
- is a source or sink of @i{bytes}.
- Some operations may be performed on any kind of @i{stream};
- Figure 21--1 provides a list of @i{standardized} operations
- that are potentially useful with any kind of @i{stream}.
- @group
- @noindent
- @w{ close stream-element-type }
- @w{ input-stream-p streamp }
- @w{ interactive-stream-p with-open-stream }
- @w{ output-stream-p }
- @noindent
- @w{ Figure 21--1: Some General-Purpose Stream Operations}
- @end group
- Other operations are only meaningful on certain @i{stream} @i{types}.
- For example, @b{read-char} is only defined for @i{character} @i{streams}
- and @b{read-byte} is only defined for @i{binary} @i{streams}.
- @menu
- * Abstract Classifications of Streams (Introduction to Streams)::
- * Input::
- * Open and Closed Streams::
- * Interactive Streams::
- * Abstract Classifications of Streams::
- * File Streams::
- * Other Subclasses of Stream::
- @end menu
- @node Abstract Classifications of Streams (Introduction to Streams), Input, Introduction to Streams, Introduction to Streams
- @subsubsection Abstract Classifications of Streams
- @node Input, Open and Closed Streams, Abstract Classifications of Streams (Introduction to Streams), Introduction to Streams
- @subsubsection Input, Output, and Bidirectional Streams
- A @i{stream}, whether a @i{character} @i{stream} or a @i{binary} @i{stream},
- can be an @i{input}
- @IGindex{input}
- @i{stream}
- @IGindex{stream}
- (source of data),
- an @i{output}
- @IGindex{output}
- @i{stream}
- @IGindex{stream}
- (sink for data),
- both,
- or (@i{e.g.}, when ``@t{:direction :probe}'' is given to @b{open}) neither.
- Figure 21--2 shows @i{operators} relating to
- @i{input} @i{streams}.
- @group
- @noindent
- @w{ clear-input read-byte read-from-string }
- @w{ listen read-char read-line }
- @w{ peek-char read-char-no-hang read-preserving-whitespace }
- @w{ read read-delimited-list unread-char }
- @noindent
- @w{ Figure 21--2: Operators relating to Input Streams. }
- @end group
- Figure 21--3 shows @i{operators} relating to
- @i{output} @i{streams}.
- @group
- @noindent
- @w{ clear-output prin1 write }
- @w{ finish-output prin1-to-string write-byte }
- @w{ force-output princ write-char }
- @w{ format princ-to-string write-line }
- @w{ fresh-line print write-string }
- @w{ pprint terpri write-to-string }
- @noindent
- @w{ Figure 21--3: Operators relating to Output Streams.}
- @end group
- A @i{stream} that is both an @i{input} @i{stream} and an @i{output} @i{stream}
- is called a @i{bidirectional}
- @IGindex{bidirectional}
- @i{stream}
- @IGindex{stream}
- .
- See the @i{functions} @b{input-stream-p} and @b{output-stream-p}.
- Any of the @i{operators} listed in @i{Figure~21--2} or @i{Figure~21--3}
- can be used with @i{bidirectional} @i{streams}. In addition, Figure 21--4
- shows a list of @i{operators} that relate specificaly to
- @i{bidirectional} @i{streams}.
- @group
- @noindent
- @w{ y-or-n-p yes-or-no-p }
- @noindent
- @w{ Figure 21--4: Operators relating to Bidirectional Streams.}
- @end group
- @node Open and Closed Streams, Interactive Streams, Input, Introduction to Streams
- @subsubsection Open and Closed Streams
- @i{Streams} are either @i{open}
- @IGindex{open}
- or @i{closed}
- @IGindex{closed}
- .
- Except as explicitly specified otherwise,
- operations that create and return @i{streams} return @i{open} @i{streams}.
- The action of @i{closing} a @i{stream} marks the end of its use as a source
- or sink of data, permitting the @i{implementation} to reclaim its internal data
- structures, and to free any external resources which might have been locked by the
- @i{stream} when it was opened.
- Except as explicitly specified otherwise,
- the consequences are undefined when a @i{closed} @i{stream}
- is used where a @i{stream} is called for.
- Coercion of @i{streams} to @i{pathnames}
- is permissible for @i{closed} @i{streams};
- in some situations, such as for a @i{truename} computation,
- the result might be different for an @i{open} @i{stream}
- and for that same @i{stream} once it has been @i{closed}.
- @node Interactive Streams, Abstract Classifications of Streams, Open and Closed Streams, Introduction to Streams
- @subsubsection Interactive Streams
- An @i{interactive stream}
- @IGindex{interactive stream}
- is one on which it makes sense to perform
- interactive querying.
- The precise meaning of an @i{interactive stream} is
- @i{implementation-defined}, and may depend on the underlying
- operating system. Some examples of the things that an
- @i{implementation} might choose to use as identifying characteristics
- of an @i{interactive stream} include:
- @table @asis
- @item @t{*}
- The @i{stream} is connected to a person (or equivalent) in such a way
- that the program can prompt for information and expect to receive different
- input depending on the prompt.
- @item @t{*}
- The program is expected to prompt for input and support ``normal input editing''.
- @item @t{*}
- @b{read-char} might wait for the user to type something before returning
- instead of immediately returning a character or end-of-file.
- @end table
- The general intent of having some @i{streams} be classified as
- @i{interactive streams} is to allow them to be distinguished from
- streams containing batch (or background or command-file) input.
- Output to batch streams is typically discarded or saved for later viewing,
- so interactive queries to such streams might not have the expected effect.
- @i{Terminal I/O} might or might not be an @i{interactive stream}.
- @node Abstract Classifications of Streams, File Streams, Interactive Streams, Introduction to Streams
- @subsubsection Abstract Classifications of Streams
- @node File Streams, Other Subclasses of Stream, Abstract Classifications of Streams, Introduction to Streams
- @subsubsection File Streams
- Some @i{streams}, called @i{file streams}
- @IGindex{file stream}
- , provide access to @i{files}.
- An @i{object} of @i{class} @b{file-stream} is used to represent a @i{file stream}.
- The basic operation for opening a @i{file} is @b{open},
- which typically returns a @i{file stream}
- (see its dictionary entry for details).
- The basic operation for closing a @i{stream} is @b{close}.
- The macro @b{with-open-file} is useful
- to express the common idiom of opening a @i{file}
- for the duration of a given body of @i{code},
- and assuring that the resulting @i{stream} is closed upon exit from that body.
- @node Other Subclasses of Stream, , File Streams, Introduction to Streams
- @subsubsection Other Subclasses of Stream
- The @i{class} @b{stream} has a number of @i{subclasses} defined
- by this specification. Figure 21--5 shows some information
- about these subclasses.
- @group
- @noindent
- @w{ Class Related Operators }
- @w{ @b{broadcast-stream} @b{make-broadcast-stream} }
- @w{ @b{broadcast-stream-streams} }
- @w{ @b{concatenated-stream} @b{make-concatenated-stream} }
- @w{ @b{concatenated-stream-streams} }
- @w{ @b{echo-stream} @b{make-echo-stream} }
- @w{ @b{echo-stream-input-stream} }
- @w{ @b{echo-stream-output-stream} }
- @w{ @b{string-stream} @b{make-string-input-stream} }
- @w{ @b{with-input-from-string} }
- @w{ @b{make-string-output-stream} }
- @w{ @b{with-output-to-string} }
- @w{ @b{get-output-stream-string} }
- @w{ @b{synonym-stream} @b{make-synonym-stream} }
- @w{ @b{synonym-stream-symbol} }
- @w{ @b{two-way-stream} @b{make-two-way-stream} }
- @w{ @b{two-way-stream-input-stream} }
- @w{ @b{two-way-stream-output-stream} }
- @noindent
- @w{ Figure 21--5: Defined Names related to Specialized Streams}
- @end group
- @node Stream Variables, Stream Arguments to Standardized Functions, Introduction to Streams, Stream Concepts
- @subsection Stream Variables
- @i{Variables} whose @i{values} must be @i{streams} are sometimes called
- @i{stream variables}
- @IGindex{stream variable}
- .
- Certain @i{stream variables} are defined by this specification
- to be the proper source of input or output in various @i{situations}
- where no specific @i{stream} has been specified instead.
- A complete list of such @i{standardized} @i{stream variables}
- appears in Figure 21--6.
- The consequences are undefined if at any time
- the @i{value} of any of these @i{variables} is not an @i{open} @i{stream}.
- @group
- @noindent
- @w{ Glossary Term Variable Name }
- @w{ @i{debug I/O} @b{*debug-io*} }
- @w{ @i{error output} @b{*error-output*} }
- @w{ @i{query I/O} @b{*query-io*} }
- @w{ @i{standard input} @b{*standard-input*} }
- @w{ @i{standard output} @b{*standard-output*} }
- @w{ @i{terminal I/O} @b{*terminal-io*} }
- @w{ @i{trace output} @b{*trace-output*} }
- @noindent
- @w{ Figure 21--6: Standardized Stream Variables}
- @end group
- Note that, by convention, @i{standardized} @i{stream variables} have names
- ending in ``@t{-input*}'' if they must be @i{input} @i{streams},
- ending in ``@t{-output*}'' if they must be @i{output} @i{streams},
- or ending in ``@t{-io*}'' if they must be @i{bidirectional} @i{streams}.
- User programs may @i{assign} or @i{bind} any @i{standardized} @i{stream variable}
- except @b{*terminal-io*}.
- @node Stream Arguments to Standardized Functions, Restrictions on Composite Streams, Stream Variables, Stream Concepts
- @subsection Stream Arguments to Standardized Functions
- The @i{operators} in Figure 21--7 accept @i{stream} @i{arguments} that
- might be either @i{open} or @i{closed} @i{streams}.
- @group
- @noindent
- @w{ broadcast-stream-streams file-author pathnamep }
- @w{ close file-namestring probe-file }
- @w{ compile-file file-write-date rename-file }
- @w{ compile-file-pathname host-namestring streamp }
- @w{ concatenated-stream-streams load synonym-stream-symbol }
- @w{ delete-file logical-pathname translate-logical-pathname }
- @w{ directory merge-pathnames translate-pathname }
- @w{ directory-namestring namestring truename }
- @w{ dribble open two-way-stream-input-stream }
- @w{ echo-stream-input-stream open-stream-p two-way-stream-output-stream }
- @w{ echo-stream-ouput-stream parse-namestring wild-pathname-p }
- @w{ ed pathname with-open-file }
- @w{ enough-namestring pathname-match-p }
- @noindent
- @w{ Figure 21--7: Operators that accept either Open or Closed Streams }
- @end group
- The @i{operators} in Figure 21--8 accept @i{stream} @i{arguments} that
- must be @i{open} @i{streams}.
- @group
- @noindent
- @w{ clear-input output-stream-p read-char-no-hang }
- @w{ clear-output peek-char read-delimited-list }
- @w{ file-length pprint read-line }
- @w{ file-position pprint-fill read-preserving-whitespace }
- @w{ file-string-length pprint-indent stream-element-type }
- @w{ finish-output pprint-linear stream-external-format }
- @w{ force-output pprint-logical-block terpri }
- @w{ format pprint-newline unread-char }
- @w{ fresh-line pprint-tab with-open-stream }
- @w{ get-output-stream-string pprint-tabular write }
- @w{ input-stream-p prin1 write-byte }
- @w{ interactive-stream-p princ write-char }
- @w{ listen print write-line }
- @w{ make-broadcast-stream print-object write-string }
- @w{ make-concatenated-stream print-unreadable-object y-or-n-p }
- @w{ make-echo-stream read yes-or-no-p }
- @w{ make-synonym-stream read-byte }
- @w{ make-two-way-stream read-char }
- @noindent
- @w{ Figure 21--8: Operators that accept Open Streams only }
- @end group
- @node Restrictions on Composite Streams, , Stream Arguments to Standardized Functions, Stream Concepts
- @subsection Restrictions on Composite Streams
- The consequences are undefined if any @i{component} of a @i{composite stream}
- is @i{closed} before the @i{composite stream} is @i{closed}.
- The consequences are undefined if the @i{synonym stream symbol} is not @i{bound}
- to an @i{open} @i{stream} from the time of the @i{synonym stream}'s creation
- until the time it is @i{closed}.
- @c end of including concept-streams
- @node Streams Dictionary, , Stream Concepts, Streams
- @section Streams Dictionary
- @c including dict-streams
- @menu
- * stream::
- * broadcast-stream::
- * concatenated-stream::
- * echo-stream::
- * file-stream::
- * string-stream::
- * synonym-stream::
- * two-way-stream::
- * input-stream-p::
- * interactive-stream-p::
- * open-stream-p::
- * stream-element-type::
- * streamp::
- * read-byte::
- * write-byte::
- * peek-char::
- * read-char::
- * read-char-no-hang::
- * terpri::
- * unread-char::
- * write-char::
- * read-line::
- * write-string::
- * read-sequence::
- * write-sequence::
- * file-length::
- * file-position::
- * file-string-length::
- * open::
- * stream-external-format::
- * with-open-file::
- * close::
- * with-open-stream::
- * listen::
- * clear-input::
- * finish-output::
- * y-or-n-p::
- * make-synonym-stream::
- * synonym-stream-symbol::
- * broadcast-stream-streams::
- * make-broadcast-stream::
- * make-two-way-stream::
- * two-way-stream-input-stream::
- * echo-stream-input-stream::
- * make-echo-stream::
- * concatenated-stream-streams::
- * make-concatenated-stream::
- * get-output-stream-string::
- * make-string-input-stream::
- * make-string-output-stream::
- * with-input-from-string::
- * with-output-to-string::
- * *debug-io*::
- * *terminal-io*::
- * stream-error::
- * stream-error-stream::
- * end-of-file::
- @end menu
- @node stream, broadcast-stream, Streams Dictionary, Streams Dictionary
- @subsection stream [System Class]
- @subsubheading Class Precedence List::
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{stream} is an @i{object} that can be used with an input or output
- function to identify an appropriate source or sink of @i{characters} or
- @i{bytes} for that operation.
- For more complete information, see @ref{Stream Concepts}.
- @subsubheading See Also::
- @ref{Stream Concepts},
- @ref{Printing Other Objects},
- {@ref{Printer}},
- {@ref{Reader}}
- @node broadcast-stream, concatenated-stream, stream, Streams Dictionary
- @subsection broadcast-stream [System Class]
- @subsubheading Class Precedence List::
- @b{broadcast-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{broadcast stream} is an @i{output} @i{stream} which
- has associated with it a set of zero or more @i{output} @i{streams}
- such that any output sent to the @i{broadcast stream} gets passed on
- as output to each of the associated @i{output} @i{streams}.
- (If a @i{broadcast stream} has no @i{component streams},
- then all output to the @i{broadcast stream} is discarded.)
- The set of operations that may be performed on a @i{broadcast stream}
- is the intersection of those for its associated @i{output} @i{streams}.
- Some output operations (@i{e.g.}, @b{fresh-line}) return @i{values} based on the
- state of the @i{stream} at the time of the operation.
- Since these @i{values} might differ for each of the @i{component streams},
- it is necessary to describe their return value specifically:
- @table @asis
- @item @t{*}
- @b{stream-element-type} returns
- the value from the last component stream,
- or @b{t} if there are no component streams.
- @item @t{*}
- @b{fresh-line} returns
- the value from the last component stream,
- or @b{nil} if there are no component streams.
- @item @t{*}
- The functions
- @b{file-length},
- @b{file-position},
- @b{file-string-length},
- and @b{stream-external-format}
- return the value from the last component stream;
- if there are no component streams,
- @b{file-length} and @b{file-position} return @t{0},
- @b{file-string-length} returns @t{1},
- and @b{stream-external-format} returns @t{:default}.
- @item @t{*}
- The functions @b{streamp} and @b{output-stream-p}
- always return @i{true} for @i{broadcast streams}.
- @item @t{*}
- The functions @b{open-stream-p} tests whether the @i{broadcast stream}
- is @i{open}_2, not whether its component streams are @i{open}.
- @item @t{*}
- The functions @b{input-stream-p} and @i{interactive-stream-p}
- return an @i{implementation-defined}, @i{generalized boolean} value.
- @item @t{*}
- For the input operations
- @b{clear-input}
- @b{listen},
- @b{peek-char},
- @b{read-byte},
- @b{read-char-no-hang},
- @b{read-char},
- @b{read-line},
- and @b{unread-char},
- the consequences are undefined if the indicated operation is performed.
- However, an @i{implementation} is permitted
- to define such a behavior as an @i{implementation-dependent} extension.
- @end table
- For any output operations not having their return values explicitly specified above
- or elsewhere in this document, it is defined that
- the @i{values} returned by such an operation are
- the @i{values} resulting from performing the operation
- on the last of its @i{component streams};
- the @i{values} resulting from performing the operation
- on all preceding @i{streams} are discarded.
- If there are no @i{component streams},
- the value is @i{implementation-dependent}.
- @subsubheading See Also::
- @ref{broadcast-stream-streams}
- ,
- @ref{make-broadcast-stream}
- @node concatenated-stream, echo-stream, broadcast-stream, Streams Dictionary
- @subsection concatenated-stream [System Class]
- @subsubheading Class Precedence List::
- @b{concatenated-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{concatenated stream} is an @i{input} @i{stream} which
- is a @i{composite stream} of zero or more other @i{input} @i{streams},
- such that the sequence of data which can be read from the
- @i{concatenated stream} is the same as the concatenation of the
- sequences of data which could be read from each of the
- constituent @i{streams}.
- Input from a @i{concatenated stream} is taken from the first
- of the associated @i{input streams} until it reaches @i{end of file}_1;
- then that @i{stream} is discarded, and subsequent input is taken
- from the next @i{input stream}, and so on.
- An @i{end of file} on the associated @i{input streams} is always managed
- invisibly by the @i{concatenated stream}---the only time a client of
- a @i{concatenated stream} sees an @i{end of file} is when an attempt is
- made to obtain data from the @i{concatenated stream} but it has no
- remaining @i{input streams} from which to obtain such data.
- @subsubheading See Also::
- @ref{concatenated-stream-streams}
- ,
- @ref{make-concatenated-stream}
- @node echo-stream, file-stream, concatenated-stream, Streams Dictionary
- @subsection echo-stream [System Class]
- @subsubheading Class Precedence List::
- @b{echo-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- An @i{echo stream} is a @i{bidirectional} @i{stream}
- that gets its input from an associated @i{input} @i{stream}
- and sends its output to an associated @i{output} @i{stream}.
- All input taken from the @i{input} @i{stream}
- is echoed to the @i{output} @i{stream}.
- Whether the input is echoed immediately after it is encountered,
- or after it has been read from the @i{input stream}
- is @i{implementation-dependent}.
- @subsubheading See Also::
- @ref{echo-stream-input-stream; echo-stream-output-stream}
- ,
- @b{echo-stream-output-stream},
- @ref{make-echo-stream}
- @node file-stream, string-stream, echo-stream, Streams Dictionary
- @subsection file-stream [System Class]
- @subsubheading Class Precedence List::
- @b{file-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- An @i{object} of @i{type} @b{file-stream} is a @i{stream} the direct
- source or sink of which is a @i{file}. Such a @i{stream} is
- created explicitly by @b{open} and @b{with-open-file}, and
- implicitly by @i{functions} such as @b{load} that process @i{files}.
- @subsubheading See Also::
- @ref{load}
- ,
- @ref{open}
- ,
- @ref{with-open-file}
- @node string-stream, synonym-stream, file-stream, Streams Dictionary
- @subsection string-stream [System Class]
- @subsubheading Class Precedence List::
- @b{string-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{string stream} is a @i{stream}
- which reads input from or writes output to an associated @i{string}.
- The @i{stream element type} of a @i{string stream} is always
- a @i{subtype} of @i{type} @b{character}.
- @subsubheading See Also::
- @ref{make-string-input-stream}
- ,
- @ref{make-string-output-stream}
- ,
- @ref{with-input-from-string}
- ,
- @ref{with-output-to-string}
- @node synonym-stream, two-way-stream, string-stream, Streams Dictionary
- @subsection synonym-stream [System Class]
- @subsubheading Class Precedence List::
- @b{synonym-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{stream} that is an alias for another @i{stream},
- which is the @i{value} of a @i{dynamic variable}
- whose @i{name} is the @i{synonym stream symbol} of the @i{synonym stream}.
- Any operations on a @i{synonym stream} will be performed
- on the @i{stream} that is then the @i{value} of the
- @i{dynamic variable} named by the @i{synonym stream symbol}.
- If the @i{value} of the @i{variable} should change,
- or if the @i{variable} should be @i{bound},
- then the @i{stream} will operate on the new @i{value} of the @i{variable}.
- @subsubheading See Also::
- @ref{make-synonym-stream}
- ,
- @ref{synonym-stream-symbol}
- @node two-way-stream, input-stream-p, synonym-stream, Streams Dictionary
- @subsection two-way-stream [System Class]
- @subsubheading Class Precedence List::
- @b{two-way-stream},
- @b{stream},
- @b{t}
- @subsubheading Description::
- A @i{bidirectional} @i{composite stream} that
- receives its input from an associated @i{input} @i{stream}
- and sends its output to an associated @i{output} @i{stream}.
- @subsubheading See Also::
- @ref{make-two-way-stream}
- ,
- @ref{two-way-stream-input-stream; two-way-stream-output-stream}
- ,
- @b{two-way-stream-output-stream}
- @node input-stream-p, interactive-stream-p, two-way-stream, Streams Dictionary
- @subsection input-stream-p, output-stream-p [Function]
- @code{input-stream-p} @i{stream} @result{} @i{generalized-boolean}
- @code{output-stream-p} @i{stream} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- @b{input-stream-p} returns @i{true} if @i{stream} is an @i{input} @i{stream};
- otherwise, returns @i{false}.
- @b{output-stream-p} returns @i{true} if @i{stream} is an @i{output} @i{stream};
- otherwise, returns @i{false}.
- @subsubheading Examples::
- @example
- (input-stream-p *standard-input*) @result{} @i{true}
- (input-stream-p *terminal-io*) @result{} @i{true}
- (input-stream-p (make-string-output-stream)) @result{} @i{false}
- (output-stream-p *standard-output*) @result{} @i{true}
- (output-stream-p *terminal-io*) @result{} @i{true}
- (output-stream-p (make-string-input-stream "jr")) @result{} @i{false}
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- @node interactive-stream-p, open-stream-p, input-stream-p, Streams Dictionary
- @subsection interactive-stream-p [Function]
- @code{interactive-stream-p} @i{stream} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- Returns @i{true} if @i{stream} is an @i{interactive stream};
- otherwise, returns @i{false}.
- @subsubheading Examples::
- @example
- (when (> measured limit)
- (let ((error (round (* (- measured limit) 100)
- limit)))
- (unless (if (interactive-stream-p *query-io*)
- (yes-or-no-p "The frammis is out of tolerance by ~D
- Is it safe to proceed? " error)
- (< error 15)) ;15
- (error "The frammis is out of tolerance by ~D
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- @subsubheading See Also::
- @ref{Stream Concepts}
- @node open-stream-p, stream-element-type, interactive-stream-p, Streams Dictionary
- @subsection open-stream-p [Function]
- @code{open-stream-p} @i{stream} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- Returns @i{true} if @i{stream} is an @i{open} @i{stream};
- otherwise, returns @i{false}.
- @i{Streams} are open until they have been explicitly closed with @b{close},
- or until they are implicitly closed due to exit from a
- @b{with-output-to-string},
- @b{with-open-file},
- @b{with-input-from-string}, or
- @b{with-open-stream} @i{form}.
- @subsubheading Examples::
- @example
- (open-stream-p *standard-input*) @result{} @i{true}
- @end example
- @subsubheading Affected By::
- @b{close}.
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- @node stream-element-type, streamp, open-stream-p, Streams Dictionary
- @subsection stream-element-type [Function]
- @code{stream-element-type} @i{stream} @result{} @i{typespec}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream}.
- @i{typespec}---a @i{type specifier}.
- @subsubheading Description::
- @b{stream-element-type} returns a @i{type specifier} that
- indicates the @i{types} of @i{objects} that may be read from
- or written to @i{stream}.
- @i{Streams} created by @b{open} have an @i{element type}
- restricted to @b{integer} or a @i{subtype} of @i{type} @b{character}.
- @subsubheading Examples::
- @example
- ;; Note that the stream must accomodate at least the specified type,
- ;; but might accomodate other types. Further note that even if it does
- ;; accomodate exactly the specified type, the type might be specified in
- ;; any of several ways.
- (with-open-file (s "test" :element-type '(integer 0 1)
- :if-exists :error
- :direction :output)
- (stream-element-type s))
- @result{} INTEGER
- @i{OR}@result{} (UNSIGNED-BYTE 16)
- @i{OR}@result{} (UNSIGNED-BYTE 8)
- @i{OR}@result{} BIT
- @i{OR}@result{} (UNSIGNED-BYTE 1)
- @i{OR}@result{} (INTEGER 0 1)
- @i{OR}@result{} (INTEGER 0 (2))
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- @node streamp, read-byte, stream-element-type, Streams Dictionary
- @subsection streamp [Function]
- @code{streamp} @i{object} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{object}---an @i{object}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- Returns @i{true} if @i{object} is of @i{type} @b{stream};
- otherwise, returns @i{false}.
- @b{streamp} is unaffected by whether @i{object},
- if it is a @i{stream}, is @i{open} or closed.
- @subsubheading Examples::
- @example
- (streamp *terminal-io*) @result{} @i{true}
- (streamp 1) @result{} @i{false}
- @end example
- @subsubheading Notes::
- @example
- (streamp @i{object}) @equiv{} (typep @i{object} 'stream)
- @end example
- @node read-byte, write-byte, streamp, Streams Dictionary
- @subsection read-byte [Function]
- @code{read-byte} @i{stream {&optional} eof-error-p eof-value} @result{} @i{byte}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{binary} @i{input} @i{stream}.
- @i{eof-error-p}---a @i{generalized boolean}.
- The default is @i{true}.
- @i{eof-value}---an @i{object}.
- The default is @b{nil}.
- @i{byte}---an @i{integer},
- or the @i{eof-value}.
- @subsubheading Description::
- @b{read-byte} reads and returns one byte from @i{stream}.
- If an @i{end of file}_2 occurs and @i{eof-error-p} is @i{false},
- the @i{eof-value} is returned.
- @subsubheading Examples::
- @example
- (with-open-file (s "temp-bytes"
- :direction :output
- :element-type 'unsigned-byte)
- (write-byte 101 s)) @result{} 101
- (with-open-file (s "temp-bytes" :element-type 'unsigned-byte)
- (format t "~S ~S" (read-byte s) (read-byte s nil 'eof)))
- @t{ |> } 101 EOF
- @result{} NIL
- @end example
- @subsubheading Side Effects::
- Modifies @i{stream}.
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- Should signal an error of @i{type} @b{error}
- if @i{stream} is not a @i{binary} @i{input} @i{stream}.
- If there are no @i{bytes} remaining in the @i{stream}
- and @i{eof-error-p} is @i{true}, an error of @i{type} @b{end-of-file} is signaled.
- @subsubheading See Also::
- @ref{read-char}
- ,
- @ref{read-sequence}
- ,
- @ref{write-byte}
- @node write-byte, peek-char, read-byte, Streams Dictionary
- @subsection write-byte [Function]
- @code{write-byte} @i{byte stream} @result{} @i{byte}
- @subsubheading Arguments and Values::
- @i{byte}---an @i{integer} of the @i{stream element type}
- of @i{stream}.
- @i{stream}---a @i{binary} @i{output} @i{stream}.
- @subsubheading Description::
- @b{write-byte} writes one byte, @i{byte}, to @i{stream}.
- @subsubheading Examples::
- @example
- (with-open-file (s "temp-bytes"
- :direction :output
- :element-type 'unsigned-byte)
- (write-byte 101 s)) @result{} 101
- @end example
- @subsubheading Side Effects::
- @i{stream} is modified.
- @subsubheading Affected By::
- The @i{element type} of the @i{stream}.
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream}.
- Should signal an error of @i{type} @b{error}
- if @i{stream} is not a @i{binary} @i{output} @i{stream}.
- Might signal an error of @i{type} @b{type-error} if @i{byte} is not
- an @i{integer} of the @i{stream element type} of @i{stream}.
- @subsubheading See Also::
- @ref{read-byte}
- ,
- @ref{write-char}
- ,
- @ref{write-sequence}
- @node peek-char, read-char, write-byte, Streams Dictionary
- @subsection peek-char [Function]
- @code{peek-char} @i{{&optional} peek-type input-stream eof-error-p
- eof-value recursive-p} @result{} @i{char}
- @subsubheading Arguments and Values::
- @i{peek-type}---a @i{character} or @b{t} or @b{nil}.
- @i{input-stream}---@i{input} @i{stream designator}.
- The default is @i{standard input}.
- @i{eof-error-p}---a @i{generalized boolean}.
- The default is @i{true}.
- @i{eof-value}---an @i{object}.
- The default is @b{nil}.
- @i{recursive-p}---a @i{generalized boolean}.
- The default is @i{false}.
- @i{char}---a @i{character} or the @i{eof-value}.
- @subsubheading Description::
- @b{peek-char} obtains the next character in @i{input-stream}
- without actually reading it, thus leaving the character
- to be read at a later time. It can
- also be used to skip over and discard intervening
- characters in the @i{input-stream}
- until a particular character is found.
- If @i{peek-type} is not supplied or @b{nil},
- @b{peek-char} returns the next character to be read from
- @i{input-stream}, without actually removing it from
- @i{input-stream}.
- The next time input is done from @i{input-stream}, the character will still
- be there.
- If @i{peek-type} is @b{t},
- then @b{peek-char} skips over @i{whitespace}_2 @i{characters},
- but not comments,
- and then performs the peeking operation on the next
- character.
- The last character examined, the one that starts an @i{object},
- is not removed from @i{input-stream}.
- If @i{peek-type} is a @i{character},
- then @b{peek-char} skips
- over input characters until a character that
- is @b{char=} to that @i{character} is found;
- that character is left in @i{input-stream}.
- If an @i{end of file}_2 occurs and @i{eof-error-p} is @i{false},
- @i{eof-value} is returned.
- { }{If @i{recursive-p} is @i{true},
- this call is expected to be embedded in a higher-level call to @b{read}
- or a similar @i{function} used by the @i{Lisp reader}.}
- When @i{input-stream} is an @i{echo stream},
- characters that are only peeked at are not echoed. In the
- case that @i{peek-type} is not @b{nil},
- the characters that are passed by @b{peek-char}
- are treated as if by @b{read-char},
- and so are echoed unless they have been marked otherwise by @b{unread-char}.
- @subsubheading Examples::
- @example
- (with-input-from-string (input-stream " 1 2 3 4 5")
- (format t "~S ~S ~S"
- (peek-char t input-stream)
- (peek-char #\4 input-stream)
- (peek-char nil input-stream)))
- @t{ |> } #\1 #\4 #\4
- @result{} NIL
- @end example
- @subsubheading Affected By::
- @b{*readtable*},
- @b{*standard-input*},
- @b{*terminal-io*}.
- @subsubheading Exceptional Situations::
- If @i{eof-error-p} is @i{true} and an @i{end of file}_2 occurs
- an error of @i{type} @b{end-of-file} is signaled.
- If @i{peek-type} is a @i{character},
- an @i{end of file}_2 occurs,
- and @i{eof-error-p} is @i{true},
- an error of @i{type} @b{end-of-file} is signaled.
- If @i{recursive-p} is @i{true}
- and an @i{end of file}_2 occurs,
- an error of @i{type} @b{end-of-file} is signaled.
- @node read-char, read-char-no-hang, peek-char, Streams Dictionary
- @subsection read-char [Function]
- @code{read-char} @i{{&optional} input-stream eof-error-p eof-value recursive-p} @result{} @i{char}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @i{eof-error-p}---a @i{generalized boolean}.
- The default is @i{true}.
- @i{eof-value}---an @i{object}.
- The default is @b{nil}.
- @i{recursive-p}---a @i{generalized boolean}.
- The default is @i{false}.
- @i{char}---a @i{character} or the @i{eof-value}.
- @subsubheading Description::
- @b{read-char} returns the next @i{character} from @i{input-stream}.
- When @i{input-stream} is an @i{echo stream},
- the character is echoed on @i{input-stream} the first time the character is
- seen.
- Characters that are not echoed by @b{read-char}
- are those that were
- put there by @b{unread-char}
- and hence are assumed to have been echoed
- already by a previous call to @b{read-char}.
- { }{If @i{recursive-p} is @i{true},
- this call is expected to be embedded in a higher-level call to @b{read}
- or a similar @i{function} used by the @i{Lisp reader}.}
- If an @i{end of file}_2 occurs and @i{eof-error-p} is @i{false},
- @i{eof-value} is returned.
- @subsubheading Examples::
- @example
- (with-input-from-string (is "0123")
- (do ((c (read-char is) (read-char is nil 'the-end)))
- ((not (characterp c)))
- (format t "~S " c)))
- @t{ |> } #\0 #\1 #\2 #\3
- @result{} NIL
- @end example
- @subsubheading Affected By::
- @b{*standard-input*},
- @b{*terminal-io*}.
- @subsubheading Exceptional Situations::
- If an @i{end of file}_2 occurs before a character can be read, and
- @i{eof-error-p} is @i{true},
- an error of @i{type} @b{end-of-file} is signaled.
- @subsubheading See Also::
- @ref{read-byte}
- ,
- @ref{read-sequence}
- ,
- @ref{write-char}
- ,
- @ref{read; read-preserving-whitespace}
- @subsubheading Notes::
- The corresponding output function is @b{write-char}.
- @node read-char-no-hang, terpri, read-char, Streams Dictionary
- @subsection read-char-no-hang [Function]
- @code{read-char-no-hang} @i{{&optional} input-stream eof-error-p
- eof-value recursive-p} @result{} @i{char}
- @subsubheading Arguments and Values::
- @i{input-stream} -- an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @i{eof-error-p}---a @i{generalized boolean}.
- The default is @i{true}.
- @i{eof-value}---an @i{object}.
- The default is @b{nil}.
- @i{recursive-p}---a @i{generalized boolean}.
- The default is @i{false}.
- @i{char}---a @i{character} or @b{nil} or the @i{eof-value}.
- @subsubheading Description::
- @b{read-char-no-hang} returns a character
- from @i{input-stream} if such a character is available. If no character
- is available, @b{read-char-no-hang} returns @b{nil}.
- { }{If @i{recursive-p} is @i{true},
- this call is expected to be embedded in a higher-level call to @b{read}
- or a similar @i{function} used by the @i{Lisp reader}.}
- If an @i{end of file}_2 occurs and @i{eof-error-p} is @i{false},
- @i{eof-value} is returned.
- @subsubheading Examples::
- @example
- ;; This code assumes an implementation in which a newline is not
- ;; required to terminate input from the console.
- (defun test-it ()
- (unread-char (read-char))
- (list (read-char-no-hang)
- (read-char-no-hang)
- (read-char-no-hang)))
- @result{} TEST-IT
- ;; Implementation A, where a Newline is not required to terminate
- ;; interactive input on the console.
- (test-it)
- @t{ |> } @b{|>>}@t{a}@b{<<|}
- @result{} (#\a NIL NIL)
- ;; Implementation B, where a Newline is required to terminate
- ;; interactive input on the console, and where that Newline remains
- ;; on the input stream.
- (test-it)
- @t{ |> } @b{|>>}@t{a{@i{[<--}~]}}@b{<<|}
- @result{} (#\a #\Newline NIL)
- @end example
- @subsubheading Affected By::
- @b{*standard-input*},
- @b{*terminal-io*}.
- @subsubheading Exceptional Situations::
- If an @i{end of file}_2 occurs
- when @i{eof-error-p} is @i{true},
- an error of @i{type} @b{end-of-file} is signaled .
- @subsubheading See Also::
- @ref{listen}
- @subsubheading Notes::
- @b{read-char-no-hang} is exactly like @b{read-char}, except
- that if it would be necessary to wait in order to get a character (as
- from a keyboard), @b{nil} is immediately returned without waiting.
- @node terpri, unread-char, read-char-no-hang, Streams Dictionary
- @subsection terpri, fresh-line [Function]
- @code{terpri} @i{{&optional} output-stream} @result{} @i{@b{nil}}
- @code{fresh-line} @i{{&optional} output-stream} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{output-stream} -- an @i{output} @i{stream designator}.
- The default is @i{standard output}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- @b{terpri} outputs a @i{newline} to @i{output-stream}.
- @b{fresh-line} is similar to @b{terpri} but outputs a @i{newline}
- only if the @i{output-stream} is not already at the start of a line.
- If for some reason this cannot be determined, then a @i{newline} is output anyway.
- @b{fresh-line} returns @i{true} if it outputs a @i{newline};
- otherwise it returns @i{false}.
- @subsubheading Examples::
- @example
- (with-output-to-string (s)
- (write-string "some text" s)
- (terpri s)
- (terpri s)
- (write-string "more text" s))
- @result{} "some text
- more text"
- (with-output-to-string (s)
- (write-string "some text" s)
- (fresh-line s)
- (fresh-line s)
- (write-string "more text" s))
- @result{} "some text
- more text"
- @end example
- @subsubheading Side Effects::
- The @i{output-stream} is modified.
- @subsubheading Affected By::
- @b{*standard-output*},
- @b{*terminal-io*}.
- @subsubheading Exceptional Situations::
- None.
- [Reviewer Note by Barmar: What if stream is closed?]
- @subsubheading Notes::
- @b{terpri} is identical in effect to
- @example
- (write-char #\Newline output-stream)
- @end example
- @node unread-char, write-char, terpri, Streams Dictionary
- @subsection unread-char [Function]
- @code{unread-char} @i{character {&optional} input-stream} @result{} @i{@b{nil}}
- @subsubheading Arguments and Values::
- @i{character}---a @i{character};
- must be the last @i{character} that was read from @i{input-stream}.
- @i{input-stream}---an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @subsubheading Description::
- @b{unread-char} places @i{character} back onto the front of
- @i{input-stream} so that it will again be the next character
- in @i{input-stream}.
- When @i{input-stream} is an @i{echo stream},
- no attempt is made to undo any echoing of the character that might already
- have been done on @i{input-stream}. However, characters placed on
- @i{input-stream} by @b{unread-char} are marked in such a way
- as to inhibit later re-echo by @b{read-char}.
- It is an error to invoke @b{unread-char}
- twice consecutively on the same @i{stream}
- without an intervening call to @b{read-char}
- (or some other input operation which implicitly reads characters)
- on that @i{stream}.
- Invoking @b{peek-char} or @b{read-char} commits all previous characters.
- The consequences of invoking @b{unread-char}
- on any character preceding that which is returned by
- @b{peek-char} (including those passed over by
- @b{peek-char} that has a @i{non-nil} @i{peek-type})
- are unspecified.
- In particular, the consequences of
- invoking @b{unread-char} after @b{peek-char}
- are unspecified.
- @subsubheading Examples::
- @example
- (with-input-from-string (is "0123")
- (dotimes (i 6)
- (let ((c (read-char is)))
- (if (evenp i) (format t "~&~S ~S~
- @t{ |> } 0 #\0
- @t{ |> } 2 #\1
- @t{ |> } 4 #\2
- @result{} NIL
- @end example
- @subsubheading Affected By::
- @b{*standard-input*},
- @b{*terminal-io*}.
- @subsubheading See Also::
- @ref{peek-char}
- ,
- @ref{read-char}
- ,
- @ref{Stream Concepts}
- @subsubheading Notes::
- @b{unread-char} is intended to be an efficient mechanism for allowing
- the @i{Lisp reader} and other parsers to perform one-character lookahead
- in @i{input-stream}.
- @node write-char, read-line, unread-char, Streams Dictionary
- @subsection write-char [Function]
- @code{write-char} @i{character {&optional} output-stream} @result{} @i{character}
- @subsubheading Arguments and Values::
- @i{character}---a @i{character}.
- @i{output-stream} -- an @i{output} @i{stream designator}.
- The default is @i{standard output}.
- @subsubheading Description::
- @b{write-char} outputs @i{character} to @i{output-stream}.
- @subsubheading Examples::
- @example
- (write-char #\a)
- @t{ |> } a
- @result{} #\a
- (with-output-to-string (s)
- (write-char #\a s)
- (write-char #\Space s)
- (write-char #\b s))
- @result{} "a b"
- @end example
- @subsubheading Side Effects::
- The @i{output-stream} is modified.
- @subsubheading Affected By::
- @b{*standard-output*},
- @b{*terminal-io*}.
- @subsubheading See Also::
- @ref{read-char}
- ,
- @ref{write-byte}
- ,
- @ref{write-sequence}
- @node read-line, write-string, write-char, Streams Dictionary
- @subsection read-line [Function]
- @code{read-line} @i{{&optional} input-stream eof-error-p eof-value recursive-p}@*
- @result{} @i{line, missing-newline-p}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @i{eof-error-p}---a @i{generalized boolean}.
- The default is @i{true}.
- @i{eof-value}---an @i{object}.
- The default is @b{nil}.
- @i{recursive-p}---a @i{generalized boolean}.
- The default is @i{false}.
- @i{line}---a @i{string} or the @i{eof-value}.
- @i{missing-newline-p}---a @i{generalized boolean}.
- @subsubheading Description::
- Reads from @i{input-stream} a line of text
- that is terminated by a @i{newline} or @i{end of file}.
- { }{If @i{recursive-p} is @i{true},
- this call is expected to be embedded in a higher-level call to @b{read}
- or a similar @i{function} used by the @i{Lisp reader}.}
- The @i{primary value}, @i{line}, is the line that is read,
- represented as a @i{string} (without the trailing @i{newline}, if any).
- If @i{eof-error-p} is @i{false}
- and the @i{end of file} for @i{input-stream} is reached
- before any @i{characters} are read,
- @i{eof-value} is returned as the @i{line}.
- The @i{secondary value}, @i{missing-newline-p},
- is a @i{generalized boolean} that is
- @i{false} if the @i{line} was terminated by a @i{newline},
- or @i{true} if the @i{line} was terminated by
- the @i{end of file} for @i{input-stream}
- (or if the @i{line} is the @i{eof-value}).
- @subsubheading Examples::
- @example
- (setq a "line 1
- line2")
- @result{} "line 1
- line2"
- (read-line (setq input-stream (make-string-input-stream a)))
- @result{} "line 1", @i{false}
- (read-line input-stream)
- @result{} "line2", @i{true}
- (read-line input-stream nil nil)
- @result{} NIL, @i{true}
- @end example
- @subsubheading Affected By::
- @b{*standard-input*},
- @b{*terminal-io*}.
- @subsubheading Exceptional Situations::
- If an @i{end of file}_2 occurs before any characters are read in the line,
- an error is signaled if @i{eof-error-p} is @i{true}.
- @subsubheading See Also::
- @ref{read; read-preserving-whitespace}
- @subsubheading Notes::
- The corresponding output function is @b{write-line}.
- @node write-string, read-sequence, read-line, Streams Dictionary
- @subsection write-string, write-line [Function]
- @code{write-string} @i{string {&optional} output-stream {&key} start end} @result{} @i{string}
- @code{write-line} @i{string {&optional} output-stream {&key} start end} @result{} @i{string}
- @subsubheading Arguments and Values::
- @i{string}---a @i{string}.
- @i{output-stream} -- an @i{output} @i{stream designator}.
- The default is @i{standard output}.
- @i{start}, @i{end}---@i{bounding index designators} of @i{string}.
- The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
- @subsubheading Description::
- @b{write-string} writes the @i{characters} of
- the subsequence of @i{string} @i{bounded} by @i{start} and @i{end}
- to @i{output-stream}.
- @b{write-line} does the same thing,
- but then outputs a newline afterwards.
- @subsubheading Examples::
- @example
- (prog1 (write-string "books" nil :end 4) (write-string "worms"))
- @t{ |> } bookworms
- @result{} "books"
- (progn (write-char #\*)
- (write-line "test12" *standard-output* :end 5)
- (write-line "*test2")
- (write-char #\*)
- nil)
- @t{ |> } *test1
- @t{ |> } *test2
- @t{ |> } *
- @result{} NIL
- @end example
- @subsubheading Affected By::
- @b{*standard-output*},
- @b{*terminal-io*}.
- @subsubheading See Also::
- @ref{read-line}
- ,
- @ref{write-char}
- @subsubheading Notes::
- @b{write-line} and @b{write-string} return @i{string},
- not the substring @i{bounded} by @i{start} and @i{end}.
- @example
- (write-string string)
- @equiv{} (dotimes (i (length string)
- (write-char (char string i)))
- (write-line string)
- @equiv{} (prog1 (write-string string) (terpri))
- @end example
- @node read-sequence, write-sequence, write-string, Streams Dictionary
- @subsection read-sequence [Function]
- @code{read-sequence} @i{sequence stream {&key} start end} @result{} @i{position}
- @i{sequence}---a @i{sequence}.
- @i{stream}---an @i{input} @i{stream}.
- @i{start}, @i{end}---@i{bounding index designators} of
- @i{sequence}. The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
- @i{position}---an @i{integer} greater than or equal to zero, and
- less than or equal to the @i{length} of the @i{sequence}.
- @subsubheading Description::
- Destructively modifies @i{sequence} by replacing the @i{elements}
- of @i{sequence} @i{bounded} by @i{start} and @i{end} with
- @i{elements} read from @i{stream}.
- @i{Sequence} is destructively modified by copying successive
- @i{elements} into it from @i{stream}. If the @i{end of file} for
- @i{stream} is reached before copying all @i{elements} of the
- subsequence, then the extra @i{elements} near the end of @i{sequence}
- are not updated.
- @i{Position} is the index of the first @i{element} of @i{sequence}
- that was not updated, which might be less than @i{end} because the
- @i{end of file} was reached.
- @subsubheading Examples::
- @example
- (defvar *data* (make-array 15 :initial-element nil))
- (values (read-sequence *data* (make-string-input-stream "test string")) *data*)
- @result{} 11, #(#\t #\e #\s #\t #\Space #\s #\t #\r #\i #\n #\g NIL NIL NIL NIL)
- @end example
- @subsubheading Side Effects::
- Modifies @i{stream} and @i{sequence}.
- @subsubheading Exceptional Situations::
- Should be prepared to signal an error of @i{type} @b{type-error}
- if @i{sequence} is not a @i{proper sequence}.
- Should signal an error of @i{type} @b{type-error}
- if @i{start} is not a non-negative @i{integer}.
- Should signal an error of @i{type} @b{type-error}
- if @i{end} is not a non-negative @i{integer} or @b{nil}.
- Might signal an error of @i{type} @b{type-error} if an @i{element} read from
- the @i{stream} is not a member of the @i{element type} of the
- @i{sequence}.
- @subsubheading See Also::
- @ref{Compiler Terminology},
- @ref{write-sequence}
- ,
- @ref{read-line}
- @subsubheading Notes::
- @b{read-sequence} is identical in effect to iterating over the indicated
- subsequence and reading one @i{element} at a time from @i{stream} and
- storing it into @i{sequence}, but may be more efficient than the
- equivalent loop. An efficient implementation is more likely to exist
- for the case where the @i{sequence} is a @i{vector} with the same
- @i{element type} as the @i{stream}.
- @node write-sequence, file-length, read-sequence, Streams Dictionary
- @subsection write-sequence [Function]
- @code{write-sequence} @i{sequence stream {&key} start end} @result{} @i{sequence}
- @i{sequence}---a @i{sequence}.
- @i{stream}---an @i{output} @i{stream}.
- @i{start}, @i{end}---@i{bounding index designators} of
- @i{sequence}. The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
- @subsubheading Description::
- @b{write-sequence} writes the @i{elements} of the subsequence
- of @i{sequence} @i{bounded} by @i{start} and @i{end} to
- @i{stream}.
- @subsubheading Examples::
- @example
- (write-sequence "bookworms" *standard-output* :end 4)
- @t{ |> } book
- @result{} "bookworms"
- @end example
- @subsubheading Side Effects::
- Modifies @i{stream}.
- @subsubheading Exceptional Situations::
- Should be prepared to signal an error of @i{type} @b{type-error}
- if @i{sequence} is not a @i{proper sequence}.
- Should signal an error of @i{type} @b{type-error}
- if @i{start} is not a non-negative @i{integer}.
- Should signal an error of @i{type} @b{type-error}
- if @i{end} is not a non-negative @i{integer} or @b{nil}.
- Might signal an error of @i{type} @b{type-error} if an @i{element} of the
- @i{bounded} @i{sequence} is not a member of the
- @i{stream element type} of the @i{stream}.
- @subsubheading See Also::
- @ref{Compiler Terminology},
- @ref{read-sequence}
- ,
- @ref{write-string; write-line}
- ,
- @b{write-line}
- @subsubheading Notes::
- @b{write-sequence} is identical in effect to iterating over the indicated
- subsequence and writing one @i{element} at a time to @i{stream}, but
- may be more efficient than the equivalent loop. An efficient implementation
- is more likely to exist for the case where the @i{sequence} is a
- @i{vector} with the same @i{element type} as the @i{stream}.
- @node file-length, file-position, write-sequence, Streams Dictionary
- @subsection file-length [Function]
- @code{file-length} @i{stream} @result{} @i{length}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream associated with a file}.
- @i{length}---a non-negative @i{integer} or @b{nil}.
- @subsubheading Description::
- @b{file-length} returns the length of @i{stream},
- or @b{nil} if the length cannot be determined.
- For a binary file, the length is measured in units of
- the @i{element type} of the @i{stream}.
- @subsubheading Examples::
- @example
- (with-open-file (s "decimal-digits.text"
- :direction :output :if-exists :error)
- (princ "0123456789" s)
- (truename s))
- @result{} #P"A:>Joe>decimal-digits.text.1"
- (with-open-file (s "decimal-digits.text")
- (file-length s))
- @result{} 10
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{stream} is not a @i{stream associated with a file}.
- @subsubheading See Also::
- @ref{open}
- @node file-position, file-string-length, file-length, Streams Dictionary
- @subsection file-position [Function]
- @code{file-position} @i{stream} @result{} @i{position}
- @code{file-position} @i{stream position-spec} @result{} @i{success-p}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream}.
- @i{position-spec}---a @i{file position designator}.
- @i{position}---a @i{file position} or @b{nil}.
- @i{success-p}---a @i{generalized boolean}.
- @subsubheading Description::
- Returns or changes the current position within a @i{stream}.
- When @i{position-spec} is not supplied,
- @b{file-position} returns the current @i{file position} in the @i{stream},
- or @b{nil} if this cannot be determined.
- When @i{position-spec} is supplied,
- the @i{file position} in @i{stream} is set to that @i{file position} (if possible).
- @b{file-position} returns @i{true}
- if the repositioning is performed successfully,
- or @i{false} if it is not.
- An @i{integer} returned by @b{file-position} of one argument
- should be acceptable as @i{position-spec} for use with the same file.
- For a character file,
- performing a single @b{read-char} or @b{write-char} operation
- may cause the file position to be increased by more than 1 because of
- character-set translations (such as translating between the @r{Common Lisp}
- @t{#\Newline} character and an external ASCII
- carriage-return/line-feed sequence) and other aspects of the
- implementation. For a binary file, every @b{read-byte}
- or @b{write-byte}
- operation increases the file position by 1.
- @subsubheading Examples::
- @example
- (defun tester ()
- (let ((noticed '()) file-written)
- (flet ((notice (x) (push x noticed) x))
- (with-open-file (s "test.bin"
- :element-type '(unsigned-byte 8)
- :direction :output
- :if-exists :error)
- (notice (file-position s)) ;1
- (write-byte 5 s)
- (write-byte 6 s)
- (let ((p (file-position s)))
- (notice p) ;2
- (notice (when p (file-position s (1- p))))) ;3
- (write-byte 7 s)
- (notice (file-position s)) ;4
- (setq file-written (truename s)))
- (with-open-file (s file-written
- :element-type '(unsigned-byte 8)
- :direction :input)
- (notice (file-position s)) ;5
- (let ((length (file-length s)))
- (notice length) ;6
- (when length
- (dotimes (i length)
- (notice (read-byte s)))))) ;7,...
- (nreverse noticed))))
- @result{} tester
- (tester)
- @result{} (0 2 T 2 0 2 5 7)
- @i{OR}@result{} (0 2 NIL 3 0 3 5 6 7)
- @i{OR}@result{} (NIL NIL NIL NIL NIL NIL)
- @end example
- @subsubheading Side Effects::
- When the @i{position-spec} argument is supplied,
- the @i{file position} in the @i{stream} might be moved.
- @subsubheading Affected By::
- The value returned by @b{file-position} increases monotonically
- as input or output operations are performed.
- @subsubheading Exceptional Situations::
- If @i{position-spec} is supplied, but is too large or otherwise inappropriate,
- an error is signaled.
- @subsubheading See Also::
- @ref{file-length}
- ,
- @ref{file-string-length}
- ,
- @ref{open}
- @subsubheading Notes::
- Implementations that have character files represented
- as a sequence of records of bounded size might choose to encode the
- file position as, for example,
- <<@i{record-number}>>*<<@i{max-record-size}>>+<<@i{character-within-record}>>.
- This is a valid encoding because it increases monotonically as
- each character is read or written, though not necessarily by 1 at
- each step. An @i{integer} might then be considered ``inappropriate''
- as @i{position-spec} to @b{file-position} if, when decoded into
- record number and character number, it turned out that the
- supplied record was too short for the specified character number.
- @node file-string-length, open, file-position, Streams Dictionary
- @subsection file-string-length [Function]
- @code{file-string-length} @i{stream object} @result{} @i{length}
- @subsubheading Arguments and Values::
- @i{stream}---an @i{output} @i{character} @i{file stream}.
- @i{object}---a @i{string} or a @i{character}.
- @i{length}---a non-negative @i{integer}, or @b{nil}.
- @subsubheading Description::
- @b{file-string-length} returns the difference between what
- @t{(file-position @i{stream})} would be after writing
- @i{object} and its current value, or @b{nil} if this cannot be determined.
- The returned value corresponds to the current state of @i{stream}
- at the time of the call and might not be
- the same if it is called again
- when the state of the @i{stream} has changed.
- @node open, stream-external-format, file-string-length, Streams Dictionary
- @subsection open [Function]
- @code{open} @i{filespec {&key} direction element-type
- if-exists if-does-not-exist
- external-format}@*
- @result{} @i{stream}
- @subsubheading Arguments and Values::
- @i{filespec}---a @i{pathname designator}.
- @i{direction}---one of @t{:input}, @t{:output}, @t{:io}, or @t{:probe}.
- The default is @t{:input}.
- @i{element-type}---a @i{type specifier}
- for @i{recognizable subtype} of @b{character};
- or a @i{type specifier}
- for a @i{finite} @i{recognizable subtype} of @i{integer};
- or one of the @i{symbols}
- @b{signed-byte},
- @b{unsigned-byte},
- or @t{:default}.
- The default is @b{character}.
- @i{if-exists}---one of @t{:error}, @t{:new-version}, @t{:rename},
- @t{:rename-and-delete}, @t{:overwrite}, @t{:append},
- @t{:supersede}, or @b{nil}.
- The default is @t{:new-version} if the version component of @i{filespec} is @t{:newest},
- or @t{:error} otherwise.
- @i{if-does-not-exist}---one of @t{:error}, @t{:create}, or @b{nil}.
- The default is @t{:error} if @i{direction} is @t{:input}
- or @i{if-exists} is @t{:overwrite} or @t{:append};
- @t{:create} if @i{direction} is @t{:output} or @t{:io},
- and @i{if-exists} is neither @t{:overwrite} nor @t{:append};
- or @b{nil} when @i{direction} is @t{:probe}.
- @i{external-format}---an @i{external file format designator}.
- The default is @t{:default}.
- @i{stream}---a @i{file stream} or @b{nil}.
- @subsubheading Description::
- @b{open} creates, opens, and returns a @i{file stream}
- that is connected to the file specified by @i{filespec}.
- @i{Filespec} is the name of the file to be opened.
- If the @i{filespec} @i{designator} is a @i{stream},
- that @i{stream} is not closed first or otherwise affected.
- The keyword arguments to @b{open} specify the characteristics
- of the @i{file stream} that is returned, and how to handle errors.
- If @i{direction} is @t{:input}
- or @t{:probe},
- or if @i{if-exists} is not @t{:new-version}
- and the version component of the @i{filespec} is @t{:newest},
- then the file opened is that file already existing in the file system
- that has a version greater than that of any other file in the file system
- whose other pathname components are the same as those of @i{filespec}.
- An implementation is required to recognize all of
- the @b{open} keyword options
- and to do something reasonable in the context of the host operating
- system.
- For example, if a file system does not support distinct file
- versions and does not distinguish the notions of deletion and expunging,
- @t{:new-version} might be treated the same as
- @t{:rename} or @t{:supersede}, and @t{:rename-and-delete} might
- be treated the same as @t{:supersede}.
- @table @asis
- @item @t{:direction}
- These are the possible values for @i{direction},
- and how they affect the nature of the @i{stream} that is created:
- @table @asis
- @item @t{:input}
- Causes the creation of an @i{input} @i{file stream}.
- @item @t{:output}
- Causes the creation of an @i{output} @i{file stream}.
- @item @t{:io}
- Causes the creation of a @i{bidirectional} @i{file stream}.
- @item @t{:probe}
- Causes the creation of a ``no-directional'' @i{file stream};
- in effect, the @i{file stream} is created
- and then closed prior to being returned by @b{open}.
- @end table
- @item @t{:element-type}
- The @i{element-type} specifies the unit of transaction for the @i{file stream}.
- If it is @t{:default},
- the unit is determined by @i{file system},
- possibly based on the @i{file}.
- @item @t{:if-exists}
- @i{if-exists} specifies the action to be taken if @i{direction} is
- @t{:output} or @t{:io} and a file of the name @i{filespec}
- already exists.
- If @i{direction} is @t{:input}, not supplied, or @t{:probe},
- @i{if-exists} is ignored.
- These are the results of @b{open} as modified by @i{if-exists}:
- @table @asis
- @item @t{:error}
- An error of @i{type} @b{file-error} is signaled.
- @item @t{:new-version}
- A new file is created with a larger version number.
- @item @t{:rename}
- The existing file is renamed to some other name and then a new file is created.
- @item @t{:rename-and-delete}
- The existing file is renamed to some other name,
- then it is deleted but not expunged, and then a new file is created.
- @item @t{:overwrite}
- Output operations on the @i{stream} destructively modify the existing file.
- If @i{direction} is @t{:io} the file is opened in a bidirectional mode
- that allows both reading and writing. The file pointer is initially
- positioned at the beginning of the file; however, the file is not truncated
- back to length zero when it is opened.
- @item @t{:append}
- Output operations on the @i{stream} destructively modify the existing file.
- The file pointer is initially positioned at the end of the file.
- If @i{direction} is @t{:io},
- the file is opened in a bidirectional mode that allows both reading and writing.
- @item @t{:supersede}
- The existing file is superseded;
- that is, a new file with the same name as the old one is created.
- If possible, the implementation should not destroy the old file until the new
- @i{stream} is closed.
- @item @b{nil}
- No file or @i{stream} is created;
- instead, @b{nil} is returned to indicate failure.
- @end table
- @item @t{:if-does-not-exist}
- @i{if-does-not-exist}
- specifies the action to be taken if
- a file of name @i{filespec} does not already exist.
- These are the results of @b{open} as modified by @i{if-does-not-exist}:
- @table @asis
- @item @t{:error}
- An error of @i{type} @b{file-error} is signaled.
- @item @t{:create}
- An empty file is created.
- Processing continues as if the file
- had already existed but no processing as
- directed by @i{if-exists} is performed.
- @item @b{nil}
- No file or @i{stream} is created;
- instead, @b{nil} is returned to indicate failure.
- @end table
- @item @t{:external-format}
- This option selects an @i{external file format} for the @i{file}:
- The only @i{standardized} value for this option is @t{:default},
- although @i{implementations} are permitted to define additional
- @i{external file formats} and @i{implementation-dependent} values
- returned by @b{stream-external-format} can also be used by @i{conforming programs}.
- The @i{external-format} is meaningful for
- any kind of @i{file stream} whose @i{element type}
- is a @i{subtype} of @i{character}.
- This option is ignored for @i{streams} for which it is not meaningful;
- however, @i{implementations} may define other @i{element types}
- for which it is meaningful.
- The consequences are unspecified if a @i{character} is written
- that cannot be represented by the given @i{external file format}.
- @end table
- When a file is opened, a @i{file stream} is constructed to serve
- as the file system's ambassador to the @r{Lisp} environment;
- operations on the @i{file stream} are reflected by operations on the file
- in the file system.
- A file can be deleted, renamed, or destructively modified by @b{open}.
- For information about opening relative pathnames,
- see @ref{Merging Pathnames}.
- @subsubheading Examples::
- @example
- (open @i{filespec} :direction :probe) @result{} #<Closed Probe File Stream...>
- (setq q (merge-pathnames (user-homedir-pathname) "test"))
- @result{} #<PATHNAME :HOST NIL :DEVICE @i{device-name} :DIRECTORY @i{directory-name}
- :NAME "test" :TYPE NIL :VERSION :NEWEST>
- (open @i{filespec} :if-does-not-exist :create) @result{} #<Input File Stream...>
- (setq s (open @i{filespec} :direction :probe)) @result{} #<Closed Probe File Stream...>
- (truename s) @result{} #<PATHNAME :HOST NIL :DEVICE @i{device-name} :DIRECTORY
- @i{directory-name} :NAME @i{filespec} :TYPE @i{extension} :VERSION 1>
- (open s :direction :output :if-exists nil) @result{} NIL
- @end example
- @subsubheading Affected By::
- The nature and state of the host computer's @i{file system}.
- @subsubheading Exceptional Situations::
- If @i{if-exists} is @t{:error}, (subject to the
- constraints on the meaning of @i{if-exists} listed above),
- an error of @i{type} @b{file-error} is signaled.
- If @i{if-does-not-exist} is @t{:error} (subject to the
- constraints on the meaning of @i{if-does-not-exist} listed above),
- an error of @i{type} @b{file-error} is signaled.
- If it is impossible for an implementation to handle some option
- in a manner close to what is specified here,
- an error of @i{type} @b{error} might be signaled.
- An error of @i{type} @b{file-error} is signaled if
- @t{(wild-pathname-p @i{filespec})} returns true.
- An error of @i{type} @b{error} is signaled if the @i{external-format}
- is not understood by the @i{implementation}.
- The various @i{file systems} in existence today have widely differing capabilities,
- and some aspects of the @i{file system} are beyond the scope of this specification
- to define. A given @i{implementation} might not be able to support all of these options
- in exactly the manner stated. An @i{implementation} is required to recognize all of
- these option keywords and to try to do something ``reasonable'' in the context of the
- host @i{file system}. Where necessary to accomodate the @i{file system},
- an @i{implementation} deviate slightly from the semantics specified here without
- being disqualified for consideration as a @i{conforming implementation}.
- If it is utterly impossible for an @i{implementation} to handle some option
- in a manner similar to what is specified here, it may simply signal an error.
- With regard to the @t{:element-type} option, if a @i{type} is
- requested that is not supported by the @i{file system}, a substitution of types
- such as that which goes on in @i{upgrading} is permissible. As a minimum
- requirement, it should be the case that opening an @i{output} @i{stream}
- to a @i{file} in a given @i{element type} and later opening
- an @i{input} @i{stream} to the same @i{file} in the same @i{element type}
- should work compatibly.
- @subsubheading See Also::
- @ref{with-open-file}
- ,
- @ref{close}
- ,
- @b{pathname},
- @b{logical-pathname},
- @ref{Merging Pathnames},
- @ref{Pathnames as Filenames}
- @subsubheading Notes::
- @b{open} does not automatically close the file when an abnormal
- exit occurs.
- When @i{element-type} is a @i{subtype} of @b{character},
- @b{read-char} and/or @b{write-char} can be
- used on the resulting @i{file stream}.
- When @i{element-type} is a @i{subtype} of @i{integer},
- @b{read-byte} and/or @b{write-byte} can be used on the resulting @i{file stream}.
- When @i{element-type} is @t{:default},
- the @i{type} can be determined by using @b{stream-element-type}.
- @node stream-external-format, with-open-file, open, Streams Dictionary
- @subsection stream-external-format [Function]
- @code{stream-external-format} @i{stream} @result{} @i{format}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{file stream}.
- @i{format}---an @i{external file format}.
- @subsubheading Description::
- Returns an @i{external file format designator} for the @i{stream}.
- @subsubheading Examples::
- @example
- (with-open-file (stream "test" :direction :output)
- (stream-external-format stream))
- @result{} :DEFAULT
- @i{OR}@result{} :ISO8859/1-1987
- @i{OR}@result{} (:ASCII :SAIL)
- @i{OR}@result{} ACME::PROPRIETARY-FILE-FORMAT-17
- @i{OR}@result{} #<FILE-FORMAT :ISO646-1983 2343673>
- @end example
- @subsubheading See Also::
- the @t{:external-format} @i{argument} to the @i{function}
- @ref{open}
- and
- the
- @ref{with-open-file}
- @i{macro}.
- @subsubheading Notes::
- The @i{format} returned is not necessarily meaningful
- to other @i{implementations}.
- @node with-open-file, close, stream-external-format, Streams Dictionary
- @subsection with-open-file [macro]
- @subsubheading Syntax::
- @code{with-open-file} @i{@r{(}stream filespec @{@i{options}@}{*}@r{)}
- @{@i{declaration}@}{*}
- @{@i{form}@}{*}}@*
- @result{} @i{results}
- @subsubheading Arguments and Values::
- @i{stream} -- a variable.
- @i{filespec}---a @i{pathname designator}.
- @i{options} -- @i{forms}; evaluated.
- @i{declaration}---a @b{declare} @i{expression}; not evaluated.
- @i{forms}---an @i{implicit progn}.
- @i{results}---the @i{values} returned by the @i{forms}.
- @subsubheading Description::
- @b{with-open-file} uses @b{open} to create a @i{file stream}
- to @i{file} named by @i{filespec}.
- @i{Filespec} is the name of the file to be opened.
- @i{Options} are used as keyword arguments to @b{open}.
- The @i{stream} @i{object} to which the @i{stream} @i{variable}
- is @i{bound} has @i{dynamic extent};
- its @i{extent} ends when the @i{form} is exited.
- @b{with-open-file} evaluates the @i{forms} as an @i{implicit progn}
- with @i{stream} bound to
- the value returned by @b{open}.
- When control leaves the body, either normally or abnormally (such as by
- use of @b{throw}), the file is automatically closed. If a new
- output file is being written, and control leaves abnormally, the file is
- aborted and the file system is left, so far as possible, as if the file
- had never been opened.
- It is possible by the use of @t{:if-exists nil}
- or @t{:if-does-not-exist nil} for
- @i{stream} to be bound to @b{nil}.
- Users of @t{:if-does-not-exist nil} should check for a valid @i{stream}.
- The consequences are undefined if an attempt is made to @i{assign} the
- @i{stream} @i{variable}. The compiler may choose to issue a
- warning if such an attempt is detected.
- @subsubheading Examples::
- @example
- (setq p (merge-pathnames "test"))
- @result{} #<PATHNAME :HOST NIL :DEVICE @i{device-name} :DIRECTORY @i{directory-name}
- :NAME "test" :TYPE NIL :VERSION :NEWEST>
- (with-open-file (s p :direction :output :if-exists :supersede)
- (format s "Here are a couple~
- (with-open-file (s p)
- (do ((l (read-line s) (read-line s nil 'eof)))
- ((eq l 'eof) "Reached end of file.")
- (format t "~&*** ~A~
- @t{ |> } *** Here are a couple
- @t{ |> } *** of test data lines
- @result{} "Reached end of file."
- @end example
- @example
- ;; Normally one would not do this intentionally because it is
- ;; not perspicuous, but beware when using :IF-DOES-NOT-EXIST NIL
- ;; that this doesn't happen to you accidentally...
- (with-open-file (foo "no-such-file" :if-does-not-exist nil)
- (read foo))
- @t{ |> } @b{|>>}@t{hello?}@b{<<|}
- @result{} HELLO? ;This value was read from the terminal, not a file!
- ;; Here's another bug to avoid...
- (with-open-file (foo "no-such-file" :direction :output :if-does-not-exist nil)
- (format foo "Hello"))
- @result{} "Hello" ;FORMAT got an argument of NIL!
- @end example
- @subsubheading Side Effects::
- Creates a @i{stream} to the @i{file} named by @i{filename} (upon entry),
- and closes the @i{stream} (upon exit).
- In some @i{implementations},
- the @i{file} might be locked in some way while it is open.
- If the @i{stream} is an @i{output} @i{stream},
- a @i{file} might be created.
- @subsubheading Affected By::
- The host computer's file system.
- @subsubheading Exceptional Situations::
- See the @i{function} @b{open}.
- @subsubheading See Also::
- @ref{open}
- ,
- @ref{close}
- ,
- @b{pathname},
- @b{logical-pathname},
- @ref{Pathnames as Filenames}
- @node close, with-open-stream, with-open-file, Streams Dictionary
- @subsection close [Function]
- @code{close} @i{stream {&key} abort} @result{} @i{result}
- @subsubheading Arguments and Values::
- @i{stream}---a @i{stream} (either @i{open} or @i{closed}).
- @i{abort}---a @i{generalized boolean}.
- The default is @i{false}.
- @i{result}---@b{t} if the @i{stream} was @i{open} at the time it was
- received as an @i{argument},
- or @i{implementation-dependent} otherwise.
- @subsubheading Description::
- @b{close} closes @i{stream}.
- Closing a @i{stream} means
- that it may no longer be used in input or output operations.
- The act of @i{closing} a @i{file stream}
- ends the association between the @i{stream} and its associated @i{file};
- the transaction with the @i{file system} is terminated,
- and input/output may no longer be performed on the @i{stream}.
- If @i{abort} is @i{true}, an attempt is made to clean up any side
- effects of having created @i{stream}.
- If @i{stream} performs output to a file
- that was created when the @i{stream} was created, the
- file is deleted and any previously existing file is not superseded.
- It is permissible to close an already closed @i{stream},
- but in that case the @i{result} is @i{implementation-dependent}.
- After @i{stream} is closed, it is still possible to perform
- the following query operations upon it:
- @b{streamp}, @b{pathname}, @b{truename},
- @b{merge-pathnames}, @b{pathname-host}, @b{pathname-device},
- @b{pathname-directory},@b{pathname-name},
- @b{pathname-type}, @b{pathname-version}, @b{namestring},
- @b{file-namestring}, @b{directory-namestring},
- @b{host-namestring}, @b{enough-namestring}, @b{open},
- @b{probe-file}, and @b{directory}.
- The effect of @b{close} on a @i{constructed stream} is
- to close the argument @i{stream} only.
- There is no effect on the @i{constituents} of @i{composite streams}.
- For a @i{stream} created with @b{make-string-output-stream},
- the result of @b{get-output-stream-string} is unspecified after @b{close}.
- @subsubheading Examples::
- @example
- (setq s (make-broadcast-stream)) @result{} #<BROADCAST-STREAM>
- (close s) @result{} T
- (output-stream-p s) @result{} @i{true}
- @end example
- @subsubheading Side Effects::
- The @i{stream} is @i{closed} (if necessary).
- If @i{abort} is @i{true} and the @i{stream} is
- an @i{output} @i{file stream}, its associated @i{file}
- might be deleted.
- @subsubheading See Also::
- @ref{open}
- @node with-open-stream, listen, close, Streams Dictionary
- @subsection with-open-stream [Macro]
- @code{with-open-stream} @i{@r{(}var stream@r{)}
- @{@i{declaration}@}{*}
- @{@i{form}@}{*}}@*
- @result{} @i{@{@i{result}@}{*}}
- @subsubheading Arguments and Values::
- @i{var}---a @i{variable} @i{name}.
- @i{stream}---a @i{form}; evaluated to produce a @i{stream}.
- @i{declaration}---a @b{declare} @i{expression}; not evaluated.
- @i{forms}---an @i{implicit progn}.
- @i{results}---the @i{values} returned by the @i{forms}.
- @subsubheading Description::
- @b{with-open-stream} performs a series of operations on
- @i{stream}, returns a value, and then closes the @i{stream}.
- @i{Var} is bound to the value of @i{stream},
- and then @i{forms} are executed
- as an @i{implicit progn}.
- @i{stream}
- is automatically closed on exit from @b{with-open-stream},
- no matter whether the exit is normal or abnormal.
- The @i{stream} has @i{dynamic extent};
- its @i{extent} ends when the @i{form} is exited.
- The consequences are undefined if an attempt is made to @i{assign} the
- the @i{variable} @i{var} with the @i{forms}.
- @subsubheading Examples::
- @example
- (with-open-stream (s (make-string-input-stream "1 2 3 4"))
- (+ (read s) (read s) (read s))) @result{} 6
- @end example
- @subsubheading Side Effects::
- The @i{stream} is closed (upon exit).
- @subsubheading See Also::
- @ref{close}
- @node listen, clear-input, with-open-stream, Streams Dictionary
- @subsection listen [Function]
- @code{listen} @i{{&optional} input-stream} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- Returns @i{true} if
- there is a character immediately available from @i{input-stream};
- otherwise, returns @i{false}.
- On a non-interactive @i{input-stream},
- @b{listen} returns @i{true} except when at @i{end of file}_1.
- If an @i{end of file} is encountered, @b{listen} returns @i{false}.
- @b{listen} is intended to be used
- when @i{input-stream} obtains characters
- from an interactive device such as a keyboard.
- @subsubheading Examples::
- @example
- (progn (unread-char (read-char)) (list (listen) (read-char)))
- @t{ |> } @b{|>>}@t{1}@b{<<|}
- @result{} (T #\1)
- (progn (clear-input) (listen))
- @result{} NIL ;Unless you're a very fast typist!
- @end example
- @subsubheading Affected By::
- @b{*standard-input*}
- @subsubheading See Also::
- @ref{interactive-stream-p}
- ,
- @ref{read-char-no-hang}
- @node clear-input, finish-output, listen, Streams Dictionary
- @subsection clear-input [Function]
- @code{clear-input} @i{{&optional} input-stream} @result{} @i{@b{nil}}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream designator}.
- The default is @i{standard input}.
- @subsubheading Description::
- Clears any available input from @i{input-stream}.
- If @b{clear-input} does not make sense for @i{input-stream},
- then @b{clear-input} does nothing.
- @subsubheading Examples::
- @example
- ;; The exact I/O behavior of this example might vary from implementation
- ;; to implementation depending on the kind of interactive buffering that
- ;; occurs. (The call to SLEEP here is intended to help even out the
- ;; differences in implementations which do not do line-at-a-time buffering.)
- (defun read-sleepily (&optional (clear-p nil) (zzz 0))
- (list (progn (print '>) (read))
- ;; Note that input typed within the first ZZZ seconds
- ;; will be discarded.
- (progn (print '>)
- (if zzz (sleep zzz))
- (print '>>)
- (if clear-p (clear-input))
- (read))))
- (read-sleepily)
- @t{ |> } > @b{|>>}@t{10}@b{<<|}
- @t{ |> } >
- @t{ |> } >> @b{|>>}@t{20}@b{<<|}
- @result{} (10 20)
- (read-sleepily t)
- @t{ |> } > @b{|>>}@t{10}@b{<<|}
- @t{ |> } >
- @t{ |> } >> @b{|>>}@t{20}@b{<<|}
- @result{} (10 20)
- (read-sleepily t 10)
- @t{ |> } > @b{|>>}@t{10}@b{<<|}
- @t{ |> } > @b{|>>}@t{20}@b{<<|} ; Some implementations won't echo typeahead here.
- @t{ |> } >> @b{|>>}@t{30}@b{<<|}
- @result{} (10 30)
- @end example
- @subsubheading Side Effects::
- The @i{input-stream} is modified.
- @subsubheading Affected By::
- @b{*standard-input*}
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{input-stream} is not a @i{stream designator}.
- @subsubheading See Also::
- @b{clear-output}
- @node finish-output, y-or-n-p, clear-input, Streams Dictionary
- @subsection finish-output, force-output, clear-output [Function]
- @code{finish-output} @i{{&optional} output-stream} @result{} @i{@b{nil}}
- @code{force-output} @i{{&optional} output-stream} @result{} @i{@b{nil}}
- @code{clear-output} @i{{&optional} output-stream} @result{} @i{@b{nil}}
- @subsubheading Arguments and Values::
- @i{output-stream}---an @i{output} @i{stream designator}.
- The default is @i{standard output}.
- @subsubheading Description::
- @b{finish-output}, @b{force-output}, and @b{clear-output}
- exercise control over the internal handling of buffered stream output.
- @b{finish-output} attempts to ensure that any buffered output
- sent to @i{output-stream} has reached its destination, and then returns.
- @b{force-output} initiates the emptying of any
- internal buffers but does not wait for completion
- or acknowledgment to return.
- @b{clear-output} attempts to abort any
- outstanding output operation in progress in order
- to allow as little output as possible
- to continue to the destination.
- If any of these operations does not make sense for @i{output-stream},
- then it does nothing.
- The precise actions of these @i{functions} are @i{implementation-dependent}.
- @subsubheading Examples::
- @example
- ;; Implementation A
- (progn (princ "am i seen?") (clear-output))
- @result{} NIL
- ;; Implementation B
- (progn (princ "am i seen?") (clear-output))
- @t{ |> } am i seen?
- @result{} NIL
- @end example
- @subsubheading Affected By::
- @b{*standard-output*}
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{output-stream} is not a @i{stream designator}.
- @subsubheading See Also::
- @ref{clear-input}
- @node y-or-n-p, make-synonym-stream, finish-output, Streams Dictionary
- @subsection y-or-n-p, yes-or-no-p [Function]
- @code{y-or-n-p} @i{{&optional} control {&rest} arguments} @result{} @i{generalized-boolean}
- @code{yes-or-no-p} @i{{&optional} control {&rest} arguments} @result{} @i{generalized-boolean}
- @subsubheading Arguments and Values::
- @i{control}---a @i{format control}.
- @i{arguments}---@i{format arguments} for @i{control}.
- @i{generalized-boolean}---a @i{generalized boolean}.
- @subsubheading Description::
- These functions ask a question and parse a response from the user.
- They return @i{true} if the answer is affirmative,
- or @i{false} if the answer is negative.
- @b{y-or-n-p} is for asking the user a question whose answer is either
- ``yes'' or ``no.''
- It is intended that the reply require
- the user to answer a yes-or-no question with a single
- character.
- @b{yes-or-no-p} is also for asking the user a question
- whose answer is either ``Yes'' or ``No.''
- It is intended that the reply require
- the user to take more action than just a single keystroke, such as typing
- the full word @t{yes} or @t{no} followed by a newline.
- @b{y-or-n-p} types out a message (if supplied), reads an answer
- in some @i{implementation-dependent} manner (intended to be short and simple,
- such as reading a single character such as @t{Y} or @t{N}).
- @b{yes-or-no-p} types out a message (if supplied),
- attracts the user's attention (for example, by ringing
- the terminal's bell),
- and reads an answer
- in some @i{implementation-dependent} manner (intended to be multiple characters,
- such as @t{YES} or @t{NO}).
- If @i{format-control} is supplied and not @b{nil},
- then a @b{fresh-line} operation is performed; then
- a message is printed as if @i{format-control} and @i{arguments}
- were given to @b{format}.
- In any case, @b{yes-or-no-p} and @b{y-or-n-p} will provide
- a prompt such as ``@t{(Y or N)}'' or ``@t{(Yes or No)}'' if appropriate.
- All input and output are performed using @i{query I/O}.
- @subsubheading Examples::
- @example
- (y-or-n-p "(t or nil) given by")
- @t{ |> } (t or nil) given by (Y or N) @b{|>>}@t{Y}@b{<<|}
- @result{} @i{true}
- (yes-or-no-p "a ~S message" 'frightening)
- @t{ |> } a FRIGHTENING message (Yes or No) @b{|>>}@t{no}@b{<<|}
- @result{} @i{false}
- (y-or-n-p "Produce listing file?")
- @t{ |> } Produce listing file?
- @t{ |> } Please respond with Y or N. @b{|>>}@t{n}@b{<<|}
- @result{} @i{false}
- @end example
- @subsubheading Side Effects::
- Output to and input from @i{query I/O} will occur.
- @subsubheading Affected By::
- @b{*query-io*}.
- @subsubheading See Also::
- @ref{format}
- @subsubheading Notes::
- @b{yes-or-no-p} and @b{yes-or-no-p} do not add question marks
- to the end of the prompt string, so any desired question mark or other
- punctuation should be explicitly included in the text query.
- @node make-synonym-stream, synonym-stream-symbol, y-or-n-p, Streams Dictionary
- @subsection make-synonym-stream [Function]
- @code{make-synonym-stream} @i{symbol} @result{} @i{synonym-stream}
- @subsubheading Arguments and Values::
- @i{symbol}---a @i{symbol} that names a @i{dynamic variable}.
- @i{synonym-stream}---a @i{synonym stream}.
- @subsubheading Description::
- Returns a @i{synonym stream} whose @i{synonym stream symbol} is @i{symbol}.
- @subsubheading Examples::
- @example
- (setq a-stream (make-string-input-stream "a-stream")
- b-stream (make-string-input-stream "b-stream"))
- @result{} #<String Input Stream>
- (setq s-stream (make-synonym-stream 'c-stream))
- @result{} #<SYNONYM-STREAM for C-STREAM>
- (setq c-stream a-stream)
- @result{} #<String Input Stream>
- (read s-stream) @result{} A-STREAM
- (setq c-stream b-stream)
- @result{} #<String Input Stream>
- (read s-stream) @result{} B-STREAM
- @end example
- @subsubheading Exceptional Situations::
- Should signal @b{type-error} if its argument is not a @i{symbol}.
- @subsubheading See Also::
- @ref{Stream Concepts}
- @node synonym-stream-symbol, broadcast-stream-streams, make-synonym-stream, Streams Dictionary
- @subsection synonym-stream-symbol [Function]
- @code{synonym-stream-symbol} @i{synonym-stream} @result{} @i{symbol}
- @subsubheading Arguments and Values::
- @i{synonym-stream}---a @i{synonym stream}.
- @i{symbol}---a @i{symbol}.
- @subsubheading Description::
- Returns the @i{symbol} whose @b{symbol-value} the @i{synonym-stream} is using.
- @subsubheading See Also::
- @ref{make-synonym-stream}
- @node broadcast-stream-streams, make-broadcast-stream, synonym-stream-symbol, Streams Dictionary
- @subsection broadcast-stream-streams [Function]
- @code{broadcast-stream-streams} @i{broadcast-stream} @result{} @i{streams}
- @subsubheading Arguments and Values::
- @i{broadcast-stream}---a @i{broadcast stream}.
- @i{streams}---a @i{list} of @i{streams}.
- @subsubheading Description::
- Returns a @i{list} of output @i{streams} that constitute
- all the @i{streams} to which the @i{broadcast-stream} is broadcasting.
- @node make-broadcast-stream, make-two-way-stream, broadcast-stream-streams, Streams Dictionary
- @subsection make-broadcast-stream [Function]
- @code{make-broadcast-stream} @i{{&rest} streams} @result{} @i{broadcast-stream}
- @subsubheading Arguments and Values::
- @i{stream}---an @i{output} @i{stream}.
- @i{broadcast-stream}---a @i{broadcast stream}.
- @subsubheading Description::
- Returns a @i{broadcast stream}.
- @subsubheading Examples::
- @example
- (setq a-stream (make-string-output-stream)
- b-stream (make-string-output-stream)) @result{} #<String Output Stream>
- (format (make-broadcast-stream a-stream b-stream)
- "this will go to both streams") @result{} NIL
- (get-output-stream-string a-stream) @result{} "this will go to both streams"
- (get-output-stream-string b-stream) @result{} "this will go to both streams"
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if any @i{stream} is not an @i{output} @i{stream}.
- @subsubheading See Also::
- @ref{broadcast-stream-streams}
- @node make-two-way-stream, two-way-stream-input-stream, make-broadcast-stream, Streams Dictionary
- @subsection make-two-way-stream [Function]
- @code{make-two-way-stream} @i{input-stream output-stream} @result{} @i{two-way-stream}
- @subsubheading Arguments and Values::
- @i{input-stream}---a @i{stream}.
- @i{output-stream}---a @i{stream}.
- @i{two-way-stream}---a @i{two-way stream}.
- @subsubheading Description::
- Returns a @i{two-way stream}
- that gets its input from @i{input-stream}
- and sends its output to @i{output-stream}.
- @subsubheading Examples::
- @example
- (with-output-to-string (out)
- (with-input-from-string (in "input...")
- (let ((two (make-two-way-stream in out)))
- (format two "output...")
- (setq what-is-read (read two))))) @result{} "output..."
- what-is-read @result{} INPUT...
- @end example
- @subsubheading Exceptional Situations::
- Should signal an error of @i{type} @b{type-error}
- if @i{input-stream} is not an @i{input} @i{stream}.
- Should signal an error of @i{type} @b{type-error}
- if @i{output-stream} is not an @i{output} @i{stream}.
- @node two-way-stream-input-stream, echo-stream-input-stream, make-two-way-stream, Streams Dictionary
- @subsection two-way-stream-input-stream, two-way-stream-output-stream
- @flushright
- @i{[Function]}
- @end flushright
- @code{two-way-stream-input-stream} @i{two-way-stream} @result{} @i{input-stream}
- @code{two-way-stream-output-stream} @i{two-way-stream} @result{} @i{output-stream}
- @subsubheading Arguments and Values::
- @i{two-way-stream}---a @i{two-way stream}.
- @i{input-stream}---an @i{input} @i{stream}.
- @i{output-stream}---an @i{output} @i{stream}.
- @subsubheading Description::
- @b{two-way-stream-input-stream} returns the @i{stream}
- from which @i{two-way-stream} receives input.
- @b{two-way-stream-output-stream} returns the @i{stream}
- to which @i{two-way-stream} sends output.
- @node echo-stream-input-stream, make-echo-stream, two-way-stream-input-stream, Streams Dictionary
- @subsection echo-stream-input-stream, echo-stream-output-stream [Function]
- @code{echo-stream-input-stream} @i{echo-stream} @result{} @i{input-stream}
- @code{echo-stream-output-stream} @i{echo-stream} @result{} @i{output-stream}
- @subsubheading Arguments and Values::
- @i{echo-stream}---an @i{echo stream}.
- @i{input-stream}---an @i{input} @i{stream}.
- @b{output-stream}---an @i{output} @i{stream}.
- @subsubheading Description::
- @b{echo-stream-input-stream} returns the @i{input} @i{stream}
- from which @i{echo-stream} receives input.
- @b{echo-stream-output-stream} returns the @i{output} @i{stream}
- to which @i{echo-stream} sends output.
- @node make-echo-stream, concatenated-stream-streams, echo-stream-input-stream, Streams Dictionary
- @subsection make-echo-stream [Function]
- @code{make-echo-stream} @i{input-stream output-stream} @result{} @i{echo-stream}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream}.
- @i{output-stream}---an @i{output} @i{stream}.
- @i{echo-stream}---an @i{echo stream}.
- @subsubheading Description::
- Creates and returns an @i{echo stream}
- that takes input from @i{input-stream}
- and sends output to @i{output-stream}.
- @subsubheading Examples::
- @example
- (let ((out (make-string-output-stream)))
- (with-open-stream
- (s (make-echo-stream
- (make-string-input-stream "this-is-read-and-echoed")
- out))
- (read s)
- (format s " * this-is-direct-output")
- (get-output-stream-string out)))
- @result{} "this-is-read-and-echoed * this-is-direct-output"
- @end example
- @subsubheading See Also::
- @ref{echo-stream-input-stream; echo-stream-output-stream}
- ,
- @b{echo-stream-output-stream},
- @ref{make-two-way-stream}
- @node concatenated-stream-streams, make-concatenated-stream, make-echo-stream, Streams Dictionary
- @subsection concatenated-stream-streams [Function]
- @code{concatenated-stream-streams} @i{concatenated-stream} @result{} @i{streams}
- @subsubheading Arguments and Values::
- @i{concatenated-stream} -- a @i{concatenated stream}.
- @i{streams}---a @i{list} of @i{input} @i{streams}.
- @subsubheading Description::
- Returns a @i{list} of @i{input} @i{streams} that constitute the
- ordered set of @i{streams} the @i{concatenated-stream} still
- has to read from, starting with the current one it is reading from.
- The list may be @i{empty} if no more @i{streams} remain to be read.
- The consequences are undefined if the @i{list structure} of the @i{streams}
- is ever modified.
- @node make-concatenated-stream, get-output-stream-string, concatenated-stream-streams, Streams Dictionary
- @subsection make-concatenated-stream [Function]
- @code{make-concatenated-stream} @i{{&rest} input-streams} @result{} @i{concatenated-stream}
- @subsubheading Arguments and Values::
- @i{input-stream}---an @i{input} @i{stream}.
- @i{concatenated-stream}---a @i{concatenated stream}.
- @subsubheading Description::
- Returns a @i{concatenated stream} that has the indicated @i{input-streams}
- initially associated with it.
- @subsubheading Examples::
- @example
- (read (make-concatenated-stream
- (make-string-input-stream "1")
- (make-string-input-stream "2"))) @result{} 12
- @end example
- @subsubheading Exceptional Situations::
- Should signal @b{type-error} if any argument is not an @i{input} @i{stream}.
- @subsubheading See Also::
- @ref{concatenated-stream-streams}
- @node get-output-stream-string, make-string-input-stream, make-concatenated-stream, Streams Dictionary
- @subsection get-output-stream-string [Function]
- @code{get-output-stream-string} @i{string-output-stream} @result{} @i{string}
- @subsubheading Arguments and Values::
- @i{string-output-stream}---a @i{stream}.
- @i{string}---a @i{string}.
- @subsubheading Description::
- Returns a @i{string} containing, in order, all the @i{characters}
- that have been output to @i{string-output-stream}.
- This operation clears any @i{characters} on @i{string-output-stream},
- so the @i{string} contains only those @i{characters} which have been output
- since the last call to @b{get-output-stream-string}
- or since the creation of the @i{string-output-stream},
- whichever occurred most recently.
- @subsubheading Examples::
- @example
- (setq a-stream (make-string-output-stream)
- a-string "abcdefghijklm") @result{} "abcdefghijklm"
- (write-string a-string a-stream) @result{} "abcdefghijklm"
- (get-output-stream-string a-stream) @result{} "abcdefghijklm"
- (get-output-stream-string a-stream) @result{} ""
- @end example
- @subsubheading Side Effects::
- The @i{string-output-stream} is cleared.
- @subsubheading Exceptional Situations::
- The consequences are undefined if @i{stream-output-string} is @i{closed}.
- The consequences are undefined if @i{string-output-stream} is a @i{stream} that
- was not produced by @b{make-string-output-stream}.
- The consequences are undefined if @i{string-output-stream} was
- created implicitly by @b{with-output-to-string} or @b{format}.
- @subsubheading See Also::
- @ref{make-string-output-stream}
- @node make-string-input-stream, make-string-output-stream, get-output-stream-string, Streams Dictionary
- @subsection make-string-input-stream [Function]
- @code{make-string-input-stream} @i{string {&optional} start end} @result{} @i{string-stream}
- @subsubheading Arguments and Values::
- @i{string}---a @i{string}.
- @i{start}, @i{end}---@i{bounding index designators} of @i{string}.
- The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
- @i{string-stream}---an @i{input} @i{string stream}.
- @subsubheading Description::
- Returns an @i{input} @i{string stream}.
- This @i{stream} will supply, in order, the @i{characters} in the substring
- of @i{string} @i{bounded} by @i{start} and @i{end}.
- After the last @i{character} has been supplied,
- the @i{string stream} will then be at @i{end of file}.
- @subsubheading Examples::
- @example
- (let ((string-stream (make-string-input-stream "1 one ")))
- (list (read string-stream nil nil)
- (read string-stream nil nil)
- (read string-stream nil nil)))
- @result{} (1 ONE NIL)
- (read (make-string-input-stream "prefixtargetsuffix" 6 12)) @result{} TARGET
- @end example
- @subsubheading See Also::
- @ref{with-input-from-string}
- @node make-string-output-stream, with-input-from-string, make-string-input-stream, Streams Dictionary
- @subsection make-string-output-stream [Function]
- @code{make-string-output-stream} @i{{&key} element-type} @result{} @i{string-stream}
- @subsubheading Arguments and Values::
- @i{element-type}---a @i{type specifier}.
- The default is @b{character}.
- @i{string-stream}---an @i{output} @i{string stream}.
- @subsubheading Description::
- Returns
- an @i{output} @i{string stream} that accepts @i{characters}
- and makes available (via @b{get-output-stream-string})
- a @i{string} that contains the @i{characters} that were actually output.
- The @i{element-type} names the @i{type} of the @i{elements}
- of the @i{string}; a @i{string} is constructed of the most specialized
- @i{type} that can accommodate @i{elements} of that @i{element-type}.
- @subsubheading Examples::
- @example
- (let ((s (make-string-output-stream)))
- (write-string "testing... " s)
- (prin1 1234 s)
- (get-output-stream-string s))
- @result{} "testing... 1234"
- @end example
- None..
- @subsubheading See Also::
- @ref{get-output-stream-string}
- ,
- @ref{with-output-to-string}
- @node with-input-from-string, with-output-to-string, make-string-output-stream, Streams Dictionary
- @subsection with-input-from-string [Macro]
- @code{with-input-from-string} @i{@r{(}var string {&key} index start end@r{)}
- @{@i{declaration}@}{*}
- @{@i{form}@}{*}}@*
- @result{} @i{@{@i{result}@}{*}}
- @subsubheading Arguments and Values::
- @i{var}---a @i{variable} @i{name}.
- @i{string}---a @i{form}; evaluated to produce a @i{string}.
- @i{index}---a @i{place}.
- @i{start}, @i{end}---@i{bounding index designators} of @i{string}.
- The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
- @i{declaration}---a @b{declare} @i{expression}; not evaluated.
- @i{forms}---an @i{implicit progn}.
- @i{result}---the @i{values} returned by the @i{forms}.
- @subsubheading Description::
- Creates an
- @i{input} @i{string stream},
- provides an opportunity to perform operations on the @i{stream}
- (returning zero or more @i{values}),
- and then closes the @i{string stream}.
- @i{String} is evaluated first, and @i{var} is bound to
- a character @i{input} @i{string stream} that supplies
- @i{characters} from the subsequence of the resulting @i{string} @i{bounded} by
- @i{start} and @i{end}.
- The body is executed as an @i{implicit progn}.
- The @i{input} @i{string stream} is automatically closed on exit from
- @b{with-input-from-string}, no matter whether the exit is normal or abnormal.
- The @i{input} @i{string stream} to which the @i{variable} @i{var}
- is @i{bound} has @i{dynamic extent};
- its @i{extent} ends when the @i{form} is exited.
- The @i{index} is a pointer within the @i{string} to be advanced.
- If @b{with-input-from-string}
- is exited normally, then @i{index} will have
- as its @i{value}
- the index into the @i{string} indicating the first character not read
- which is @t{(length @i{string})} if all characters were used.
- The place specified by @i{index}
- is not updated as reading progresses, but only at the
- end of the operation.
- @i{start} and @i{index} may both specify the same variable,
- which is a pointer within the @i{string} to be advanced,
- perhaps repeatedly by some containing loop.
- The consequences are undefined if an attempt is made to @i{assign}
- the @i{variable} @i{var}.
- @subsubheading Examples::
- @example
- (with-input-from-string (s "XXX1 2 3 4xxx"
- :index ind
- :start 3 :end 10)
- (+ (read s) (read s) (read s))) @result{} 6
- ind @result{} 9
- (with-input-from-string (s "Animal Crackers" :index j :start 6)
- (read s)) @result{} CRACKERS
- @end example
- The variable @t{j} is set to @t{15}.
- @subsubheading Side Effects::
- The @i{value} of the @i{place} named by @i{index}, if any, is modified.
- @subsubheading See Also::
- @ref{make-string-input-stream}
- ,
- @ref{Traversal Rules and Side Effects}
- @node with-output-to-string, *debug-io*, with-input-from-string, Streams Dictionary
- @subsection with-output-to-string [Macro]
- @code{with-output-to-string} @i{@r{(}var {&optional} string-form {&key} element-type@r{)}
- @{@i{declaration}@}{*}
- @{@i{form}@}{*}}@*
- @result{} @i{@{@i{result}@}{*}}
- @subsubheading Arguments and Values::
- @i{var}---a @i{variable} @i{name}.
- @i{string-form}---a @i{form} or @b{nil};
- if @i{non-nil}, evaluated to produce @i{string}.
- @i{string}---a @i{string} that has a @i{fill pointer}.
- @i{element-type}---a @i{type specifier}; evaluated.
- The default is @b{character}.
- @i{declaration}---a @b{declare} @i{expression}; not evaluated.
- @i{forms}---an @i{implicit progn}.
- @i{results}---If a @i{string-form} is not supplied or @b{nil},
- a @i{string}; otherwise,
- the @i{values} returned by the @i{forms}.
- @subsubheading Description::
- @b{with-output-to-string} creates a
- character @i{output} @i{stream}, performs a series of operations
- that may send results to this @i{stream}, and then closes the @i{stream}.
- The @i{element-type} names the @i{type} of the elements
- of the @i{stream}; a @i{stream} is constructed of the most specialized
- @i{type} that can accommodate elements of the given @i{type}.
- The body is executed as an @i{implicit progn} with @i{var}
- bound to an @i{output} @i{string stream}.
- All output to that @i{string stream} is saved in a @i{string}.
- If @i{string} is supplied, @i{element-type} is ignored,
- and the output is incrementally appended to @i{string} as
- if by use of @b{vector-push-extend}.
- The @i{output} @i{stream}
- is automatically closed on exit from @b{with-output-from-string},
- no matter whether the exit is normal or abnormal.
- The @i{output} @i{string stream} to which the @i{variable} @i{var}
- is @i{bound} has @i{dynamic extent};
- its @i{extent} ends when the @i{form} is exited.
- If no @i{string} is provided, then @b{with-output-from-string}
- produces a @i{stream} that accepts characters and returns a @i{string}
- of the indicated @i{element-type}.
- If @i{string} is provided,
- @b{with-output-to-string} returns the results of evaluating the last @i{form}.
- The consequences are undefined if an attempt is made to @i{assign}
- the @i{variable} @i{var}.
- @subsubheading Examples::
- @example
- (setq fstr (make-array '(0) :element-type 'base-char
- :fill-pointer 0 :adjustable t)) @result{} ""
- (with-output-to-string (s fstr)
- (format s "here's some output")
- (input-stream-p s)) @result{} @i{false}
- fstr @result{} "here's some output"
- @end example
- @subsubheading Side Effects::
- The @i{string} is modified.
- @subsubheading Exceptional Situations::
- The consequences are undefined if destructive modifications are performed
- directly on the @i{string} during the @i{dynamic extent} of the call.
- @subsubheading See Also::
- @ref{make-string-output-stream}
- ,
- @b{vector-push-extend},
- @ref{Traversal Rules and Side Effects}
- @node *debug-io*, *terminal-io*, with-output-to-string, Streams Dictionary
- @subsection *debug-io*, *error-output*, *query-io*,
- @subheading *standard-input*, *standard-output*,
- @subheading *trace-output*
- @flushright
- @i{[Variable]}
- @end flushright
- @subsubheading Value Type::
- For @b{*standard-input*}:
- an @i{input} @i{stream}
- For @b{*error-output*}, @b{*standard-output*}, and @b{*trace-output*}:
- an @i{output} @i{stream}.
- For @b{*debug-io*}, @b{*query-io*}:
- a @i{bidirectional} @i{stream}.
- @subsubheading Initial Value::
- @i{implementation-dependent}, but
- it must be an @i{open} @i{stream}
- that is not a @i{generalized synonym stream}
- to an @i{I/O customization variables}
- but that might be a @i{generalized synonym stream} to
- the value of some @i{I/O customization variable}.
- The initial value might also be a @i{generalized synonym stream}
- to either the @i{symbol} @b{*terminal-io*} or to the @i{stream}
- that is its @i{value}.
- @subsubheading Description::
- These @i{variables} are collectively called the
- @i{standardized} @i{I/O customization variables}.
- They can be @i{bound} or @i{assigned} in order to
- change the default destinations for input and/or output
- used by various @i{standardized} @i{operators} and facilities.
- The @i{value} of @b{*debug-io*}, called @i{debug I/O},
- is a @i{stream} to be used for interactive debugging purposes.
- The @i{value} of @b{*error-output*}, called @i{error output},
- is a @i{stream} to which warnings and non-interactive error messages should be sent.
- The @i{value} of @b{*query-io*}, called @i{query I/O},
- is a @i{bidirectional} @i{stream}
- to be used when asking questions of the user. The question should be output
- to this @i{stream}, and the answer read from it.
- The @i{value} of @b{*standard-input*}, called @i{standard input},
- is a @i{stream} that is used by many @i{operators}
- as a default source of input when no specific @i{input} @i{stream}
- is explicitly supplied.
- The @i{value} of @b{*standard-output*}, called @i{standard output},
- is a @i{stream} that is used by many @i{operators}
- as a default destination for output when no specific @i{output} @i{stream}
- is explicitly supplied.
- The @i{value} of @b{*trace-output*}, called @i{trace output},
- is the @i{stream} on which traced functions (see @b{trace})
- and the @b{time} @i{macro} print their output.
- @subsubheading Examples::
- @example
- (with-output-to-string (*error-output*)
- (warn "this string is sent to *error-output*"))
- @result{} "Warning: this string is sent to *error-output*
- " ;The exact format of this string is @i{implementation-dependent}.
- (with-input-from-string (*standard-input* "1001")
- (+ 990 (read))) @result{} 1991
- (progn (setq out (with-output-to-string (*standard-output*)
- (print "print and format t send things to")
- (format t "*standard-output* now going to a string")))
- :done)
- @result{} :DONE
- out
- @result{} "
- \"print and format t send things to\" *standard-output* now going to a string"
- (defun fact (n) (if (< n 2) 1 (* n (fact (- n 1)))))
- @result{} FACT
- (trace fact)
- @result{} (FACT)
- ;; Of course, the format of traced output is implementation-dependent.
- (with-output-to-string (*trace-output*)
- (fact 3))
- @result{} "
- 1 Enter FACT 3
- | 2 Enter FACT 2
- | 3 Enter FACT 1
- | 3 Exit FACT 1
- | 2 Exit FACT 2
- 1 Exit FACT 6"
- @end example
- @subsubheading See Also::
- @b{*terminal-io*},
- @b{synonym-stream},
- @ref{Time}
- ,
- @ref{trace; untrace}
- ,
- {@ref{Conditions}},
- {@ref{Reader}},
- {@ref{Printer}}
- @subsubheading Notes::
- The intent of the constraints on the initial @i{value}
- of the @i{I/O customization variables} is to ensure that it
- is always safe to @i{bind} or @i{assign} such a @i{variable} to
- the @i{value} of another @i{I/O customization variable}, without
- unduly restricting @i{implementation} flexibility.
- It is common for an @i{implementation} to make
- the initial @i{values} of @b{*debug-io*} and @b{*query-io*}
- be the @i{same} @i{stream},
- and to make
- the initial @i{values} of @b{*error-output*} and @b{*standard-output*}
- be the @i{same} @i{stream}.
- The functions @b{y-or-n-p} and @b{yes-or-no-p} use @i{query I/O}
- for their input and output.
- In the normal @i{Lisp read-eval-print loop},
- input is read from @i{standard input}.
- Many input functions, including @b{read} and @b{read-char},
- take a @i{stream} argument that defaults to @i{standard input}.
- In the normal @i{Lisp read-eval-print loop}, output is sent to @i{standard output}.
- Many output functions, including @b{print} and @b{write-char},
- take a @i{stream} argument that defaults to @i{standard output}.
- A program that wants, for example, to divert output to a file should do so by
- @i{binding} @b{*standard-output*}; that way error messages sent to
- @b{*error-output*} can still get to the user by going through
- @b{*terminal-io*} (if @b{*error-output*} is bound to @b{*terminal-io*}),
- which is usually what is desired.
- @node *terminal-io*, stream-error, *debug-io*, Streams Dictionary
- @subsection *terminal-io* [Variable]
- @subsubheading Value Type::
- a @i{bidirectional} @i{stream}.
- @subsubheading Initial Value::
- @i{implementation-dependent}, but
- it must be an @i{open} @i{stream}
- that is not a @i{generalized synonym stream}
- to an @i{I/O customization variables}
- but that might be a @i{generalized synonym stream} to
- the @i{value} of some @i{I/O customization variable}.
- @subsubheading Description::
- The @i{value} of @b{*terminal-io*}, called @i{terminal I/O}, is ordinarily
- a @i{bidirectional} @i{stream} that connects to the user's console.
- Typically, writing to this @i{stream}
- would cause the output to appear
- on a display screen, for example, and reading from the @i{stream} would
- accept input from a keyboard. It is intended
- that standard input functions such as @b{read} and @b{read-char},
- when used with this @i{stream}, cause echoing of the input
- into the output side of the @i{stream}. The means by which this is
- accomplished are @i{implementation-dependent}.
- The effect of changing the @i{value} of @b{*terminal-io*},
- either by @i{binding} or @i{assignment},
- is @i{implementation-defined}.
- @subsubheading Examples::
- @example
- (progn (prin1 'foo) (prin1 'bar *terminal-io*))
- @t{ |> } FOOBAR
- @result{} BAR
- (with-output-to-string (*standard-output*)
- (prin1 'foo)
- (prin1 'bar *terminal-io*))
- @t{ |> } BAR
- @result{} "FOO"
- @end example
- @subsubheading See Also::
- @b{*debug-io*},
- @b{*error-output*},
- @b{*query-io*},
- @b{*standard-input*},
- @b{*standard-output*},
- @b{*trace-output*}
- @node stream-error, stream-error-stream, *terminal-io*, Streams Dictionary
- @subsection stream-error [Condition Type]
- @subsubheading Class Precedence List::
- @b{stream-error},
- @b{error},
- @b{serious-condition},
- @b{condition},
- @b{t}
- @subsubheading Description::
- The @i{type} @b{stream-error}
- consists of error conditions that are related to receiving input from
- or sending output to a @i{stream}.
- The ``offending stream'' is initialized by
- the @t{:stream} initialization argument to @b{make-condition},
- and is @i{accessed} by the @i{function} @b{stream-error-stream}.
- @subsubheading See Also::
- @ref{stream-error-stream}
- @node stream-error-stream, end-of-file, stream-error, Streams Dictionary
- @subsection stream-error-stream [Function]
- @code{stream-error-stream} @i{condition} @result{} @i{stream}
- @subsubheading Arguments and Values::
- @i{condition}---a @i{condition} of @i{type} @b{stream-error}.
- @i{stream}---a @i{stream}.
- @subsubheading Description::
- Returns the offending @i{stream} of a @i{condition} of @i{type} @b{stream-error}.
- @subsubheading Examples::
- @example
- (with-input-from-string (s "(FOO")
- (handler-case (read s)
- (end-of-file (c)
- (format nil "~&End of file on ~S." (stream-error-stream c)))))
- "End of file on #<String Stream>."
- @end example
- @subsubheading See Also::
- @b{stream-error},
- @ref{Conditions}
- @node end-of-file, , stream-error-stream, Streams Dictionary
- @subsection end-of-file [Condition Type]
- @subsubheading Class Precedence List::
- @b{end-of-file},
- @b{stream-error},
- @b{error},
- @b{serious-condition},
- @b{condition},
- @b{t}
- @subsubheading Description::
- The @i{type} @b{end-of-file} consists of
- error conditions related to read operations that are done on
- @i{streams} that have no more data.
- @subsubheading See Also::
- @ref{stream-error-stream}
- @c end of including dict-streams
- @c %**end of chapter
|