scheme48.html 1.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This manual is for Scheme48 version 1.3.
  4. Copyright (C) 2004, 2005, 2006 Taylor Campbell.
  5. All rights reserved.
  6. This manual includes material derived from works bearing the following
  7. notice:
  8. Copyright (C) 1993-2005 Richard Kelsey, Jonathan Rees, and
  9. Mike Sperber.
  10. All rights reserved.
  11. Redistribution and use in source and binary forms, with or without
  12. modification, are permitted provided that the following conditions
  13. are met:
  14. Redistributions of source code must retain the above copyright
  15. notice, this list of conditions and the following disclaimer.
  16. Redistributions in binary form must reproduce the above copyright
  17. notice, this list of conditions and the following disclaimer in the
  18. documentation and/or other materials provided with the distribution.
  19. The name of the authors may not be used to endorse or promote
  20. products derived from this software without specific prior written
  21. permission.
  22. THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR
  23. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
  26. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  30. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  31. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. POSSIBILITY OF SUCH DAMAGE.
  33. -->
  34. <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
  35. <head>
  36. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  37. <title>The Nearly Complete Scheme48 1.3 Reference Manual</title>
  38. <meta name="description" content="The Nearly Complete Scheme48 1.3 Reference Manual">
  39. <meta name="keywords" content="The Nearly Complete Scheme48 1.3 Reference Manual">
  40. <meta name="resource-type" content="document">
  41. <meta name="distribution" content="global">
  42. <meta name="Generator" content="makeinfo">
  43. <link href="#Top" rel="start" title="Top">
  44. <link href="#Concept-index" rel="index" title="Concept index">
  45. <link href="#SEC_Contents" rel="contents" title="Table of Contents">
  46. <style type="text/css">
  47. <!--
  48. a.summary-letter {text-decoration: none}
  49. blockquote.indentedblock {margin-right: 0em}
  50. div.display {margin-left: 3.2em}
  51. div.example {margin-left: 3.2em}
  52. div.lisp {margin-left: 3.2em}
  53. kbd {font-style: oblique}
  54. pre.display {font-family: inherit}
  55. pre.format {font-family: inherit}
  56. pre.menu-comment {font-family: serif}
  57. pre.menu-preformatted {font-family: serif}
  58. span.nolinebreak {white-space: nowrap}
  59. span.roman {font-family: initial; font-weight: normal}
  60. span.sansserif {font-family: sans-serif; font-weight: normal}
  61. ul.no-bullet {list-style: none}
  62. -->
  63. </style>
  64. </head>
  65. <body lang="en">
  66. <h1 class="settitle" align="center">The Nearly Complete Scheme48 1.3 Reference Manual</h1>
  67. <span id="SEC_Contents"></span>
  68. <h2 class="contents-heading">Table of Contents</h2>
  69. <div class="contents">
  70. <ul class="no-bullet">
  71. <li><a id="toc-Introduction" href="#Introduction-_0026-acknowledgements">1 Introduction</a>
  72. <ul class="no-bullet">
  73. <li><a id="toc-This-manual" href="#This-manual">1.1 This manual</a></li>
  74. <li><a id="toc-Acknowledgements" href="#Acknowledgements">1.2 Acknowledgements</a></li>
  75. </ul></li>
  76. <li><a id="toc-User-environment-1" href="#User-environment">2 User environment</a>
  77. <ul class="no-bullet">
  78. <li><a id="toc-Running-Scheme48-1" href="#Running-Scheme48">2.1 Running Scheme48</a>
  79. <ul class="no-bullet">
  80. <li><a id="toc-Command-processor-introduction" href="#Command-processor-introduction">2.1.1 Command processor introduction</a></li>
  81. </ul></li>
  82. <li><a id="toc-Emacs-integration-1" href="#Emacs-integration">2.2 Emacs integration</a></li>
  83. <li><a id="toc-Using-the-module-system-1" href="#Using-the-module-system">2.3 Using the module system</a>
  84. <ul class="no-bullet">
  85. <li><a id="toc-Configuration-mutation" href="#Configuration-mutation">2.3.1 Configuration mutation</a></li>
  86. <li><a id="toc-Listing-interfaces" href="#Listing-interfaces">2.3.2 Listing interfaces</a></li>
  87. </ul></li>
  88. <li><a id="toc-Command-processor-1" href="#Command-processor">2.4 Command processor</a>
  89. <ul class="no-bullet">
  90. <li><a id="toc-Basic-commands-1" href="#Basic-commands">2.4.1 Basic commands</a></li>
  91. <li><a id="toc-Switches" href="#Command-processor-switches">2.4.2 Switches</a></li>
  92. <li><a id="toc-Emacs-integration-commands-1" href="#Emacs-integration-commands">2.4.3 Emacs integration commands</a></li>
  93. <li><a id="toc-Focus-value-1" href="#Focus-value">2.4.4 Focus value</a></li>
  94. <li><a id="toc-Command-levels-1" href="#Command-levels">2.4.5 Command levels</a></li>
  95. <li><a id="toc-Module-commands-1" href="#Module-commands">2.4.6 Module commands</a></li>
  96. <li><a id="toc-SRFI-7-1" href="#SRFI-7">2.4.7 SRFI 7</a></li>
  97. <li><a id="toc-Debugging-commands-1" href="#Debugging-commands">2.4.8 Debugging commands</a></li>
  98. <li><a id="toc-Inspector-1" href="#Inspector">2.4.9 Inspector</a></li>
  99. <li><a id="toc-Command-programs-1" href="#Command-programs">2.4.10 Command programs</a></li>
  100. <li><a id="toc-Image_002dbuilding-commands-1" href="#Image_002dbuilding-commands">2.4.11 Image-building commands</a></li>
  101. <li><a id="toc-Resource-statistics-and-control-1" href="#Resource-statistics-and-control">2.4.12 Resource statistics and control</a></li>
  102. </ul></li>
  103. </ul></li>
  104. <li><a id="toc-Module-system-1" href="#Module-system">3 Module system</a>
  105. <ul class="no-bullet">
  106. <li><a id="toc-Module-system-architecture-1" href="#Module-system-architecture">3.1 Module system architecture</a></li>
  107. <li><a id="toc-Module-configuration-language-1" href="#Module-configuration-language">3.2 Module configuration language</a></li>
  108. <li><a id="toc-Macros-in-concert-with-modules-1" href="#Macros-in-concert-with-modules">3.3 Macros in concert with modules</a></li>
  109. <li><a id="toc-Static-type-system-1" href="#Static-type-system">3.4 Static type system</a>
  110. <ul class="no-bullet">
  111. <li><a id="toc-Types-in-the-configuration-language" href="#Types-in-the-configuration-language">3.4.1 Types in the configuration language</a></li>
  112. </ul></li>
  113. </ul></li>
  114. <li><a id="toc-System-facilities-1" href="#System-facilities">4 System facilities</a>
  115. <ul class="no-bullet">
  116. <li><a id="toc-System-features-1" href="#System-features">4.1 System features</a>
  117. <ul class="no-bullet">
  118. <li><a id="toc-Miscellaneous-features-1" href="#Miscellaneous-features">4.1.1 Miscellaneous features</a></li>
  119. <li><a id="toc-Various-utilities-1" href="#Various-utilities">4.1.2 Various utilities</a></li>
  120. <li><a id="toc-Filenames-1" href="#Filenames">4.1.3 Filenames</a>
  121. <ul class="no-bullet">
  122. <li><a id="toc-Filename-translations" href="#Filename-translations">4.1.3.1 Filename translations</a></li>
  123. </ul></li>
  124. <li><a id="toc-Fluid_002fdynamic-bindings-1" href="#Fluid_002fdynamic-bindings">4.1.4 Fluid/dynamic bindings</a></li>
  125. <li><a id="toc-ASCII-character-encoding-1" href="#ASCII-character-encoding">4.1.5 ASCII character encoding</a></li>
  126. <li><a id="toc-Integer-enumerations-1" href="#Integer-enumerations">4.1.6 Integer enumerations</a></li>
  127. <li><a id="toc-Cells-1" href="#Cells">4.1.7 Cells</a></li>
  128. <li><a id="toc-Queues-1" href="#Queues">4.1.8 Queues</a></li>
  129. <li><a id="toc-Hash-tables-1" href="#Hash-tables">4.1.9 Hash tables</a></li>
  130. <li><a id="toc-Weak-references-1" href="#Weak-references">4.1.10 Weak references</a>
  131. <ul class="no-bullet">
  132. <li><a id="toc-Weak-pointers" href="#Weak-pointers">4.1.10.1 Weak pointers</a></li>
  133. <li><a id="toc-Populations-_0028weak-sets_0029" href="#Populations-_0028weak-sets_0029">4.1.10.2 Populations (weak sets)</a></li>
  134. </ul></li>
  135. <li><a id="toc-Type-annotations-1" href="#Type-annotations">4.1.11 Type annotations</a></li>
  136. <li><a id="toc-Explicit-renaming-macros-1" href="#Explicit-renaming-macros">4.1.12 Explicit renaming macros</a></li>
  137. </ul></li>
  138. <li><a id="toc-Condition-system-1" href="#Condition-system">4.2 Condition system</a>
  139. <ul class="no-bullet">
  140. <li><a id="toc-Signalling_002c-handling_002c-and-representing-conditions" href="#Signalling_002c-handling_002c-and-representing-conditions">4.2.1 Signalling, handling, and representing conditions</a></li>
  141. <li><a id="toc-Displaying-conditions" href="#Displaying-conditions">4.2.2 Displaying conditions</a></li>
  142. </ul></li>
  143. <li><a id="toc-Bitwise-manipulation-1" href="#Bitwise-manipulation">4.3 Bitwise manipulation</a>
  144. <ul class="no-bullet">
  145. <li><a id="toc-Bitwise-integer-operations" href="#Bitwise-integer-operations">4.3.1 Bitwise integer operations</a></li>
  146. <li><a id="toc-Byte-vectors" href="#Byte-vectors">4.3.2 Byte vectors</a></li>
  147. </ul></li>
  148. <li><a id="toc-Generic-dispatch-system-1" href="#Generic-dispatch-system">4.4 Generic dispatch system</a></li>
  149. <li><a id="toc-I_002fO-system-1" href="#I_002fO-system">4.5 I/O system</a>
  150. <ul class="no-bullet">
  151. <li><a id="toc-Ports-1" href="#Ports">4.5.1 Ports</a>
  152. <ul class="no-bullet">
  153. <li><a id="toc-Port-operations" href="#Port-operations">4.5.1.1 Port operations</a></li>
  154. <li><a id="toc-Current-ports" href="#Current-ports">4.5.1.2 Current ports</a></li>
  155. </ul></li>
  156. <li><a id="toc-Programmatic-ports-1" href="#Programmatic-ports">4.5.2 Programmatic ports</a>
  157. <ul class="no-bullet">
  158. <li><a id="toc-Port-data-type-1" href="#Port-data-type">4.5.2.1 Port data type</a></li>
  159. <li><a id="toc-Port-handlers-1" href="#Port-handlers">4.5.2.2 Port handlers</a></li>
  160. <li><a id="toc-Buffered-ports-_0026-handlers-1" href="#Buffered-ports-_0026-handlers">4.5.2.3 Buffered ports &amp; handlers</a></li>
  161. </ul></li>
  162. <li><a id="toc-Miscellaneous-I_002fO-internals-1" href="#Miscellaneous-I_002fO-internals">4.5.3 Miscellaneous I/O internals</a></li>
  163. <li><a id="toc-Channels-1" href="#Channels">4.5.4 Channels</a>
  164. <ul class="no-bullet">
  165. <li><a id="toc-Low_002dlevel-channel-operations" href="#Low_002dlevel-channel-operations">4.5.4.1 Low-level channel operations</a></li>
  166. <li><a id="toc-Higher_002dlevel-channel-operations" href="#Higher_002dlevel-channel-operations">4.5.4.2 Higher-level channel operations</a></li>
  167. </ul></li>
  168. <li><a id="toc-Channel-ports-1" href="#Channel-ports">4.5.5 Channel ports</a></li>
  169. </ul></li>
  170. <li><a id="toc-Reader-_0026-writer-1" href="#Reader-_0026-writer">4.6 Reader &amp; writer</a>
  171. <ul class="no-bullet">
  172. <li><a id="toc-Reader-1" href="#Reader">4.6.1 Reader</a></li>
  173. <li><a id="toc-Writer-1" href="#Writer">4.6.2 Writer</a>
  174. <ul class="no-bullet">
  175. <li><a id="toc-Object-disclosure" href="#Object-disclosure">4.6.2.1 Object disclosure</a></li>
  176. </ul></li>
  177. </ul></li>
  178. <li><a id="toc-Records-1" href="#Records">4.7 Records</a>
  179. <ul class="no-bullet">
  180. <li><a id="toc-Jonathan-Rees_0027s-define_002drecord_002dtype-macro" href="#Jonathan-Rees_0027s-define_002drecord_002dtype-macro">4.7.1 Jonathan Rees&rsquo;s <code>define-record-type</code> macro</a></li>
  181. <li><a id="toc-Richard-Kelsey_0027s-define_002drecord_002dtype-macro" href="#Richard-Kelsey_0027s-define_002drecord_002dtype-macro">4.7.2 Richard Kelsey&rsquo;s <code>define-record-type</code> macro</a></li>
  182. <li><a id="toc-Record-types" href="#Record-types">4.7.3 Record types</a></li>
  183. <li><a id="toc-Low_002dlevel-record-manipulation" href="#Low_002dlevel-record-manipulation">4.7.4 Low-level record manipulation</a></li>
  184. </ul></li>
  185. <li><a id="toc-Suspending-and-resuming-heap-images-1" href="#Suspending-and-resuming-heap-images">4.8 Suspending and resuming heap images</a>
  186. <ul class="no-bullet">
  187. <li><a id="toc-System-initialization" href="#System-initialization">4.8.1 System initialization</a></li>
  188. <li><a id="toc-Manual-system-initialization" href="#Manual-system-initialization">4.8.2 Manual system initialization</a></li>
  189. </ul></li>
  190. </ul></li>
  191. <li><a id="toc-Multithreading-1" href="#Multithreading">5 Multithreading</a>
  192. <ul class="no-bullet">
  193. <li><a id="toc-Basic-thread-operations-1" href="#Basic-thread-operations">5.1 Basic thread operations</a></li>
  194. <li><a id="toc-Optimistic-concurrency-1" href="#Optimistic-concurrency">5.2 Optimistic concurrency</a>
  195. <ul class="no-bullet">
  196. <li><a id="toc-High_002dlevel-optimistic-concurrency" href="#High_002dlevel-optimistic-concurrency">5.2.1 High-level optimistic concurrency</a></li>
  197. <li><a id="toc-Logging-variants-of-Scheme-procedures" href="#Logging-variants-of-Scheme-procedures">5.2.2 Logging variants of Scheme procedures</a></li>
  198. <li><a id="toc-Synchronized-records" href="#Synchronized-records">5.2.3 Synchronized records</a></li>
  199. <li><a id="toc-Optimistic-concurrency-example" href="#Optimistic-concurrency-example">5.2.4 Optimistic concurrency example</a></li>
  200. <li><a id="toc-Low_002dlevel-optimistic-concurrency" href="#Low_002dlevel-optimistic-concurrency">5.2.5 Low-level optimistic concurrency</a></li>
  201. </ul></li>
  202. <li><a id="toc-Higher_002dlevel-synchronization-1" href="#Higher_002dlevel-synchronization">5.3 Higher-level synchronization</a>
  203. <ul class="no-bullet">
  204. <li><a id="toc-Condition-variables" href="#Condition-variables">5.3.1 Condition variables</a></li>
  205. <li><a id="toc-Placeholders" href="#Placeholders">5.3.2 Placeholders</a></li>
  206. <li><a id="toc-Value-pipes" href="#Value-pipes">5.3.3 Value pipes</a></li>
  207. </ul></li>
  208. <li><a id="toc-Concurrent-ML-1" href="#Concurrent-ML">5.4 Concurrent ML</a>
  209. <ul class="no-bullet">
  210. <li><a id="toc-Rendezvous-concepts-1" href="#Rendezvous-concepts">5.4.1 Rendezvous concepts</a></li>
  211. <li><a id="toc-Delayed-rendezvous" href="#Delayed-rendezvous">5.4.2 Delayed rendezvous</a>
  212. <ul class="no-bullet">
  213. <li><a id="toc-Negative-acknowledgements" href="#Negative-acknowledgements">5.4.2.1 Negative acknowledgements</a></li>
  214. </ul></li>
  215. <li><a id="toc-Rendezvous-combinators" href="#Rendezvous-base-combinators">5.4.3 Rendezvous combinators</a>
  216. <ul class="no-bullet">
  217. <li><a id="toc-Timing-rendezvous" href="#Timing-rendezvous">5.4.3.1 Timing rendezvous</a></li>
  218. </ul></li>
  219. <li><a id="toc-Rendezvous-communication-channels-1" href="#Rendezvous-communication-channels">5.4.4 Rendezvous communication channels</a>
  220. <ul class="no-bullet">
  221. <li><a id="toc-Synchronous-channels" href="#Synchronous-channels">5.4.4.1 Synchronous channels</a></li>
  222. <li><a id="toc-Asynchronous-channels" href="#Asynchronous-channels">5.4.4.2 Asynchronous channels</a></li>
  223. </ul></li>
  224. <li><a id="toc-Rendezvous_002dsynchronized-cells-1" href="#Rendezvous_002dsynchronized-cells">5.4.5 Rendezvous-synchronized cells</a>
  225. <ul class="no-bullet">
  226. <li><a id="toc-Placeholders_003a-single_002dassignment-cells" href="#Placeholders_003a-single_002dassignment-cells">5.4.5.1 Placeholders: single-assignment cells</a></li>
  227. <li><a id="toc-Jars_003a-multiple_002dassignment-cells" href="#Jars_003a-multiple_002dassignment-cells">5.4.5.2 Jars: multiple-assignment cells</a></li>
  228. </ul></li>
  229. <li><a id="toc-Concurrent-ML-to-Scheme-correspondence-1" href="#Concurrent-ML-to-Scheme-correspondence">5.4.6 Concurrent ML to Scheme correspondence</a></li>
  230. </ul></li>
  231. <li><a id="toc-Pessimistic-concurrency-1" href="#Pessimistic-concurrency">5.5 Pessimistic concurrency</a></li>
  232. <li><a id="toc-Custom-thread-synchronization-1" href="#Custom-thread-synchronization">5.6 Custom thread synchronization</a></li>
  233. </ul></li>
  234. <li><a id="toc-Libraries-1" href="#Libraries">6 Libraries</a>
  235. <ul class="no-bullet">
  236. <li><a id="toc-Boxed-bitwise_002dinteger-masks-1" href="#Boxed-bitwise_002dinteger-masks">6.1 Boxed bitwise-integer masks</a>
  237. <ul class="no-bullet">
  238. <li><a id="toc-Mask-types" href="#Mask-types">6.1.1 Mask types</a></li>
  239. <li><a id="toc-Masks" href="#Masks">6.1.2 Masks</a></li>
  240. </ul></li>
  241. <li><a id="toc-Enumerated_002ffinite-types-and-sets-1" href="#Enumerated_002ffinite-types-and-sets">6.2 Enumerated/finite types and sets</a>
  242. <ul class="no-bullet">
  243. <li><a id="toc-Enumerated_002ffinite-types" href="#Enumerated_002ffinite-types">6.2.1 Enumerated/finite types</a></li>
  244. <li><a id="toc-Sets-over-enumerated-types" href="#Sets-over-enumerated-types">6.2.2 Sets over enumerated types</a></li>
  245. </ul></li>
  246. <li><a id="toc-Macros-for-writing-loops-1" href="#Macros-for-writing-loops">6.3 Macros for writing loops</a>
  247. <ul class="no-bullet">
  248. <li><a id="toc-Main-looping-macros-1" href="#Main-looping-macros">6.3.1 Main looping macros</a></li>
  249. <li><a id="toc-Sequence-types-1" href="#Sequence-types">6.3.2 Sequence types</a></li>
  250. <li><a id="toc-Synchronous-sequences-1" href="#Synchronous-sequences">6.3.3 Synchronous sequences</a></li>
  251. <li><a id="toc-Examples-1" href="#Examples">6.3.4 Examples</a></li>
  252. <li><a id="toc-Defining-sequence-types-1" href="#Defining-sequence-types">6.3.5 Defining sequence types</a></li>
  253. <li><a id="toc-Loop-macro-expansion-1" href="#Loop-macro-expansion">6.3.6 Loop macro expansion</a></li>
  254. </ul></li>
  255. <li><a id="toc-Library-data-structures-1" href="#Library-data-structures">6.4 Library data structures</a>
  256. <ul class="no-bullet">
  257. <li><a id="toc-Multi_002ddimensional-arrays" href="#Multi_002ddimensional-arrays">6.4.1 Multi-dimensional arrays</a></li>
  258. <li><a id="toc-Red_002fblack-search-trees" href="#Red_002fblack-search-trees">6.4.2 Red/black search trees</a></li>
  259. <li><a id="toc-Sparse-vectors" href="#Sparse-vectors">6.4.3 Sparse vectors</a></li>
  260. </ul></li>
  261. <li><a id="toc-I_002fO-extensions-1" href="#I_002fO-extensions">6.5 I/O extensions</a></li>
  262. <li><a id="toc-TCP-_0026-UDP-sockets-1" href="#TCP-_0026-UDP-sockets">6.6 TCP &amp; UDP sockets</a>
  263. <ul class="no-bullet">
  264. <li><a id="toc-TCP-sockets" href="#TCP-sockets">6.6.1 TCP sockets</a></li>
  265. <li><a id="toc-UDP-sockets" href="#UDP-sockets">6.6.2 UDP sockets</a></li>
  266. </ul></li>
  267. <li><a id="toc-Common_002dLisp_002dstyle-formatting-1" href="#Common_002dLisp_002dstyle-formatting">6.7 Common-Lisp-style formatting</a></li>
  268. <li><a id="toc-Library-utilities-1" href="#Library-utilities">6.8 Library utilities</a>
  269. <ul class="no-bullet">
  270. <li><a id="toc-Destructuring" href="#Destructuring">6.8.1 Destructuring</a></li>
  271. <li><a id="toc-Pretty_002dprinting" href="#Pretty_002dprinting">6.8.2 Pretty-printing</a></li>
  272. <li><a id="toc-Strongly-connected-graph-components" href="#Strongly-connected-graph-components">6.8.3 Strongly connected graph components</a></li>
  273. <li><a id="toc-Nondeterminism" href="#Nondeterminism">6.8.4 Nondeterminism</a></li>
  274. <li><a id="toc-Miscellaneous-utilities" href="#Miscellaneous-utilities">6.8.5 Miscellaneous utilities</a></li>
  275. <li><a id="toc-Multiple-value-binding" href="#Multiple-value-binding">6.8.6 Multiple value binding</a></li>
  276. <li><a id="toc-Object-dumper" href="#Object-dumper">6.8.7 Object dumper</a></li>
  277. <li><a id="toc-Simple-time-access" href="#Simple-time-access">6.8.8 Simple time access</a></li>
  278. </ul></li>
  279. </ul></li>
  280. <li><a id="toc-C-interface-1" href="#C-interface">7 C interface</a>
  281. <ul class="no-bullet">
  282. <li><a id="toc-Overview-of-the-C-interface" href="#Overview-of-the-C-interface">7.1 Overview of the C interface</a>
  283. <ul class="no-bullet">
  284. <li><a id="toc-Scheme-structures" href="#Scheme-structures">7.1.1 Scheme structures</a></li>
  285. <li><a id="toc-C-naming-conventions" href="#C-naming-conventions">7.1.2 C naming conventions</a></li>
  286. <li><a id="toc-Garbage-collection" href="#Garbage-collection">7.1.3 Garbage collection</a></li>
  287. </ul></li>
  288. <li><a id="toc-Shared-bindings-between-Scheme-and-C-1" href="#Shared-bindings-between-Scheme-and-C">7.2 Shared bindings between Scheme and C</a>
  289. <ul class="no-bullet">
  290. <li><a id="toc-Scheme-shared-binding-interface" href="#Scheme-shared-binding-interface">7.2.1 Scheme shared binding interface</a></li>
  291. <li><a id="toc-C-shared-binding-interface" href="#C-shared-binding-interface">7.2.2 C shared binding interface</a></li>
  292. </ul></li>
  293. <li><a id="toc-Calling-C-functions-from-Scheme-1" href="#Calling-C-functions-from-Scheme">7.3 Calling C functions from Scheme</a></li>
  294. <li><a id="toc-Dynamic-loading-of-C-modules-1" href="#Dynamic-loading-of-C-modules">7.4 Dynamic loading of C modules</a>
  295. <ul class="no-bullet">
  296. <li><a id="toc-Old-dynamic-loading-interface" href="#Old-dynamic-loading-interface">7.4.1 Old dynamic loading interface</a></li>
  297. </ul></li>
  298. <li><a id="toc-Accessing-Scheme-data-from-C-1" href="#Accessing-Scheme-data-from-C">7.5 Accessing Scheme data from C</a></li>
  299. <li><a id="toc-Calling-Scheme-procedures-from-C-1" href="#Calling-Scheme-procedures-from-C">7.6 Calling Scheme procedures from C</a></li>
  300. <li><a id="toc-Interacting-with-the-Scheme-heap-in-C-1" href="#Interacting-with-the-Scheme-heap-in-C">7.7 Interacting with the Scheme heap in C</a>
  301. <ul class="no-bullet">
  302. <li><a id="toc-Keeping-C-data-structures-in-the-Scheme-heap" href="#Keeping-C-data-structures-in-the-Scheme-heap">7.7.1 Keeping C data structures in the Scheme heap</a></li>
  303. <li><a id="toc-C-code-and-heap-images" href="#C-code-and-heap-images">7.7.2 C code and heap images</a></li>
  304. </ul></li>
  305. <li><a id="toc-Using-Scheme-records-in-C-1" href="#Using-Scheme-records-in-C">7.8 Using Scheme records in C</a></li>
  306. <li><a id="toc-Raising-exceptions-from-C-1" href="#Raising-exceptions-from-C">7.9 Raising exceptions from C</a></li>
  307. <li><a id="toc-Unsafe-C-macros-1" href="#Unsafe-C-macros">7.10 Unsafe C macros</a></li>
  308. </ul></li>
  309. <li><a id="toc-POSIX-interface-1" href="#POSIX-interface">8 POSIX interface</a>
  310. <ul class="no-bullet">
  311. <li><a id="toc-Processes" href="#POSIX-processes">8.1 Processes</a></li>
  312. <li><a id="toc-Signals" href="#POSIX-signals">8.2 Signals</a>
  313. <ul class="no-bullet">
  314. <li><a id="toc-Sending-_0026-receiving-signals" href="#Sending-_0026-receiving-signals">8.2.1 Sending &amp; receiving signals</a></li>
  315. </ul></li>
  316. <li><a id="toc-Process-environment" href="#POSIX-process-environment">8.3 Process environment</a></li>
  317. <li><a id="toc-Users-and-groups" href="#POSIX-users-and-groups">8.4 Users and groups</a></li>
  318. <li><a id="toc-Host-OS-and-machine-identification" href="#POSIX-host-OS-and-machine-identification">8.5 Host OS and machine identification</a></li>
  319. <li><a id="toc-File-system-access" href="#POSIX-file-system-access">8.6 File system access</a></li>
  320. <li><a id="toc-Time" href="#POSIX-time">8.7 Time</a></li>
  321. <li><a id="toc-I_002fO-utilities" href="#POSIX-I_002fO-utilities">8.8 I/O utilities</a></li>
  322. <li><a id="toc-Regular-expressions" href="#POSIX-regular-expressions">8.9 Regular expressions</a>
  323. <ul class="no-bullet">
  324. <li><a id="toc-Direct-POSIX-regular-expression-interface" href="#Direct-POSIX-regular-expression-interface">8.9.1 Direct POSIX regular expression interface</a></li>
  325. <li><a id="toc-High_002dlevel-regular-expression-construction" href="#High_002dlevel-regular-expression-construction">8.9.2 High-level regular expression construction</a>
  326. <ul class="no-bullet">
  327. <li><a id="toc-Character-sets" href="#Character-sets">8.9.2.1 Character sets</a></li>
  328. <li><a id="toc-Anchoring" href="#Anchoring">8.9.2.2 Anchoring</a></li>
  329. <li><a id="toc-Composite-expressions" href="#Composite-expressions">8.9.2.3 Composite expressions</a></li>
  330. <li><a id="toc-Case-sensitivity" href="#Case-sensitivity">8.9.2.4 Case sensitivity</a></li>
  331. <li><a id="toc-Submatches-and-matching" href="#Submatches-and-matching">8.9.2.5 Submatches and matching</a></li>
  332. </ul></li>
  333. </ul></li>
  334. <li><a id="toc-C-to-Scheme-correspondence" href="#POSIX-C-to-Scheme-correspondence">8.10 C to Scheme correspondence</a></li>
  335. </ul></li>
  336. <li><a id="toc-Pre_002dScheme_003a-A-low_002dlevel-dialect-of-Scheme" href="#Pre_002dScheme">9 Pre-Scheme: A low-level dialect of Scheme</a>
  337. <ul class="no-bullet">
  338. <li><a id="toc-Differences-between-Pre_002dScheme-_0026-Scheme-1" href="#Differences-between-Pre_002dScheme-_0026-Scheme">9.1 Differences between Pre-Scheme &amp; Scheme</a></li>
  339. <li><a id="toc-Type-specifiers" href="#Pre_002dScheme-type-specifiers">9.2 Type specifiers</a></li>
  340. <li><a id="toc-Standard-environment" href="#Standard-Pre_002dScheme-environment">9.3 Standard environment</a>
  341. <ul class="no-bullet">
  342. <li><a id="toc-Scheme-bindings" href="#Scheme-bindings-in-Pre_002dScheme">9.3.1 Scheme bindings</a></li>
  343. <li><a id="toc-Tail-call-optimization" href="#Tail-call-optimization-in-Pre_002dScheme">9.3.2 Tail call optimization</a></li>
  344. <li><a id="toc-Bitwise-manipulation-2" href="#Pre_002dScheme-bitwise-manipulation">9.3.3 Bitwise manipulation</a></li>
  345. <li><a id="toc-Compound-data-manipulation" href="#Compound-Pre_002dScheme-data-manipulation">9.3.4 Compound data manipulation</a></li>
  346. <li><a id="toc-Error-handling" href="#Pre_002dScheme-error-handling">9.3.5 Error handling</a></li>
  347. <li><a id="toc-Input-_0026-output" href="#Input-_0026-output-in-Pre_002dScheme">9.3.6 Input &amp; output</a></li>
  348. <li><a id="toc-Access-to-C-functions-and-macros" href="#Pre_002dScheme-access-to-C-functions-and-macros">9.3.7 Access to C functions and macros</a></li>
  349. </ul></li>
  350. <li><a id="toc-More-Pre_002dScheme-packages-1" href="#More-Pre_002dScheme-packages">9.4 More Pre-Scheme packages</a>
  351. <ul class="no-bullet">
  352. <li><a id="toc-Floating-point-operation" href="#Pre_002dScheme-floating-point-operation">9.4.1 Floating point operation</a></li>
  353. <li><a id="toc-Record-types-1" href="#Pre_002dScheme-record-types">9.4.2 Record types</a></li>
  354. <li><a id="toc-Multiple-return-values" href="#Multiple-return-values-in-Pre_002dScheme">9.4.3 Multiple return values</a></li>
  355. <li><a id="toc-Low_002dlevel-memory-manipulation" href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">9.4.4 Low-level memory manipulation</a></li>
  356. </ul></li>
  357. <li><a id="toc-Invoking-the-Pre_002dScheme-compiler-1" href="#Invoking-the-Pre_002dScheme-compiler">9.5 Invoking the Pre-Scheme compiler</a>
  358. <ul class="no-bullet">
  359. <li><a id="toc-Loading-the-compiler" href="#Loading-the-compiler">9.5.1 Loading the compiler</a></li>
  360. <li><a id="toc-Calling-the-compiler" href="#Calling-the-compiler">9.5.2 Calling the compiler</a></li>
  361. </ul></li>
  362. <li><a id="toc-Example-Pre_002dScheme-compiler-usage-1" href="#Example-Pre_002dScheme-compiler-usage">9.6 Example Pre-Scheme compiler usage</a></li>
  363. <li><a id="toc-Running-Pre_002dScheme-as-Scheme-1" href="#Running-Pre_002dScheme-as-Scheme">9.7 Running Pre-Scheme as Scheme</a></li>
  364. </ul></li>
  365. <li><a id="toc-References-1" href="#References">References</a></li>
  366. <li><a id="toc-Concept-index-1" href="#Concept-index" rel="index">Concept index</a></li>
  367. <li><a id="toc-Binding-index-1" href="#Binding-index" rel="index">Binding index</a></li>
  368. <li><a id="toc-Structure-index-1" href="#Structure-index" rel="index">Structure index</a></li>
  369. </ul>
  370. </div>
  371. <span id="Top"></span><div class="header">
  372. <p>
  373. Next: <a href="#Introduction-_0026-acknowledgements" accesskey="n" rel="next">Introduction &amp; acknowledgements</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  374. </div>
  375. <span id="The-Nearly-Complete-Scheme48-Reference-Manual"></span><h1 class="top">The Nearly Complete Scheme48 Reference Manual</h1>
  376. <p>This manual is for Scheme48 version 1.3.
  377. </p>
  378. <p>Copyright &copy; 2004, 2005, 2006 Taylor Campbell.
  379. All rights reserved.
  380. </p>
  381. <p>This manual includes material derived from works bearing the following
  382. notice:
  383. </p>
  384. <p>Copyright &copy; 1993&ndash;2005 Richard Kelsey, Jonathan Rees, and
  385. Mike Sperber.
  386. All rights reserved.
  387. </p>
  388. <blockquote>
  389. <p>Redistribution and use in source and binary forms, with or without
  390. modification, are permitted provided that the following conditions
  391. are met:
  392. </p>
  393. <ul>
  394. <li> Redistributions of source code must retain the above copyright
  395. notice, this list of conditions and the following disclaimer.
  396. </li><li> Redistributions in binary form must reproduce the above copyright
  397. notice, this list of conditions and the following disclaimer in the
  398. documentation and/or other materials provided with the distribution.
  399. </li><li> The name of the authors may not be used to endorse or promote
  400. products derived from this software without specific prior written
  401. permission.
  402. </li></ul>
  403. </blockquote>
  404. <p>THIS SOFTWARE IS PROVIDED BY THE AUTHORS &ldquo;AS IS&rdquo; AND ANY EXPRESS OR
  405. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  406. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  407. DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
  408. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  409. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  410. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  411. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  412. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  413. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  414. POSSIBILITY OF SUCH DAMAGE.
  415. </p>
  416. <table class="menu" border="0" cellspacing="0">
  417. <tr><td align="left" valign="top">&bull; <a href="#Introduction-_0026-acknowledgements" accesskey="1">Introduction &amp; acknowledgements</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  418. </td></tr>
  419. <tr><td align="left" valign="top">&bull; <a href="#User-environment" accesskey="2">User environment</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  420. </td></tr>
  421. <tr><td align="left" valign="top">&bull; <a href="#Module-system" accesskey="3">Module system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  422. </td></tr>
  423. <tr><td align="left" valign="top">&bull; <a href="#System-facilities" accesskey="4">System facilities</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  424. </td></tr>
  425. <tr><td align="left" valign="top">&bull; <a href="#Multithreading" accesskey="5">Multithreading</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  426. </td></tr>
  427. <tr><td align="left" valign="top">&bull; <a href="#Libraries" accesskey="6">Libraries</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  428. </td></tr>
  429. <tr><td align="left" valign="top">&bull; <a href="#C-interface" accesskey="7">C interface</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  430. </td></tr>
  431. <tr><td align="left" valign="top">&bull; <a href="#POSIX-interface" accesskey="8">POSIX interface</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  432. </td></tr>
  433. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme" accesskey="9">Pre-Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A low-level dialect of Scheme
  434. </td></tr>
  435. <tr><td align="left" valign="top">&bull; <a href="#References">References</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  436. </td></tr>
  437. <tr><td align="left" valign="top">&bull; <a href="#Concept-index" rel="index">Concept index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  438. </td></tr>
  439. <tr><td align="left" valign="top">&bull; <a href="#Binding-index" rel="index">Binding index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  440. </td></tr>
  441. <tr><td align="left" valign="top">&bull; <a href="#Structure-index" rel="index">Structure index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  442. </td></tr>
  443. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  444. </pre></th></tr></table>
  445. <hr>
  446. <span id="Introduction-_0026-acknowledgements"></span><div class="header">
  447. <p>
  448. Next: <a href="#User-environment" accesskey="n" rel="next">User environment</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  449. </div>
  450. <span id="Introduction"></span><h2 class="chapter">1 Introduction</h2>
  451. <p>Scheme48 is an implementation of Scheme based on a byte-code virtual
  452. machine with design goals of simplicity and cleanliness. To briefly
  453. enumerate some interesting aspects of it, Scheme48 features:
  454. </p><ul>
  455. <li> an advanced module system based on Jonathan Rees&rsquo;s W7 security kernel
  456. with well-integrated interaction between macros and modules;
  457. </li><li> a virtual machine written in a dialect of Scheme itself, Pre-Scheme,
  458. for which a compiler is written with Scheme48;
  459. </li><li> a sophisticated, user-level, pre&euml;mptive multithreading system with
  460. numerous high-level concurrency abstractions;
  461. </li><li> a composable, lock-free shared-memory thread synchronization mechanism
  462. known as <em>optimistic concurrency</em>; and
  463. </li><li> an advanced user environment that is well-integrated with the module
  464. and thread systems to facilitate very rapid development of software
  465. systems scaling from small to large and single-threaded to
  466. multi-threaded.
  467. </li></ul>
  468. <p>It was originally written by Jonathan Rees and Richard Kelsey in 1986
  469. in response to the fact that so many Lisp implementations had started
  470. out simple and grown to be complex monsters of projects. It has been
  471. used in a number of research areas, including:
  472. </p><ul>
  473. <li> mobile robots at Cornell [Donald 92];
  474. </li><li> a multi-user collaboration system, sometimes known as a &lsquo;MUD&rsquo;
  475. (&lsquo;multi-user dungeon&rsquo;) or &lsquo;MUSE&rsquo; (&lsquo;multi-user simulation environment&rsquo;),
  476. as well as general research in capability-based security [Museme; Rees
  477. 96]; and
  478. </li><li> advanced distributed computing with higher-order mobile agents at NEC&rsquo;s
  479. Princeton research lab [Cejtin <i>et al.</i> 95].
  480. </li></ul>
  481. <p>The system is tied together in a modular fashion by a configuration
  482. language that permits quite easy mixing and matching of components, so
  483. much so that Scheme48 can be used essentially as its own OS, as it was
  484. in Cornell&rsquo;s mobile robots program, or just as easily within another,
  485. as the standard distribution is. The standard distribution is quite
  486. portable and needs only a 32-bit byte-addressed POSIX system.
  487. </p>
  488. <p>The name &lsquo;Scheme48&rsquo; commemorates the time it took Jonathan Rees and
  489. Richard Kelsey to originally write Scheme48 on August 6th &amp; 7th, 1986:
  490. forty-eight hours. (It has been joked that the system has expanded to
  491. such a size now that it requires forty-eight hours to <em>read</em> the
  492. source.)
  493. </p>
  494. <span id="This-manual"></span><h3 class="section">1.1 This manual</h3>
  495. <p>This manual begins in the form of an introduction to the usage of
  496. Scheme48, suitable for those new to the system, after which it is
  497. primarily a reference material, organized by subject. Included in the
  498. manual is also a complete reference manual for Pre-Scheme, a low-level
  499. dialect of Scheme for systems programming and in which the Scheme48
  500. virtual machine is written; see <a href="#Pre_002dScheme">Pre-Scheme</a>.
  501. </p>
  502. <p>This manual is, except for some sections pilfered and noted as such
  503. from the official but incomplete Scheme48 reference manual, solely the
  504. work of Taylor Campbell, on whom all responsibility for the content of
  505. the manual lies. The authors of Scheme48 do not endorse this manual.
  506. </p>
  507. <span id="Acknowledgements"></span><h3 class="section">1.2 Acknowledgements</h3>
  508. <p>Thanks to Jonathan Rees and Richard Kelsey for having decided so many
  509. years ago to make a simple Scheme implementation with a clean design in
  510. the first place, and for having worked on it so hard for so many years
  511. (almost twenty!); to Martin Gasbichler and Mike Sperber, for having
  512. picked up Scheme48 in the past couple years when Richard and Jonathan
  513. were unable to work actively on it; to Jeremy Fincher for having asked
  514. numerous questions about Scheme48 as he gathered knowledge from which
  515. he intended to build an implementation of his own Lisp dialect, thereby
  516. inducing me to decide to write the manual in the first place; to Jorgen
  517. Sch&auml;fer, for having also asked so many questions, proofread various
  518. drafts, and made innumerable suggestions to the manual.
  519. </p><hr>
  520. <span id="User-environment"></span><div class="header">
  521. <p>
  522. Next: <a href="#Module-system" accesskey="n" rel="next">Module system</a>, Previous: <a href="#Introduction-_0026-acknowledgements" accesskey="p" rel="prev">Introduction &amp; acknowledgements</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  523. </div>
  524. <span id="User-environment-1"></span><h2 class="chapter">2 User environment</h2>
  525. <table class="menu" border="0" cellspacing="0">
  526. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Running-Scheme48" accesskey="1">Running Scheme48</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  527. </td></tr>
  528. <tr><td align="left" valign="top">&bull; <a href="#Emacs-integration" accesskey="2">Emacs integration</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  529. </td></tr>
  530. <tr><td align="left" valign="top">&bull; <a href="#Using-the-module-system" accesskey="3">Using the module system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  531. </td></tr>
  532. <tr><td align="left" valign="top">&bull; <a href="#Command-processor" accesskey="4">Command processor</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  533. </td></tr>
  534. </table>
  535. <hr>
  536. <span id="Running-Scheme48"></span><div class="header">
  537. <p>
  538. Next: <a href="#Emacs-integration" accesskey="n" rel="next">Emacs integration</a>, Up: <a href="#User-environment" accesskey="u" rel="up">User environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  539. </div>
  540. <span id="Running-Scheme48-1"></span><h3 class="section">2.1 Running Scheme48</h3>
  541. <span id="index-heap-image-resumption"></span>
  542. <span id="index-resuming-heap-images"></span>
  543. <p>Scheme48 is run by invoking its virtual machine on a dumped heap image
  544. to resume a saved system state. The common case of invoking the
  545. default image, <samp>scheme48.image</samp>, which contains the usual command
  546. processor, run-time system, <i>&amp;c.</i>, is what the <code>scheme48</code>
  547. script that is installed does. The actual virtual machine executable
  548. itself, <code>scheme48vm</code>, is typically not installed into an
  549. executable directory such as <samp>/usr/local/bin/</samp> on Unix, but in
  550. the Scheme48 library directory, which is, by default on Unix
  551. installations of Scheme48, <samp>/usr/local/lib/</samp>. However, both
  552. <code>scheme48</code> and <code>scheme48vm</code> share the following
  553. command-line options; the only difference is that <code>scheme48</code>
  554. has a default <samp>-i</samp> argument.
  555. </p>
  556. <dl compact="compact">
  557. <dt><samp>-h <var>heap-size</var></samp></dt>
  558. <dd><span id="index-heap-size"></span>
  559. <span id="index-memory-size"></span>
  560. <p>The size of Scheme48&rsquo;s heap, in cells. By default, the heap size is 3
  561. megacells, or 12 megabytes, permitting 6 megabytes per semispace &mdash;
  562. Scheme48 uses a simple stop &amp; copy garbage collector.<a id="DOCF1" href="#FOOT1"><sup>1</sup></a> Since
  563. the current garbage collector cannot resize the heap dynamically if it
  564. becomes consistently too full, users on machines with much RAM may be
  565. more comfortable with liberally increasing this option.
  566. </p>
  567. </dd>
  568. <dt><samp>-s <var>stack-size</var></samp></dt>
  569. <dd><span id="index-stack-size"></span>
  570. <p>The stack size, in cells. The default stack size is 10000 bytes, or
  571. 2500 cells. Note that this is only the size of the stack cache
  572. segment of memory for fast stack frame storage. When this overflows,
  573. there is no error; instead, Scheme48 simply copies the contents of the
  574. stack cache into the heap, until the frames it copied into the heap
  575. are needed later, at which point they are copied back into the stack
  576. cache. The <samp>-s</samp> option therefore affects only performance, not
  577. the probability of fatal stack overflow errors.
  578. </p>
  579. </dd>
  580. <dt><samp>-i <var>image-filename</var></samp></dt>
  581. <dd><p>The filename of the suspended heap image to resume. When running the
  582. <code>scheme48</code> executable, the default is the regular Scheme48
  583. image; when running the virtual machine directly, this option must be
  584. passed explicitly. For information on creating custom heap images,
  585. see <a href="#Image_002dbuilding-commands">Image-building commands</a>, and also see <a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a>.
  586. </p>
  587. </dd>
  588. <dt><samp>-a <var>argument</var> &hellip;</samp></dt>
  589. <dd><p>Command-line arguments to pass to the heap image&rsquo;s resumer, rather than
  590. being parsed by the virtual machine. In the usual Scheme48 command
  591. processor image, these arguments are put in a list of strings that will
  592. be the initial <a href="#Focus-value">focus value</a>.
  593. </p>
  594. </dd>
  595. <dt><samp>-u</samp></dt>
  596. <dd><span id="index-undefined-imported-bindings"></span>
  597. <p>Muffles warnings on startup about undefined imported foreign bindings.
  598. </p></dd>
  599. </dl>
  600. <span id="index-batch-mode"></span>
  601. <p>The usual Scheme48 image may accept an argument of <code>batch</code>, using
  602. the <samp>-a</samp> switch to the virtual machine. This enters Scheme48
  603. in batch mode, which displays no welcoming banner, prints no prompt
  604. for inputs, and exits when an EOF is read. This may be used to run
  605. scripts from the command-line, often in the <a href="#Command-programs">exec language</a>, by sending text to Scheme48 through Unix
  606. pipes or shell heredocs. For example, this Unix shell command will
  607. load the command program in the file <samp>foo.scm</samp> into the exec
  608. language environment and exit Scheme48 when the program returns:
  609. </p>
  610. <div class="example">
  611. <pre class="example">echo ,exec ,load foo.scm | scheme48 -a batch</pre></div>
  612. <p>This Unix shell command will load <samp>packages.scm</samp> into the module
  613. language environment, open the <code>tests</code> structure into the user
  614. environment, and call the procedure <code>run-tests</code> with zero
  615. arguments:
  616. </p>
  617. <div class="example">
  618. <pre class="example">scheme48 -a batch &lt;&lt;END
  619. ,config ,load packages.scm
  620. ,open tests
  621. (run-tests)
  622. END</pre></div>
  623. <p>Scheme48 also supports [SRFI 22] and [SRFI 7] by providing R5RS and
  624. [SRFI 7] script interpreters in the location where Scheme48 binaries
  625. are kept as <code>scheme-r5rs</code> and <code>scheme-srfi-7</code>. See the
  626. [SRFI 22] and [SRFI 7] documents for more details. Scheme48&rsquo;s command
  627. processor also has commands for loading [SRFI 7] programs, with or
  628. without a [SRFI 22] script header; see <a href="#SRFI-7">SRFI 7</a>.
  629. </p>
  630. <span id="Command-processor-introduction"></span><h4 class="subsection">2.1.1 Command processor introduction</h4>
  631. <p>The Scheme48 command processor is started up on resumption of the usual
  632. Scheme48 image. This is by default what the <code>scheme48</code> script
  633. installed by Scheme48 does. It will first print out a banner that
  634. contains some general information about the system, which will typically
  635. look something like this:
  636. </p>
  637. <div class="example">
  638. <pre class="example">Welcome to Scheme 48 1.3 (made by root on Sun Jul 10 10:57:03 EDT 2005)
  639. Copyright (c) 1993-2005 by Richard Kelsey and Jonathan Rees.
  640. Please report bugs to scheme-48-bugs@s48.org.
  641. Get more information at http://www.s48.org/.
  642. Type ,? (comma question-mark) for help.</pre></div>
  643. <p>After the banner, it will initiate a REPL (read-eval-print loop). At
  644. first, there should be a simple &lsquo;<samp>&gt;</samp>&rsquo; prompt. The command processor
  645. interprets Scheme code as well as <em>commands</em>. Commands operate the
  646. system at a level above or outside Scheme. They begin with a comma, and
  647. they continue until the end of the line, unless they expect a Scheme
  648. expression argument, which may continue as many lines as desired. Here
  649. is an example of a command invocation:
  650. </p>
  651. <div class="example">
  652. <pre class="example">&gt; ,set load-noisily on</pre></div>
  653. <p>This will set the <a href="#Command-processor-switches"><code>load-noisily</code> switch</a> on.
  654. </p>
  655. <p><strong>Note:</strong> If a command accepts a Scheme expression argument that
  656. is followed by more arguments, all of the arguments after the Scheme
  657. expression must be put on the same line as the last line of the Scheme
  658. expression.
  659. </p>
  660. <p>Certain operations, such as breakpoints and errors, result in a
  661. recursive command processor to be invoked. This is known as
  662. <em>pushing a command level</em>. See <a href="#Command-levels">Command levels</a>. Also, the
  663. command processor supports an <em>object inspector</em>, an interactive
  664. program for inspecting the components of objects, including continuation
  665. or stack frame objects; the debugger is little more than the inspector,
  666. working on continuations. See <a href="#Inspector">Inspector</a>.
  667. </p>
  668. <p>Evaluation of code takes place in the <em>interaction environment</em>.
  669. (This is what R5RS&rsquo;s <code>interaction-environment</code> returns.)
  670. Initially, this is the <em>user environment</em>, which by default is a
  671. normal R5RS Scheme environment. There are commands that set the
  672. interaction environment and evaluate code in other environments, too;
  673. see <a href="#Module-commands">Module commands</a>.
  674. </p>
  675. <p>The command processor&rsquo;s prompt has a variety of forms. As above, it
  676. starts out with as a simple &lsquo;<samp>&gt;</samp>&rsquo;. Several factors can affect the
  677. prompt. The complete form of the prompt is as follows:
  678. </p>
  679. <ul>
  680. <li> It begins with an optional <a href="#Command-levels">command level</a>
  681. number: at the top level, there is no command level number; as command
  682. levels are pushed, the number is incremented, starting at 1.
  683. </li><li> Optionally, the name of the interaction environment follows the
  684. command level number: if the interaction environment is the user
  685. environment, there is no name printed here; named environments are
  686. printed with their names; unnamed environments (usually created using
  687. the <code>,new-package</code> command; see <a href="#Module-commands">Module commands</a>) are
  688. printed with their numeric identifiers. If a command level number
  689. preceded an environment name, a space is printed between them.
  690. </li><li> If the command processor is in the regular REPL mode, it ends with a
  691. &lsquo;<samp>&gt;</samp>&rsquo; and a space before the user input area; if it is in
  692. <a href="#Inspector">inspector mode</a>, it ends with a &lsquo;<samp>:</samp>&rsquo; and a
  693. space before the user input area.
  694. </li></ul>
  695. <p>For example, this prompt denotes that the user is in inspector mode at
  696. command level 3 and that the interaction environment is an environment
  697. named <code>frobozz</code>:
  698. </p>
  699. <div class="example">
  700. <pre class="example">3 frobozz: </pre></div>
  701. <p>This prompt shows that the user is in the regular REPL mode at the top
  702. level, but in the <a href="#Module-commands">environment for module
  703. descriptions</a>:
  704. </p>
  705. <div class="example">
  706. <pre class="example">config&gt; </pre></div>
  707. <p>For a complete listing of all the commands in the command processor,
  708. see <a href="#Command-processor">Command processor</a>.
  709. </p>
  710. <hr>
  711. <span id="Emacs-integration"></span><div class="header">
  712. <p>
  713. Next: <a href="#Using-the-module-system" accesskey="n" rel="next">Using the module system</a>, Previous: <a href="#Running-Scheme48" accesskey="p" rel="prev">Running Scheme48</a>, Up: <a href="#User-environment" accesskey="u" rel="up">User environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  714. </div>
  715. <span id="Emacs-integration-1"></span><h3 class="section">2.2 Emacs integration</h3>
  716. <p>Emacs is the canonical development environment for Scheme48. The
  717. <samp>scheme.el</samp> and <samp>cmuscheme.el</samp> packages provide support for
  718. editing Scheme code and running inferior Scheme processes,
  719. respectively. Also, the <samp>scheme48.el</samp> package provides more
  720. support for integrating directly with
  721. Scheme48.<a id="DOCF2" href="#FOOT2"><sup>2</sup></a> <samp>scheme.el</samp> and
  722. <samp>cmuscheme.el</samp> come with GNU Emacs; <samp>scheme48.el</samp> is
  723. available separately from
  724. </p>
  725. <div class="display">
  726. <pre class="display"><a href="http://www.emacswiki.org/cgi-bin/wiki/download/scheme48.el">http://www.emacswiki.org/cgi-bin/wiki/download/scheme48.el</a>.</pre></div>
  727. <p>To load <samp>scheme48.el</samp> if it is in the directory <var>emacs-dir</var>,
  728. add these lines to your <samp>.emacs</samp>:
  729. </p>
  730. <div class="lisp">
  731. <pre class="lisp">(add-to-list 'load-path &quot;<var>emacs-dir</var>/&quot;)
  732. (autoload 'scheme48-mode &quot;scheme48&quot;
  733. &quot;Major mode for improved Scheme48 integration.&quot;
  734. t)
  735. (add-hook 'hack-local-variables-hook
  736. (lambda ()
  737. (if (and (boundp 'scheme48-package)
  738. scheme48-package)
  739. (progn (scheme48-mode)
  740. (hack-local-variables-prop-line)))))</pre></div>
  741. <p>The <code>add-hook</code> call sets Emacs up so that any file with a
  742. <code>scheme48-package</code> local variable specified in the file&rsquo;s
  743. <code>-*-</code> line or <code>Local Variables</code> section will be entered in
  744. Scheme48 mode. Files should use the <code>scheme48-package</code> variable
  745. to enable Scheme48 mode; they should not specify Scheme48 mode
  746. explicitly, since this would fail in Emacs instances without
  747. <samp>scheme48.el</samp>. That is, put this at the tops of files:
  748. </p>
  749. <div class="lisp">
  750. <pre class="lisp">;;; -*- Mode: Scheme; scheme48-package: ... -*-</pre></div>
  751. <p>Avoid this at the tops of files:
  752. </p>
  753. <div class="lisp">
  754. <pre class="lisp">;;; -*- Mode: Scheme48 -*- </pre></div>
  755. <p>There is also SLIME48, the Superior Lisp Interaction Mode for Emacs
  756. with Scheme48. It provides a considerably higher level of integration
  757. the other Emacs packages do, although it is less mature. It is at
  758. </p>
  759. <div class="display">
  760. <pre class="display"><a href="http://mumble.net/~campbell/scheme/slime48.tar.gz">http://mumble.net/~campbell/scheme/slime48.tar.gz</a>;</pre></div>
  761. <p>there is also a Darcs repository<a id="DOCF3" href="#FOOT3"><sup>3</sup></a> at
  762. </p>
  763. <div class="display">
  764. <pre class="display"><a href="http://mumble.net/~campbell/darcs/slime48/">http://mumble.net/~campbell/darcs/slime48/</a>.</pre></div>
  765. <p>Finally, <samp>paredit.el</samp> implements pseudo-structural editing
  766. facilities for S-expressions: it automatically balances parentheses and
  767. provides a number of high-level operations on S-expressions.
  768. <samp>Paredit.el</samp> is available on the web at
  769. </p>
  770. <div class="display">
  771. <pre class="display"><a href="http://mumble.net/~campbell/emacs/paredit.el">http://mumble.net/~campbell/emacs/paredit.el</a>.</pre></div>
  772. <p><samp>cmuscheme.el</samp> defines these:
  773. </p>
  774. <dl>
  775. <dt id="index-run_002dscheme">Emacs command: <strong>run-scheme</strong> <em>[scheme-prog]</em></dt>
  776. <dd><p>Starts an inferior Scheme process or switches to a running one. With
  777. no argument, this uses the value of <code>scheme-program-name</code> to run
  778. the inferior Scheme system; with a prefix argument <var>scheme-prog</var>,
  779. this invokes <var>scheme-prog</var>.
  780. </p></dd></dl>
  781. <dl>
  782. <dt id="index-scheme_002dprogram_002dname">Emacs variable: <strong>scheme-program-name</strong></dt>
  783. <dd><p>The Scheme program to invoke for inferior Scheme processes.
  784. </p></dd></dl>
  785. <p>Under <code>scheme48-mode</code> with <samp>scheme.el</samp>, <samp>cmuscheme.el</samp>,
  786. and <samp>scheme48.el</samp>, these keys are defined:
  787. </p>
  788. <dl compact="compact">
  789. <dt><kbd>C-M-f</kbd> &mdash; <code>forward-sexp</code></dt>
  790. <dt><kbd>C-M-b</kbd> &mdash; <code>backward-sexp</code></dt>
  791. <dt><kbd>C-M-k</kbd> &mdash; <code>kill-sexp</code></dt>
  792. <dt><kbd><span class="key">ESC</span> C-<span class="key">DEL</span></kbd> (<em>not</em> <kbd>C-M-<span class="key">DEL</span></kbd>) &mdash; <code>backward-kill-sexp</code></dt>
  793. <dt><kbd>C-M-q</kbd> &mdash; <code>indent-sexp</code></dt>
  794. <dt><kbd>C-M-@</kbd> &mdash; <code>mark-sexp</code></dt>
  795. <dt><kbd>C-M-<span class="key">SPC</span></kbd> &mdash; <code>mark-sexp</code></dt>
  796. <dd><p>S-expression manipulation commands. <kbd>C-M-f</kbd> moves forward by one
  797. S-expression; <kbd>C-M-b</kbd> moves backward by one. <kbd>C-M-k</kbd> kills the
  798. S-expression following the point; <kbd><span class="key">ESC</span> C-<span class="key">DEL</span></kbd> kills the
  799. S-expression preceding the point. <kbd>C-M-q</kbd> indents the S-expression
  800. following the point. <kbd>C-M-@</kbd> &amp; <kbd>C-M-<span class="key">SPC</span></kbd>, equivalent to
  801. one another, mark the S-expression following the point.
  802. </p>
  803. </dd>
  804. <dt><kbd>C-c z</kbd> &mdash; <code>switch-to-scheme</code></dt>
  805. <dd><p>Switches to the inferior Scheme process buffer.
  806. </p>
  807. </dd>
  808. <dt><kbd>C-c C-l</kbd> &mdash; <code>scheme48-load-file</code></dt>
  809. <dd><p>Loads the file corresponding with the current buffer into Scheme48. If
  810. that file was not previously loaded into Scheme48 with <kbd>C-c C-l</kbd>,
  811. Scheme48 records the current interaction environment in place as it
  812. loads the file; if the file was previously recorded, it is loaded into
  813. the recorded environment. See <a href="#Emacs-integration-commands">Emacs integration commands</a>.
  814. </p>
  815. </dd>
  816. <dt><kbd>C-c C-r</kbd> &mdash; <code>scheme48-send-region</code></dt>
  817. <dt><kbd>C-c M-r</kbd> &mdash; <code>scheme48-send-region-and-go</code></dt>
  818. <dd><p><kbd>C-c C-r</kbd> sends the currently selected region to the current
  819. inferior Scheme process. The file of the current buffer is recorded as
  820. in the <kbd>C-c C-l</kbd> command, and code is evaluated in the recorded
  821. package. <kbd>C-c M-r</kbd> does similarly, but subsequently also switches
  822. to the inferior Scheme process buffer.
  823. </p>
  824. </dd>
  825. <dt><kbd>C-M-x</kbd> &mdash; <code>scheme48-send-definition</code></dt>
  826. <dt><kbd>C-c C-e</kbd> &mdash; <code>scheme48-send-definition</code></dt>
  827. <dt><kbd>C-c M-e</kbd> &mdash; <code>scheme48-send-definition-and-go</code></dt>
  828. <dd><p><kbd>C-M-x</kbd> (GNU convention) and <kbd>C-c C-e</kbd> send the top-level
  829. definition that the current point is within to the current inferior
  830. Scheme process. <kbd>C-c M-e</kbd> does similarly, but subsequently also
  831. switches to the inferior Scheme process buffer. <kbd>C-c C-e</kbd> and
  832. <kbd>C-c M-e</kbd> also respect Scheme48&rsquo;s file/environment mapping.
  833. </p>
  834. </dd>
  835. <dt><kbd>C-x C-e</kbd> &mdash; <code>scheme48-send-last-sexp</code></dt>
  836. <dd><p>Sends the S-expression preceding the point to the inferior Scheme
  837. process. This also respects Scheme48&rsquo;s file/environment mapping.
  838. </p></dd>
  839. </dl>
  840. <hr>
  841. <span id="Using-the-module-system"></span><div class="header">
  842. <p>
  843. Next: <a href="#Command-processor" accesskey="n" rel="next">Command processor</a>, Previous: <a href="#Emacs-integration" accesskey="p" rel="prev">Emacs integration</a>, Up: <a href="#User-environment" accesskey="u" rel="up">User environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  844. </div>
  845. <span id="Using-the-module-system-1"></span><h3 class="section">2.3 Using the module system</h3>
  846. <p>Scheme48 is deeply integrated with an advanced module system. For
  847. complete detail of its module system, see <a href="#Module-system">Module system</a>. Briefly,
  848. however:
  849. </p>
  850. <ul>
  851. <li> <em>Packages</em> are top-level environments suitable for
  852. evaluating expressions and definitions, either interactively, from
  853. files loaded on-the-fly, or as the bodies of modules. They can also
  854. access bindings exported by structures by <em>opening</em> the
  855. structures.
  856. </li><li> <em>Structures</em> are libraries, or implementations of
  857. interfaces, exporting sets of bindings that packages can access.
  858. Underlying structures are usually packages, in which the user can, in
  859. some cases, interactively evaluate code during development.
  860. </li></ul>
  861. <p>Scheme48&rsquo;s usual development system, the command processor, provides a
  862. number of commands for working with the module system. For complete
  863. details, see <a href="#Module-commands">Module commands</a>. Chief among these commands are
  864. <code>,open</code> and <code>,in</code>. &lsquo;<samp>,open <var>struct</var> &hellip;</samp>&rsquo;
  865. makes all of the bindings from each of <var>struct</var> &hellip; available
  866. in the interaction environment. Many of the sections in this manual
  867. describe one or more structures with the name they are given. For
  868. example, in order to use, or open, the multi-dimensional array library
  869. in the current interaction environment, one would enter
  870. </p>
  871. <div class="lisp">
  872. <pre class="lisp">,open arrays</pre></div>
  873. <p>to the command processor. &lsquo;<samp>,in <var>struct</var></samp>&rsquo; sets the
  874. interaction environment to be the package underlying <var>struct</var>.
  875. For instance, if, during development, the user decides that the
  876. package of the existing structure <code>foo</code> should open the structure
  877. <code>bar</code>, he might type
  878. </p>
  879. <div class="lisp">
  880. <pre class="lisp">,in foo
  881. ,open bar</pre></div>
  882. <p>The initial interaction environment is known as the <em>user
  883. package</em>; the interaction environment may be reverted to the user
  884. package with the <code>,user</code> command.
  885. </p>
  886. <p>Module descriptions, or code in the <a href="#Module-configuration-language">module configuration language</a> should be loaded into the
  887. special environment for that language with the <code>,config</code> command
  888. (see <a href="#Module-commands">Module commands</a>). <i>E.g.</i>, if <samp>packages.scm</samp> contains a
  889. set of module descriptions that the user wishes to load, among which
  890. is the definition of a structure <code>frobozz</code> which he wishes to
  891. open, he will typically send the following to the command processor
  892. prompt:
  893. </p>
  894. <div class="lisp">
  895. <pre class="lisp">,config ,load packages.scm
  896. ,open frobozz</pre></div>
  897. <p><strong>Note:</strong> These are commands for the interactive command
  898. processor, <em>not</em> special directives to store in files to work
  899. with the module system. The module language is disjoint from Scheme;
  900. for complete detail on it, see <a href="#Module-system">Module system</a>.
  901. </p>
  902. <span id="Configuration-mutation"></span><h4 class="subsection">2.3.1 Configuration mutation</h4>
  903. <p><i>(This section was derived from work copyrighted &copy;
  904. 1993&ndash;2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
  905. </p>
  906. <span id="index-code-reloading"></span>
  907. <span id="index-reloading-code"></span>
  908. <p>During program development, it is often desirable to make changes to
  909. packages and interfaces. In static languages, it is usually necessary
  910. to re-compile and re-link a program in order for such changes to be
  911. reflected in a running system. Even in interactive Common Lisp
  912. systems, a change to a package&rsquo;s exports often requires reloading
  913. clients that have already mentioned names whose bindings change. In
  914. those systems, once <code>read</code> resolves a use of a name to a symbol,
  915. that resolution is fixed, so a change in the way that a name resolves
  916. to a symbol can be reflected only by re-<code>read</code>ing all such
  917. references.
  918. </p>
  919. <p>The Scheme48 development environment supports rapid turnaround in
  920. modular program development by allowing mutations to a program&rsquo;s
  921. configuration and giving a clear semantics to such mutation. The rule
  922. is that variable bindings in a running program are always resolved
  923. according to the current structure and interface bindings, even when
  924. these bindings change as a result of edits to the configuration. For
  925. example, consider the following:
  926. </p>
  927. <div class="lisp">
  928. <pre class="lisp">(define-interface foo-interface (export a c))
  929. (define-structure foo foo-interface
  930. (open scheme)
  931. (begin (define a 1)
  932. (define (b x) (+ a x))
  933. (define (c y) (* (b a) y))))
  934. (define-structure bar (export d)
  935. (open scheme foo)
  936. (begin (define (d w) (+ (b w) a))))</pre></div>
  937. <p>This program has a bug. The variable named <code>b</code>, which is free in
  938. the definition of <code>d</code>, has no binding in <code>bar</code>&rsquo;s package.
  939. Suppose that <code>b</code> was intended to be exported by <code>foo</code>, but
  940. was mistakenly omitted. It is not necessary to re-process <code>bar</code> or
  941. any of <code>foo</code>&rsquo;s other clients at this point. One need only change
  942. <code>foo-interface</code> and inform the development system of that change
  943. (using, say, an appropriate Emacs command), and <code>foo</code>&rsquo;s binding of
  944. <code>b</code> will be found when the procedure <code>d</code> is called and its
  945. reference to <code>b</code> actually evaluated.
  946. </p>
  947. <p>Similarly, it is possible to replace a structure; clients of the old
  948. structure will be modified so that they see bindings from the new one.
  949. Shadowing is also supported in the same way. Suppose that a client
  950. package <var>C</var> opens a structure <code>mumble</code> that exports a name
  951. <code>x</code>, and <code>mumble</code>&rsquo;s implementation obtains the binding of
  952. <code>x</code> from some other structure <code>frotz</code>. <var>C</var> will see the
  953. binding from <code>frotz</code>. If one then alters <code>mumble</code> so that it
  954. shadows <code>bar</code>&rsquo;s binding of <code>x</code> with a definition of its own,
  955. procedures in <var>C</var> that refer to <code>x</code> will subsequently
  956. automatically see <code>mumble</code>&rsquo;s definition instead of the one from
  957. <code>frotz</code> that they saw earlier.
  958. </p>
  959. <p>This semantics might appear to require a large amount of computation on
  960. every variable reference: the specified behaviour appears to require
  961. scanning the package&rsquo;s list of opened structures and examining their
  962. interfaces &mdash; on every variable reference evaluated, not just at
  963. compile-time. However, the development environment uses caching with
  964. cache invalidation to make variable references fast, and most of the
  965. code is invoked only when the virtual machine traps due to a reference
  966. to an undefined variable.
  967. </p>
  968. <span id="Listing-interfaces"></span><h4 class="subsection">2.3.2 Listing interfaces</h4>
  969. <span id="index-interfaces"></span>
  970. <span id="index-list_002dinterfaces"></span>
  971. <p>The <code>list-interfaces</code> structure provides a utility for examining
  972. interfaces. It is usually opened into the config package with
  973. <code>,config ,open list-interfaces</code> in order to have access to the
  974. structures &amp; interfaces easily.
  975. </p>
  976. <dl>
  977. <dt id="index-list_002dinterface">procedure: <strong>list-interface</strong> <em>struct-or-interface --&gt; unspecified</em></dt>
  978. <dd><p>Lists all of the bindings exported by <var>struct-or-interface</var> along
  979. with their <a href="#Static-type-system">static types</a>. For example,
  980. </p>
  981. <div class="lisp">
  982. <pre class="lisp">&gt; ,config ,open list-interfaces
  983. &gt; ,config (list-interface condvars)
  984. condvar-has-value? (proc (:condvar) :value)
  985. condvar-value (proc (:condvar) :value)
  986. condvar? (proc (:value) :boolean)
  987. make-condvar (proc (&amp;rest :value) :condvar)
  988. maybe-commit-and-set-condvar! (proc (:condvar :value) :boolean)
  989. maybe-commit-and-wait-for-condvar (proc (:condvar) :boolean)
  990. set-condvar-has-value?! (proc (:condvar :value) :unspecific)
  991. set-condvar-value! (proc (:condvar :value) :unspecific)</pre></div>
  992. </dd></dl>
  993. <hr>
  994. <span id="Command-processor"></span><div class="header">
  995. <p>
  996. Previous: <a href="#Using-the-module-system" accesskey="p" rel="prev">Using the module system</a>, Up: <a href="#User-environment" accesskey="u" rel="up">User environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  997. </div>
  998. <span id="Command-processor-1"></span><h3 class="section">2.4 Command processor</h3>
  999. <p>The Scheme48 command processor is the main development environment. It
  1000. incorporates a read-eval-print loop as well as an interactive inspector
  1001. and debugger. It is well-integrated with the module system for rapid
  1002. dynamic development, which is made even more convenient with the Emacs
  1003. interface, <samp>scheme48.el</samp>; see <a href="#Emacs-integration">Emacs integration</a>.
  1004. </p>
  1005. <table class="menu" border="0" cellspacing="0">
  1006. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  1007. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Basic-commands" accesskey="1">Basic commands</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1008. </td></tr>
  1009. <tr><td align="left" valign="top">&bull; <a href="#Command-processor-switches" accesskey="2">Command processor switches</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1010. </td></tr>
  1011. <tr><td align="left" valign="top">&bull; <a href="#Emacs-integration-commands" accesskey="3">Emacs integration commands</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1012. </td></tr>
  1013. <tr><td align="left" valign="top">&bull; <a href="#Focus-value" accesskey="4">Focus value</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1014. </td></tr>
  1015. <tr><td align="left" valign="top">&bull; <a href="#Command-levels" accesskey="5">Command levels</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1016. </td></tr>
  1017. <tr><td align="left" valign="top">&bull; <a href="#Module-commands" accesskey="6">Module commands</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1018. </td></tr>
  1019. <tr><td align="left" valign="top">&bull; <a href="#SRFI-7" accesskey="7">SRFI 7</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1020. </td></tr>
  1021. <tr><td align="left" valign="top">&bull; <a href="#Debugging-commands" accesskey="8">Debugging commands</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1022. </td></tr>
  1023. <tr><td align="left" valign="top">&bull; <a href="#Inspector" accesskey="9">Inspector</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1024. </td></tr>
  1025. <tr><td align="left" valign="top">&bull; <a href="#Command-programs">Command programs</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1026. </td></tr>
  1027. <tr><td align="left" valign="top">&bull; <a href="#Image_002dbuilding-commands">Image-building commands</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1028. </td></tr>
  1029. <tr><td align="left" valign="top">&bull; <a href="#Resource-statistics-and-control">Resource statistics and control</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1030. </td></tr>
  1031. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  1032. </pre></th></tr></table>
  1033. <hr>
  1034. <span id="Basic-commands"></span><div class="header">
  1035. <p>
  1036. Next: <a href="#Command-processor-switches" accesskey="n" rel="next">Command processor switches</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1037. </div>
  1038. <span id="Basic-commands-1"></span><h4 class="subsection">2.4.1 Basic commands</h4>
  1039. <p>There are several generally useful commands built-in, along with many
  1040. others described in subsequent sections:
  1041. </p>
  1042. <span id="index-help"></span>
  1043. <span id="index-command-processor-help"></span>
  1044. <dl>
  1045. <dt id="index-_002chelp">command: <strong>,help</strong></dt>
  1046. <dt id="index-_002chelp-1">command: <strong>,help</strong> <em>command</em></dt>
  1047. <dt id="index-_002c_003f">command: <strong>,?</strong></dt>
  1048. <dt id="index-_002c_003f-1">command: <strong>,?</strong> <em>command</em></dt>
  1049. <dd><p>Requests help on commands. <code>,?</code> is an alias for
  1050. <code>,help</code>. Plain &lsquo;<samp>,help</samp>&rsquo; lists a synopsis of all commands
  1051. available, as well as all <a href="#Command-processor-switches">switches</a>. &lsquo;<samp>,help <var>command</var></samp>&rsquo; requests help on the particular
  1052. command <var>command</var>.
  1053. </p></dd></dl>
  1054. <span id="index-exiting-Scheme"></span>
  1055. <span id="index-quitting-Scheme"></span>
  1056. <dl>
  1057. <dt id="index-_002cexit">command: <strong>,exit</strong></dt>
  1058. <dt id="index-_002cexit-1">command: <strong>,exit</strong> <em>status</em></dt>
  1059. <dt id="index-_002cexit_002dwhen_002ddone">command: <strong>,exit-when-done</strong></dt>
  1060. <dt id="index-_002cexit_002dwhen_002ddone-1">command: <strong>,exit-when-done</strong> <em>status</em></dt>
  1061. <dd><p>Exits the command processor. &lsquo;<samp>,exit</samp>&rsquo; immediately exits with an
  1062. exit status of 0. &lsquo;<samp>,exit <var>status</var></samp>&rsquo; exits with the status that
  1063. evaluating the expression <var>status</var> in the interaction environment
  1064. produces. <code>,exit-when-done</code> is like <code>,exit</code>, but it
  1065. waits until all threads complete before exiting.
  1066. </p></dd></dl>
  1067. <dl>
  1068. <dt id="index-_002cgo">command: <strong>,go</strong> <em>expression</em></dt>
  1069. <dd><p><code>,go</code> is like <code>,exit</code>, except that it requires an
  1070. argument, and it evaluates <var>expression</var> in the interaction
  1071. environment in a <em>tail context</em> with respect to the command
  1072. processor. This means that the command processor may no longer be
  1073. reachable by the garbage collector, and may be collected as garbage
  1074. during the evaluation of <var>expression</var>. For example, the full
  1075. Scheme48 command processor is bootstrapped from a minimal one that
  1076. supports the <code>,go</code> command. The full command processor is
  1077. initiated in an argument to the command, but the minimal one is no
  1078. longer reachable, so it may be collected as garbage, leaving only the
  1079. full one.
  1080. </p></dd></dl>
  1081. <dl>
  1082. <dt id="index-_002crun">command: <strong>,run</strong> <em>expression</em></dt>
  1083. <dd><p>Evaluates <var>expression</var> in the interaction environment. Alone, this
  1084. command is not very useful, but it is required in situations such as
  1085. the <a href="#Inspector">inspector</a> and <a href="#Command-programs">command programs</a>.
  1086. </p></dd></dl>
  1087. <dl>
  1088. <dt id="index-_002cundefine">command: <strong>,undefine</strong> <em>name</em></dt>
  1089. <dd><p>Removes the binding for <var>name</var> in the interaction environment.
  1090. </p></dd></dl>
  1091. <dl>
  1092. <dt id="index-_002cload">command: <strong>,load</strong> <em>filename &hellip;</em></dt>
  1093. <dd><p>Loads the contents each <var>filename</var> as Scheme source code into the
  1094. interaction environment. Each <var>filename</var> is translated first
  1095. (see <a href="#Filenames">Filenames</a>). The given filenames may be surrounded or not by
  1096. double-quotes; however, if a filename contains spaces, it must be
  1097. surrounded by double-quotes. The differences between the
  1098. <code>,load</code> command and Scheme&rsquo;s <code>load</code> procedure are that
  1099. <code>,load</code> does not require its arguments to be quoted, allows
  1100. arbitrarily many arguments while the <code>load</code> procedure accepts only
  1101. one filename (and an optional environment), and works even in
  1102. environments in which <code>load</code> is not bound.
  1103. </p></dd></dl>
  1104. <dl>
  1105. <dt id="index-_002ctranslate">command: <strong>,translate</strong> <em>from to</em></dt>
  1106. <dd><p>A convenience for registering a filename translation without needing to
  1107. open the <code>filenames</code> structure. For more details on filename
  1108. translations, see <a href="#Filenames">Filenames</a>; this command corresponds with the
  1109. <code>filename</code> structure&rsquo;s <code>set-translation!</code> procedure. As
  1110. with <code>,load</code>, each of the filenames <var>from</var> and <var>to</var> may
  1111. be surrounded or not by double-quotes, unless there is a space in the
  1112. filenames, in which case it must be surrounded by double-quotes.
  1113. </p>
  1114. <p>Note that in the exec language (see <a href="#Command-programs">Command programs</a>),
  1115. <code>translate</code> is the same as the <code>filenames</code> structure&rsquo;s
  1116. <code>set-translation!</code> procedure, <em>not</em> the procedure named
  1117. <code>translate</code> from the <code>filenames</code> structure.
  1118. </p></dd></dl>
  1119. <hr>
  1120. <span id="Command-processor-switches"></span><div class="header">
  1121. <p>
  1122. Next: <a href="#Emacs-integration-commands" accesskey="n" rel="next">Emacs integration commands</a>, Previous: <a href="#Basic-commands" accesskey="p" rel="prev">Basic commands</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1123. </div>
  1124. <span id="Switches"></span><h4 class="subsection">2.4.2 Switches</h4>
  1125. <span id="index-command-processor-settings"></span>
  1126. <span id="index-configuring-the-command-processor"></span>
  1127. <p>The Scheme48 command processor keeps track of a set of <em>switches</em>,
  1128. user-settable configurations.
  1129. </p>
  1130. <dl>
  1131. <dt id="index-_002cset">command: <strong>,set</strong> <em>switch</em></dt>
  1132. <dt id="index-_002cset-1">command: <strong>,set</strong> <em>switch {on|off|?}</em></dt>
  1133. <dt id="index-_002cunset">command: <strong>,unset</strong> <em>switch</em></dt>
  1134. <dt id="index-_002cset-2">command: <strong>,set</strong> <em>?</em></dt>
  1135. <dd><p>&lsquo;<samp>,set <var>switch</var></samp>&rsquo; &amp; &lsquo;<samp>,set <var>switch</var> on</samp>&rsquo; set the switch
  1136. <var>switch</var> on. &lsquo;<samp>,unset <var>switch</var></samp>&rsquo; &amp; &lsquo;<samp>,set <var>switch</var>
  1137. off</samp>&rsquo; turn <var>switch</var> off. &lsquo;<samp>,set <var>switch</var> ?</samp>&rsquo; gives a brief
  1138. description of <var>switch</var>&rsquo;s current status. &lsquo;<samp>,set ?</samp>&rsquo; gives
  1139. information about all the available switches and their current state.
  1140. </p></dd></dl>
  1141. <p>The following switches are defined. Each switch is listed with its
  1142. name and its default status.
  1143. </p>
  1144. <dl compact="compact">
  1145. <dt><code>ask-before-loading</code> <em>(off)</em></dt>
  1146. <dd><p>If this is on, Scheme48 will prompt the user before loading modules&rsquo;
  1147. code. If it is off, it will quietly just load it.
  1148. </p>
  1149. <span id="index-batch-mode-1"></span>
  1150. </dd>
  1151. <dt><code>batch</code> <em>(off)</em></dt>
  1152. <dd><p>Batch mode is intended for automated uses of the command processor.
  1153. With batch mode on, errors cause the command processor to exit, and the
  1154. prompt is not printed.
  1155. </p>
  1156. </dd>
  1157. <dt><code>break-on-warnings</code> <em>(off)</em></dt>
  1158. <dd><p>If the <code>break-on-warnings</code> switch is on, <a href="#Condition-system">warnings</a> signalled that reach the command processor&rsquo;s handler
  1159. will cause a <a href="#Command-levels">command level</a> to be pushed,
  1160. similarly to breakpoints and errors.
  1161. </p>
  1162. </dd>
  1163. <dt><code>inline-values</code> <em>(off)</em></dt>
  1164. <dd><p><code>Inline-values</code> tells whether or not certain procedures may be
  1165. integrated in-line.
  1166. </p>
  1167. <span id="index-command-levels"></span>
  1168. <span id="index-disabling-command-levels"></span>
  1169. </dd>
  1170. <dt><code>levels</code> <em>(on)</em></dt>
  1171. <dd><p>Errors will push a new <a href="#Command-levels">command level</a> if this
  1172. switch is on, or they will just reset back to the top level if
  1173. <code>levels</code> is off.
  1174. </p>
  1175. </dd>
  1176. <dt><code>load-noisily</code> <em>(off)</em></dt>
  1177. <dd><p>Loading source files will cause messages to be printed if
  1178. <code>load-noisily</code> is on; otherwise they will be suppressed.
  1179. </p></dd>
  1180. </dl>
  1181. <hr>
  1182. <span id="Emacs-integration-commands"></span><div class="header">
  1183. <p>
  1184. Next: <a href="#Focus-value" accesskey="n" rel="next">Focus value</a>, Previous: <a href="#Command-processor-switches" accesskey="p" rel="prev">Command processor switches</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1185. </div>
  1186. <span id="Emacs-integration-commands-1"></span><h4 class="subsection">2.4.3 Emacs integration commands</h4>
  1187. <p>There are several commands that exist mostly for <a href="#Emacs-integration">Emacs integration</a>; although they may be used elsewhere,
  1188. they are not very useful or convenient without <samp>scheme48.el</samp>.
  1189. </p>
  1190. <dl>
  1191. <dt id="index-_002cfrom_002dfile">command: <strong>,from-file</strong> <em>filename</em></dt>
  1192. <dt id="index-_002cend">command: <strong>,end</strong></dt>
  1193. <dd><p>&lsquo;<samp>,from-file <var>filename</var></samp>&rsquo; proclaims that the code following the
  1194. command, until an <code>,end</code> command, comes from <var>filename</var> &mdash;
  1195. for example, this may be due to an appropriate Emacs command, such as
  1196. <kbd>C-c C-l</kbd> in <samp>scheme48.el</samp> &mdash;; if this is the first time the
  1197. command processor has seen code from <var>filename</var>, it is registered
  1198. to correspond with the interaction environment wherein the
  1199. <code>,from-file</code> command was used. If it is not the first time,
  1200. the code is evaluated within the package that was registered for
  1201. <var>filename</var>.
  1202. </p></dd></dl>
  1203. <dl>
  1204. <dt id="index-_002cforget">command: <strong>,forget</strong> <em>filename</em></dt>
  1205. <dd><p>Clears the command processor&rsquo;s memory of the package to which
  1206. <var>filename</var> corresponds.
  1207. </p></dd></dl>
  1208. <hr>
  1209. <span id="Focus-value"></span><div class="header">
  1210. <p>
  1211. Next: <a href="#Command-levels" accesskey="n" rel="next">Command levels</a>, Previous: <a href="#Emacs-integration-commands" accesskey="p" rel="prev">Emacs integration commands</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1212. </div>
  1213. <span id="Focus-value-1"></span><h4 class="subsection">2.4.4 Focus value</h4>
  1214. <p>The Scheme48 command processor maintains a current <em>focus value</em>.
  1215. This is typically the value that the last expression evaluated to, or a
  1216. list of values if it returned multiple values. If it evaluated to
  1217. either zero values or Scheme48&rsquo;s &lsquo;unspecific&rsquo; token (see <a href="#System-features">System features</a>), the focus value is unchanged. At the initial startup of
  1218. Scheme48, the focus value is set to the arguments passed to Scheme48&rsquo;s
  1219. virtual machine after the <samp>-a</samp> argument on the command-line
  1220. (see <a href="#Running-Scheme48">Running Scheme48</a>). The focus value is accessed through the
  1221. <code>##</code> syntax; the reader substitutes a special quotation (special
  1222. so that the compiler will not generate warnings about a regular
  1223. <code>quote</code> expression containing a weird value) for occurrences of
  1224. <code>##</code>. Several commands, such as <code>,inspect</code> and
  1225. <code>,dis</code>, either accept an argument or use the current focus
  1226. value. Also, in the <a href="#Inspector">inspector</a>, the focus object
  1227. is the object that is currently being inspected.
  1228. </p>
  1229. <div class="example">
  1230. <pre class="example">&gt; (cons 1 2)
  1231. '(1 . 2)
  1232. &gt; ##
  1233. '(1 . 2)
  1234. &gt; (begin (display &quot;Hello, world!&quot;) (newline))
  1235. Hello, world!
  1236. &gt; ##
  1237. '(1 . 2)
  1238. &gt; (cdr ##)
  1239. 2
  1240. &gt; (define x 5)
  1241. ; no values returned
  1242. &gt; (+ ## x)
  1243. 7
  1244. &gt; (values 1 2 3)
  1245. ; 3 values returned
  1246. 1
  1247. 2
  1248. 3
  1249. &gt; ##
  1250. '(1 2 3)</pre></div>
  1251. <hr>
  1252. <span id="Command-levels"></span><div class="header">
  1253. <p>
  1254. Next: <a href="#Module-commands" accesskey="n" rel="next">Module commands</a>, Previous: <a href="#Focus-value" accesskey="p" rel="prev">Focus value</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1255. </div>
  1256. <span id="Command-levels-1"></span><h4 class="subsection">2.4.5 Command levels</h4>
  1257. <span id="index-command-levels-1"></span>
  1258. <p>The Scheme48 command processor maintains a stack of <em>command
  1259. levels</em>, or recursive invocations of the command processor. Each
  1260. command level retains information about the point from the previous
  1261. command level at which it was pushed: the threads that were running &mdash;
  1262. which the command processor suspends &mdash;, including the thread of that
  1263. command level itself; the continuation of what pushed the level; and,
  1264. if applicable, the <a href="#Condition-system">condition</a> that caused
  1265. the command level to be pushed. Each command level has its own thread
  1266. scheduler, which controls all threads running at that level, including
  1267. those threads&rsquo; children.
  1268. </p>
  1269. <span id="index-disabling-command-levels-1"></span>
  1270. <p>Some beginning users may find command levels confusing, particularly
  1271. those who are new to Scheme or who are familiar with the more
  1272. simplistic interaction methods of other Scheme systems. These users
  1273. may disable the command level system with the <a href="#Command-processor-switches"><code>levels</code> switch</a> by writing the command
  1274. &lsquo;<samp>,set levels off</samp>&rsquo;.
  1275. </p>
  1276. <dl>
  1277. <dt id="index-_002cpush">command: <strong>,push</strong></dt>
  1278. <dt id="index-_002cpop">command: <strong>,pop</strong></dt>
  1279. <dt id="index-_002cresume">command: <strong>,resume</strong></dt>
  1280. <dt id="index-_002cresume-1">command: <strong>,resume</strong> <em>level</em></dt>
  1281. <dt id="index-_002creset">command: <strong>,reset</strong></dt>
  1282. <dt id="index-_002creset-1">command: <strong>,reset</strong> <em>level</em></dt>
  1283. <dd><p>&lsquo;<samp>,push</samp>&rsquo; pushes a new command level. &lsquo;<samp>,pop</samp>&rsquo; pops the current
  1284. command level. <kbd>C-d</kbd>/<kbd>^D</kbd>, or EOF, has the same effect as the
  1285. <code>,pop</code> command. Popping the top command level inquires the
  1286. user whether to exit or to return to the top level. &lsquo;<samp>,resume
  1287. <var>level</var></samp>&rsquo; pops all command levels down to <var>level</var> and resumes
  1288. all threads that were running at <var>level</var> when it was suspended to
  1289. push another command level. &lsquo;<samp>,reset <var>level</var></samp>&rsquo; resets the
  1290. command processor to <var>level</var>, terminating all threads at that
  1291. level but the command reader thread. <code>,resume</code> &amp;
  1292. <code>,reset</code> with no argument use the top command level.
  1293. </p></dd></dl>
  1294. <dl>
  1295. <dt id="index-_002ccondition">command: <strong>,condition</strong></dt>
  1296. <dt id="index-_002cthreads">command: <strong>,threads</strong></dt>
  1297. <dd><p>&lsquo;<samp>,condition</samp>&rsquo; sets the focus value to the condition that caused the
  1298. command level to be pushed, or prints &lsquo;no condition&rsquo; if there was no
  1299. relevant condition. &lsquo;<samp>,threads</samp>&rsquo; invokes the inspector on the list
  1300. of threads of the previous command level, or on nothing if the current
  1301. command level is the top one.
  1302. </p></dd></dl>
  1303. <div class="example">
  1304. <pre class="example">&gt; ,push
  1305. 1&gt; ,push
  1306. 2&gt; ,pop
  1307. 1&gt; ,reset
  1308. Top level
  1309. &gt; ,open threads formats
  1310. &gt; ,push
  1311. 1&gt; ,push
  1312. 2&gt; (spawn (lambda ()
  1313. (let loop ()
  1314. (sleep 10000) ; Sleep for ten seconds.
  1315. (format #t &quot;~&amp;foo~%&quot;)
  1316. (loop)))
  1317. 'my-thread)
  1318. 2&gt;
  1319. foo
  1320. ,push
  1321. 3&gt; ,threads
  1322. ; 2 values returned
  1323. [0] '#{Thread 4 my-thread}
  1324. [1] '#{Thread 3 command-loop}
  1325. 3: q
  1326. '(#{Thread 4 my-thread} #{Thread 3 command-loop})
  1327. 3&gt; ,resume 1
  1328. foo
  1329. 2&gt;
  1330. foo
  1331. ,push
  1332. 3&gt; ,reset 1
  1333. Back to 1&gt; ,pop
  1334. &gt; </pre></div>
  1335. <hr>
  1336. <span id="Module-commands"></span><div class="header">
  1337. <p>
  1338. Next: <a href="#SRFI-7" accesskey="n" rel="next">SRFI 7</a>, Previous: <a href="#Command-levels" accesskey="p" rel="prev">Command levels</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1339. </div>
  1340. <span id="Module-commands-1"></span><h4 class="subsection">2.4.6 Module commands</h4>
  1341. <p>Scheme48&rsquo;s command processor is well-integrated with its
  1342. <a href="#Module-system">module system</a>. It has several dedicated
  1343. environments, including the user package and the config package, and
  1344. can be used to evaluate code within most packages in the Scheme48 image
  1345. during program development. The config package includes bindings for
  1346. Scheme48&rsquo;s configuration language; structure &amp; interface definitions
  1347. may be evaluated in it. The command processor also has provisions
  1348. to support rapid development and module reloading by automatically
  1349. updating references to redefined variables in compiled code without
  1350. having to reload all of that code.
  1351. </p>
  1352. <span id="index-opening-structures"></span>
  1353. <span id="index-structures_002c-opening"></span>
  1354. <dl>
  1355. <dt id="index-_002copen">command: <strong>,open</strong> <em>struct &hellip;</em></dt>
  1356. <dd><p>Opens each <var>struct</var> into the interaction environment, making all
  1357. of its exported bindings available. This may have the consequence of
  1358. loading code to implement those bindings. If there was code evaluated
  1359. in the interaction environment that referred to a previously undefined
  1360. variable for whose name a binding was exported by one of these
  1361. structures, a message is printed to the effect that that binding is
  1362. now available, and the code that referred to that undefined variable
  1363. will be modified to subsequently refer to the newly available binding.
  1364. </p></dd></dl>
  1365. <dl>
  1366. <dt id="index-_002cload_002dpackage">command: <strong>,load-package</strong> <em>struct</em></dt>
  1367. <dd><span id="index-reloading-code-1"></span>
  1368. <span id="index-code-reloading-1"></span>
  1369. </dd><dt id="index-_002creload_002dpackage">command: <strong>,reload-package</strong> <em>struct</em></dt>
  1370. <dd><p><code>,load-package</code> and <code>,reload-package</code> both load the
  1371. code associated with the package underlying <var>struct</var>, after
  1372. ensuring that all of the other structures opened by that package are
  1373. loaded as well. <code>,load-package</code> loads the code only if has
  1374. not already been loaded; <code>,reload-package</code> unconditionally
  1375. loads it.
  1376. </p></dd></dl>
  1377. <span id="index-user-package"></span>
  1378. <span id="index-config-package"></span>
  1379. <dl>
  1380. <dt id="index-_002cuser">command: <strong>,user</strong></dt>
  1381. <dt id="index-_002cuser-1">command: <strong>,user</strong> <em>command-or-exp</em></dt>
  1382. <dt id="index-_002cconfig">command: <strong>,config</strong></dt>
  1383. <dt id="index-_002cconfig-1">command: <strong>,config</strong> <em>command-or-exp</em></dt>
  1384. <dt id="index-_002cfor_002dsyntax">command: <strong>,for-syntax</strong></dt>
  1385. <dt id="index-_002cfor_002dsyntax-1">command: <strong>,for-syntax</strong> <em>command-or-exp</em></dt>
  1386. <dt id="index-_002cnew_002dpackage">command: <strong>,new-package</strong></dt>
  1387. <dt id="index-_002cin">command: <strong>,in</strong> <em>structure</em></dt>
  1388. <dt id="index-_002cin-1">command: <strong>,in</strong> <em>structure command-or-exp</em></dt>
  1389. <dd><p>These all operate on the interaction environment. &lsquo;<samp>,user</samp>&rsquo; sets it
  1390. to the user package, which is the default at initial startup.
  1391. &lsquo;<samp>,user <var>command-or-exp</var></samp>&rsquo; temporarily sets the interaction
  1392. environment to the user package, processes <var>command-or-exp</var>, and
  1393. reverts the interaction environment to what it was before
  1394. <code>,user</code> was invoked. The <code>,config</code> &amp;
  1395. <code>,for-syntax</code> commands are similar, except that they operate on
  1396. the config package and the package used for the user package&rsquo;s macros
  1397. (see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>). &lsquo;<samp>,new-package</samp>&rsquo; creates
  1398. a temporary, unnamed package with a vanilla R5RS environment and sets
  1399. the interaction environment to it. That new package is not accessible
  1400. in any way except to the user of the command processor, and it is
  1401. destroyed after the user switches to another environment (unless the
  1402. user uses the <code>,structure</code> command; see below). &lsquo;<samp>,in
  1403. <var>structure</var></samp>&rsquo; sets the interaction environment to be
  1404. <var>structure</var>&rsquo;s package; <var>structure</var> is a name whose value is
  1405. extracted from the config package. &lsquo;<samp>,in <var>structure</var>
  1406. <var>command-or-exp</var></samp>&rsquo; sets the interaction environment to
  1407. <var>structure</var> temporarily to process <var>command-or-exp</var> and then
  1408. reverts it to what it was before the use of <code>,in</code>. Note that,
  1409. within a structure, the bindings available are exactly those bindings
  1410. that would be available within the structure&rsquo;s static code, <i>i.e.</i> code
  1411. in the structure&rsquo;s <code>begin</code> package clauses or code in files
  1412. referred to by <code>files</code> package clauses.
  1413. </p></dd></dl>
  1414. <dl>
  1415. <dt id="index-_002cuser_002dpackage_002dis">command: <strong>,user-package-is</strong> <em>struct</em></dt>
  1416. <dt id="index-_002cconfig_002dpackage_002dis">command: <strong>,config-package-is</strong> <em>struct</em></dt>
  1417. <dd><p><code>,user-package-is</code> &amp; <code>,config-package-is</code> set the user
  1418. &amp; config packages, respectively, to be <var>struct</var>&rsquo;s package.
  1419. <var>Struct</var> is a name whose value is accessed from the current config
  1420. package.
  1421. </p></dd></dl>
  1422. <dl>
  1423. <dt id="index-_002cstructure">command: <strong>,structure</strong> <em>name interface</em></dt>
  1424. <dd><p>This defines a structure named <var>name</var> in the config package that is
  1425. a view of <var>interface</var> on the current interaction environment.
  1426. </p></dd></dl>
  1427. <hr>
  1428. <span id="SRFI-7"></span><div class="header">
  1429. <p>
  1430. Next: <a href="#Debugging-commands" accesskey="n" rel="next">Debugging commands</a>, Previous: <a href="#Module-commands" accesskey="p" rel="prev">Module commands</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1431. </div>
  1432. <span id="SRFI-7-1"></span><h4 class="subsection">2.4.7 SRFI 7</h4>
  1433. <span id="index-srfi_002d7"></span>
  1434. <p>Scheme48 supports [SRFI 7] after loading the <code>srfi-7</code> structure by
  1435. providing two commands for loading [SRFI 7] programs:
  1436. </p>
  1437. <dl>
  1438. <dt id="index-_002cload_002dsrfi_002d7_002dprogram">command: <strong>,load-srfi-7-program</strong> <em>name filename</em></dt>
  1439. <dt id="index-_002cload_002dsrfi_002d7_002dscript">command: <strong>,load-srfi-7-script</strong> <em>name filename</em></dt>
  1440. <dd><p>These load [SRFI 7] a program into a newly constructed structure, named
  1441. <var>name</var>, which opens whatever other structures are needed by
  1442. features specified in the program. <code>,load-srfi-7-program</code>
  1443. loads a simple [SRFI 7] program; <code>,load-srfi-7-script</code> skips
  1444. the first line, intended for [SRFI 22] Unix scripts.
  1445. </p></dd></dl>
  1446. <hr>
  1447. <span id="Debugging-commands"></span><div class="header">
  1448. <p>
  1449. Next: <a href="#Inspector" accesskey="n" rel="next">Inspector</a>, Previous: <a href="#SRFI-7" accesskey="p" rel="prev">SRFI 7</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1450. </div>
  1451. <span id="Debugging-commands-1"></span><h4 class="subsection">2.4.8 Debugging commands</h4>
  1452. <p>There are a number of commands useful for debugging, along with a
  1453. continuation inspector, all of which composes a convenient debugger.
  1454. </p>
  1455. <dl>
  1456. <dt id="index-_002cbound_003f">command: <strong>,bound?</strong> <em>name</em></dt>
  1457. <dt id="index-_002cwhere">command: <strong>,where</strong></dt>
  1458. <dt id="index-_002cwhere-1">command: <strong>,where</strong> <em>procedure</em></dt>
  1459. <dd><p><code>,bound?</code> prints out binding information about <var>name</var>, if
  1460. it is bound in the interaction environment, or &lsquo;Not bound&rsquo; if
  1461. <var>name</var> is unbound. <code>,where</code> prints out information about
  1462. what file and package its procedure argument was created in. If
  1463. <var>procedure</var> is not passed, <code>,where</code> uses the focus value.
  1464. If <code>,where</code>&rsquo;s argument is not a procedure, it informs the user
  1465. of this fact. If <code>,where</code> cannot find the location of its
  1466. argument&rsquo;s creation, it prints &lsquo;Source file not recorded.&rsquo;
  1467. </p></dd></dl>
  1468. <span id="index-macro-expansion"></span>
  1469. <span id="index-expanding-macros"></span>
  1470. <span id="index-syntax-expansion"></span>
  1471. <span id="index-disassembly"></span>
  1472. <dl>
  1473. <dt id="index-_002cexpand">command: <strong>,expand</strong></dt>
  1474. <dt id="index-_002cexpand-1">command: <strong>,expand</strong> <em>exp</em></dt>
  1475. <dt id="index-_002cdis">command: <strong>,dis</strong></dt>
  1476. <dt id="index-_002cdis-1">command: <strong>,dis</strong> <em>proc</em></dt>
  1477. <dd><p><code>,expand</code> prints out a macro-expansion of <var>exp</var>, or the
  1478. focus value if <var>exp</var> is not provided. The expression to be
  1479. expanded should be an ordinary S-expression. The expansion may contain
  1480. &lsquo;generated names&rsquo; and &lsquo;qualified names.&rsquo; These merely contain lexical
  1481. context information that allow one to differentiate between identifiers
  1482. with the same name. Generated names look like <code>#{Generated
  1483. <var>name</var> <var>unique-numeric-id</var>}</code>. Qualified names appear to be
  1484. vectors; they look like <code>#(&gt;&gt; <var>introducer-macro</var> <var>name</var>
  1485. <var>unique-numeric-id</var>)</code>, where <var>introducer-macro</var> is the macro
  1486. that introduced the name.
  1487. </p>
  1488. <p><code>,dis</code> prints out a disassembly of its procedure, continuation,
  1489. or template argument. If <var>proc</var> is passed, it is evaluated in the
  1490. interaction environment; if not, <code>,dis</code> disassembles the focus
  1491. value. The disassembly is of Scheme48&rsquo;s virtual machine&rsquo;s byte
  1492. code.<a id="DOCF4" href="#FOOT4"><sup>4</sup></a>
  1493. </p></dd></dl>
  1494. <dl>
  1495. <dt id="index-_002ccondition-1">command: <strong>,condition</strong></dt>
  1496. <dt id="index-_002cthreads-1">command: <strong>,threads</strong></dt>
  1497. <dd><p>For the descriptions of these commands, see <a href="#Command-levels">Command levels</a>. These
  1498. are mentioned here because they are relevant in the context of
  1499. debugging.
  1500. </p></dd></dl>
  1501. <span id="index-tracing"></span>
  1502. <span id="index-procedures_002c-tracing"></span>
  1503. <dl>
  1504. <dt id="index-_002ctrace">command: <strong>,trace</strong></dt>
  1505. <dt id="index-_002ctrace-1">command: <strong>,trace</strong> <em>name &hellip;</em></dt>
  1506. <dt id="index-_002cuntrace">command: <strong>,untrace</strong></dt>
  1507. <dt id="index-_002cuntrace-1">command: <strong>,untrace</strong> <em>name &hellip;</em></dt>
  1508. <dd><p>Traced procedures will print out information about when they are
  1509. entered and when they exit. &lsquo;<samp>,trace</samp>&rsquo; lists all of the traced
  1510. procedures&rsquo; bindings. &lsquo;<samp>,trace <var>name</var> &hellip;</samp>&rsquo; sets each
  1511. <var>name</var> in the interaction environment, which should be bound to a
  1512. procedure, to be a traced procedure over the original procedure.
  1513. &lsquo;<samp>,untrace</samp>&rsquo; resets all traced procedures to their original,
  1514. untraced procedures. &lsquo;<samp>,untrace <var>name</var> &hellip;</samp>&rsquo; untraces each
  1515. individual traced procedure of <var>name</var> &hellip; in the interaction
  1516. environment.
  1517. </p></dd></dl>
  1518. <span id="index-backtrace"></span>
  1519. <span id="index-continuation-previews"></span>
  1520. <span id="index-previewing-continuations"></span>
  1521. <dl>
  1522. <dt id="index-_002cpreview">command: <strong>,preview</strong></dt>
  1523. <dd><p>Prints a trace of the previous command level&rsquo;s suspended continuation.
  1524. This is analogous with stack traces in many debuggers.
  1525. </p></dd></dl>
  1526. <dl>
  1527. <dt id="index-_002cdebug">command: <strong>,debug</strong></dt>
  1528. <dd><p>Invokes the debugger: runs the inspector on the previous command
  1529. level&rsquo;s saved continuation. For more details, see <a href="#Inspector">Inspector</a>.
  1530. </p></dd></dl>
  1531. <span id="index-proceeding-from-errors"></span>
  1532. <span id="index-returning-from-errors"></span>
  1533. <span id="index-condition-restarting"></span>
  1534. <dl>
  1535. <dt id="index-_002cproceed">command: <strong>,proceed</strong></dt>
  1536. <dt id="index-_002cproceed-1">command: <strong>,proceed</strong> <em>exp</em></dt>
  1537. <dd><p>Returns to the continuation of the condition signalling of the previous
  1538. command level. Only certain kinds of conditions will push a new
  1539. command level, however &mdash; breakpoints, errors, and interrupts, and,
  1540. if the <code>break-on-warnings</code> switch is on, warnings &mdash;; also,
  1541. certain kinds of errors that do push new command levels do not permit
  1542. being proceeded from. In particular, only with a few VM primitives may
  1543. the <code>,proceed</code> command be used. If <var>exp</var> is passed, it is
  1544. evaluated in the interaction environment to produce the values to
  1545. return; if it is not passed, zero values are returned.
  1546. </p></dd></dl>
  1547. <hr>
  1548. <span id="Inspector"></span><div class="header">
  1549. <p>
  1550. Next: <a href="#Command-programs" accesskey="n" rel="next">Command programs</a>, Previous: <a href="#Debugging-commands" accesskey="p" rel="prev">Debugging commands</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1551. </div>
  1552. <span id="Inspector-1"></span><h4 class="subsection">2.4.9 Inspector</h4>
  1553. <p>Scheme48 provides a simple interactive object inspector. The command
  1554. processor&rsquo;s prompt&rsquo;s end changes from &lsquo;<samp>&gt;</samp>&rsquo; to &lsquo;<samp>:</samp>&rsquo; when in
  1555. inspection mode. The inspector is the basis of the debugger, which is,
  1556. for the most part, merely an inspector of continuations. In the
  1557. debugger, the prompt is &lsquo;<samp>debug:</samp>&rsquo;. In the inspector, objects are
  1558. printed followed by menus of their components. Entries in the menu are
  1559. printed with the index, which optionally includes a symbolic name, and
  1560. the value of the component. For example, a pair whose car is the
  1561. symbol <code>a</code> and whose cdr is the symbol <code>b</code> would be printed
  1562. by the inspector like this:
  1563. </p>
  1564. <div class="example">
  1565. <pre class="example">'(a . b)
  1566. [0: car] 'a
  1567. [1: cdr] 'b</pre></div>
  1568. <p>The inspector maintains a stack of the focus objects it previously
  1569. inspected. Selecting a new focus object pushes the current one onto
  1570. the stack; the <code>u</code> command pops the stack.
  1571. </p>
  1572. <dl>
  1573. <dt id="index-_002cinspect">command: <strong>,inspect</strong></dt>
  1574. <dt id="index-_002cinspect-1">command: <strong>,inspect</strong> <em>exp</em></dt>
  1575. <dd><p>Invokes the inspector. If <var>exp</var> is present, it is evaluated in the
  1576. user package and its result is inspected (or a list of results, if it
  1577. returned multiple values, is inspected). If <var>exp</var> is absent, the
  1578. current focus value is inspected.
  1579. </p></dd></dl>
  1580. <p>The inspector operates with its own set of commands, separate from the
  1581. regular interaction commands, although regular commands may be invoked
  1582. from the inspector as normal. Inspector commands are entered with or
  1583. without a preceding comma at the inspector prompt. Multiple inspector
  1584. commands may be entered on one line; an input may also consist of an
  1585. expression to be evaluated. If an expression is evaluated, its value
  1586. is selected as the focus object. Note, however, that, since inspector
  1587. commands are symbols, variables cannot be evaluated just by entering
  1588. their names; one must use either the <code>,run</code> command or wrap the
  1589. variables in a <code>begin</code>.
  1590. </p>
  1591. <p>These inspector commands are defined:
  1592. </p>
  1593. <dl>
  1594. <dt id="index-menu">inspector command: <strong>menu</strong></dt>
  1595. <dt id="index-m">inspector command: <strong>m</strong></dt>
  1596. <dd><p><code>Menu</code> prints a menu for the focus object. <code>M</code> moves
  1597. forward in the current menu if there are more than sixteen items to be
  1598. displayed.
  1599. </p></dd></dl>
  1600. <dl>
  1601. <dt id="index-u">inspector command: <strong>u</strong></dt>
  1602. <dd><p>Pops the stack of focus objects, discarding the current one and setting
  1603. the focus object to the current top of the stack.
  1604. </p></dd></dl>
  1605. <dl>
  1606. <dt id="index-q">inspector command: <strong>q</strong></dt>
  1607. <dd><p>Quits the inspector, going back into the read-eval-print loop.
  1608. </p></dd></dl>
  1609. <dl>
  1610. <dt id="index-template">inspector command: <strong>template</strong></dt>
  1611. <dd><p>Attempts to coerce the focus object into a template. If successful,
  1612. this selects it as the new focus object; if not, this prints an error
  1613. to that effect. Templates are the static components of closures and
  1614. continuations: they contain the code for the procedure, the top-level
  1615. references made by the procedure, literal constants used in the code,
  1616. and any inferior templates of closures that may be constructed by the
  1617. code.
  1618. </p></dd></dl>
  1619. <dl>
  1620. <dt id="index-d">inspector command: <strong>d</strong></dt>
  1621. <dd><p>Goes down to the parent of the continuation being inspected. This
  1622. command is valid only in the debugger mode, <i>i.e.</i> when the focus object
  1623. is a continuation.
  1624. </p></dd></dl>
  1625. <hr>
  1626. <span id="Command-programs"></span><div class="header">
  1627. <p>
  1628. Next: <a href="#Image_002dbuilding-commands" accesskey="n" rel="next">Image-building commands</a>, Previous: <a href="#Inspector" accesskey="p" rel="prev">Inspector</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1629. </div>
  1630. <span id="Command-programs-1"></span><h4 class="subsection">2.4.10 Command programs</h4>
  1631. <span id="index-exec-language"></span>
  1632. <span id="index-exec-package"></span>
  1633. <p>The Scheme48 command processor can be controlled programmatically by
  1634. <em>command programs</em>, programs written in the <em>exec language</em>.
  1635. This language is essentially a mirror of the commands but in a syntax
  1636. using S-expressions. The language also includes all of Scheme. The
  1637. exec language is defined as part of the <em>exec package</em>.
  1638. </p>
  1639. <dl>
  1640. <dt id="index-_002cexec">command: <strong>,exec</strong></dt>
  1641. <dt id="index-_002cexec-1">command: <strong>,exec</strong> <em>command</em></dt>
  1642. <dd><p>Sets the interaction environment to be the exec package. If an
  1643. argument is passed, it is set temporarily, only to run the given
  1644. command.
  1645. </p></dd></dl>
  1646. <p>Commands in the exec language are invoked as procedures in Scheme.
  1647. Arguments should be passed as follows:
  1648. </p>
  1649. <ul>
  1650. <li> Identifiers, such as those of structure names in the config package,
  1651. should be passed as literal symbols. For instance, the command
  1652. &lsquo;<samp>,in frobbotz</samp>&rsquo; would become in the exec language <code>(in
  1653. 'frobbotz)</code>.
  1654. </li><li> Filenames should be passed as strings; <i>e.g.</i>, &lsquo;<samp>,dump frob.image</samp>&rsquo;
  1655. becomes <code>(dump &quot;frob.image&quot;)</code>.
  1656. </li><li> Commands should be represented in list values with the car being the
  1657. command name and the cdr being the arguments. Note that when applying
  1658. a command an argument that is a command invocation is often quoted to
  1659. produce a list, but the list should not include any quotation; for
  1660. instance, &lsquo;<samp>,in mumble ,undefine frobnicate</samp>&rsquo; would become <code>(in
  1661. 'mumble '(undefine frobnicate))</code>, even though simply &lsquo;<samp>,undefine
  1662. frobnicate</samp>&rsquo; would become <code>(undefine 'frobnicate)</code>.
  1663. <p>The reason for this is that the command invocation in the exec language
  1664. is different from a list that represents a command invocation passed as
  1665. an argument to another command; since commands in the exec language are
  1666. ordinary procedures, the arguments must be quoted, but the quoted
  1667. arguments are not themselves evaluated: they are applied as commands.
  1668. </p>
  1669. <p>An argument to a command that expects a command invocation can also be
  1670. a procedure, which would simply be called with zero arguments. For
  1671. instance, <code>(config (lambda () (display (interaction-environment))
  1672. (newline)))</code> will call the given procedure with the interaction
  1673. environment set to the config package.
  1674. </p>
  1675. </li><li> Expressions must be passed using the <code>run</code> command. For
  1676. example, the equivalent of &lsquo;<samp>,user (+ 1 2)</samp>&rsquo; in the exec language
  1677. would be <code>(user '(run (+ 1 2)))</code>.
  1678. </li></ul>
  1679. <p>Command programs can be loaded by running the <code>,load</code> command
  1680. in the exec package. Scripts to load application bundles are usually
  1681. written in the exec language and loaded into the exec package. For
  1682. example, this command program, when loaded into the exec package, will
  1683. load <samp>foo.scm</samp> into the config package, ensure that the package
  1684. <code>frobbotzim</code> is loaded, and open the <code>quuxim</code> structure in
  1685. the user package:
  1686. </p>
  1687. <div class="lisp">
  1688. <pre class="lisp">(config '(load &quot;foo.scm&quot;))
  1689. (load-package 'frobbotzim)
  1690. (user '(open quuxim))</pre></div>
  1691. <hr>
  1692. <span id="Image_002dbuilding-commands"></span><div class="header">
  1693. <p>
  1694. Next: <a href="#Resource-statistics-and-control" accesskey="n" rel="next">Resource statistics and control</a>, Previous: <a href="#Command-programs" accesskey="p" rel="prev">Command programs</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1695. </div>
  1696. <span id="Image_002dbuilding-commands-1"></span><h4 class="subsection">2.4.11 Image-building commands</h4>
  1697. <span id="index-dumping-heap-images"></span>
  1698. <span id="index-heap-image-dumping"></span>
  1699. <span id="index-image-dumping"></span>
  1700. <span id="index-writing-heap-images"></span>
  1701. <span id="index-heap-image-writing"></span>
  1702. <span id="index-image-writing"></span>
  1703. <p>Since Scheme48&rsquo;s operation revolves about an image-based model, these
  1704. commands provide a way to save heap images on the file system, which
  1705. may be resumed by invoking the Scheme48 virtual machine on them as in
  1706. <a href="#Running-Scheme48">Running Scheme48</a>.
  1707. </p>
  1708. <dl>
  1709. <dt id="index-_002cbuild">command: <strong>,build</strong> <em>resumer filename</em></dt>
  1710. <dt id="index-_002cdump">command: <strong>,dump</strong> <em>filename</em></dt>
  1711. <dt id="index-_002cdump-1">command: <strong>,dump</strong> <em>filename message</em></dt>
  1712. <dd><p><code>,build</code> evaluates <var>resumer</var>, whose value should be a unary
  1713. procedure, and builds a heap image in <var>filename</var> that, when resumed
  1714. by the virtual machine, will pass the resumer all of the command-line
  1715. arguments after the <samp>-a</samp> argument to the virtual machine. The
  1716. run-time system will have been initialized as with <a href="#Suspending-and-resuming-heap-images">usual resumers</a>, and a basic condition handler
  1717. will have been installed by the time that the resumer is called. On
  1718. Unix, <var>resumer</var> must return an integer exit status for the process.
  1719. <code>,dump</code> dumps the Scheme48 command processor, including all of
  1720. the current settings, to <var>filename</var>. If <var>message</var> is passed,
  1721. it should be a string delimited by double-quotes, and it will be
  1722. printed as part of the welcome banner on startup; its default value, if
  1723. it is not present, is <code>&quot;(suspended image)&quot;</code>.
  1724. </p></dd></dl>
  1725. <hr>
  1726. <span id="Resource-statistics-and-control"></span><div class="header">
  1727. <p>
  1728. Previous: <a href="#Image_002dbuilding-commands" accesskey="p" rel="prev">Image-building commands</a>, Up: <a href="#Command-processor" accesskey="u" rel="up">Command processor</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1729. </div>
  1730. <span id="Resource-statistics-and-control-1"></span><h4 class="subsection">2.4.12 Resource statistics and control</h4>
  1731. <p>Scheme48 provides several devices for querying statistics about various
  1732. resources and controlling resources, both in the command processor and
  1733. programmatically.
  1734. </p>
  1735. <span id="index-garbage-collection_002c-forcing"></span>
  1736. <span id="index-forcing-garbage-collection"></span>
  1737. <dl>
  1738. <dt id="index-_002ccollect">command: <strong>,collect</strong></dt>
  1739. <dd><p>Forces a garbage collection and prints the amount of space in the heap
  1740. before and after the collection.
  1741. </p></dd></dl>
  1742. <span id="index-timing-execution"></span>
  1743. <span id="index-execution-timing"></span>
  1744. <dl>
  1745. <dt id="index-_002ctime">command: <strong>,time</strong> <em>expression</em></dt>
  1746. <dd><p>Evaluates <var>expression</var> and prints how long it took. Three numbers
  1747. are printed: run time, GC time, and real time. The run time is the
  1748. amount of time in Scheme code; the GC time is the amount of time spent
  1749. in the garbage collector; and the real time is the actual amount of
  1750. time that passed during the expression&rsquo;s evaluation.
  1751. </p></dd></dl>
  1752. <span id="index-debug-data-storage-control"></span>
  1753. <span id="index-storage-control-of-debug-data"></span>
  1754. <dl>
  1755. <dt id="index-_002ckeep">command: <strong>,keep</strong></dt>
  1756. <dt id="index-_002ckeep-1">command: <strong>,keep</strong> <em>kind &hellip;</em></dt>
  1757. <dt id="index-_002cflush">command: <strong>,flush</strong></dt>
  1758. <dt id="index-_002cflush-1">command: <strong>,flush</strong> <em>kind &hellip;</em></dt>
  1759. <dd><p>Scheme48 maintains several different kinds of information used for
  1760. debugging information. &lsquo;<samp>,keep</samp>&rsquo; with no arguments shows what kinds
  1761. of debugging data are preserved and what kinds are not. &lsquo;<samp>,keep
  1762. <var>kind</var> &hellip;</samp>&rsquo; requests that the debugging data of the given kinds
  1763. should be kept; the <code>,flush</code> command requests the opposite.
  1764. &lsquo;<samp>,flush</samp>&rsquo; with no arguments flushes location names and resets the
  1765. debug data table. The following are the kinds of debugging data:
  1766. </p>
  1767. <dl compact="compact">
  1768. <dt><code>names</code></dt>
  1769. <dd><p>procedure names
  1770. </p></dd>
  1771. <dt><code>maps</code></dt>
  1772. <dd><p>environment maps used by the debugger to show local variable names
  1773. </p></dd>
  1774. <dt><code>files</code></dt>
  1775. <dd><p>filenames where procedures were defined
  1776. </p></dd>
  1777. <dt><code>source</code></dt>
  1778. <dd><p>source code surrounding continuations, printed by the debugger
  1779. </p></dd>
  1780. <dt><code>tabulate</code></dt>
  1781. <dd><p>if true, will store debug data records in a global table that can be
  1782. easily flushed; if false, will store directly in compiled code
  1783. </p></dd>
  1784. </dl>
  1785. <p><code>,flush</code> can also accept <code>location-names</code>, which will
  1786. flush the table of top-level variables&rsquo; names (printed, for example, by
  1787. the <code>,bound?</code> command); <code>file-packages</code>, which will flush
  1788. the table that maps filenames to packages in which code from those files
  1789. should be evaluated; or <code>table</code>, in which case the table of debug
  1790. data is flushed.
  1791. </p>
  1792. <p>Removing much debug data can significantly reduce the size of Scheme48
  1793. heap images, but it can also make error messages and debugging much
  1794. more difficult. Usually, all debug data is retained; only for images
  1795. that must be small and that do not need to be debuggable should the
  1796. debugging data flags be turned off.
  1797. </p></dd></dl>
  1798. <span id="index-space-usage-analysis"></span>
  1799. <span id="index-heap-space-analysis"></span>
  1800. <span id="index-displaying-heap-usage"></span>
  1801. <span id="index-spatial"></span>
  1802. <p>The <code>spatial</code> structure exports these utilities for displaying
  1803. various statistics about the heap:
  1804. </p>
  1805. <dl>
  1806. <dt id="index-space">procedure: <strong>space</strong> <em>--&gt; unspecified</em></dt>
  1807. <dt id="index-vector_002dspace">procedure: <strong>vector-space</strong> <em>[predicate] --&gt; unspecified</em></dt>
  1808. <dt id="index-record_002dspace">procedure: <strong>record-space</strong> <em>[predicate] --&gt; unspecified</em></dt>
  1809. <dd><p><code>Space</code> prints out a list of the numbers of all objects and the
  1810. number of bytes allocated for those objects on the heap, partitioned by
  1811. the objects&rsquo; primitive types and whether or not they are immutable
  1812. (pure) or mutable (impure). <code>Vector-space</code> prints the number of
  1813. vectors and the number of bytes used to store those vectors of several
  1814. different varieties, based on certain heuristics about their form. If
  1815. the predicate argument is passed, it gathers only vectors that satisfy
  1816. that predicate. <code>Record-space</code> prints out, for each record type
  1817. in the heap, both the number of all instances of that record type and
  1818. the number of bytes used to store all of those instances. Like
  1819. <code>vector-space</code>, if the predicate argument is passed,
  1820. <code>record-space</code> will consider only those records that satisfy the
  1821. predicate.
  1822. </p>
  1823. <p>All of these three procedures first invoke the garbage collector before
  1824. gathering statistics.
  1825. </p></dd></dl>
  1826. <span id="index-object-reference-analysis"></span>
  1827. <span id="index-storage-leak-analysis"></span>
  1828. <span id="index-heap-traversal"></span>
  1829. <span id="index-traverse"></span>
  1830. <p>The <code>traverse</code> structure provides a simple utility for finding
  1831. paths by which objects refer to one another.
  1832. </p>
  1833. <dl>
  1834. <dt id="index-traverse_002dbreadth_002dfirst">procedure: <strong>traverse-breadth-first</strong> <em>object --&gt; unspecified</em></dt>
  1835. <dt id="index-traverse_002ddepth_002dfirst">procedure: <strong>traverse-depth-first</strong> <em>object --&gt; unspecified</em></dt>
  1836. <dd><p>These traverse the heap, starting at <var>object</var>, recording all
  1837. objects transitively referred to. <code>Traverse-breadth-first</code> uses
  1838. a FIFO-queue-directed breadth-first graph traversal, while
  1839. <code>traverse-depth-first</code> uses a LIFO-stack-directed depth-first
  1840. graph traversal. The traversal halts at any leaves in the graph,
  1841. which are distinguished by an internal <em>leaf predicate</em> in the
  1842. module. See below on <code>set-leaf-predicate!</code> on how to customize
  1843. this and what the default is.
  1844. </p>
  1845. <p>The traversal information is recorded in a global resource; it is not
  1846. thread-safe, and intended only for interactive usage. The record can
  1847. be reset by passing some simple object with no references to either
  1848. <code>traverse-breadth-first</code> or <code>traverse-depth-first</code>; <i>e.g.</i>,
  1849. <code>(traverse-depth-first #f)</code>.
  1850. </p></dd></dl>
  1851. <dl>
  1852. <dt id="index-trail">procedure: <strong>trail</strong> <em>object --&gt; unspecified</em></dt>
  1853. <dd><p>After traversing the heap from an initial object, <code>(trail
  1854. <var>object</var>)</code> prints the path of references and intermediate objects
  1855. by which the initial object holds a transitive reference to
  1856. <var>object</var>.
  1857. </p></dd></dl>
  1858. <dl>
  1859. <dt id="index-set_002dleaf_002dpredicate_0021">procedure: <strong>set-leaf-predicate!</strong> <em>predicate --&gt; unspecified</em></dt>
  1860. <dt id="index-usual_002dleaf_002dpredicate">procedure: <strong>usual-leaf-predicate</strong> <em>object --&gt; boolean</em></dt>
  1861. <dd><p><code>Set-leaf-predicate!</code> sets the current leaf predicate to be
  1862. <var>predicate</var>. <code>Usual-leaf-predicate</code> is the default leaf
  1863. predicate; it considers simple numbers (integers and flonums),
  1864. strings, byte vectors, characters, and immediate objects (true, false,
  1865. nil, and the unspecific object) to be leaves, and everything else to
  1866. be branches.
  1867. </p></dd></dl>
  1868. <hr>
  1869. <span id="Module-system"></span><div class="header">
  1870. <p>
  1871. Next: <a href="#System-facilities" accesskey="n" rel="next">System facilities</a>, Previous: <a href="#User-environment" accesskey="p" rel="prev">User environment</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1872. </div>
  1873. <span id="Module-system-1"></span><h2 class="chapter">3 Module system</h2>
  1874. <p>Scheme48 has an advanced module system that is designed to interact
  1875. well with macros, incremental compilation, and the <a href="#User-environment">interactive development environment&rsquo;s</a> code reloading
  1876. facilities for rapid program development. For details on the
  1877. integration of the module system and the user environment for rapid
  1878. code reloading, see <a href="#Using-the-module-system">Using the module system</a>.
  1879. </p>
  1880. <table class="menu" border="0" cellspacing="0">
  1881. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Module-system-architecture" accesskey="1">Module system architecture</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1882. </td></tr>
  1883. <tr><td align="left" valign="top">&bull; <a href="#Module-configuration-language" accesskey="2">Module configuration language</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Language of the module system
  1884. </td></tr>
  1885. <tr><td align="left" valign="top">&bull; <a href="#Macros-in-concert-with-modules" accesskey="3">Macros in concert with modules</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1886. </td></tr>
  1887. <tr><td align="left" valign="top">&bull; <a href="#Static-type-system" accesskey="4">Static type system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  1888. </td></tr>
  1889. </table>
  1890. <hr>
  1891. <span id="Module-system-architecture"></span><div class="header">
  1892. <p>
  1893. Next: <a href="#Module-configuration-language" accesskey="n" rel="next">Module configuration language</a>, Up: <a href="#Module-system" accesskey="u" rel="up">Module system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1894. </div>
  1895. <span id="Module-system-architecture-1"></span><h3 class="section">3.1 Module system architecture</h3>
  1896. <span id="index-configuration-language"></span>
  1897. <span id="index-module-language"></span>
  1898. <p>The fundamental mechanism by which Scheme code is evaluated is the
  1899. lexical environment. Scheme48&rsquo;s module system revolves around this
  1900. fundamental concept. Its purpose is to control the denotation of names
  1901. in code<a id="DOCF5" href="#FOOT5"><sup>5</sup></a> in a
  1902. structured, modular manner. The module system is manipulated by a
  1903. static <em>configuration language</em>, described in the next section;
  1904. this section describes the concepts in the architecture of the module
  1905. system.
  1906. </p>
  1907. <span id="index-packages"></span>
  1908. <span id="index-structures"></span>
  1909. <span id="index-interfaces-1"></span>
  1910. <span id="index-modules"></span>
  1911. <p>The <em>package</em> is the entity internal to the module system that
  1912. maps a set of names to denotations. For example, the package that
  1913. represents the Scheme language maps <code>lambda</code> to a descriptor for
  1914. the special form that the compiler interprets to construct a procedure,
  1915. <code>car</code> to the procedure that accesses the car of a pair, <i>&amp;c</i>.
  1916. Packages are not explicitly manipulated by the configuration language,
  1917. but they lie underneath structures, which are described below. A
  1918. package also contains the code of a module and controls the visibility
  1919. of names within that code. It also includes some further information,
  1920. such as optimizer switches. A <em>structure</em> is a view on a package;
  1921. that is, it contains a package and an <em>interface</em> that lists all of
  1922. the names it exports to the outside. Multiple structures may be
  1923. constructed atop a single package; this mechanism is often used to offer
  1924. multiple abstraction levels to the outside. A <em>module</em> is an
  1925. abstract entity: it consists of some code, the namespace visible to the
  1926. code, and the set of abstractions or views upon that code.
  1927. </p>
  1928. <span id="index-opening-structures-1"></span>
  1929. <span id="index-structures_002c-opening-1"></span>
  1930. <p>A package contains a list of the structures whose bindings should be
  1931. available in the code of that package. If a structure is referred to
  1932. in a such a list of a package, the package is said to <em>open</em> that
  1933. structure. It is illegal for a package to open two structures whose
  1934. interfaces contain the same name.<a id="DOCF6" href="#FOOT6"><sup>6</sup></a> Packages may also modify the names of the bindings
  1935. that they import. They may import only selected bindings, exclude
  1936. certain bindings from structures, rename imported bindings, create
  1937. alias bindings, and add prefixes to names.
  1938. </p>
  1939. <span id="index-scheme"></span>
  1940. <span id="index-prescheme"></span>
  1941. <p>Most packages will open the standard <code>scheme</code> structure, although
  1942. it is not implicitly opened, and the module system allows not opening
  1943. <code>scheme</code>. It may seem to be not very useful to not open it, but
  1944. this is necessary if some bindings from it are intended to be shadowed
  1945. by another structure, and it allows for entirely different languages
  1946. from Scheme to be used in a package&rsquo;s code. For example, Scheme48&rsquo;s
  1947. byte code interpreter virtual machine is implemented in a subset of
  1948. Scheme called Pre-Scheme, which is described in a later chapter in this
  1949. manual. The modules that compose the VM all open not the <code>scheme</code>
  1950. structure but the <em><code>prescheme</code></em> structure. The configuration
  1951. language itself is controlled by the module system, too. In another
  1952. example, from Scsh, the Scheme shell, there is a structure <code>scsh</code>
  1953. that contains all of the Unix shell programming facilities. However,
  1954. the <code>scsh</code> structure necessarily modifies some of the bindings
  1955. related to I/O that the <code>scheme</code> structure exports. Modules could
  1956. not open both <code>scheme</code> and <code>scsh</code>, because they both provide
  1957. several bindings with the same names, so Scsh defines a more convenient
  1958. <code>scheme-with-scsh</code> structure that opens both <code>scheme</code>, but
  1959. with all of the shadowed bindings excluded, and <code>scsh</code>; modules
  1960. that use Scsh would open neither <code>scsh</code> nor <code>scheme</code>: they
  1961. instead open just <code>scheme-with-scsh</code>.
  1962. </p>
  1963. <span id="index-interface-reuse"></span>
  1964. <span id="index-compound-interfaces"></span>
  1965. <span id="index-interface-abstraction"></span>
  1966. <p>Interfaces are separated from structures in order that they may be
  1967. re&uuml;sed and combined. For example, several different modules may
  1968. implement the same abstractions differently. The structures that they
  1969. include would, in such cases, re&uuml;se the same interfaces. Also, it is
  1970. sometimes desirable to combine several interfaces into a <em>compound
  1971. interface</em>; see the <code>compound-interface</code> form in the next section.
  1972. Furthermore, during interactive development, interface definitions may
  1973. be reloaded, and the structures that use them will automatically begin
  1974. using the new interfaces; see <a href="#Using-the-module-system">Using the module system</a>.
  1975. </p>
  1976. <span id="index-parameterized-modules"></span>
  1977. <span id="index-generic-modules"></span>
  1978. <span id="index-higher_002dorder-modules"></span>
  1979. <span id="index-functors"></span>
  1980. <p>Scheme48&rsquo;s module system also supports <em>parameterized modules</em>.
  1981. Parameterized modules, sometimes known as <em>generic modules</em>,
  1982. <em>higher-order modules</em> or <em>functors</em>, are essentially functions
  1983. at the module system level that map structures to structures. They may
  1984. be instantiated or applied arbitrarily many times, and they may accept
  1985. and return arbitrarily many structures. Parameterized modules may also
  1986. accept and return other parameterized modules.
  1987. </p><hr>
  1988. <span id="Module-configuration-language"></span><div class="header">
  1989. <p>
  1990. Next: <a href="#Macros-in-concert-with-modules" accesskey="n" rel="next">Macros in concert with modules</a>, Previous: <a href="#Module-system-architecture" accesskey="p" rel="prev">Module system architecture</a>, Up: <a href="#Module-system" accesskey="u" rel="up">Module system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  1991. </div>
  1992. <span id="Module-configuration-language-1"></span><h3 class="section">3.2 Module configuration language</h3>
  1993. <span id="index-configuration-language-1"></span>
  1994. <span id="index-module-language-1"></span>
  1995. <p>Scheme48&rsquo;s module system is used through a <em>module configuration
  1996. language</em>. <em>The configuration language is entirely separate from
  1997. Scheme.</em> Typically, in one configuration, or set of components that
  1998. compose a program, there is an <samp>interfaces.scm</samp> file that defines
  1999. all of the interfaces used by the configuration, and there is also a
  2000. <samp>packages.scm</samp> file that defines all of the packages &amp; structures
  2001. that compose it. Note that modules are not necessarily divided into
  2002. files or restricted to one file: modules may include arbitrarily many
  2003. files, and modules&rsquo; code may also be written in-line to structure
  2004. expressions (see the <code>begin</code> package clause below), although that
  2005. is usually only for expository purposes and trivial modules.
  2006. </p>
  2007. <span id="index-package-clauses"></span>
  2008. <p>Structures are always created with corresponding <em>package clauses</em>.
  2009. Each clause specifies an attribute of the package that underlies the
  2010. structure or structures created using the clauses. There are several
  2011. different types of clauses:
  2012. </p>
  2013. <span id="index-opening-structures-2"></span>
  2014. <span id="index-structures_002c-opening-2"></span>
  2015. <span id="index-accessing-structures"></span>
  2016. <span id="index-structures_002c-accessing"></span>
  2017. <span id="index-structure_002drefs"></span>
  2018. <span id="index-structure_002dref"></span>
  2019. <dl>
  2020. <dt id="index-open">package clause: <strong>open</strong> <em>structure &hellip;</em></dt>
  2021. <dt id="index-access">package clause: <strong>access</strong> <em>structure &hellip;</em></dt>
  2022. <dd><p><code>Open</code> specifies that the package should open each of the listed
  2023. structures, whose packages will be loaded if necessary. <code>Access</code>
  2024. specifies that each listed structure should be accessible using the
  2025. <code>(structure-ref <var>structure</var> <var>identifier</var>)</code> special form,
  2026. which evaluates to the value of <var>identifier</var> exported by the
  2027. accessed structure <var>structure</var>. <code>Structure-ref</code> is available
  2028. from the <code>structure-refs</code> structure. Each <var>structure</var> passed
  2029. to <code>access</code> is not opened, however; the bindings exported thereby
  2030. are available only using <code>structure-ref</code>. While the qualified
  2031. <code>structure-ref</code> mechanism is no longer useful in the presence of
  2032. modified structures (see below on <code>modify</code>, <code>subset</code>, &amp;
  2033. <code>with-prefix</code>), some old code still uses it, and <code>access</code> is
  2034. also useful to force that the listed structures&rsquo; packages be loaded
  2035. without cluttering the namespace of the package whose clauses the
  2036. <code>access</code> clause is among.
  2037. </p></dd></dl>
  2038. <dl>
  2039. <dt id="index-for_002dsyntax-2">package clause: <strong>for-syntax</strong> <em>package-clause &hellip;</em></dt>
  2040. <dd><p>Specifies a set of package clauses for the next floor of the reflective
  2041. tower; see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>.
  2042. </p></dd></dl>
  2043. <dl>
  2044. <dt id="index-files">package clause: <strong>files</strong> <em>file-specifier &hellip;</em></dt>
  2045. <dt id="index-begin">package clause: <strong>begin</strong> <em>code &hellip;</em></dt>
  2046. <dd><p><code>Files</code> and <code>begin</code> specify the package&rsquo;s code. <code>Files</code>
  2047. takes a sequence of namelists for the filenames of files that contain
  2048. code; see <a href="#Filenames">Filenames</a>. <code>Begin</code> accepts in-line program code.
  2049. </p></dd></dl>
  2050. <span id="index-compiler-optimization"></span>
  2051. <span id="index-optimizer"></span>
  2052. <dl>
  2053. <dt id="index-optimize">package clause: <strong>optimize</strong> <em>optimizer-specifier &hellip;</em></dt>
  2054. <dt id="index-integrate">package clause: <strong>integrate</strong> <em>[on?]</em></dt>
  2055. <dd><p><code>Optimize</code> clauses request that specified compiler optimizers be
  2056. applied to the code. (Actually, &lsquo;optimizer&rsquo; is a misnomer. The
  2057. <code>optimize</code> clause may specify arbitrary passes that the compiler
  2058. can be extended with.)
  2059. <code>Integrate</code> clauses specify whether or not integrable procedures
  2060. from other modules, most notably Scheme primitives such as <code>car</code>
  2061. or <code>vector-ref</code>, should actually be integrated in this package.
  2062. This is by default on. Most modules should leave it on for any
  2063. reasonable performance; only a select few, into which code is intended
  2064. to be dynamically loaded frequently and in which redefinition of
  2065. imported procedures is common, need turn this off. The value of the
  2066. argument to <code>integrate</code> clauses should be a literal boolean, <i>i.e.</i>
  2067. <code>#t</code> or <code>#f</code>; if no argument is supplied, integration is
  2068. enabled by default.
  2069. </p>
  2070. <span id="index-auto_002dintegrate-optimizer"></span>
  2071. <span id="index-procedure-integration"></span>
  2072. <span id="index-integrated-procedures"></span>
  2073. <span id="index-in_002dline-procedures"></span>
  2074. <span id="index-flat_002denvironments-optimizer"></span>
  2075. <span id="index-closure-flattening"></span>
  2076. <span id="index-flat-closures"></span>
  2077. <span id="index-environment-flattening"></span>
  2078. <span id="index-flat-environments"></span>
  2079. <p>Currently, the only optimizer built-in to Scheme48 is the automatic
  2080. procedure integrator, or <code>auto-integrate</code>, which attempts stronger
  2081. type reconstruction than is attempted with most code (see <a href="#Static-type-system">Static type system</a>) and selects procedures below a certain size to be made
  2082. integrable (so that the body will be compiled in-line in all known call
  2083. sites). Older versions of Scheme48 also provided another optimizer,
  2084. <code>flat-environments</code>, which would flatten certain lexical closure
  2085. environments, rather than using a nested environment structure. Now,
  2086. however, Scheme48&rsquo;s byte code compiler always flattens environments;
  2087. specifying <code>flat-environments</code> in an <code>optimize</code> clause does
  2088. nothing.
  2089. </p></dd></dl>
  2090. <span id="index-structure-definition-forms"></span>
  2091. <p>A configuration is a sequence of definitions. There are definition
  2092. forms for only structures and interfaces.
  2093. </p>
  2094. <dl>
  2095. <dt id="index-define_002dstructure">configuration form: <strong>define-structure</strong> <em>name interface package-clause &hellip;</em></dt>
  2096. <dt id="index-define_002dstructures">configuration form: <strong>define-structures</strong> <em>((name interface) &hellip;) package-clause &hellip;</em></dt>
  2097. <dd><p><code>Define-structure</code> creates a package with the given package
  2098. clauses and defines <var>name</var> to be the single view atop it, with the
  2099. interface <var>interface</var>. <code>Define-structures</code> also creates a
  2100. package with the given package clauses; upon that package, it defines
  2101. each <var>name</var> to be a view on it with the corresponding interface.
  2102. </p></dd></dl>
  2103. <dl>
  2104. <dt id="index-define_002dmodule">configuration form: <strong>define-module</strong> <em>(name parameter &hellip;) definition &hellip; result</em></dt>
  2105. <dt id="index-def">configuration form: <strong>def</strong> <em>name &hellip; (parameterized-module argument &hellip;)</em></dt>
  2106. <dd><p><code>Define-module</code> defines <var>name</var> to be a parameterized module
  2107. that accepts the given parameters.
  2108. </p></dd></dl>
  2109. <span id="index-interface-definition-forms"></span>
  2110. <dl>
  2111. <dt id="index-define_002dinterface">configuration form: <strong>define-interface</strong> <em>name interface</em></dt>
  2112. <dd><p>Defines <var>name</var> to be the interface that <var>interface</var> evaluates
  2113. to. <var>Interface</var> may either be an interface constructor application
  2114. or simply a name defined to be an interface by some prior
  2115. <code>define-interface</code> form.
  2116. </p></dd></dl>
  2117. <span id="index-simple-interfaces"></span>
  2118. <dl>
  2119. <dt id="index-export">interface constructor: <strong>export</strong> <em>export-specifier &hellip;</em></dt>
  2120. <dd><p><code>Export</code> constructs a simple interface with the given export
  2121. specifiers. The export specifiers specify names to export and their
  2122. corresponding static types. Each <var>export-specifier</var> should have
  2123. one of the following forms:
  2124. </p>
  2125. <dl compact="compact">
  2126. <dt><code><var>symbol</var></code></dt>
  2127. <dd><p>in which case <var>symbol</var> is exported with the most general value type;
  2128. </p>
  2129. </dd>
  2130. <dt><code>(<var>symbol</var> <var>type</var>)</code></dt>
  2131. <dd><p>in which case <var>symbol</var> is exported with the given type; or
  2132. </p>
  2133. </dd>
  2134. <dt><code>((<var>symbol</var> &hellip;) <var>type</var>)</code></dt>
  2135. <dd><p>in which case each <var>symbol</var> is exported with the same given type
  2136. </p></dd>
  2137. </dl>
  2138. <p>For details on the valid forms of <var>type</var>, see <a href="#Static-type-system">Static type system</a>. <strong>Note:</strong> All macros listed in interfaces <em>must</em> be
  2139. explicitly annotated with the type <code>:syntax</code>; otherwise they would
  2140. be exported with a Scheme value type, which would confuse the compiler,
  2141. because it would not realize that they are macros: it would instead
  2142. treat them as ordinary variables that have regular run-time values.
  2143. </p></dd></dl>
  2144. <span id="index-compound-interfaces-1"></span>
  2145. <dl>
  2146. <dt id="index-compound_002dinterface">interface constructor: <strong>compound-interface</strong> <em>interface &hellip;</em></dt>
  2147. <dd><p>This constructs an interface that contains all of the export specifiers
  2148. from each <var>interface</var>.
  2149. </p></dd></dl>
  2150. <span id="index-anonymous-structures"></span>
  2151. <p>Structures may also be constructed anonymously; this is typically most
  2152. useful in passing them to or returning them from parameterized modules.
  2153. </p>
  2154. <dl>
  2155. <dt id="index-structure">structure constructor: <strong>structure</strong> <em>interface package-clauses</em></dt>
  2156. <dt id="index-structures-1">structure constructor: <strong>structures</strong> <em>(interface &hellip;) package-clauses</em></dt>
  2157. <dd><p><code>Structure</code> creates a package with the given clauses and evaluates
  2158. to a structure over it with the given interface. <code>Structures</code>
  2159. does similarly, but it evaluates to a number of structures, each with
  2160. the corresponding <var>interface</var>.
  2161. </p></dd></dl>
  2162. <span id="index-modified-structures"></span>
  2163. <span id="index-modified-interfaces"></span>
  2164. <dl>
  2165. <dt id="index-subset">structure constructor: <strong>subset</strong> <em>structure (name &hellip;)</em></dt>
  2166. <dt id="index-with_002dprefix">structure constructor: <strong>with-prefix</strong> <em>structure name</em></dt>
  2167. <dt id="index-modify">structure constructor: <strong>modify</strong> <em>structure modifier &hellip;</em></dt>
  2168. <dd><p>These modify the interface of <var>structure</var>. <code>Subset</code> evaluates
  2169. to a structure that exports only <var>name</var> &hellip;, excluding any
  2170. other names that <var>structure</var> exported. <code>With-prefix</code> adds a
  2171. prefix <var>name</var> to every name listed in <var>structure</var>&rsquo;s interface.
  2172. Both <code>subset</code> and <code>with-prefix</code> are syntactic sugar for the
  2173. more general <code>modify</code>, which applies the modifier commands in a
  2174. strictly right-to-left or last-to-first order. <strong>Note:</strong> These
  2175. all <em>denote new structures with new interfaces</em>; they do not
  2176. destructively modify existing structures&rsquo; interfaces.
  2177. </p></dd></dl>
  2178. <dl>
  2179. <dt id="index-prefix">modifier command: <strong>prefix</strong> <em>name</em></dt>
  2180. <dt id="index-expose">modifier command: <strong>expose</strong> <em>name &hellip;</em></dt>
  2181. <dt id="index-hide">modifier command: <strong>hide</strong> <em>name &hellip;</em></dt>
  2182. <dt id="index-alias">modifier command: <strong>alias</strong> <em>(from to) &hellip;</em></dt>
  2183. <dt id="index-rename">modifier command: <strong>rename</strong> <em>(from to) &hellip;</em></dt>
  2184. <dd><p><code>Prefix</code> adds the prefix <var>name</var> to every exported name in the
  2185. structure&rsquo;s interface. <code>Expose</code> exposes only <var>name</var> &hellip;;
  2186. any other names are hidden. <code>Hide</code> hides <var>name</var> &hellip;.
  2187. <code>Alias</code> exports each <var>to</var> as though it were the corresponding
  2188. <var>from</var>, as well as each <var>from</var>. <code>Rename</code> exports each
  2189. <var>to</var> as if it were the corresponding <var>from</var>, but it also hides
  2190. the corresponding <var>from</var>.
  2191. </p>
  2192. <p>Examples:
  2193. </p>
  2194. <div class="lisp">
  2195. <pre class="lisp">(modify <var>structure</var>
  2196. (prefix foo:)
  2197. (expose bar baz quux))</pre></div>
  2198. <p>makes only <code>foo:bar</code>, <code>foo:baz</code>, and <code>foo:quux</code>,
  2199. available.
  2200. </p>
  2201. <div class="lisp">
  2202. <pre class="lisp">(modify <var>structure</var>
  2203. (hide baz:quux)
  2204. (prefix baz:)
  2205. (rename (foo bar)
  2206. (mumble frotz))
  2207. (alias (gargle mumph)))</pre></div>
  2208. <p>exports <code>baz:gargle</code> as what was originally <code>mumble</code>,
  2209. <code>baz:mumph</code> as an alias for what was originally <code>gargle</code>,
  2210. <code>baz:frotz</code> as what was originally <code>mumble</code>, <code>baz:bar</code>
  2211. as what was originally <code>foo</code>, <em>not</em> <code>baz:quux</code> &mdash; what
  2212. was originally simply <code>quux</code> &mdash;, and everything else that
  2213. <var>structure</var> exported, but with a prefix of <code>baz:</code>.
  2214. </p></dd></dl>
  2215. <p>There are several simple utilities for binding variables to structures
  2216. locally and returning multiple structures not necessarily over the same
  2217. package (<i>i.e.</i> not with <code>structures</code>). These are all valid in the
  2218. bodies of <code>define-module</code> and <code>def</code> forms, and in the
  2219. arguments to parameterized modules and <code>open</code> package clauses.
  2220. </p>
  2221. <dl>
  2222. <dt id="index-begin-1">syntax: <strong>begin</strong> <em>body</em></dt>
  2223. <dt id="index-let">syntax: <strong>let</strong> <em>((name value) &hellip;) body</em></dt>
  2224. <dt id="index-receive">syntax: <strong>receive</strong> <em>(name &hellip;) producer body</em></dt>
  2225. <dt id="index-values">syntax: <strong>values</strong> <em>value &hellip;</em></dt>
  2226. <dd><p>These are all as in ordinary Scheme. Note, however, that there is no
  2227. reasonable way by which to use <code>values</code> except to call it, so it
  2228. is considered a syntax; also note that <code>receive</code> may not receive
  2229. a variable number of values &mdash; <i>i.e.</i> there are no &lsquo;rest lists&rsquo; &mdash;,
  2230. because list values in the configuration language are nonsensical.
  2231. </p></dd></dl>
  2232. <span id="index-macros-in-the-module-configuration-language"></span>
  2233. <span id="index-configuration-language-macros"></span>
  2234. <span id="index-module-language-macros"></span>
  2235. <p>Finally, the configuration language also supports syntactic extensions,
  2236. or macros, as in Scheme.
  2237. </p>
  2238. <dl>
  2239. <dt id="index-define_002dsyntax">configuration form: <strong>define-syntax</strong> <em>name transformer-specifier</em></dt>
  2240. <dd><p>Defines the syntax transformer <var>name</var> to be the transformer
  2241. specified by <var>transformer-specifier</var>. <var>Transformer-specifier</var>
  2242. is exactly the same as in Scheme code; it is evaluated as ordinary
  2243. Scheme.
  2244. </p></dd></dl>
  2245. <hr>
  2246. <span id="Macros-in-concert-with-modules"></span><div class="header">
  2247. <p>
  2248. Next: <a href="#Static-type-system" accesskey="n" rel="next">Static type system</a>, Previous: <a href="#Module-configuration-language" accesskey="p" rel="prev">Module configuration language</a>, Up: <a href="#Module-system" accesskey="u" rel="up">Module system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2249. </div>
  2250. <span id="Macros-in-concert-with-modules-1"></span><h3 class="section">3.3 Macros in concert with modules</h3>
  2251. <p>One reason that the standard Scheme language does not support a module
  2252. system yet is the issue of macros and modularity. There are several
  2253. issues to deal with:
  2254. </p>
  2255. <ul>
  2256. <li> <span id="index-separate-compilation"></span>
  2257. that compilation of code that uses macros requires presence of those
  2258. macros&rsquo; definitions, which prevents true separate compilation, because
  2259. those macros may be from other modules;
  2260. </li><li> <span id="index-hygiene-of-macros-in-modules"></span>
  2261. <span id="index-referential-transparency-of-macros-in-modules"></span>
  2262. <span id="index-macro-hygiene-in-modules"></span>
  2263. <span id="index-macro-referential-transparency-in-modules"></span>
  2264. that a macro&rsquo;s expansion must preserve referential transparency and
  2265. hygiene, for example in cases where it refers to names from within the
  2266. module in which it was defined, even if those names weren&rsquo;t exported;
  2267. and
  2268. </li><li> <span id="index-phase-separation"></span>
  2269. <span id="index-towers-of-evaluation-phases"></span>
  2270. that a macro&rsquo;s code may be arbitrary Scheme code, which in turn can use
  2271. other modules, so one module&rsquo;s compile-time, when macros are expanded,
  2272. is another&rsquo;s run-time, when the code used in macros is executed by the
  2273. expander: this makes a tower of phases of code evaluation over which
  2274. some coherent control must be provided.
  2275. </li></ul>
  2276. <p>Scheme48&rsquo;s module system tries to address all of these issues
  2277. coherently and comprehensively. Although it cannot offer <em>total</em>
  2278. separate compilation, it can offer incremental compilation, and
  2279. compiled modules can be dumped to the file system &amp; restored in the
  2280. process of incremental compilation.<a id="DOCF7" href="#FOOT7"><sup>7</sup></a>
  2281. </p>
  2282. <p>Scheme48&rsquo;s module system is also very careful to preserve non-local
  2283. module references from a macro&rsquo;s expansion. Macros in Scheme48 are
  2284. required to perform hygienic renaming in order for this preservation,
  2285. however; see <a href="#Explicit-renaming-macros">Explicit renaming macros</a>. For a brief example,
  2286. consider the <code>delay</code> syntax for lazy evaluation. It expands to a
  2287. simple procedure call:
  2288. </p>
  2289. <div class="lisp">
  2290. <pre class="lisp">(delay <var>expression</var>)
  2291. &rarr; (make-promise (lambda () <var>expression</var>))</pre></div>
  2292. <p>However, <code>make-promise</code> is not exported from the <code>scheme</code>
  2293. structure. The expansion works correctly due to the hygienic renaming
  2294. performed by the <code>delay</code> macro transformer: when it hygienically
  2295. renames <code>make-promise</code>, the output contains not the symbol but a
  2296. special token that refers exactly to the binding of <code>make-promise</code>
  2297. from the environment in which the <code>delay</code> macro transformer was
  2298. defined. Special care is taken to preserve this information. Had
  2299. <code>delay</code> expanded to a simple S-expression with simple symbols, it
  2300. would have generated a free reference to <code>make-promise</code>, which
  2301. would cause run-time undefined variable errors, or, if the module in
  2302. which <code>delay</code> was used had its <em>own</em> binding of or imported a
  2303. binding of the name <code>make-promise</code>, <code>delay</code>&rsquo;s expansion
  2304. would refer to the wrong binding, and there could potentially be
  2305. drastic and entirely unintended impact upon its semantics.
  2306. </p>
  2307. <span id="index-reflective-tower"></span>
  2308. <span id="index-syntactic-tower"></span>
  2309. <span id="index-for_002dsyntax"></span>
  2310. <p>Finally, Scheme48&rsquo;s module system has a special design for the tower of
  2311. phases, called a <em>reflective tower</em>.<a id="DOCF8" href="#FOOT8"><sup>8</sup></a> Every storey represents the environment available at
  2312. successive macro levels. That is, when the right-hand side of a macro
  2313. definition or binding is evaluated in an environment, the next storey
  2314. in that environment&rsquo;s reflective tower is used to evaluate that macro
  2315. binding. For example, in this code, there are two storeys used in the
  2316. tower:
  2317. </p>
  2318. <div class="lisp">
  2319. <pre class="lisp">(define (foo ...bar...)
  2320. (let-syntax ((baz ...quux...))
  2321. ...zot...))</pre></div>
  2322. <p>In order to evaluate code in one storey of the reflective tower, it is
  2323. necessary to expand all macros first. Most of the code in this example
  2324. will eventually be evaluated in the first storey of the reflective
  2325. tower (assuming it is an ordinary top-level definition), but, in order
  2326. to expand macros in that code, the <code>let-syntax</code> must be expanded.
  2327. This causes <code>...quux...</code> to be evaluated in the <em>second</em>
  2328. storey of the tower, after which macro expansion can proceed, and long
  2329. after which the enclosing program can be evaluated.
  2330. </p>
  2331. <span id="index-for_002dsyntax-1"></span>
  2332. <p>The module system provides a simple way to manipulate the reflective
  2333. tower. There is a package clause, <code>for-syntax</code>, that simply
  2334. contains package clauses for the next storey in the tower. For
  2335. example, a package with the following clauses:
  2336. </p>
  2337. <div class="lisp">
  2338. <pre class="lisp">(open scheme foo bar)
  2339. (for-syntax (open scheme baz quux))</pre></div>
  2340. <p>has all the bindings of <code>scheme</code>, <code>foo</code>, &amp; <code>bar</code>, at the
  2341. ground storey; and the environment in which macros&rsquo; definitions are
  2342. evaluated provides everything from <code>scheme</code>, <code>baz</code>, &amp;
  2343. <code>quux</code>.
  2344. </p>
  2345. <p>With no <code>for-syntax</code> clauses, the <code>scheme</code> structure is
  2346. implicitly opened; however, if there are <code>for-syntax</code> clauses,
  2347. <code>scheme</code> must be explicitly opened.<a id="DOCF9" href="#FOOT9"><sup>9</sup></a> Also, <code>for-syntax</code> clauses
  2348. may be arbitrarily nested: reflective towers are theoretically infinite
  2349. in height. (They are internally implemented lazily, so they grow
  2350. exactly as high as they need to be.)
  2351. </p>
  2352. <p>Here is a simple, though contrived, example of using <code>for-syntax</code>.
  2353. The <code>while-loops</code> structure exports <code>while</code>, a macro similar
  2354. to C&rsquo;s <code>while</code> loop. <code>While</code>&rsquo;s transformer unhygienically
  2355. binds the name <code>exit</code> to a procedure that exits from the loop.
  2356. It necessarily, therefore, uses <a href="#Explicit-renaming-macros">explicit renaming macros</a> in order to break hygiene; it also, in the
  2357. macro transformer, uses the <code>destructure</code> macro to destructure the
  2358. input form (see <a href="#Library-utilities">Library utilities</a>, in particular, the structure
  2359. <code>destructuring</code> for destructuring S-expressions).
  2360. </p>
  2361. <div class="lisp">
  2362. <pre class="lisp">(define-structure while-loops (export while)
  2363. (open scheme)
  2364. (for-syntax (open scheme destructuring))
  2365. (begin
  2366. (define-syntax while
  2367. (lambda (form r compare)
  2368. (destructure (((WHILE test . body) form))
  2369. `(,(r 'CALL-WITH-CURRENT-CONTINUATION)
  2370. (,(r 'LAMBDA) (EXIT)
  2371. (,(r 'LET) (r 'LOOP) ()
  2372. (,(r 'IF) ,test
  2373. (,(r 'BEGIN)
  2374. ,@body
  2375. (,(r 'LOOP)))))))))
  2376. (CALL-WITH-CURRENT-CONTINUATION LAMBDA LET IF BEGIN))))</pre></div>
  2377. <p>This next <code>while-example</code> structure defines an example procedure
  2378. <code>foo</code> that uses <code>while</code>. Since <code>while-example</code> has no
  2379. macro definitions, there is no need for any <code>for-syntax</code> clauses;
  2380. it imports <code>while</code> from the <code>while-loops</code> structure only at
  2381. the ground storey, because it has no macro bindings to evaluate the
  2382. transformer expressions of:
  2383. </p>
  2384. <div class="lisp">
  2385. <pre class="lisp">(define-structure while-example (export foo)
  2386. (open scheme while-loops)
  2387. (begin
  2388. (define (foo x)
  2389. (while (&gt; x 9)
  2390. (if (integer? (sqrt x))
  2391. (exit (expt x 2))
  2392. (set! x (- x 1)))))))</pre></div>
  2393. <hr>
  2394. <span id="Static-type-system"></span><div class="header">
  2395. <p>
  2396. Previous: <a href="#Macros-in-concert-with-modules" accesskey="p" rel="prev">Macros in concert with modules</a>, Up: <a href="#Module-system" accesskey="u" rel="up">Module system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2397. </div>
  2398. <span id="Static-type-system-1"></span><h3 class="section">3.4 Static type system</h3>
  2399. <span id="index-type-inference"></span>
  2400. <span id="index-static-type-analysis"></span>
  2401. <p>Scheme48 supports a rudimentary static type system. It is intended
  2402. mainly to catch some classes of type and arity mismatch errors early,
  2403. at compile-time. By default, there is only <em>extremely</em> basic
  2404. analysis, which is typically only good enough to catch arity errors and
  2405. the really egregious type errors. The full reconstructor, which is
  2406. still not very sophisticated, is enabled by specifying an optimizer
  2407. pass that invokes the code usage analyzer. The only optimizer pass
  2408. built-in to Scheme48, the automatic procedure integrator, named
  2409. <code>auto-integrate</code>, does so.
  2410. </p>
  2411. <p>The type reconstructor attempts to assign the most specific type it can
  2412. to program terms, signalling warnings for terms that are certain to be
  2413. invalid by Scheme&rsquo;s dynamic semantics. Since the reconstructor is not
  2414. very sophisticated, it frequently gives up and assigns very general
  2415. types to many terms. Note, however, that it is very lenient in that it
  2416. only assigns more general types: it will <em>never</em> signal a warning
  2417. because it could not reconstruct a very specific type. For example,
  2418. the following program will produce no warnings:
  2419. </p>
  2420. <div class="lisp">
  2421. <pre class="lisp">(define (foo x y) (if x (+ y 1) (car y)))</pre></div>
  2422. <p>Calls to <code>foo</code> that are clearly invalid, such as <code>(foo #t
  2423. 'a)</code>, could cause the type analyzer to signal warnings, but it is not
  2424. sophisticated enough to determine that <code>foo</code>&rsquo;s second argument
  2425. must be either a number or a pair; it simply assigns a general value
  2426. type (see below).
  2427. </p>
  2428. <p>There are some tricky cases that depend on the order by which arguments
  2429. are evaluated in a combination, because that order is not specified in
  2430. Scheme. In these cases, the relevant types are narrowed to the most
  2431. specific ones that could not possibly cause errors at run-time for any
  2432. order. For example,
  2433. </p>
  2434. <div class="lisp">
  2435. <pre class="lisp">(lambda (x) (+ (begin (set! x '(3)) 5) (car x)))</pre></div>
  2436. <p>will be assigned the type <code>(proc (:pair) :number)</code>, because, if
  2437. the arguments are evaluated right-to-left, and <code>x</code> is not a pair,
  2438. there will be a run-time type error.
  2439. </p>
  2440. <p>The type reconstructor presumes that all code is potentially reachable,
  2441. so it may signal warnings for code that the most trivial control flow
  2442. analyzer could decide unreachable. For example, it would signal a
  2443. warning for <code>(if #t 3 (car 7))</code>. Furthermore, it does not account
  2444. for continuation throws; for example, though it is a perfectly valid
  2445. Scheme program, the type analyzer might signal a warning for this code:
  2446. </p>
  2447. <div class="lisp">
  2448. <pre class="lisp">(call-with-current-continuation
  2449. (lambda (k) (0 (k))))</pre></div>
  2450. <span id="index-type-lattice"></span>
  2451. <p>The type system is based on a type lattice. There are several maximum
  2452. or &lsquo;top&rsquo; elements, such as <code>:values</code>, <code>:syntax</code>, and
  2453. <code>:structure</code>; and one minimum or &lsquo;bottom&rsquo; element, <code>:error</code>.
  2454. This description of the type system makes use of the following
  2455. notations: <code><var>E</var> : <var>T</var></code> means that the term <var>E</var> has the
  2456. type, or some compatible subtype of, <var>T</var>; and <code><var>T<sub>a</sub></var>
  2457. &lt;= <var>T<sub>b</sub></var></code> means that <var>T<sub>a</sub></var> is a compatible
  2458. subtype of <var>T<sub>b</sub></var> &mdash; that is, any term whose static type is
  2459. <var>T<sub>a</sub></var> is valid in any context that expects the type
  2460. <var>T<sub>b</sub></var> &mdash;.
  2461. </p>
  2462. <p>Note that the previous text has used the word &lsquo;term,&rsquo; not &lsquo;expression,&rsquo;
  2463. because static types are assigned to not only Scheme expressions. For
  2464. example, <code>cond</code> macro has the type <code>:syntax</code>. Structures in
  2465. the configuration language also have static types: their interfaces.
  2466. (Actually, they really have the type <code>:structure</code>, but this is a
  2467. deficiency in the current implementation&rsquo;s design.) Types, in fact,
  2468. have their own type: <code>:type</code>. Here are some examples of values,
  2469. first-class or otherwise, and their types:
  2470. </p>
  2471. <div class="example">
  2472. <pre class="example">cond : :syntax
  2473. (values 1 'foo '(x . y))
  2474. : (some-values :exact-integer :symbol :pair)
  2475. :syntax : :type
  2476. 3 : :exact-integer
  2477. (define-structure foo (export a b) ...)
  2478. foo : (export a b)</pre></div>
  2479. <span id="index-parametric-polymorphism"></span>
  2480. <p>One notable deficiency of the type system is the absence of any sort of
  2481. parametric polymorphism.
  2482. </p>
  2483. <span id="index-join-types"></span>
  2484. <span id="index-meet-types"></span>
  2485. <dl>
  2486. <dt id="index-join">type constructor: <strong>join</strong> <em>type &hellip;</em></dt>
  2487. <dt id="index-meet">type constructor: <strong>meet</strong> <em>type &hellip;</em></dt>
  2488. <dd><p><code>Join</code> and <code>meet</code> construct the supremum and infimum elements
  2489. in the type lattice of the given types. That is, for any two disjoint
  2490. types <var>T<sub>a</sub></var> and <var>T<sub>b</sub></var>, let <var>T<sub>j</sub></var> be
  2491. <code>(join <var>T<sub>a</sub></var> <var>T<sub>b</sub></var>)</code> and <var>T<sub>m</sub></var> be
  2492. <code>(meet <var>T<sub>a</sub></var> <var>T<sub>b</sub></var>)</code>:
  2493. </p>
  2494. <ul>
  2495. <li> <var>T<sub>j</sub></var> &lt;= <var>T<sub>a</sub></var> and <var>T<sub>j</sub></var> &lt;= <var>T<sub>b</sub></var>
  2496. </li><li> <var>T<sub>a</sub></var> &lt;= <var>T<sub>m</sub></var> and <var>T<sub>b</sub></var> &lt;= <var>T<sub>m</sub></var>
  2497. </li></ul>
  2498. <p>For example, <code>(join :pair :null)</code> allows either pairs or nil,
  2499. <i>i.e.</i> lists, and <code>(meet :integer :exact)</code> accepts only integers
  2500. that are also exact.
  2501. </p>
  2502. <p>(More complete definitions of supremum, infimum, and other elements of
  2503. lattice theory, may be found elsewhere.)
  2504. </p></dd></dl>
  2505. <dl>
  2506. <dt id="index-_003aerror">type: <strong>:error</strong></dt>
  2507. <dd><p>This is the minimal, or &lsquo;bottom,&rsquo; element in the type lattice. It is
  2508. the type of, for example, calls to <code>error</code>.
  2509. </p></dd></dl>
  2510. <dl>
  2511. <dt id="index-_003avalues">type: <strong>:values</strong></dt>
  2512. <dt id="index-_003aarguments">type: <strong>:arguments</strong></dt>
  2513. <dd><p>All Scheme <em>expressions</em> have the type <code>:values</code>. They may
  2514. have more specific types as well, but all expressions&rsquo; types are
  2515. compatible subtypes of <code>:values</code>. <code>:Values</code> is a maximal
  2516. element of the type lattice. <code>:Arguments</code> is synonymous with
  2517. <code>:values</code>.
  2518. </p></dd></dl>
  2519. <dl>
  2520. <dt id="index-_003avalue">type: <strong>:value</strong></dt>
  2521. <dd><p>Scheme expressions that have a single result have the type
  2522. <code>:value</code>, or some compatible subtype thereof; it is itself a
  2523. compatible subtype of <code>:values</code>.
  2524. </p></dd></dl>
  2525. <dl>
  2526. <dt id="index-some_002dvalues">type constructor: <strong>some-values</strong> <em>type &hellip;</em></dt>
  2527. <dd><p><code>Some-values</code> is used to denote the types of expressions that have
  2528. multiple results: if <code><var>E<sub>1</sub></var> &hellip; <var>E<sub>n</sub></var></code> have
  2529. the types <code><var>T<sub>1</sub></var> &hellip; <var>T<sub>n</sub></var></code>, then the Scheme
  2530. expression <code>(values <var>E<sub>1</sub></var> &hellip; <var>E<sub>n</sub></var>)</code> has
  2531. the type <code>(some-values <var>T<sub>1</sub></var> &hellip; <var>T<sub>n</sub></var>)</code>.
  2532. </p>
  2533. <p><code>Some-values</code>-constructed types are compatible subtypes of
  2534. <code>:values</code>.
  2535. </p>
  2536. <p><code>Some-values</code> also accepts &lsquo;optional&rsquo; and &lsquo;rest&rsquo; types, similarly
  2537. to Common Lisp&rsquo;s &lsquo;optional&rsquo; and &lsquo;rest&rsquo; formal parameters. The sequence
  2538. of types may contain a <code>&amp;opt</code> token, followed by which is any
  2539. number of further types, which are considered to be optional. For
  2540. example, <code>make-vector</code>&rsquo;s domain is <code>(some-values
  2541. :exact-integer &amp;opt :value)</code>. There may also be a <code>&amp;rest</code> token,
  2542. which must follow the <code>&amp;opt</code> token if there is one. Following the
  2543. <code>&amp;rest</code> token is one more type, which the rest of the sequents in
  2544. a sequence after the required or optional sequents must satisfy. For
  2545. example, <code>map</code>&rsquo;s domain is <code>(some-values :procedure (join
  2546. :pair :null) &amp;rest (join :pair :null))</code>: it accepts one procedure and
  2547. at least one list (pair or null) argument.
  2548. </p></dd></dl>
  2549. <dl>
  2550. <dt id="index-procedure">type constructor: <strong>procedure</strong> <em>domain codomain</em></dt>
  2551. <dt id="index-proc">type constructor: <strong>proc</strong> <em>(arg-type &hellip;) result-type</em></dt>
  2552. <dd><p>Procedure type constructors. Procedure types are always compatible
  2553. subtypes of <code>:value</code>. <code>Procedure</code> is a simple constructor
  2554. from a specific domain and codomain; <var>domain</var> and <var>codomain</var>
  2555. must be compatible subtypes of <code>:values</code>. <code>Proc</code> is a more
  2556. convenient constructor. It is equivalent to <code>(procedure
  2557. (some-values <var>arg-type</var> &hellip;) <var>result-type</var>)</code>.
  2558. </p></dd></dl>
  2559. <dl>
  2560. <dt id="index-_003aboolean">type: <strong>:boolean</strong></dt>
  2561. <dt id="index-_003achar">type: <strong>:char</strong></dt>
  2562. <dt id="index-_003anull">type: <strong>:null</strong></dt>
  2563. <dt id="index-_003aunspecific">type: <strong>:unspecific</strong></dt>
  2564. <dt id="index-_003apair">type: <strong>:pair</strong></dt>
  2565. <dt id="index-_003astring">type: <strong>:string</strong></dt>
  2566. <dt id="index-_003asymbol">type: <strong>:symbol</strong></dt>
  2567. <dt id="index-_003avector">type: <strong>:vector</strong></dt>
  2568. <dt id="index-_003aprocedure">type: <strong>:procedure</strong></dt>
  2569. <dt id="index-_003ainput_002dport">type: <strong>:input-port</strong></dt>
  2570. <dt id="index-_003aoutput_002dport">type: <strong>:output-port</strong></dt>
  2571. <dd><p>Types that represent standard Scheme data. These are all compatible
  2572. subtypes of <code>:value</code>. <code>:Procedure</code> is the general type for
  2573. all procedures; see <code>proc</code> and <code>procedure</code> for procedure
  2574. types with specific domains and codomains.
  2575. </p></dd></dl>
  2576. <dl>
  2577. <dt id="index-_003anumber">type: <strong>:number</strong></dt>
  2578. <dt id="index-_003acomplex">type: <strong>:complex</strong></dt>
  2579. <dt id="index-_003areal">type: <strong>:real</strong></dt>
  2580. <dt id="index-_003arational">type: <strong>:rational</strong></dt>
  2581. <dt id="index-_003ainteger">type: <strong>:integer</strong></dt>
  2582. <dd><p>Types of the Scheme numeric tower. <code>:integer &lt;= :rational
  2583. &lt;= :real &lt;= :complex &lt;= :number</code>
  2584. </p></dd></dl>
  2585. <dl>
  2586. <dt id="index-_003aexact">type: <strong>:exact</strong></dt>
  2587. <dt id="index-_003ainexact">type: <strong>:inexact</strong></dt>
  2588. <dt id="index-_003aexact_002dinteger">type: <strong>:exact-integer</strong></dt>
  2589. <dt id="index-_003ainexact_002dreal">type: <strong>:inexact-real</strong></dt>
  2590. <dd><p><code>:Exact</code> and <code>:inexact</code> are the types of exact and inexact
  2591. numbers, respectively. They are typically met with one of the types in
  2592. the numeric tower above; <code>:exact-integer</code> and <code>:inexact-real</code>
  2593. are two conveniences for the most common meets.
  2594. </p></dd></dl>
  2595. <dl>
  2596. <dt id="index-_003aother">type: <strong>:other</strong></dt>
  2597. <dd><p><code>:Other</code> is for types that do not fall into any of the previous
  2598. value categories. (<code>:other &lt;= :value</code>) All new types
  2599. introduced, for example by <a href="#Type-annotations"><code>loophole</code></a>,
  2600. are compatible subtypes of <code>:other</code>.
  2601. </p></dd></dl>
  2602. <dl>
  2603. <dt id="index-variable">type constructor: <strong>variable</strong> <em>type</em></dt>
  2604. <dd><p>This is the type of all assignable variables, where <code><var>type</var>
  2605. &lt;= :value</code>. Assignment to variables whose types are value
  2606. types, not assignable variable types, is invalid.
  2607. </p></dd></dl>
  2608. <dl>
  2609. <dt id="index-_003asyntax">type: <strong>:syntax</strong></dt>
  2610. <dt id="index-_003astructure">type: <strong>:structure</strong></dt>
  2611. <dd><p><code>:Syntax</code> and <code>:structure</code> are two other maximal elements of
  2612. the type lattice, along with <code>:values</code>. <code>:Syntax</code> is the
  2613. type of macros or syntax transformers. <code>:Structure</code> is the
  2614. general type of all structures.
  2615. </p></dd></dl>
  2616. <span id="Types-in-the-configuration-language"></span><h4 class="subsection">3.4.1 Types in the configuration language</h4>
  2617. <p>Scheme48&rsquo;s configuration language has several places in which to write
  2618. types. However, due to the definitions of certain elements of the
  2619. configuration language, notably the <code>export</code> syntax, the allowable
  2620. type syntax is far more limited than the above. Only the following are
  2621. provided:
  2622. </p>
  2623. <dl>
  2624. <dt id="index-_003avalues-1">type: <strong>:values</strong></dt>
  2625. <dt id="index-_003avalue-1">type: <strong>:value</strong></dt>
  2626. <dt id="index-_003aarguments-1">type: <strong>:arguments</strong></dt>
  2627. <dt id="index-_003asyntax-1">type: <strong>:syntax</strong></dt>
  2628. <dt id="index-_003astructure-1">type: <strong>:structure</strong></dt>
  2629. <dd><p>All of the built-in maximal elements of the type lattice are provided,
  2630. as well as the simple compatible subtype <code>:values</code>, <code>:value</code>.
  2631. </p></dd></dl>
  2632. <dl>
  2633. <dt id="index-_003aboolean-1">type: <strong>:boolean</strong></dt>
  2634. <dt id="index-_003achar-1">type: <strong>:char</strong></dt>
  2635. <dt id="index-_003anull-1">type: <strong>:null</strong></dt>
  2636. <dt id="index-_003aunspecific-1">type: <strong>:unspecific</strong></dt>
  2637. <dt id="index-_003apair-1">type: <strong>:pair</strong></dt>
  2638. <dt id="index-_003astring-1">type: <strong>:string</strong></dt>
  2639. <dt id="index-_003asymbol-1">type: <strong>:symbol</strong></dt>
  2640. <dt id="index-_003avector-1">type: <strong>:vector</strong></dt>
  2641. <dt id="index-_003aprocedure-1">type: <strong>:procedure</strong></dt>
  2642. <dt id="index-_003ainput_002dport-1">type: <strong>:input-port</strong></dt>
  2643. <dt id="index-_003aoutput_002dport-1">type: <strong>:output-port</strong></dt>
  2644. <dt id="index-_003anumber-1">type: <strong>:number</strong></dt>
  2645. <dt id="index-_003acomplex-1">type: <strong>:complex</strong></dt>
  2646. <dt id="index-_003areal-1">type: <strong>:real</strong></dt>
  2647. <dt id="index-_003arational-1">type: <strong>:rational</strong></dt>
  2648. <dt id="index-_003ainteger-1">type: <strong>:integer</strong></dt>
  2649. <dt id="index-_003aexact_002dinteger-1">type: <strong>:exact-integer</strong></dt>
  2650. <dd><p>These are the only value types provided in the configuration language.
  2651. Note the conspicuous absence of <code>:exact</code>, <code>:inexact</code>, and
  2652. <code>:inexact-real</code>.
  2653. </p></dd></dl>
  2654. <dl>
  2655. <dt id="index-procedure-1">type constructor: <strong>procedure</strong> <em>domain codomain</em></dt>
  2656. <dt id="index-proc-1">type constructor: <strong>proc</strong> <em>(arg-type &hellip;) result-type</em></dt>
  2657. <dd><p>These two are the only type constructors available. Note here the
  2658. conspicuous absence of <code>some-values</code>, so procedure types that are
  2659. constructed by <code>procedure</code> can accept only one argument (or use
  2660. the overly general <code>:values</code> type) &amp; return only one result (or,
  2661. again, use <code>:values</code> for the codomain), and procedure types that
  2662. are constructed by <code>proc</code> are similar in the result type.
  2663. </p></dd></dl>
  2664. <hr>
  2665. <span id="System-facilities"></span><div class="header">
  2666. <p>
  2667. Next: <a href="#Multithreading" accesskey="n" rel="next">Multithreading</a>, Previous: <a href="#Module-system" accesskey="p" rel="prev">Module system</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2668. </div>
  2669. <span id="System-facilities-1"></span><h2 class="chapter">4 System facilities</h2>
  2670. <p>This chapter details many facilities that the Scheme48 run-time system
  2671. provides.
  2672. </p>
  2673. <table class="menu" border="0" cellspacing="0">
  2674. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#System-features" accesskey="1">System features</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2675. </td></tr>
  2676. <tr><td align="left" valign="top">&bull; <a href="#Condition-system" accesskey="2">Condition system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2677. </td></tr>
  2678. <tr><td align="left" valign="top">&bull; <a href="#Bitwise-manipulation" accesskey="3">Bitwise manipulation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2679. </td></tr>
  2680. <tr><td align="left" valign="top">&bull; <a href="#Generic-dispatch-system" accesskey="4">Generic dispatch system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2681. </td></tr>
  2682. <tr><td align="left" valign="top">&bull; <a href="#I_002fO-system" accesskey="5">I/O system</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2683. </td></tr>
  2684. <tr><td align="left" valign="top">&bull; <a href="#Reader-_0026-writer" accesskey="6">Reader &amp; writer</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2685. </td></tr>
  2686. <tr><td align="left" valign="top">&bull; <a href="#Records" accesskey="7">Records</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2687. </td></tr>
  2688. <tr><td align="left" valign="top">&bull; <a href="#Suspending-and-resuming-heap-images" accesskey="8">Suspending and resuming heap images</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2689. </td></tr>
  2690. </table>
  2691. <hr>
  2692. <span id="System-features"></span><div class="header">
  2693. <p>
  2694. Next: <a href="#Condition-system" accesskey="n" rel="next">Condition system</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2695. </div>
  2696. <span id="System-features-1"></span><h3 class="section">4.1 System features</h3>
  2697. <p>Scheme48 provides a variety of miscellaneous features built-in to the
  2698. system.
  2699. </p>
  2700. <table class="menu" border="0" cellspacing="0">
  2701. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  2702. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Miscellaneous-features" accesskey="1">Miscellaneous features</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2703. </td></tr>
  2704. <tr><td align="left" valign="top">&bull; <a href="#Various-utilities" accesskey="2">Various utilities</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2705. </td></tr>
  2706. <tr><td align="left" valign="top">&bull; <a href="#Filenames" accesskey="3">Filenames</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2707. </td></tr>
  2708. <tr><td align="left" valign="top">&bull; <a href="#Fluid_002fdynamic-bindings" accesskey="4">Fluid/dynamic bindings</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2709. </td></tr>
  2710. <tr><td align="left" valign="top">&bull; <a href="#ASCII-character-encoding" accesskey="5">ASCII character encoding</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2711. </td></tr>
  2712. <tr><td align="left" valign="top">&bull; <a href="#Integer-enumerations" accesskey="6">Integer enumerations</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2713. </td></tr>
  2714. <tr><td align="left" valign="top">&bull; <a href="#Cells" accesskey="7">Cells</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2715. </td></tr>
  2716. <tr><td align="left" valign="top">&bull; <a href="#Queues" accesskey="8">Queues</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2717. </td></tr>
  2718. <tr><td align="left" valign="top">&bull; <a href="#Hash-tables" accesskey="9">Hash tables</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2719. </td></tr>
  2720. <tr><td align="left" valign="top">&bull; <a href="#Weak-references">Weak references</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2721. </td></tr>
  2722. <tr><td align="left" valign="top">&bull; <a href="#Type-annotations">Type annotations</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2723. </td></tr>
  2724. <tr><td align="left" valign="top">&bull; <a href="#Explicit-renaming-macros">Explicit renaming macros</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  2725. </td></tr>
  2726. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  2727. </pre></th></tr></table>
  2728. <hr>
  2729. <span id="Miscellaneous-features"></span><div class="header">
  2730. <p>
  2731. Next: <a href="#Various-utilities" accesskey="n" rel="next">Various utilities</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2732. </div>
  2733. <span id="Miscellaneous-features-1"></span><h4 class="subsection">4.1.1 Miscellaneous features</h4>
  2734. <span id="index-features"></span>
  2735. <p>The structure <code>features</code> provides some very miscellaneous features
  2736. in Scheme48.
  2737. </p>
  2738. <span id="index-immutability"></span>
  2739. <span id="index-mutability"></span>
  2740. <dl>
  2741. <dt id="index-immutable_003f">procedure: <strong>immutable?</strong> <em>object --&gt; boolean</em></dt>
  2742. <dt id="index-make_002dimmutable_0021">procedure: <strong>make-immutable!</strong> <em>object --&gt; object</em></dt>
  2743. <dd><p>All Scheme objects in Scheme48 have a flag determining whether or not
  2744. they may be mutated. All immediate Scheme objects (<code>()</code>,
  2745. <code>#f</code>, <i>&amp;c.</i>) are immutable; all fixnums (small integers) are
  2746. immutable; and all stored objects &mdash; vectors, pairs, <i>&amp;c.</i> &mdash; may be
  2747. mutable. <code>Immutable?</code> returns <code>#t</code> if <var>object</var> may not
  2748. be mutated, and <code>make-immutable!</code>, a bit ironically, modifies
  2749. <var>object</var> so that it may not be mutated, if it was not already
  2750. immutable, and returns it.
  2751. </p>
  2752. <div class="lisp">
  2753. <pre class="lisp">(immutable? #t) &rArr; #t
  2754. (define p (cons 1 2))
  2755. (immutable? p) &rArr; #f
  2756. (car p) &rArr; 1
  2757. (set-car! p 5)
  2758. (car p) &rArr; 5
  2759. (define q (make-immutable! p))
  2760. (eq? p q) &rArr; #t
  2761. (car p) &rArr; 5
  2762. (immutable? q) &rArr; #t
  2763. (set-car! p 6) error&rarr; immutable pair</pre></div>
  2764. </dd></dl>
  2765. <dl>
  2766. <dt id="index-string_002dhash">procedure: <strong>string-hash</strong> <em>string --&gt; integer-hash-code</em></dt>
  2767. <dd><p>Computes a basic but fast hash of <var>string</var>.
  2768. </p>
  2769. <div class="lisp">
  2770. <pre class="lisp">(string-hash &quot;Hello, world!&quot;) &rArr; 1161</pre></div>
  2771. </dd></dl>
  2772. <span id="index-forcing-buffered-output"></span>
  2773. <span id="index-output-port-buffer-forcing"></span>
  2774. <span id="index-buffered-output-forcing"></span>
  2775. <span id="index-flushing-output-buffers"></span>
  2776. <dl>
  2777. <dt id="index-force_002doutput">procedure: <strong>force-output</strong> <em>port --&gt; unspecified</em></dt>
  2778. <dd><p>Forces all buffered output to be sent out of <var>port</var>.
  2779. </p>
  2780. <p>This is identical to the binding of the same name exported by the
  2781. <a href="#Ports"><code>i/o</code> structure</a>.
  2782. </p></dd></dl>
  2783. <span id="index-noise-output"></span>
  2784. <dl>
  2785. <dt id="index-current_002dnoise_002dport">procedure: <strong>current-noise-port</strong> <em>--&gt; output-port</em></dt>
  2786. <dd><p>The current noise port is a port for sending noise messages that are
  2787. inessential to the operation of a program.
  2788. </p></dd></dl>
  2789. <span id="index-silly"></span>
  2790. <p>The <code>silly</code> structure exports a single procedure, implemented as
  2791. a VM primitive for the silly reason of efficiency, hence the name of
  2792. the structure.<a id="DOCF10" href="#FOOT10"><sup>10</sup></a> It is used in an inner loop of the reader.
  2793. </p>
  2794. <dl>
  2795. <dt id="index-reverse_002dlist_002d_003estring">procedure: <strong>reverse-list-&gt;string</strong> <em>char-list count --&gt; string</em></dt>
  2796. <dd><p>Returns a string of the first <var>count</var> characters in
  2797. <var>char-list</var>, in reverse. It is a serious error if <var>char-list</var>
  2798. is not a list whose length is at least <var>count</var>; the error is not
  2799. detected by the VM, so bogus pointers may be involved as a result.
  2800. Use this routine with care in inner loops.
  2801. </p></dd></dl>
  2802. <span id="index-debug_002dmessages"></span>
  2803. <p>The <code>debug-messages</code> structure exports a procedure for emitting
  2804. very basic debugging messages for low-level problems.
  2805. </p>
  2806. <dl>
  2807. <dt id="index-debug_002dmessage">procedure: <strong>debug-message</strong> <em>item &hellip; --&gt; unspecified</em></dt>
  2808. <dd><p>Prints <var>item</var> &hellip; directly to an error port,<a id="DOCF11" href="#FOOT11"><sup>11</sup></a>
  2809. eliding buffering and thread synchronization on the Scheme side.
  2810. Objects are printed as follows:
  2811. </p>
  2812. <ul>
  2813. <li> Fixnums (small integers) are written in decimal.
  2814. </li><li> Characters are written literally with a <code>#\</code> prefix. No
  2815. naming translation is performed, so the space and newline characters
  2816. are written literally, not as <code>#\space</code> or <code>#\newline</code>.
  2817. </li><li> Records are written as #{<var>type-name</var>}, where
  2818. <var>type-name</var> is the name of the record&rsquo;s type.
  2819. </li><li> Strings and symbols are written literally.
  2820. </li><li> Booleans and the empty list are written normally, <i>i.e.</i> as
  2821. <code>#t</code>, <code>#f</code>, or <code>()</code>.
  2822. </li><li> Pairs are written as <code>(...)</code>.
  2823. </li><li> Vectors are written as <code>#(...)</code>.
  2824. </li><li> Objects of certain primitive types are written as
  2825. #{<var>type</var>}: procedures, templates, locations, code (byte)
  2826. vectors, and continuations.<a id="DOCF12" href="#FOOT12"><sup>12</sup></a>
  2827. </li><li> Everything else is printed as #{???}.
  2828. </li></ul>
  2829. </dd></dl>
  2830. <span id="index-code_002dquote-1"></span>
  2831. <p>The <code>code-quote</code> structure exports a variant of <code>quote</code> that
  2832. is useful in some sophisticated macros.
  2833. </p>
  2834. <dl>
  2835. <dt id="index-code_002dquote">special form: <strong>code-quote</strong> <em>object --&gt; object</em></dt>
  2836. <dd><p>Evaluates to the literal value of <var>object</var>. This is semantically
  2837. identical to <code>quote</code>, but <var>object</var> may be anything, and the
  2838. compiler will not signal any warnings regarding its value, while such
  2839. warnings would be signalled for <code>quote</code> expressions that do not
  2840. wrap readable S-expressions: arbitrary, compound, unreadable data may
  2841. be stored in <code>code-quote</code>. Values computed at compile-time may
  2842. thus be transmitted to run-time code. However, care should be taken
  2843. in doing this.
  2844. </p></dd></dl>
  2845. <hr>
  2846. <span id="Various-utilities"></span><div class="header">
  2847. <p>
  2848. Next: <a href="#Filenames" accesskey="n" rel="next">Filenames</a>, Previous: <a href="#Miscellaneous-features" accesskey="p" rel="prev">Miscellaneous features</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  2849. </div>
  2850. <span id="Various-utilities-1"></span><h4 class="subsection">4.1.2 Various utilities</h4>
  2851. <span id="index-util"></span>
  2852. <p>The <code>util</code> structure contains some miscellaneous utility routines
  2853. extensively used internally in the run-time system. While they are not
  2854. meant to compose a comprehensive library (such as, for example, [SRFI
  2855. 1]), they were found useful in building the run-time system without
  2856. introducing massive libraries into the core of the system.
  2857. </p>
  2858. <span id="index-unspecific"></span>
  2859. <span id="index-unspecified"></span>
  2860. <dl>
  2861. <dt id="index-unspecific-1">procedure: <strong>unspecific</strong> <em>--&gt; unspecific</em></dt>
  2862. <dd><p>Returns Scheme48&rsquo;s <em>unspecific</em> token, which is used wherever R5RS
  2863. uses the term &lsquo;unspecific&rsquo; or &lsquo;unspecified.&rsquo; In this manual, the term
  2864. &lsquo;unspecified&rsquo; is used to mean that the values returned by a particular
  2865. procedure are not specified and may be anything, including a varying
  2866. number of values, whereas &lsquo;unspecific&rsquo; refers to Scheme48&rsquo;s specific
  2867. &lsquo;unspecific&rsquo; value that the <code>unspecific</code> procedure returns.
  2868. </p></dd></dl>
  2869. <dl>
  2870. <dt id="index-reduce">procedure: <strong>reduce</strong> <em>kons knil list --&gt; final-knil</em></dt>
  2871. <dd><p>Reduces <var>list</var> by repeatedly applying <var>kons</var> to elements of
  2872. <var>list</var> and the current <var>knil</var> value. This is the fundamental
  2873. list recursion operator.
  2874. </p>
  2875. <div class="lisp">
  2876. <pre class="lisp">(reduce <var>kons</var> <var>knil</var>
  2877. (cons <var>elt<sub>1</sub></var>
  2878. (cons <var>elt<sub>2</sub></var>
  2879. (&hellip;(cons <var>elt<sub>N</sub></var> '())&hellip;))))
  2880. &equiv;
  2881. (<var>kons</var> <var>elt<sub>1</sub></var>
  2882. (<var>kons</var> <var>elt<sub>2</sub></var>
  2883. (&hellip;(<var>kons</var> <var>elt<sub>N</sub></var> <var>knil</var>)&hellip;)))</pre></div>
  2884. <p>Example:
  2885. </p>
  2886. <div class="lisp">
  2887. <pre class="lisp">(reduce append '() '((1 2 3) (4 5 6) (7 8 9)))
  2888. &rArr; (1 2 3 4 5 6 7 8 9)
  2889. (append '(1 2 3)
  2890. (append '(4 5 6)
  2891. (append '(7 8 9) '())))
  2892. &rArr; (1 2 3 4 5 6 7 8 9)</pre></div>
  2893. </dd></dl>
  2894. <dl>
  2895. <dt id="index-fold">procedure: <strong>fold</strong> <em>combiner list accumulator --&gt; final-accumulator</em></dt>
  2896. <dd><p>Folds <var>list</var> into an accumulator by repeatedly combining each
  2897. element into an accumulator with <var>combiner</var>. This is the
  2898. fundamental list iteration operator.
  2899. </p>
  2900. <div class="lisp">
  2901. <pre class="lisp">(fold <var>combiner</var>
  2902. (list <var>elt<sub>1</sub></var> <var>elt<sub>2</sub></var> &hellip; <var>elt<sub>N</sub></var>)
  2903. <var>accumulator</var>)
  2904. &equiv;
  2905. (let* ((accum<sub>1</sub> (<var>combiner</var> <var>elt<sub>1</sub></var> <var>accumulator</var>))
  2906. (accum<sub>2</sub> (<var>combiner</var> <var>elt<sub>2</sub></var> accum<sub>1</sub>))
  2907. &hellip;
  2908. (accum<sub>N</sub> (<var>combiner</var> <var>elt<sub>N</sub></var> accum<sub>N-1</sub>)))
  2909. accum<sub>N</sub>)</pre></div>
  2910. <p>Example:
  2911. </p>
  2912. <div class="lisp">
  2913. <pre class="lisp">(fold cons '() '(a b c d))
  2914. &rArr; (d c b a)
  2915. (cons 'd (cons 'c (cons 'b (cons 'a '()))))
  2916. &rArr; (d c b a)</pre></div>
  2917. </dd></dl>
  2918. <dl>
  2919. <dt id="index-fold_002d_003e2">procedure: <strong>fold-&gt;2</strong> <em>combiner list accumulator<sub>1</sub> accumulator<sub>2</sub> --&gt; [final-accumulator<sub>1</sub> final-accumulator<sub>2</sub>]</em></dt>
  2920. <dt id="index-fold_002d_003e3">procedure: <strong>fold-&gt;3</strong> <em>combiner list accumulator<sub>1</sub> accumulator<sub>2</sub> accumulator<sub>3</sub> --&gt; [final-accumulator<sub>1</sub> final-accumulator<sub>2</sub> final-accumulator<sub>3</sub>]</em></dt>
  2921. <dd><p>Variants of <code>fold</code> for two and three accumulators, respectively.
  2922. </p>
  2923. <div class="lisp">
  2924. <pre class="lisp">;;; Partition <var>list</var> by elements that satisfy <var>pred?</var> and those
  2925. ;;; that do not.
  2926. (fold-&gt;2 (lambda (elt satisfied unsatisfied)
  2927. (if (<var>pred?</var> elt)
  2928. (values (cons elt satisfied) unsatisfied)
  2929. (values satisfied (cons elt unsatisfied))))
  2930. <var>list</var>
  2931. '() '())</pre></div>
  2932. </dd></dl>
  2933. <dl>
  2934. <dt id="index-filter">procedure: <strong>filter</strong> <em>predicate list --&gt; filtered-list</em></dt>
  2935. <dd><p>Returns a list of all elements in <var>list</var> that satisfy
  2936. <var>predicate</var>.
  2937. </p>
  2938. <div class="lisp">
  2939. <pre class="lisp">(filter odd? '(3 1 4 1 5 9 2 6 5 3 5))
  2940. &rArr; (3 1 1 5 9 5 3 5)</pre></div>
  2941. </dd></dl>
  2942. <dl>
  2943. <dt id="index-posq">procedure: <strong>posq</strong> <em>object list --&gt; integer or <code>#f</code></em></dt>
  2944. <dt id="index-posv">procedure: <strong>posv</strong> <em>object list --&gt; integer or <code>#f</code></em></dt>
  2945. <dt id="index-position">procedure: <strong>position</strong> <em>object list --&gt; integer or <code>#f</code></em></dt>
  2946. <dd><p>These find the position of the first element equal to <var>object</var> in
  2947. <var>list</var>. <code>Posq</code> compares elements by <code>eq?</code>; <code>posv</code>
  2948. compares by <code>eqv?</code>; <code>position</code> compares by <code>equal?</code>.
  2949. </p>
  2950. <div class="lisp">
  2951. <pre class="lisp">(posq 'c '(a b c d e f))
  2952. &rArr; 2
  2953. (posv 1/2 '(1 1/2 2 3/2))
  2954. &rArr; 1
  2955. (position '(d . e) '((a . b) (b . c) (c . d) (d . e) (e . f)))
  2956. &rArr; 3</pre></div>
  2957. </dd></dl>
  2958. <dl>
  2959. <dt id="index-any">procedure: <strong>any</strong> <em>predicate list --&gt; value or <code>#f</code></em></dt>
  2960. <dt id="index-every">procedure: <strong>every</strong> <em>predicate list --&gt; boolean</em></dt>
  2961. <dd><p><code>Any</code> returns the value that <var>predicate</var> returns for the first
  2962. element in <var>list</var> for which <var>predicate</var> returns a true value;
  2963. if no element of <var>list</var> satisfied <var>predicate</var>, <code>any</code>
  2964. returns <code>#f</code>. <code>Every</code> returns <code>#t</code> if every element of
  2965. <var>list</var> satisfies <var>predicate</var>, or <code>#f</code> if there exist any
  2966. that do not.
  2967. </p>
  2968. <div class="lisp">
  2969. <pre class="lisp">(any (lambda (x) (and (even? x) (sqrt x)))
  2970. '(0 1 4 9 16))
  2971. &rArr; 2
  2972. (every odd? '(1 3 5 7 9))
  2973. &rArr; #t</pre></div>
  2974. </dd></dl>
  2975. <dl>
  2976. <dt id="index-sublist">procedure: <strong>sublist</strong> <em>list start end --&gt; list</em></dt>
  2977. <dd><p>Returns a list of the elements in <var>list</var> including &amp; after that at
  2978. the index <var>start</var> and before the index <var>end</var>.
  2979. </p>
  2980. <div class="lisp">
  2981. <pre class="lisp">(sublist '(a b c d e f g h i) 3 6) &rArr; (d e f)</pre></div>
  2982. </dd></dl>
  2983. <dl>
  2984. <dt id="index-last">procedure: <strong>last</strong> <em>list --&gt; value</em></dt>
  2985. <dd><p>Returns the last element in <var>list</var>. <code>Last</code>&rsquo;s effect is
  2986. undefined if <var>list</var> is empty.
  2987. </p>
  2988. <div class="lisp">
  2989. <pre class="lisp">(last '(a b c)) &rArr; c</pre></div>
  2990. </dd></dl>
  2991. <dl>
  2992. <dt id="index-insert">procedure: <strong>insert</strong> <em>object list elt&lt; --&gt; list</em></dt>
  2993. <dd><p>Inserts <var>object</var> into the sorted list <var>list</var>, comparing the
  2994. order of <var>object</var> and each element by <var>elt&lt;</var>.
  2995. </p>
  2996. <div class="lisp">
  2997. <pre class="lisp">(insert 3 '(0 1 2 4 5) &lt;) &rArr; (0 1 2 3 4 5)</pre></div>
  2998. </dd></dl>
  2999. <hr>
  3000. <span id="Filenames"></span><div class="header">
  3001. <p>
  3002. Next: <a href="#Fluid_002fdynamic-bindings" accesskey="n" rel="next">Fluid/dynamic bindings</a>, Previous: <a href="#Various-utilities" accesskey="p" rel="prev">Various utilities</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3003. </div>
  3004. <span id="Filenames-1"></span><h4 class="subsection">4.1.3 Filenames</h4>
  3005. <span id="index-filenames"></span>
  3006. <p>There are some basic filename manipulation facilities exported by the
  3007. <code>filenames</code> structure.<a id="DOCF13" href="#FOOT13"><sup>13</sup></a>
  3008. </p>
  3009. <dl>
  3010. <dt id="index-_002ascheme_002dfile_002dtype_002a">constant: <strong>*scheme-file-type*</strong> <em>--&gt; symbol</em></dt>
  3011. <dt id="index-_002aload_002dfile_002dtype_002a">constant: <strong>*load-file-type*</strong> <em>--&gt; symbol</em></dt>
  3012. <dd><p><code>*Scheme-file-type*</code> is a symbol denoting the file extension that
  3013. Scheme48 assumes for Scheme source files; any other extension, for
  3014. instance in the filename list of a structure definition, must be
  3015. written explicitly. <code>*Load-file-type*</code> is a symbol denoting the
  3016. preferable file extension to load files from. (<code>*Load-file-type*</code>
  3017. was used mostly in bootstrapping Scheme48 from Pseudoscheme or T long
  3018. ago and is no longer very useful.)
  3019. </p></dd></dl>
  3020. <dl>
  3021. <dt id="index-file_002dname_002ddirectory">procedure: <strong>file-name-directory</strong> <em>filename --&gt; string</em></dt>
  3022. <dt id="index-file_002dname_002dnondirectory">procedure: <strong>file-name-nondirectory</strong> <em>filename --&gt; string</em></dt>
  3023. <dd><p><code>File-name-directory</code> returns the directory component of the
  3024. filename denoted by the string <var>filename</var>, including a trailing
  3025. separator (on Unix, <code>/</code>). <code>File-name-nondirectory</code> returns
  3026. everything but the directory component of the filename denoted by the
  3027. string <var>filename</var>, including the extension.
  3028. </p>
  3029. <div class="lisp">
  3030. <pre class="lisp">(file-name-directory &quot;/usr/local/lib/scheme48/scheme48.image&quot;)
  3031. &rArr; &quot;/usr/local/lib/scheme48/&quot;
  3032. (file-name-nondirectory &quot;/usr/local/lib/scheme48/scheme48.image&quot;)
  3033. &rArr; &quot;scheme48.image&quot;
  3034. (file-name-directory &quot;scheme48.image&quot;)
  3035. &rArr; &quot;&quot;
  3036. (file-name-nondirectory &quot;scheme48.image&quot;)
  3037. &rArr; &quot;scheme48.image&quot;</pre></div>
  3038. </dd></dl>
  3039. <span id="index-namelists"></span>
  3040. <p><em>Namelists</em> are platform-independent means by which to name files.
  3041. They are represented as readable S-expressions of any of the following
  3042. forms:
  3043. </p>
  3044. <dl compact="compact">
  3045. <dt><code><var>basename</var></code></dt>
  3046. <dd><p>represents a filename with only a basename and no directory or file
  3047. type/extension;
  3048. </p>
  3049. </dd>
  3050. <dt><code>(<var>directory</var> <var>basename</var> [<var>type</var>])</code></dt>
  3051. <dd><p>represents a filename with a single preceding directory component and
  3052. an optional file type/extension; and
  3053. </p>
  3054. </dd>
  3055. <dt><code>((<var>directory</var> &hellip;) <var>basename</var> [<var>type</var>])</code></dt>
  3056. <dd><p>represents a filename with a sequence of directory components, a
  3057. basename, and an optional file type/extension.
  3058. </p></dd>
  3059. </dl>
  3060. <p>Each atomic component &mdash; that is, the basename, the type/extension,
  3061. and each individual directory component &mdash; may be either a string or
  3062. a symbol. Symbols are converted to the canonical case of the host
  3063. operating system by <code>namestring</code> (on Unix, lowercase); the case of
  3064. string components is not touched.
  3065. </p>
  3066. <dl>
  3067. <dt id="index-namestring">procedure: <strong>namestring</strong> <em>namelist directory default-type --&gt; string</em></dt>
  3068. <dd><p>Converts <var>namelist</var> to a string in the format required by the host
  3069. operating system.<a id="DOCF14" href="#FOOT14"><sup>14</sup></a> If <var>namelist</var> did not have a directory
  3070. component, <var>directory</var>, a string in the underlying operating
  3071. system&rsquo;s format for directory prefixes, is added to the resulting
  3072. namestring; and, if <var>namelist</var> did not have a type/extension,
  3073. <var>default-type</var>, which may be a string or a symbol and which should
  3074. <em>not</em> already contain the host operating system&rsquo;s delimiter
  3075. (usually a dot), is appended to the resulting namestring.
  3076. </p>
  3077. <p><var>Directory</var> or <var>default-type</var> may be <code>#f</code>, in which case
  3078. they are not prefixed or appended to the resulting filename.
  3079. </p>
  3080. <div class="lisp">
  3081. <pre class="lisp">(namestring 'foo #f #f) &rArr; &quot;foo&quot;
  3082. (namestring 'foo &quot;bar&quot; 'baz) &rArr; &quot;bar/foo.baz&quot;
  3083. (namestring '(rts defenum) &quot;scheme&quot; 'scm)
  3084. &rArr; &quot;scheme/rts/defenum.scm&quot;
  3085. (namestring '((foo bar) baz quux) &quot;zot&quot; #f)
  3086. &rArr; &quot;zot/foo/bar/baz.quux&quot;
  3087. (namestring &quot;zot/foo/bar/baz.quux&quot; #f &quot;mumble&quot;)
  3088. &rArr; &quot;zot/foo/bar/baz.quux.mumble&quot;</pre></div>
  3089. </dd></dl>
  3090. <span id="Filename-translations"></span><h4 class="subsubsection">4.1.3.1 Filename translations</h4>
  3091. <span id="index-filename-translations"></span>
  3092. <p>Scheme48 keeps a registry of <em>filename translations</em>, translations
  3093. from filename prefixes to the real prefixes. This allows abstraction
  3094. of actual directory prefixes without necessitating running Scheme code
  3095. to construct directory pathnames (for example, in configuration files).
  3096. Interactively, in the usual command processor, users can set filename
  3097. translations with the <code>,translate</code>; see <a href="#Basic-commands">Basic commands</a>.
  3098. </p>
  3099. <dl>
  3100. <dt id="index-translations">procedure: <strong>translations</strong> <em>--&gt; string/string-alist</em></dt>
  3101. <dd><p>Returns the alist of filename translations.
  3102. </p></dd></dl>
  3103. <dl>
  3104. <dt id="index-set_002dtranslation_0021">procedure: <strong>set-translation!</strong> <em>from to --&gt; unspecified</em></dt>
  3105. <dd><p>Adds a filename prefix translation, overwriting an existing one if one
  3106. already existed.
  3107. </p></dd></dl>
  3108. <dl>
  3109. <dt id="index-translate">procedure: <strong>translate</strong> <em>filename --&gt; translated-filename</em></dt>
  3110. <dd><p>Translates the first prefix of <var>filename</var> found in the registry of
  3111. translations and returns the translated filename.
  3112. </p></dd></dl>
  3113. <div class="lisp">
  3114. <pre class="lisp">(set-translation! &quot;s48&quot; &quot;/home/me/scheme/scheme48/scheme&quot;)
  3115. (translate (namestring '(bcomp frame) &quot;s48&quot; 'scm))
  3116. &rArr; &quot;/home/me/scheme/scheme48/scheme/bcomp/frame.scm&quot;
  3117. (translate (namestring &quot;comp-packages&quot; &quot;s48&quot; 'scm))
  3118. &rArr; &quot;/home/me/scheme/scheme48/scheme/comp-packages.scm&quot;
  3119. (translate &quot;s48/frobozz&quot;)
  3120. &rArr; &quot;/home/me/scheme/scheme48/scheme/frobozz&quot;
  3121. (set-translation! &quot;scheme48&quot; &quot;s48&quot;)
  3122. (translate (namestring '((scheme48 big) filename) #f 'scm))
  3123. &rArr; scheme48/big/filename.scm
  3124. (translate (translate (namestring '((scheme48 big) filename) #f 'scm)))
  3125. &rArr; &quot;/home/me/scheme/scheme48/scheme/big/filename.scm&quot;</pre></div>
  3126. <span id="index-_003dscheme48_002f"></span>
  3127. <p>One filename translation is built-in, mapping <code>=scheme48/</code> to the
  3128. directory of system files in a Scheme48 installation, which on Unix is
  3129. typically a directory in <code>/usr/local/lib</code>.
  3130. </p>
  3131. <div class="lisp">
  3132. <pre class="lisp">(translate &quot;=scheme48/scheme48.image&quot;)
  3133. &rArr; /usr/local/scheme48/scheme48.image</pre></div>
  3134. <hr>
  3135. <span id="Fluid_002fdynamic-bindings"></span><div class="header">
  3136. <p>
  3137. Next: <a href="#ASCII-character-encoding" accesskey="n" rel="next">ASCII character encoding</a>, Previous: <a href="#Filenames" accesskey="p" rel="prev">Filenames</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3138. </div>
  3139. <span id="Fluid_002fdynamic-bindings-1"></span><h4 class="subsection">4.1.4 Fluid/dynamic bindings</h4>
  3140. <span id="index-fluid-bindings"></span>
  3141. <span id="index-dynamic-bindings"></span>
  3142. <span id="index-fluids"></span>
  3143. <p>The <code>fluids</code> structure provides a facility for dynamically bound
  3144. resources, like special variables in Common Lisp, but with first-class,
  3145. unforgeable objects.
  3146. </p>
  3147. <p>Every <a href="#Multithreading">thread</a> in Scheme48 maintains a
  3148. <em>fluid or dynamic environment</em>. It maps <em>fluid descriptors</em> to
  3149. their values, much like a lexical environment maps names to their
  3150. values. The dynamic environment is implemented by deep binding and
  3151. dynamically scoped. Fluid variables are represented as first-class
  3152. objects for which there is a top-level value and possibly a binding in
  3153. the current dynamic environment. Escape procedures, as created with
  3154. Scheme&rsquo;s <code>call-with-current-continuation</code>, also store &amp; preserve
  3155. the dynamic environment at the time of their continuation&rsquo;s capture and
  3156. restore it when invoked.
  3157. </p>
  3158. <p>The convention for naming variables that are bound to fluid objects
  3159. is to add a prefix of <code>$</code> (dollar sign); <i>e.g.</i>, <code>$foo</code>.
  3160. </p>
  3161. <dl>
  3162. <dt id="index-make_002dfluid">procedure: <strong>make-fluid</strong> <em>top-level-value --&gt; fluid</em></dt>
  3163. <dd><p>Fluid constructor.
  3164. </p></dd></dl>
  3165. <dl>
  3166. <dt id="index-fluid">procedure: <strong>fluid</strong> <em>fl --&gt; value</em></dt>
  3167. <dt id="index-set_002dfluid_0021">procedure: <strong>set-fluid!</strong> <em>fl value --&gt; unspecified</em></dt>
  3168. <dt id="index-fluid_002dcell_002dref">procedure: <strong>fluid-cell-ref</strong> <em>fluid-cell --&gt; value</em></dt>
  3169. <dt id="index-fluid_002dcell_002dset_0021">procedure: <strong>fluid-cell-set!</strong> <em>fluid-cell value --&gt; unspecified</em></dt>
  3170. <dd><p><code>Fluid</code> returns the value that the current dynamic environment
  3171. associates with <var>fl</var>, if it has an association; if not, it returns
  3172. <var>fl</var>&rsquo;s top-level value, as passed to <code>make-fluid</code> to create
  3173. <var>fl</var>. <code>Set-fluid!</code> assigns the value of the association in
  3174. the current dynamic environment for <var>fl</var> to <var>value</var>, or, if
  3175. there is no such association, it assigns the top-level value of
  3176. <var>fl</var> to <var>value</var>. Direct assignment of fluids is deprecated,
  3177. however, and may be removed in a later release; instead, programmers
  3178. should use fluids that are bound to <a href="#Cells">mutable cells</a>.
  3179. <code>Fluid-cell-ref</code> and <code>fluid-cell-set!</code> are conveniences for
  3180. this; they simply call the corresponding cell operations after
  3181. fetching the cell that the fluid refers to by using <code>fluid</code>.
  3182. </p></dd></dl>
  3183. <dl>
  3184. <dt id="index-let_002dfluid">procedure: <strong>let-fluid</strong> <em>fluid value thunk --&gt; values</em></dt>
  3185. <dt id="index-let_002dfluids">procedure: <strong>let-fluids</strong> <em>fluid<sub>0</sub> value<sub>0</sub> fluid<sub>1</sub> value<sub>1</sub> &hellip; thunk --&gt; values</em></dt>
  3186. <dd><p>These dynamically bind their fluid arguments to the corresponding value
  3187. arguments and apply <var>thunk</var> with the new dynamic environment,
  3188. restoring the old one after <var>thunk</var> returns and returning the value
  3189. it returns.
  3190. </p></dd></dl>
  3191. <div class="lisp">
  3192. <pre class="lisp">(define $mumble (make-fluid 0))
  3193. (let ((a (fluid $mumble))
  3194. (b (let-fluid $mumble 1
  3195. (lambda () (fluid $mumble))))
  3196. (c (fluid $mumble))
  3197. (d (let-fluid $mumble 2
  3198. (lambda ()
  3199. (let-fluid $mumble 3
  3200. (lambda () (fluid $mumble)))))))
  3201. (list a b c d))
  3202. &rArr; (0 1 0 3)
  3203. (let ((note (lambda (when)
  3204. (display when)
  3205. (display &quot;: &quot;)
  3206. (write (fluid $mumble))
  3207. (newline))))
  3208. (note 'initial)
  3209. (let-fluid $mumble 1 (lambda () (note 'let-fluid)))
  3210. (note 'after-let-fluid)
  3211. (let-fluid $mumble 1
  3212. (lambda ()
  3213. (note 'outer-let-fluid)
  3214. (let-fluid $mumble 2 (lambda () (note 'inner-let-fluid)))))
  3215. (note 'after-inner-let-fluid)
  3216. ((call-with-current-continuation
  3217. (lambda (k)
  3218. (lambda ()
  3219. (let-fluid $mumble 1
  3220. (lambda ()
  3221. (note 'let-fluid-within-cont)
  3222. (let-fluid $mumble 2
  3223. (lambda () (note 'inner-let-fluid-within-cont)))
  3224. (k (lambda () (note 'let-fluid-thrown)))))))))
  3225. (note 'after-throw))
  3226. -| initial: 0
  3227. -| let-fluid: 1
  3228. -| after-let-fluid: 0
  3229. -| outer-let-fluid: 1
  3230. -| inner-let-fluid: 2
  3231. -| let-fluid-within-cont: 1
  3232. -| inner-let-fluid-within-cont: 2
  3233. -| let-fluid-thrown: 0
  3234. -| after-throw: 0</pre></div>
  3235. <hr>
  3236. <span id="ASCII-character-encoding"></span><div class="header">
  3237. <p>
  3238. Next: <a href="#Integer-enumerations" accesskey="n" rel="next">Integer enumerations</a>, Previous: <a href="#Fluid_002fdynamic-bindings" accesskey="p" rel="prev">Fluid/dynamic bindings</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3239. </div>
  3240. <span id="ASCII-character-encoding-1"></span><h4 class="subsection">4.1.5 ASCII character encoding</h4>
  3241. <span id="index-ascii"></span>
  3242. <p>These names are exported by the <code>ascii</code> structure.
  3243. </p>
  3244. <dl>
  3245. <dt id="index-char_002d_003eascii">procedure: <strong>char-&gt;ascii</strong> <em>char --&gt; ascii-integer</em></dt>
  3246. <dt id="index-ascii_002d_003echar">procedure: <strong>ascii-&gt;char</strong> <em>ascii-integer --&gt; character</em></dt>
  3247. <dd><p>These convert characters to and from their integer ASCII encodings.
  3248. <code>Char-&gt;ascii</code> and <code>ascii-&gt;char</code> are similar to R5RS&rsquo;s
  3249. <code>char-&gt;integer</code> and <code>integer-&gt;char</code>, but they are guaranteed
  3250. to use the ASCII encoding. Scheme48&rsquo;s <code>integer-&gt;char</code> and
  3251. <code>char-&gt;integer</code> deliberately do not use the ASCII encoding to
  3252. encourage programmers to make use of only what R5RS guarantees.
  3253. </p>
  3254. <div class="lisp">
  3255. <pre class="lisp">(char-&gt;ascii #\a) &rArr; 97
  3256. (ascii-&gt;char 97) &rArr; #\a</pre></div>
  3257. </dd></dl>
  3258. <dl>
  3259. <dt id="index-ascii_002dlimit">constant: <strong>ascii-limit</strong> <em>--&gt; integer</em></dt>
  3260. <dt id="index-ascii_002dwhitespaces">constant: <strong>ascii-whitespaces</strong> <em>--&gt; ascii-integer-list</em></dt>
  3261. <dd><p><code>Ascii-limit</code> is an integer that is one greater than the highest
  3262. number that <code>char-&gt;ascii</code> may return or <code>ascii-&gt;char</code> will
  3263. accept. <code>Ascii-whitespaces</code> is a list of the integer encodings of
  3264. all characters that are considered whitespace: space (32), horizontal
  3265. tab (9), line-feed/newline (10), vertical tab (11), form-feed/page (12),
  3266. and carriage return (13).
  3267. </p></dd></dl>
  3268. <hr>
  3269. <span id="Integer-enumerations"></span><div class="header">
  3270. <p>
  3271. Next: <a href="#Cells" accesskey="n" rel="next">Cells</a>, Previous: <a href="#ASCII-character-encoding" accesskey="p" rel="prev">ASCII character encoding</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3272. </div>
  3273. <span id="Integer-enumerations-1"></span><h4 class="subsection">4.1.6 Integer enumerations</h4>
  3274. <span id="index-enumerated"></span>
  3275. <p>Scheme48 provides a facility for <em>integer enumerations</em>, somewhat
  3276. akin to C enums. The names described in this section are exported by
  3277. the <code>enumerated</code> structure.
  3278. </p>
  3279. <p><strong>Note:</strong> These enumerations are <em>not</em> compatible with the
  3280. <a href="#Enumerated_002ffinite-types-and-sets">enumerated/finite type
  3281. facility</a>.
  3282. </p>
  3283. <dl>
  3284. <dt id="index-define_002denumeration">syntax: <strong>define-enumeration</strong> <em>enumeration-name (enumerand-name &hellip;)</em></dt>
  3285. <dd><p>Defines <var>enumeration-name</var> to be a static enumeration. (Note that
  3286. it is <em>not</em> a regular variable. It is actually a macro, though its
  3287. exact syntax is not exposed; it must be exported with the
  3288. <a href="#Static-type-system"><code>:syntax</code> type</a>.)
  3289. <var>Enumeration-name</var> thereafter may be used with the enumeration
  3290. operators described below.
  3291. </p></dd></dl>
  3292. <dl>
  3293. <dt id="index-enum">syntax: <strong>enum</strong> <em>enumeration-name enumerand-name --&gt; enumerand-integer</em></dt>
  3294. <dt id="index-components">syntax: <strong>components</strong> <em>enumeration-name --&gt; component-vector</em></dt>
  3295. <dd><p><code>Enum</code> expands to the integer value represented symbolically by
  3296. <var>enumerand-name</var> in the enumeration <var>enumeration-name</var> as
  3297. defined by <code>define-enumeration</code>. <code>Components</code> expands to a
  3298. literal vector of the components in <var>enumeration-name</var> as defined
  3299. by <code>define-enumeration</code>. In both cases, <var>enumerand-name</var> must
  3300. be written literally as the name of the enumerand; see
  3301. <code>name-&gt;enumerand</code> for extracting an enumerand&rsquo;s integer given a
  3302. run-time symbol naming an enumerand.
  3303. </p></dd></dl>
  3304. <dl>
  3305. <dt id="index-enumerand_002d_003ename">syntax: <strong>enumerand-&gt;name</strong> <em>enumerand-integer enumeration-name --&gt; symbol</em></dt>
  3306. <dt id="index-name_002d_003eenumerand">syntax: <strong>name-&gt;enumerand</strong> <em>enumerand-name enumeration-name --&gt; integer-enumerand</em></dt>
  3307. <dd><p><code>Enumerand-&gt;name</code> expands to a form that evaluates to the symbolic
  3308. name that the integer value of the expression <var>enumerand-integer</var>
  3309. is mapped to by <var>enumeration-name</var> as defined by
  3310. <code>define-enumeration</code>. <code>Name-&gt;enumerand</code> expands to a form
  3311. that evaluates to the integer value of the enumerand in
  3312. <var>enumeration-name</var> that is represented symbolically by the value of
  3313. the expression <var>enumerand-name</var>.
  3314. </p></dd></dl>
  3315. <span id="index-enum_002dcase-1"></span>
  3316. <p>The <code>enum-case</code> structure provides a handy utility of the same
  3317. name for dispatching on enumerands.
  3318. </p>
  3319. <dl>
  3320. <dt id="index-enum_002dcase">syntax: <strong>enum-case</strong></dt>
  3321. <dd><div class="lisp">
  3322. <pre class="lisp">(enum-case <var>enumeration-name</var> <var>key</var>
  3323. ((<var>enumerand-name</var> &hellip;) <var>body</var>)
  3324. &hellip;
  3325. [(else <var>else-body</var>)])</pre></div>
  3326. <p>Matches <var>key</var> with the clause one of whose names maps in
  3327. <var>enumeration-name</var> to the integer value of <var>key</var>. <var>Key</var>
  3328. must be an exact, non-negative integer. If no matching clause is
  3329. found, and <var>else-body</var> is present, <code>enum-case</code> will evaluate
  3330. <var>else-body</var>; if <var>else-body</var> is not present, <code>enum-case</code>
  3331. will return an unspecific value.
  3332. </p></dd></dl>
  3333. <p>Examples:
  3334. </p>
  3335. <div class="lisp">
  3336. <pre class="lisp">(define-enumeration foo
  3337. (bar
  3338. baz))
  3339. (enum foo bar) &rArr; 0
  3340. (enum foo baz) &rArr; 1
  3341. (enum-case foo (enum foo bar)
  3342. ((baz) 'x)
  3343. (else 'y))
  3344. &rArr; y
  3345. (enum-case foo (enum foo baz)
  3346. ((bar) 'a)
  3347. ((baz) 'b))
  3348. &rArr; b
  3349. (enumerand-&gt;name 1 foo) &rArr; baz
  3350. (name-&gt;enumerand 'bar foo) &rArr; 0
  3351. (components foo) &rArr; #(bar baz)</pre></div>
  3352. <hr>
  3353. <span id="Cells"></span><div class="header">
  3354. <p>
  3355. Next: <a href="#Queues" accesskey="n" rel="next">Queues</a>, Previous: <a href="#Integer-enumerations" accesskey="p" rel="prev">Integer enumerations</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3356. </div>
  3357. <span id="Cells-1"></span><h4 class="subsection">4.1.7 Cells</h4>
  3358. <span id="index-cells"></span>
  3359. <p>Scheme48 also provides a simple mutable cell data type from the
  3360. <code>cells</code> structure. It uses them internally for local, lexical
  3361. variables that are assigned, but cells are available still to the rest
  3362. of the system for general use.
  3363. </p>
  3364. <dl>
  3365. <dt id="index-make_002dcell">procedure: <strong>make-cell</strong> <em>contents --&gt; cell</em></dt>
  3366. <dt id="index-cell_003f">procedure: <strong>cell?</strong> <em>object --&gt; boolean</em></dt>
  3367. <dt id="index-cell_002dref">procedure: <strong>cell-ref</strong> <em>cell --&gt; value</em></dt>
  3368. <dt id="index-cell_002dset_0021">procedure: <strong>cell-set!</strong> <em>cell value --&gt; unspecified</em></dt>
  3369. <dd><p><code>Make-cell</code> creates a new cell with the given contents.
  3370. <code>Cell?</code> is the disjoint type predicate for cells. <code>Cell-ref</code>
  3371. returns the current contents of <var>cell</var>. <code>Cell-set!</code> assigns
  3372. the contents of <var>cell</var> to <var>value</var>.
  3373. </p></dd></dl>
  3374. <p>Examples:
  3375. </p>
  3376. <div class="lisp">
  3377. <pre class="lisp">(define cell (make-cell 42))
  3378. (cell-ref cell) &rArr; 42
  3379. (cell? cell) &rArr; #t
  3380. (cell-set! cell 'frobozz)
  3381. (cell-ref cell) &rArr; frobozz</pre></div>
  3382. <hr>
  3383. <span id="Queues"></span><div class="header">
  3384. <p>
  3385. Next: <a href="#Hash-tables" accesskey="n" rel="next">Hash tables</a>, Previous: <a href="#Cells" accesskey="p" rel="prev">Cells</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3386. </div>
  3387. <span id="Queues-1"></span><h4 class="subsection">4.1.8 Queues</h4>
  3388. <span id="index-FIFOs"></span>
  3389. <span id="index-queues"></span>
  3390. <p>The <code>queues</code> structure exports names for procedures that operate
  3391. on simple first-in, first-out queues.
  3392. </p>
  3393. <dl>
  3394. <dt id="index-make_002dqueue">procedure: <strong>make-queue</strong> <em>--&gt; queue</em></dt>
  3395. <dt id="index-queue_003f">procedure: <strong>queue?</strong> <em>object --&gt; boolean</em></dt>
  3396. <dd><p><code>Make-queue</code> constructs an empty queue. <code>Queue?</code> is the
  3397. disjoint type predicate for queues.
  3398. </p></dd></dl>
  3399. <dl>
  3400. <dt id="index-queue_002dempty_003f">procedure: <strong>queue-empty?</strong> <em>queue --&gt; boolean</em></dt>
  3401. <dt id="index-empty_002dqueue_0021">procedure: <strong>empty-queue!</strong> <em>queue --&gt; unspecified</em></dt>
  3402. <dd><p><code>Queue-empty?</code> returns <code>#t</code> if <var>queue</var> contains zero
  3403. elements or <code>#f</code> if it contains some. <code>Empty-queue!</code> removes
  3404. all elements from <var>queue</var>.
  3405. </p></dd></dl>
  3406. <dl>
  3407. <dt id="index-enqueue_0021">procedure: <strong>enqueue!</strong> <em>queue object --&gt; unspecified</em></dt>
  3408. <dt id="index-dequeue_0021">procedure: <strong>dequeue!</strong> <em>queue --&gt; value</em></dt>
  3409. <dt id="index-maybe_002ddequeue_0021">procedure: <strong>maybe-dequeue!</strong> <em>queue --&gt; value or <code>#f</code></em></dt>
  3410. <dt id="index-queue_002dhead">procedure: <strong>queue-head</strong> <em>queue --&gt; value</em></dt>
  3411. <dd><p><code>Enqueue!</code> adds <var>object</var> to <var>queue</var>. <code>Dequeue!</code>
  3412. removes &amp; returns the next object available from <var>queue</var>; if
  3413. <var>queue</var> is empty, <code>dequeue!</code> signals an error.
  3414. <code>Maybe-dequeue!</code> is like <code>dequeue!</code>, but it returns <code>#f</code>
  3415. in the case of an absence of any element, rather than signalling an
  3416. error. <code>Queue-head</code> returns the next element available from
  3417. <var>queue</var> without removing it, or it signals an error if <var>queue</var>
  3418. is empty.
  3419. </p></dd></dl>
  3420. <dl>
  3421. <dt id="index-queue_002dlength">procedure: <strong>queue-length</strong> <em>queue --&gt; integer</em></dt>
  3422. <dd><p>Returns the number of objects in <var>queue</var>.
  3423. </p></dd></dl>
  3424. <dl>
  3425. <dt id="index-on_002dqueue_003f">procedure: <strong>on-queue?</strong> <em>queue object --&gt; boolean</em></dt>
  3426. <dt id="index-delete_002dfrom_002dqueue_0021">procedure: <strong>delete-from-queue!</strong> <em>queue object --&gt; unspecified</em></dt>
  3427. <dd><p><code>On-queue?</code> returns true if <var>queue</var> contains <var>object</var> or
  3428. <code>#f</code> if not. <code>Delete-from-queue!</code> removes the first
  3429. occurrence of <var>object</var> from <var>queue</var> that would be dequeued.
  3430. </p></dd></dl>
  3431. <dl>
  3432. <dt id="index-queue_002d_003elist">procedure: <strong>queue-&gt;list</strong> <em>queue --&gt; list</em></dt>
  3433. <dt id="index-list_002d_003equeue">procedure: <strong>list-&gt;queue</strong> <em>list --&gt; queue</em></dt>
  3434. <dd><p>These convert queues to and from lists of their elements.
  3435. <code>Queue-&gt;list</code> returns a list in the order in which its elements
  3436. were added to the queue. <code>List-&gt;queue</code> returns a queue that will
  3437. produce elements starting at the head of the list.
  3438. </p></dd></dl>
  3439. <p>Examples:
  3440. </p>
  3441. <div class="lisp">
  3442. <pre class="lisp">(define q (make-queue))
  3443. (enqueue! q 'foo)
  3444. (enqueue! q 'bar)
  3445. (queue-&gt;list q) &rArr; (foo bar)
  3446. (on-queue? q 'bar) &rArr; #t
  3447. (dequeue! q) &rArr; 'foo
  3448. (queue-empty? q) &rArr; #f
  3449. (delete-from-queue! queue 'bar)
  3450. (queue-empty? q) &rArr; #t
  3451. (enqueue! q 'frobozz)
  3452. (empty-queue! q)
  3453. (queue-empty? q) &rArr; #t
  3454. (dequeue! q) error&rarr; empty queue</pre></div>
  3455. <p>Queues are integrated with Scheme48&rsquo;s <a href="#Optimistic-concurrency">optimistic concurrency</a> facilities, in that every procedure exported
  3456. except for <code>queue-&gt;list</code> ensures fusible atomicity in operation
  3457. &mdash; that is, every operation except for <code>queue-&gt;list</code> ensures that
  3458. the transaction it performs is atomic, and that it may be fused within
  3459. larger atomic transactions, as transactions wrapped within
  3460. <code>call-ensuring-atomicity</code> <i>&amp;c.</i> may be.
  3461. </p>
  3462. <hr>
  3463. <span id="Hash-tables"></span><div class="header">
  3464. <p>
  3465. Next: <a href="#Weak-references" accesskey="n" rel="next">Weak references</a>, Previous: <a href="#Queues" accesskey="p" rel="prev">Queues</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3466. </div>
  3467. <span id="Hash-tables-1"></span><h4 class="subsection">4.1.9 Hash tables</h4>
  3468. <span id="index-tables"></span>
  3469. <p>Scheme48 provides a simple hash table facility in the structure
  3470. <code>tables</code>.
  3471. </p>
  3472. <dl>
  3473. <dt id="index-make_002dtable">procedure: <strong>make-table</strong> <em>[hasher] --&gt; table</em></dt>
  3474. <dt id="index-make_002dstring_002dtable">procedure: <strong>make-string-table</strong> <em>--&gt; string-table</em></dt>
  3475. <dt id="index-make_002dsymbol_002dtable">procedure: <strong>make-symbol-table</strong> <em>--&gt; symbol-table</em></dt>
  3476. <dt id="index-make_002dinteger_002dtable">procedure: <strong>make-integer-table</strong> <em>--&gt; integer-table</em></dt>
  3477. <dd><p>Hash table constructors. <code>Make-table</code> creates a table that hashes
  3478. keys either with <var>hasher</var>, if it is passed to <code>make-table</code>, or
  3479. <code>default-hash-function</code>, and it compares keys for equality with
  3480. <code>eq?</code>, unless they are numbers, in which case it compares with
  3481. <code>eqv?</code>. <code>Make-string-table</code> makes a table whose hash function
  3482. is <code>string-hash</code> and that compares the equality of keys with
  3483. <code>string=?</code>. <code>Make-symbol-table</code> constructs a table that
  3484. hashes symbol keys by converting them to strings and hashing them with
  3485. <code>string-hash</code>; it compares keys&rsquo; equality by <code>eq?</code>. Tables
  3486. made by <code>make-integer-table</code> hash keys by taking their absolute
  3487. value, and test for key equality with the <code>=</code> procedure.
  3488. </p></dd></dl>
  3489. <dl>
  3490. <dt id="index-make_002dtable_002dmaker">procedure: <strong>make-table-maker</strong> <em>comparator hasher --&gt; table-maker</em></dt>
  3491. <dd><p>Customized table constructor constructor: this returns a nullary
  3492. procedure that creates a new table that uses <var>comparator</var> to compare
  3493. keys for equality and <var>hasher</var> to hash keys.
  3494. </p></dd></dl>
  3495. <dl>
  3496. <dt id="index-table_003f">procedure: <strong>table?</strong> <em>object --&gt; boolean</em></dt>
  3497. <dd><p>Hash table disjoint type predicate.
  3498. </p></dd></dl>
  3499. <dl>
  3500. <dt id="index-table_002dref">procedure: <strong>table-ref</strong> <em>table key --&gt; value or <code>#f</code></em></dt>
  3501. <dt id="index-table_002dset_0021">procedure: <strong>table-set!</strong> <em>table key value --&gt; unspecified</em></dt>
  3502. <dd><p><code>Table-ref</code> returns the value associated with <var>key</var> in
  3503. <var>table</var>, or <code>#f</code> if there is no such association.
  3504. If <var>value</var> is <code>#f</code>, <code>table-set!</code> ensures that there is no
  3505. longer an association with <var>key</var> in <var>table</var>; if <var>value</var> is
  3506. any other value, <code>table-set!</code> creates a new association or assigns
  3507. an existing one in <var>table</var> whose key is <var>key</var> and whose
  3508. associated value is <var>value</var>.
  3509. </p></dd></dl>
  3510. <dl>
  3511. <dt id="index-table_002dwalk">procedure: <strong>table-walk</strong> <em>proc table --&gt; unspecified</em></dt>
  3512. <dd><p><code>Table-walk</code> applies <var>proc</var> to the key &amp; value, in that order
  3513. of arguments, of every association in <var>table</var>.
  3514. </p></dd></dl>
  3515. <dl>
  3516. <dt id="index-make_002dtable_002dimmutable_0021">procedure: <strong>make-table-immutable!</strong> <em>table --&gt; table</em></dt>
  3517. <dd><p>This makes the structure of <var>table</var> immutable, though not its
  3518. contents. <code>Table-set!</code> may not be used with tables that have been
  3519. made immutable.
  3520. </p></dd></dl>
  3521. <dl>
  3522. <dt id="index-default_002dhash_002dfunction">procedure: <strong>default-hash-function</strong> <em>value --&gt; integer-hash-code</em></dt>
  3523. <dt id="index-string_002dhash-1">procedure: <strong>string-hash</strong> <em>string --&gt; integer-hash-code</em></dt>
  3524. <dd><p>Two built-in hashing functions. <code>Default-hash-function</code> can hash
  3525. any Scheme value that could usefully be used in a <code>case</code> clause.
  3526. <code>String-hash</code> is likely to be fast, as it is implemented as a VM
  3527. primitive. <code>String-hash</code> is the same as what the <code>features</code>
  3528. structure exports under the same name.
  3529. </p></dd></dl>
  3530. <hr>
  3531. <span id="Weak-references"></span><div class="header">
  3532. <p>
  3533. Next: <a href="#Type-annotations" accesskey="n" rel="next">Type annotations</a>, Previous: <a href="#Hash-tables" accesskey="p" rel="prev">Hash tables</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3534. </div>
  3535. <span id="Weak-references-1"></span><h4 class="subsection">4.1.10 Weak references</h4>
  3536. <span id="index-weak"></span>
  3537. <p>Scheme48 provides an interface to weakly held references in basic weak
  3538. pointers and <em>populations</em>, or sets whose elements are weakly held.
  3539. The facility is in the structure <code>weak</code>.
  3540. </p>
  3541. <span id="Weak-pointers"></span><h4 class="subsubsection">4.1.10.1 Weak pointers</h4>
  3542. <dl>
  3543. <dt id="index-make_002dweak_002dpointer">procedure: <strong>make-weak-pointer</strong> <em>contents --&gt; weak-pointer</em></dt>
  3544. <dt id="index-weak_002dpointer_003f">procedure: <strong>weak-pointer?</strong> <em>object --&gt; boolean</em></dt>
  3545. <dt id="index-weak_002dpointer_002dref">procedure: <strong>weak-pointer-ref</strong> <em>weak-pointer --&gt; value or <code>#f</code></em></dt>
  3546. <dd><p><code>Make-weak-pointer</code> creates a weak pointer that points to
  3547. <var>contents</var>. <code>Weak-pointer?</code> is the weak pointer disjoint type
  3548. predicate. <code>Weak-pointer-ref</code> accesses the value contained within
  3549. <code>weak-pointer</code>, or returns <code>#f</code> if there were no strong
  3550. references to the contents and a garbage collection occurred. Weak
  3551. pointers resemble <a href="#Cells">cells</a>, except that they are
  3552. immutable and hold their contents weakly, not strongly.
  3553. </p></dd></dl>
  3554. <span id="Populations-_0028weak-sets_0029"></span><h4 class="subsubsection">4.1.10.2 Populations (weak sets)</h4>
  3555. <dl>
  3556. <dt id="index-make_002dpopulation">procedure: <strong>make-population</strong> <em>--&gt; population</em></dt>
  3557. <dt id="index-add_002dto_002dpopulation_0021">procedure: <strong>add-to-population!</strong> <em>object population --&gt; unspecified</em></dt>
  3558. <dt id="index-population_002d_003elist">procedure: <strong>population-&gt;list</strong> <em>population --&gt; list</em></dt>
  3559. <dt id="index-walk_002dpopulation">procedure: <strong>walk-population</strong> <em>proc population --&gt; unspecified</em></dt>
  3560. <dd><p><code>Make-population</code> constructs an empty population.
  3561. <code>Add-to-population!</code> adds <var>object</var> to the population
  3562. <var>population</var>. <code>Population-&gt;list</code> returns a list of the
  3563. elements of <var>population</var>. Note, though, that this can be
  3564. dangerous in that it can create strong references to the population&rsquo;s
  3565. contents and potentially leak space because of this.
  3566. <code>Walk-population</code> applies <var>proc</var> to every element in
  3567. <var>population</var>.
  3568. </p></dd></dl>
  3569. <hr>
  3570. <span id="Type-annotations"></span><div class="header">
  3571. <p>
  3572. Next: <a href="#Explicit-renaming-macros" accesskey="n" rel="next">Explicit renaming macros</a>, Previous: <a href="#Weak-references" accesskey="p" rel="prev">Weak references</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3573. </div>
  3574. <span id="Type-annotations-1"></span><h4 class="subsection">4.1.11 Type annotations</h4>
  3575. <span id="index-type-system-loopholes"></span>
  3576. <span id="index-loopholes-in-the-type-system"></span>
  3577. <span id="index-loopholes"></span>
  3578. <p>Scheme48 allows optional type annotations with the <code>loophole</code>
  3579. special form from the <code>loopholes</code> structure.
  3580. </p>
  3581. <dl>
  3582. <dt id="index-loophole">syntax: <strong>loophole</strong> <em>type expression --&gt; values</em></dt>
  3583. <dd><p>This is exactly equivalent in semantics to <var>expression</var>, except the
  3584. static type analyzer is informed that the whole expression has the type
  3585. <var>type</var>. For details on the form of <var>type</var>, see <a href="#Static-type-system">Static type system</a>.
  3586. </p></dd></dl>
  3587. <p>Type annotations can be used for several different purposes:
  3588. </p>
  3589. <ul>
  3590. <li> simply to give more information to the static type analyzer;
  3591. </li><li> to work as a simple abstract data type facility: passing a type name
  3592. that does not already exist creates a new disjoint value type; and
  3593. </li><li> to prevent the type system from generating warnings in the rare cases
  3594. where it would do so incorrectly, such as in the <code>primitive-cwcc</code>,
  3595. <code>primitive-catch</code>, and <code>with-continuation</code> devices (to be
  3596. documented in a later edition of this manual).
  3597. </li></ul>
  3598. <p>To see an example of the second use, see <samp>rts/jar-defrecord.scm</samp>
  3599. in Scheme48&rsquo;s source tree.
  3600. </p>
  3601. <p><strong>Note:</strong> Type annotations do <em>not</em> damage the safety of
  3602. Scheme&rsquo;s type system. They affect only the static type analyzer, which
  3603. does not change run-time object representations; it only checks type
  3604. soundness of code and generates warnings for programs that would cause
  3605. run-time type errors.
  3606. </p>
  3607. <hr>
  3608. <span id="Explicit-renaming-macros"></span><div class="header">
  3609. <p>
  3610. Previous: <a href="#Type-annotations" accesskey="p" rel="prev">Type annotations</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3611. </div>
  3612. <span id="Explicit-renaming-macros-1"></span><h4 class="subsection">4.1.12 Explicit renaming macros</h4>
  3613. <span id="index-low_002dlevel-macros"></span>
  3614. <span id="index-macros_002c-low_002dlevel"></span>
  3615. <span id="index-unhygienic-macros"></span>
  3616. <span id="index-macros_002c-unhygienic"></span>
  3617. <p>Scheme48 supports a simple low-level macro system based on explicitly
  3618. renaming identifiers to preserve hygiene. The macro system is
  3619. well-integrated with the module system; see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>.
  3620. </p>
  3621. <p><em>Explicit renaming</em> macro transformers operate on simple
  3622. S-expressions extended with <em>identifiers</em>, which are like symbols
  3623. but contain more information about lexical context. In order to
  3624. preserve that lexical context, transformers must explicitly call a
  3625. <em>renamer</em> procedure to produce an identifier with the proper scope.
  3626. To test whether identifiers have the same denotation, transformers are
  3627. also given an identifier comparator.
  3628. </p>
  3629. <p>The facility provided by Scheme48 is almost identical to the explicit
  3630. renaming macro facility described in [Clinger 91].<a id="DOCF15" href="#FOOT15"><sup>15</sup></a> It differs only by the <code>transformer</code>
  3631. keyword, which is described in the paper but not used by Scheme48, and
  3632. in the annotation of auxiliary names.
  3633. </p>
  3634. <dl>
  3635. <dt id="index-define_002dsyntax-1">syntax: <strong>define-syntax</strong> <em>name transformer [aux-names]</em></dt>
  3636. <dd><p>Introduces a derived syntax <var>name</var> with the given transformer,
  3637. which may be an explicit renaming transformer procedure, a pair whose
  3638. car is such a procedure and whose cdr is a list of auxiliary
  3639. identifiers, or the value of a <code>syntax-rules</code> expression. In the
  3640. first case, the added operand <var>aux-names</var> may, and usually should
  3641. except in the case of local (non-exported) syntactic bindings, be a
  3642. list of all of the auxiliary top-level identifiers used by the macro.
  3643. </p></dd></dl>
  3644. <p>Explicit renaming transformer procedures are procedures of three
  3645. arguments: an input form, an identifier renamer procedure, and an
  3646. identifier comparator procedure. The input form is the whole form of
  3647. the macro&rsquo;s invocation (including, at the car, the identifier whose
  3648. denotation was the syntactic binding). The identifier renamer accepts
  3649. an identifier as an argument and returns an identifier that is
  3650. hygienically renamed to refer absolutely to the identifier&rsquo;s denotation
  3651. in the environment of the macro&rsquo;s definition, not in the environment of
  3652. the macro&rsquo;s usage. In order to preserve hygiene of syntactic
  3653. transformations, macro transformers must call this renamer procedure
  3654. for any literal identifiers in the output. The renamer procedure is
  3655. referentially transparent; that is, two invocations of it with the same
  3656. arguments in terms of <code>eq?</code> will produce the same results in the
  3657. sense of <code>eq?</code>.
  3658. </p>
  3659. <p>For example, this simple transformer for a <code>swap!</code> macro is
  3660. incorrect:
  3661. </p>
  3662. <div class="lisp">
  3663. <pre class="lisp">(define-syntax swap!
  3664. (lambda (form rename compare)
  3665. (let ((a (cadr form))
  3666. (b (caddr form)))
  3667. `(LET ((TEMP ,a))
  3668. (SET! ,a ,b)
  3669. (SET! ,b TEMP)))))</pre></div>
  3670. <p>The introduction of the literal identifier <code>temp</code> into the output
  3671. may conflict with one of the input variables if it were to also be
  3672. named <code>temp</code>: <code>(swap! temp foo)</code> or <code>(swap! bar temp)</code>
  3673. would produce the wrong result. Also, the macro would fail in another
  3674. very strange way if the user were to have a local variable named
  3675. <code>let</code> or <code>set!</code>, or it would simply produce invalid output if
  3676. there were no binding of <code>let</code> or <code>set!</code> in the environment
  3677. in which the macro was used. These are basic problems of abstraction:
  3678. the user of the macro should not need to know how the macro is
  3679. internally implemented, notably with a <code>temp</code> variable and using
  3680. the <code>let</code> and <code>set!</code> special forms.
  3681. </p>
  3682. <p>Instead, the macro must hygienically rename these identifiers using
  3683. the renamer procedure it is given, and it should list the top-level
  3684. identifiers it renames (which cannot otherwise be extracted
  3685. automatically from the macro&rsquo;s definition):
  3686. </p>
  3687. <div class="lisp">
  3688. <pre class="lisp">(define-syntax swap!
  3689. (lambda (form rename compare)
  3690. (let ((a (cadr form))
  3691. (b (caddr form)))
  3692. `(,(rename 'LET) ((,(rename 'TEMP) ,a))
  3693. (,(rename 'SET!) ,a ,b)
  3694. (,(rename 'SET!) ,b ,(rename 'TEMP)))))
  3695. (LET SET!))</pre></div>
  3696. <p>However, some macros are unhygienic by design, <i>i.e.</i> they insert
  3697. identifiers into the output intended to be used in the environment of
  3698. the macro&rsquo;s usage. For example, consider a <code>loop</code> macro that
  3699. loops endlessly, but binds a variable named <code>exit</code> to an escape
  3700. procedure to the continuation of the <code>loop</code> expression, with
  3701. which the user of the macro can escape the loop:
  3702. </p>
  3703. <div class="lisp">
  3704. <pre class="lisp">(define-syntax loop
  3705. (lambda (form rename compare)
  3706. (let ((body (cdr form)))
  3707. `(,(rename 'CALL-WITH-CURRENT-CONTINUATION)
  3708. (,(rename 'LAMBDA) (EXIT) ; Literal, unrenamed EXIT.
  3709. (,(rename 'LET) ,(rename 'LOOP) ()
  3710. ,@body
  3711. (,(rename 'LOOP)))))))
  3712. (CALL-WITH-CURRENT-CONTINUATION LAMBDA LET))</pre></div>
  3713. <p>Note that macros that expand to <code>loop</code> must also be unhygienic;
  3714. for instance, this na&iuml;ve definition of a
  3715. <code>loop-while</code> macro is incorrect, because it hygienically renames
  3716. <code>exit</code> automatically by of the definition of <code>syntax-rules</code>,
  3717. so the identifier it refers to is not the one introduced
  3718. unhygienically by <code>loop</code>:
  3719. </p>
  3720. <div class="lisp">
  3721. <pre class="lisp">(define-syntax loop-while
  3722. (syntax-rules ()
  3723. ((LOOP-WHILE test body ...)
  3724. (LOOP (IF (NOT test)
  3725. (EXIT)) ; Hygienically renamed.
  3726. body ...))))</pre></div>
  3727. <p>Instead, a transformer must be written to not hygienically rename
  3728. <code>exit</code> in the output:
  3729. </p>
  3730. <div class="lisp">
  3731. <pre class="lisp">(define-syntax loop-while
  3732. (lambda (form rename compare)
  3733. (let ((test (cadr form))
  3734. (body (cddr form)))
  3735. `(,(rename 'LOOP)
  3736. (,(rename 'IF) (,(rename 'NOT) ,test)
  3737. (EXIT)) ; Not hygienically renamed.
  3738. ,@body)))
  3739. (LOOP IF NOT))</pre></div>
  3740. <p>To understand the necessity of annotating macros with the list of
  3741. auxiliary names they use, consider the following definition of the
  3742. <code>delay</code> form, which transforms <code>(delay <var>exp</var>)</code> into
  3743. <code>(make-promise (lambda () <var>exp</var>))</code>, where <code>make-promise</code>
  3744. is some non-exported procedure defined in the same module as the
  3745. <code>delay</code> macro:
  3746. </p>
  3747. <div class="lisp">
  3748. <pre class="lisp">(define-syntax delay
  3749. (lambda (form rename compare)
  3750. (let ((exp (cadr form)))
  3751. `(,(rename 'MAKE-PROMISE) (,(rename 'LAMBDA) () ,exp)))))</pre></div>
  3752. <p>This preserves hygiene as necessary, but, while the compiler can know
  3753. whether <code>make-promise</code> is <em>exported</em> or not, it cannot in
  3754. general determine whether <code>make-promise</code> is <em>local</em>, <i>i.e.</i>
  3755. not accessible in any way whatsoever, even in macro output, from any
  3756. other modules. In this case, <code>make-promise</code> is <em>not</em> local,
  3757. but the compiler cannot in general know this, and it would be an
  3758. unnecessarily heavy burden on the compiler, the linker, and related
  3759. code-processing systems to assume that all bindings are not local. It
  3760. is therefore better<a id="DOCF16" href="#FOOT16"><sup>16</sup></a> to annotate such
  3761. definitions with the list of auxiliary names used by the transformer:
  3762. </p>
  3763. <div class="lisp">
  3764. <pre class="lisp">(define-syntax delay
  3765. (lambda (form rename compare)
  3766. (let ((exp (cadr form)))
  3767. `(,(rename 'MAKE-PROMISE) (,(rename 'LAMBDA) () ,exp))))
  3768. (MAKE-PROMISE LAMBDA))</pre></div>
  3769. <hr>
  3770. <span id="Condition-system"></span><div class="header">
  3771. <p>
  3772. Next: <a href="#Bitwise-manipulation" accesskey="n" rel="next">Bitwise manipulation</a>, Previous: <a href="#System-features" accesskey="p" rel="prev">System features</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  3773. </div>
  3774. <span id="Condition-system-1"></span><h3 class="section">4.2 Condition system</h3>
  3775. <span id="index-exceptions-1"></span>
  3776. <span id="index-conditions-2"></span>
  3777. <p>As of version 1.3 (different from all older versions), Scheme48
  3778. supports two different condition systems. One of them, the original
  3779. one, is a simple system where conditions are represented as tagged
  3780. lists. This section documents the original one. The new condition
  3781. system is [SRFI 34, 35], and there is a complicated translation layer
  3782. between the old one, employed by the run-time system, and the new one,
  3783. which is implemented in a layer high above that as a library, but a
  3784. library which is always loaded in the usual development environment.
  3785. See the [SRFI 34, 35] documents for documentation of the new condition
  3786. system. [SRFI 34] is available from the <code>exceptions</code> structure;
  3787. SRFI 35, from the <code>conditions</code> structure.
  3788. </p>
  3789. <p><strong>Note:</strong> The condition system changed in Scheme48 version 1.3.
  3790. While the old one is still available, the names of the structures that
  3791. implement it changed. <code>Signals</code> is now <code>simple-signals</code>,
  3792. and <code>conditions</code> is now <code>simple-conditions</code>. The structure
  3793. that <code>signals</code> <em>now</em> names implements the same interface,
  3794. but with [SRFI 34, 35] underlying it. The structure that the name
  3795. <code>conditions</code> <em>now</em> identifies [SRFI 35]. You will have to
  3796. update all old code that relied on the old <code>signals</code> and
  3797. <code>conditions</code> structure either by using those structures&rsquo; new
  3798. names or by invasively modifying all code to use [SRFI 34, 35]. Also,
  3799. the only way to completely elide the use of the SRFIs is to evaluate
  3800. this in an environment with the <code>exceptions-internal</code> and
  3801. <code>vm-exceptions</code> structure open:
  3802. </p>
  3803. <div class="lisp">
  3804. <pre class="lisp">(begin (initialize-vm-exceptions! really-signal-condition)
  3805. ;; INITIALIZE-VM-EXCEPTIONS! returns a very large object,
  3806. ;; which we probably don't want printed at the REPL.
  3807. #t)</pre></div>
  3808. <span id="Signalling_002c-handling_002c-and-representing-conditions"></span><h4 class="subsection">4.2.1 Signalling, handling, and representing conditions</h4>
  3809. <span id="index-conditions"></span>
  3810. <span id="index-exceptions"></span>
  3811. <span id="index-errors"></span>
  3812. <span id="index-warnings"></span>
  3813. <span id="index-signalling-conditions"></span>
  3814. <span id="index-condition-types"></span>
  3815. <span id="index-condition-handlers"></span>
  3816. <p>Scheme48 provides a simple condition system.<a id="DOCF17" href="#FOOT17"><sup>17</sup></a> <em>Conditions</em> are objects that
  3817. describe exceptional situations. Scheme48 keeps a registry of
  3818. <em>condition types</em>, which just have references to their supertypes.
  3819. Conditions are simple objects that contain only two fields, the type
  3820. and the type-specific data (the <em>stuff</em>). Accessor procedures
  3821. should be defined for particular condition types to extract the data
  3822. contained within the &lsquo;stuff&rsquo; fields of instances of of those condition
  3823. types. Condition types are represented as symbols. <em>Condition
  3824. handlers</em> are part of the system&rsquo;s dynamic context; they are used to
  3825. handle exceptional situations when conditions are signalled that
  3826. describe such exceptional situations. <em>Signalling</em> a condition
  3827. signals that an exceptional situation occurred and invokes the current
  3828. condition handler on the condition.
  3829. </p>
  3830. <p>Scheme48&rsquo;s condition system is split up into three structures:
  3831. </p>
  3832. <dl compact="compact">
  3833. <dt><code>simple-signals</code></dt>
  3834. <dd><p>Exports procedures to signal conditions and construct conditions, as
  3835. well as some utilities for common kinds of conditions.
  3836. </p>
  3837. </dd>
  3838. <dt><code>handle</code></dt>
  3839. <dd><p>Exports facilities for handling signalled conditions.
  3840. </p>
  3841. </dd>
  3842. <dt><code>simple-conditions</code></dt>
  3843. <dd><p>The system of representing conditions as objects.
  3844. </p></dd>
  3845. </dl>
  3846. <span id="index-simple_002dsignals"></span>
  3847. <p>The <code>simple-signals</code> structure exports these procedures:
  3848. </p>
  3849. <dl>
  3850. <dt id="index-make_002dcondition">procedure: <strong>make-condition</strong> <em>type-name stuff --&gt; condition</em></dt>
  3851. <dd><p>The condition object constructor.
  3852. </p></dd></dl>
  3853. <dl>
  3854. <dt id="index-signal_002dcondition">procedure: <strong>signal-condition</strong> <em>condition --&gt; values (may not return)</em></dt>
  3855. <dt id="index-signal">procedure: <strong>signal</strong> <em>type-name stuff &hellip; --&gt; values (may not return)</em></dt>
  3856. <dd><p><code>Signal-condition</code> signals the given condition. <code>Signal</code> is
  3857. a convenience atop the common conjunction of <code>signal-condition</code>
  3858. and <code>make-condition</code>: it constructs a condition with the given
  3859. type name and stuff, whereafter it signals that condition with
  3860. <code>signal-condition</code>.
  3861. </p></dd></dl>
  3862. <dl>
  3863. <dt id="index-error">procedure: <strong>error</strong> <em>message irritant &hellip; --&gt; values (may not return)</em></dt>
  3864. <dt id="index-warn">procedure: <strong>warn</strong> <em>message irritant &hellip; --&gt; values (may not return)</em></dt>
  3865. <dt id="index-syntax_002derror">procedure: <strong>syntax-error</strong> <em>message irritant &hellip; --&gt; expression (may not return)</em></dt>
  3866. <dt id="index-call_002derror">procedure: <strong>call-error</strong> <em>message irritant &hellip; --&gt; values (may not return)</em></dt>
  3867. <dt id="index-note">procedure: <strong>note</strong> <em>message irritant &hellip; --&gt; values (may not return)</em></dt>
  3868. <dd><p>Conveniences for signalling standard condition types. These procedures
  3869. generally either do not return or return an unspecified value, unless
  3870. specified to by a user of the debugger. <code>Syntax-error</code> returns
  3871. the expression <code>(quote syntax-error)</code>, if the condition handler
  3872. returns to <code>syntax-error</code> in the first place.
  3873. </p>
  3874. <span id="index-error-messages"></span>
  3875. <span id="index-condition-messages"></span>
  3876. <p>By convention, the message should be lowercased (<i>i.e.</i> the first word
  3877. should not be capitalized), and it should not end with punctuation.
  3878. The message is typically not a complete sentence. For example, these
  3879. all follow Scheme48&rsquo;s convention:
  3880. </p>
  3881. <ul class="no-bullet">
  3882. <li><!-- /@w --> argument type error
  3883. </li><li><!-- /@w --> wrong number of arguments
  3884. </li><li><!-- /@w --> invalid syntax
  3885. </li><li><!-- /@w --> ill-typed right-hand side
  3886. </li><li><!-- /@w --> out of memory, unable to continue
  3887. </li></ul>
  3888. <p>These, on the other hand, do not follow the convention and should be
  3889. avoided:
  3890. </p>
  3891. <ul class="no-bullet">
  3892. <li><!-- /@w --> Argument type error:
  3893. </li><li><!-- /@w --> An argument of the wrong type was passed.
  3894. </li><li><!-- /@w --> possible type mismatch:
  3895. </li><li><!-- /@w --> Luser is an idiot!
  3896. </li></ul>
  3897. <p>Elaboration on a message is performed usually by wrapping an irritant
  3898. in a descriptive list. For example, one might write:
  3899. </p>
  3900. <div class="lisp">
  3901. <pre class="lisp">(error &quot;invalid argument&quot;
  3902. '(not a pair)
  3903. `(while calling ,frobbotz)
  3904. `(received ,object))</pre></div>
  3905. <p>This might be printed as:
  3906. </p>
  3907. <div class="example">
  3908. <pre class="example">Error: invalid argument
  3909. (not a pair)
  3910. (while calling #{Procedure 123 (frobbotz in ...)})
  3911. (received #(a b c d))</pre></div>
  3912. </dd></dl>
  3913. <span id="index-installing-condition-handlers"></span>
  3914. <span id="index-handle"></span>
  3915. <p>The <code>handle</code> structure exports the following procedures:
  3916. </p>
  3917. <dl>
  3918. <dt id="index-with_002dhandler">procedure: <strong>with-handler</strong> <em>handler thunk --&gt; values</em></dt>
  3919. <dd><p>Sets up <var>handler</var> as the condition handler for the dynamic extent
  3920. of <var>thunk</var>. <var>Handler</var> should be a procedure of two arguments:
  3921. the condition that was signalled and a procedure of zero arguments that
  3922. propagates the condition up to the next dynamically enclosing handler.
  3923. When a condition is signalled, <var>handler</var> is tail-called from the
  3924. point that the condition was signalled at. Note that, because
  3925. <var>handler</var> is tail-called at that point, it will <em>return</em> to
  3926. that point also.
  3927. </p>
  3928. <p><strong>Warning:</strong> <code>With-handler</code> is potentially very dangerous.
  3929. If an exception occurs and a condition is raised in the handler, the
  3930. handler itself will be called with that new condition! Furthermore,
  3931. the handler may accidentally return to an unexpecting signaller, which
  3932. can cause very confusing errors. Be careful with <code>with-handler</code>;
  3933. to be perfectly safe, it might be a good idea to throw back out to
  3934. where the handler was initially installed before doing anything:
  3935. </p>
  3936. <div class="lisp">
  3937. <pre class="lisp">((call-with-current-continuation
  3938. (lambda (k)
  3939. (lambda ()
  3940. (with-handler (lambda (c propagate)
  3941. (k (lambda () <var>handler body</var>)))
  3942. (lambda () <var>body</var>))))))</pre></div>
  3943. </dd></dl>
  3944. <dl>
  3945. <dt id="index-ignore_002derrors">procedure: <strong>ignore-errors</strong> <em>thunk --&gt; values or condition</em></dt>
  3946. <dt id="index-report_002derrors_002das_002dwarnings">procedure: <strong>report-errors-as-warnings</strong> <em>thunk message irritant &hellip; --&gt; values</em></dt>
  3947. <dd><p><code>Ignore-errors</code> sets up a condition handler that will return error
  3948. conditions to the point where <code>ignore-errors</code> was called, and
  3949. propagate all other conditions. If no condition is signalled during
  3950. the dynamic extent of <var>thunk</var>, <code>ignore-errors</code> simply returns
  3951. whatever <var>thunk</var> returned. <code>Report-errors-as-warnings</code>
  3952. downgrades errors to warnings while executing <var>thunk</var>. If an error
  3953. occurs, a warning is signalled with the given message, and a list of
  3954. irritants constructed by adding the error condition to the end of the
  3955. list <var>irritant</var> &hellip;.
  3956. </p></dd></dl>
  3957. <span id="index-conditions-1"></span>
  3958. <span id="index-condition-types-1"></span>
  3959. <span id="index-simple_002dconditions"></span>
  3960. <p>Finally, the <code>simple-conditions</code> structure defines the condition
  3961. type system. (Note that conditions themselves are constructed only by
  3962. <code>make-condition</code> (and <code>signal</code>) from the
  3963. <code>simple-signals</code> structure.) Conditions are very basic values
  3964. that have only two universally defined fields: the type and the stuff.
  3965. The type is a symbol denoting a condition type. The type is specified
  3966. in the first argument to <code>make-condition</code> or <code>signal</code>. The
  3967. stuff field contains whatever a particular condition type stores in
  3968. conditions of that type. The stuff field is always a list; it is
  3969. created from the arguments after the first to <code>make-condition</code> or
  3970. <code>signal</code>. Condition types are denoted by symbols, kept in a
  3971. global registry that maps condition type names to their supertype
  3972. names.
  3973. </p>
  3974. <dl>
  3975. <dt id="index-define_002dcondition_002dtype">procedure: <strong>define-condition-type</strong> <em>name supertype-names --&gt; unspecified</em></dt>
  3976. <dd><p>Registers the symbol <var>name</var> as a condition type. Its supertypes
  3977. are named in the list <var>supertype-names</var>.
  3978. </p></dd></dl>
  3979. <dl>
  3980. <dt id="index-condition_002dpredicate">procedure: <strong>condition-predicate</strong> <em>ctype-name --&gt; predicate</em></dt>
  3981. <dd><p>Returns a procedure of one argument that returns <code>#t</code> if that
  3982. argument is a condition whose type&rsquo;s name is <var>ctype-name</var> or
  3983. <code>#f</code> if not.
  3984. </p></dd></dl>
  3985. <dl>
  3986. <dt id="index-condition_002dtype">procedure: <strong>condition-type</strong> <em>condition --&gt; type-name</em></dt>
  3987. <dt id="index-condition_002dstuff">procedure: <strong>condition-stuff</strong> <em>condition --&gt; list</em></dt>
  3988. <dd><p>Accessors for the two immutable fields of conditions.
  3989. </p></dd></dl>
  3990. <dl>
  3991. <dt id="index-error_003f">procedure: <strong>error?</strong> <em>condition --&gt; boolean</em></dt>
  3992. <dt id="index-warning_003f">procedure: <strong>warning?</strong> <em>condition --&gt; boolean</em></dt>
  3993. <dt id="index-note_003f">procedure: <strong>note?</strong> <em>condition --&gt; boolean</em></dt>
  3994. <dt id="index-syntax_002derror_003f">procedure: <strong>syntax-error?</strong> <em>condition --&gt; boolean</em></dt>
  3995. <dt id="index-call_002derror_003f">procedure: <strong>call-error?</strong> <em>condition --&gt; boolean</em></dt>
  3996. <dt id="index-read_002derror_003f">procedure: <strong>read-error?</strong> <em>condition --&gt; boolean</em></dt>
  3997. <dt id="index-interrupt_003f">procedure: <strong>interrupt?</strong> <em>condition --&gt; boolean</em></dt>
  3998. <dd><p>Condition predicates for built-in condition types.
  3999. </p></dd></dl>
  4000. <dl>
  4001. <dt id="index-make_002dexception">procedure: <strong>make-exception</strong> <em>opcode reason arguments --&gt; exception</em></dt>
  4002. <dt id="index-exception_003f">procedure: <strong>exception?</strong> <em>condition --&gt; boolean</em></dt>
  4003. <dt id="index-exception_002dopcode">procedure: <strong>exception-opcode</strong> <em>exception --&gt; integer-opcode</em></dt>
  4004. <dt id="index-exception_002dreason">procedure: <strong>exception-reason</strong> <em>exception --&gt; symbol</em></dt>
  4005. <dt id="index-exception_002darguments">procedure: <strong>exception-arguments</strong> <em>exception --&gt; list</em></dt>
  4006. <dd><p><em>Exceptions</em> represent run-time errors in the Scheme48 VM. They
  4007. contain information about what opcode the VM was executing when it
  4008. happened, what the reason for the exception occurring was, and the
  4009. relevant arguments.
  4010. </p></dd></dl>
  4011. <span id="Displaying-conditions"></span><h4 class="subsection">4.2.2 Displaying conditions</h4>
  4012. <span id="index-printing-conditions"></span>
  4013. <span id="index-displaying-conditions"></span>
  4014. <p>The <code>display-conditions</code> structure is also relevant in this
  4015. section.
  4016. </p>
  4017. <dl>
  4018. <dt id="index-display_002dcondition">procedure: <strong>display-condition</strong> <em>condition port --&gt; unspecified</em></dt>
  4019. <dd><p>Prints <var>condition</var> to <var>port</var> for a user to read. For example:
  4020. </p>
  4021. <div class="lisp">
  4022. <pre class="lisp">(display-condition (make-condition 'error
  4023. &quot;Foo bar baz&quot;
  4024. 'quux
  4025. '(zot mumble: frotz))
  4026. (current-output-port))
  4027. -| Error: Foo bar baz
  4028. -| quux
  4029. -| (zot mumble: frotz)</pre></div>
  4030. </dd></dl>
  4031. <dl>
  4032. <dt id="index-_0026disclose_002dcondition">method table: <strong>&amp;disclose-condition</strong> <em>condition --&gt; disclosed</em></dt>
  4033. <dd><p>Method table (see <a href="#Generic-dispatch-system">Generic dispatch system</a>) for a generic procedure
  4034. (not exposed) used to translate a condition object into a more readable
  4035. format. See <a href="#Writer">Writer</a>.
  4036. </p></dd></dl>
  4037. <dl>
  4038. <dt id="index-limited_002dwrite">procedure: <strong>limited-write</strong> <em>object port max-depth max-length --&gt; unspecified</em></dt>
  4039. <dd><p>A utility for avoiding excessive output: prints <var>object</var> to
  4040. <var>port</var>, but will never print more than <var>max-length</var> of a
  4041. subobject&rsquo;s components, leaving a <code>---</code> after the last component,
  4042. and won&rsquo;t recur further down the object graph from the vertex
  4043. <var>object</var> beyond <var>max-depth</var>, instead printing an octothorpe
  4044. (<code>#</code>).
  4045. </p>
  4046. <div class="lisp">
  4047. <pre class="lisp">(let ((x (cons #f #f)))
  4048. (set-car! x x)
  4049. (set-cdr! x x)
  4050. (limited-write x (current-output-port) 2 2))
  4051. -| ((# # ---) (# # ---) ---)</pre></div>
  4052. </dd></dl>
  4053. <hr>
  4054. <span id="Bitwise-manipulation"></span><div class="header">
  4055. <p>
  4056. Next: <a href="#Generic-dispatch-system" accesskey="n" rel="next">Generic dispatch system</a>, Previous: <a href="#Condition-system" accesskey="p" rel="prev">Condition system</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4057. </div>
  4058. <span id="Bitwise-manipulation-1"></span><h3 class="section">4.3 Bitwise manipulation</h3>
  4059. <span id="index-binary-data-operation"></span>
  4060. <span id="index-bitwise-integer-operations"></span>
  4061. <span id="index-byte-manipulation"></span>
  4062. <p>Scheme48 provides two structures for bit manipulation: bitwise integer
  4063. operations, the <code>bitwise</code> structure, and homogeneous vectors of
  4064. bytes (integers between 0 and 255, inclusive), the <code>byte-vectors</code>
  4065. structure.
  4066. </p>
  4067. <span id="Bitwise-integer-operations"></span><h4 class="subsection">4.3.1 Bitwise integer operations</h4>
  4068. <span id="index-bitwise"></span>
  4069. <p>The <code>bitwise</code> structure exports these procedures:
  4070. </p>
  4071. <dl>
  4072. <dt id="index-bitwise_002dand">procedure: <strong>bitwise-and</strong> <em>integer &hellip; --&gt; integer</em></dt>
  4073. <dt id="index-bitwise_002dior">procedure: <strong>bitwise-ior</strong> <em>integer &hellip; --&gt; integer</em></dt>
  4074. <dt id="index-bitwise_002dxor">procedure: <strong>bitwise-xor</strong> <em>integer &hellip; --&gt; integer</em></dt>
  4075. <dt id="index-bitwise_002dnot">procedure: <strong>bitwise-not</strong> <em>integer --&gt; integer</em></dt>
  4076. <dd><p>Basic twos-complement bitwise boolean logic operations.
  4077. </p></dd></dl>
  4078. <dl>
  4079. <dt id="index-arithmetic_002dshift">procedure: <strong>arithmetic-shift</strong> <em>integer count --&gt; integer</em></dt>
  4080. <dd><p>Shifts <var>integer</var> by the given bit count. If <var>count</var> is
  4081. positive, the shift is a left shift; otherwise, it is a right shift.
  4082. <code>Arithmetic-shift</code> preserves <var>integer</var>&rsquo;s sign.
  4083. </p></dd></dl>
  4084. <dl>
  4085. <dt id="index-bit_002dcount">procedure: <strong>bit-count</strong> <em>integer --&gt; integer</em></dt>
  4086. <dd><p>Returns the number of bits that are set in <var>integer</var>. If
  4087. <var>integer</var> is negative, it is flipped by the bitwise NOT operation
  4088. before counting.
  4089. </p>
  4090. <div class="lisp">
  4091. <pre class="lisp">(bit-count #b11010010) &rArr; 4</pre></div>
  4092. </dd></dl>
  4093. <span id="Byte-vectors"></span><h4 class="subsection">4.3.2 Byte vectors</h4>
  4094. <span id="index-byte_002dvectors"></span>
  4095. <p>The structure <code>byte-vectors</code> exports analogues of regular vector
  4096. procedures for <em>byte vectors</em>, homogeneous vectors of bytes:
  4097. </p>
  4098. <dl>
  4099. <dt id="index-make_002dbyte_002dvector">procedure: <strong>make-byte-vector</strong> <em>length fill --&gt; byte-vector</em></dt>
  4100. <dt id="index-byte_002dvector">procedure: <strong>byte-vector</strong> <em>byte &hellip; --&gt; byte-vector</em></dt>
  4101. <dt id="index-byte_002dvector_003f">procedure: <strong>byte-vector?</strong> <em>object --&gt; boolean</em></dt>
  4102. <dt id="index-byte_002dvector_002dlength">procedure: <strong>byte-vector-length</strong> <em>byte-vector --&gt; integer</em></dt>
  4103. <dt id="index-byte_002dvector_002dref">procedure: <strong>byte-vector-ref</strong> <em>byte-vector index --&gt; byte</em></dt>
  4104. <dt id="index-byte_002dvector_002dset_0021">procedure: <strong>byte-vector-set!</strong> <em>byte-vector index byte --&gt; unspecified</em></dt>
  4105. <dd><p><var>Fill</var> and each <var>byte</var> must be bytes, <i>i.e.</i> integers within the
  4106. inclusive range 0 to 255. Note that <code>make-byte-vector</code> is not an
  4107. exact analogue of <code>make-vector</code>, because the <var>fill</var> parameter
  4108. is required.
  4109. </p></dd></dl>
  4110. <p>Old versions of Scheme48 referred to byte vectors as &lsquo;code vectors&rsquo;
  4111. (since they were used to denote byte code). The <code>code-vectors</code>
  4112. structure exports <code>make-code-vector</code>, <code>code-vector?</code>,
  4113. <code>code-vector-length</code>, <code>code-vector-ref</code>, and
  4114. <code>code-vector-set!</code>, identical to the analogously named byte
  4115. vector operations.
  4116. </p><hr>
  4117. <span id="Generic-dispatch-system"></span><div class="header">
  4118. <p>
  4119. Next: <a href="#I_002fO-system" accesskey="n" rel="next">I/O system</a>, Previous: <a href="#Bitwise-manipulation" accesskey="p" rel="prev">Bitwise manipulation</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4120. </div>
  4121. <span id="Generic-dispatch-system-1"></span><h3 class="section">4.4 Generic dispatch system</h3>
  4122. <span id="index-multimethod-dispatch"></span>
  4123. <span id="index-type-dispatch"></span>
  4124. <span id="index-generic-functions"></span>
  4125. <span id="index-generic-predicate-dispatch"></span>
  4126. <span id="index-methods"></span>
  4127. <span id="index-meta_002dmethods"></span>
  4128. <p>Scheme48 supports a CLOS-style generic procedure dispatch system, based
  4129. on type predicates. The main interface is exported by <code>methods</code>.
  4130. The internals of the system are exposed by the <code>meta-methods</code>
  4131. structure, but they are not documented here. The generic dispatch
  4132. system is used in Scheme48&rsquo;s <a href="#Writer">writer</a> and numeric
  4133. system.
  4134. </p>
  4135. <p><em>Types</em> in Scheme48&rsquo;s generic dispatch system are represented using
  4136. type predicates, rather than having every object have a single,
  4137. well-defined &lsquo;class.&rsquo; The naming convention for simple types is to
  4138. prefix the type name with a colon. The types support multiple
  4139. inheritance. Method specificity is determined based on descending
  4140. order of argument importance. That is, given two methods, <var>M</var> &amp;
  4141. <var>N</var>, such that they are both applicable to a given sequence of
  4142. arguments, and an index <var>i</var> into that sequence, such that <var>i</var>
  4143. is the first index in <var>M</var>&rsquo;s &amp; <var>N</var>&rsquo;s lists of argument type
  4144. specifiers, from left to right, where the type differs: if the type for
  4145. <var>M</var>&rsquo;s argument at <var>i</var> is more specific than the corresponding
  4146. type in <var>N</var>&rsquo;s specifiers, <var>M</var> is considered to be more specific
  4147. than <var>N</var>, even if the remaining argument type specifiers in <var>N</var>
  4148. are more specific.
  4149. </p>
  4150. <dl>
  4151. <dt id="index-define_002dsimple_002dtype">syntax: <strong>define-simple-type</strong> <em>name (supertype &hellip;) predicate</em></dt>
  4152. <dd><p>Defines <var>name</var> to be a <em>simple type</em> with the given predicate
  4153. and the given supertypes.
  4154. </p></dd></dl>
  4155. <dl>
  4156. <dt id="index-singleton">procedure: <strong>singleton</strong> <em>value --&gt; simple-type</em></dt>
  4157. <dd><p>Creates a <em>singleton type</em> that matches only <var>value</var>.
  4158. </p></dd></dl>
  4159. <dl>
  4160. <dt id="index-define_002dgeneric">syntax: <strong>define-generic</strong> <em>proc-name method-table-name [prototype]</em></dt>
  4161. <dd><p>Defines <var>proc-name</var> to be a <em>generic procedure</em> that, when
  4162. invoked, will dispatch on its arguments via the <em>method table</em> that
  4163. <var>method-table-name</var> is defined to be and apply the most specific
  4164. method it can determine defined in the <var>method-table-name</var> method
  4165. table to its arguments. The convention for naming variables that will
  4166. be bound to method tables is to add an ampersand to the front of the
  4167. name. <var>Prototype</var> is a suggestion for what method prototypes
  4168. should follow the shape of, but it is currently ignored.
  4169. </p></dd></dl>
  4170. <dl>
  4171. <dt id="index-define_002dmethod">syntax: <strong>define-method</strong> <em>method-table prototype body</em></dt>
  4172. <dd><p>Adds a <em>method</em> to <var>method-table</var>, which is usually one defined
  4173. by <code>define-generic</code>.<a id="DOCF18" href="#FOOT18"><sup>18</sup></a> <var>Prototype</var> should be a list whose elements
  4174. may be either identifiers, in which case that parameter is not used for
  4175. dispatching, or lists of two elements, the <code>car</code> of which is the
  4176. parameter name and the <code>cadr</code> of which should evaluate to the type
  4177. on which to dispatch. As in many generic dispatch systems of similar
  4178. designs, methods may invoke the next-most-specific method. By default,
  4179. the name <code>next-method</code> is bound in <var>body</var> to a nullary
  4180. procedure that calls the next-most-specific method. The name of this
  4181. procedure may be specified by the user by putting the sequence
  4182. <code>&quot;next&quot; <var>next-method-name</var></code> in <var>prototype</var>, in which case
  4183. it will be <var>next-method-name</var> that is bound to that procedure. For
  4184. example:
  4185. </p>
  4186. <div class="lisp">
  4187. <pre class="lisp">(define-method &amp;frob ((foo :bar) &quot;next&quot; frobozz)
  4188. (if (mumble? foo)
  4189. (frobozz) ; Invoke the next method.
  4190. (yargh blargle foo)))</pre></div>
  4191. </dd></dl>
  4192. <p>A number of simple types are already defined &amp; exported by the
  4193. <code>methods</code> structure. Entries are listed as <code><var>type-name</var>
  4194. &lt;- (<var>supertype</var> &hellip;), <var>predicate</var></code>
  4195. </p>
  4196. <ul>
  4197. <li> <code>:values &lt;- (), (lambda (x) #t)</code> &mdash; Abstract supertype of
  4198. all run-time values
  4199. </li><li> <code>:value &lt;- (:values), (lambda (x) #t)</code> &mdash; Abstract
  4200. supertype of all first-class values
  4201. </li><li> <code>:zero &lt;- (:values), (lambda (x) #f)</code> &mdash; Type that no
  4202. objects satisfy
  4203. </li><li> <code>:number &lt;- (:value), number?</code>
  4204. </li><li> <code>:complex &lt;- (:number), complex?</code> &mdash; (This happens to be
  4205. equivalent to <code>:number</code>.)
  4206. </li><li> <code>:real &lt;- (:complex), real?</code>
  4207. </li><li> <code>:rational &lt;- (:real), rational?</code>
  4208. </li><li> <code>:integer &lt;- (:rational), integer?</code>
  4209. </li><li> <code>:exact-integer &lt;- (:integer),
  4210. (lambda (x) (and (integer? x) (exact? x)))</code>
  4211. </li><li> <code>:boolean &lt;- (:value), boolean?</code>
  4212. </li><li> <code>:symbol &lt;- (:value), symbol?</code>
  4213. </li><li> <code>:char &lt;- (:value), char?</code>
  4214. </li><li> <code>:null &lt;- (:value), null?</code>
  4215. </li><li> <code>:pair &lt;- (:value), pair?</code>
  4216. </li><li> <code>:vector &lt;- (:value), vector?</code>
  4217. </li><li> <code>:string &lt;- (:value), string?</code>
  4218. </li><li> <code>:procedure &lt;- (:value), procedure?</code>
  4219. </li><li> <code>:input-port &lt;- (:value), input-port?</code>
  4220. </li><li> <code>:output-port &lt;- (:value), output-port?</code>
  4221. </li><li> <code>:eof-object &lt;- (:value), eof-object?</code>
  4222. </li><li> <code>:record &lt;- (:value), record?</code>
  4223. </li></ul>
  4224. <hr>
  4225. <span id="I_002fO-system"></span><div class="header">
  4226. <p>
  4227. Next: <a href="#Reader-_0026-writer" accesskey="n" rel="next">Reader &amp; writer</a>, Previous: <a href="#Generic-dispatch-system" accesskey="p" rel="prev">Generic dispatch system</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4228. </div>
  4229. <span id="I_002fO-system-1"></span><h3 class="section">4.5 I/O system</h3>
  4230. <p>Scheme48 supports a sophisticated, non-blocking, user-extensible I/O
  4231. system untied to any particular operating system&rsquo;s I/O facilities. It
  4232. is based in three levels: channels, ports, and the facilities already
  4233. built with both ports and channels in Scheme48, such as buffering.
  4234. </p>
  4235. <table class="menu" border="0" cellspacing="0">
  4236. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  4237. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Ports" accesskey="1">Ports</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Abstract &amp; generalized I/O objects.
  4238. </td></tr>
  4239. <tr><td align="left" valign="top">&bull; <a href="#Programmatic-ports" accesskey="2">Programmatic ports</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Designing custom ports.
  4240. </td></tr>
  4241. <tr><td align="left" valign="top">&bull; <a href="#Miscellaneous-I_002fO-internals" accesskey="3">Miscellaneous I/O internals</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Various internal I/O system routines.
  4242. </td></tr>
  4243. <tr><td align="left" valign="top">&bull; <a href="#Channels" accesskey="4">Channels</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Low-level interface to OS facilities.
  4244. </td></tr>
  4245. <tr><td align="left" valign="top">&bull; <a href="#Channel-ports" accesskey="5">Channel ports</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Ports built upon channels.
  4246. </td></tr>
  4247. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  4248. </pre></th></tr></table>
  4249. <hr>
  4250. <span id="Ports"></span><div class="header">
  4251. <p>
  4252. Next: <a href="#Programmatic-ports" accesskey="n" rel="next">Programmatic ports</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4253. </div>
  4254. <span id="Ports-1"></span><h4 class="subsection">4.5.1 Ports</h4>
  4255. <p>While channels provide the low-level interface directly to the OS&rsquo;s I/O
  4256. facilities, <em>ports</em> provide a more abstract &amp; generalized mechanism
  4257. for I/O transmission. Rather than being specific to channels or being
  4258. themselves primitive I/O devices, ports are functionally parameterized.
  4259. This section describes the usual I/O operations on ports. The next
  4260. section describes the programmatic port parameterization mechanism, and
  4261. the section following that describes the most commonly used built-in
  4262. port abstraction, ports atop channels.
  4263. </p>
  4264. <span id="Port-operations"></span><h4 class="subsubsection">4.5.1.1 Port operations</h4>
  4265. <span id="index-i_002fo"></span>
  4266. <p>The following names are exported by the <code>i/o</code> structure.
  4267. </p>
  4268. <dl>
  4269. <dt id="index-input_002dport_003f">procedure: <strong>input-port?</strong> <em>value --&gt; boolean</em></dt>
  4270. <dt id="index-output_002dport_003f">procedure: <strong>output-port?</strong> <em>value --&gt; boolean</em></dt>
  4271. <dd><p>These return <code>#t</code> if their argument is both a port and either an
  4272. input port or output port, respectively, or <code>#f</code> if neither
  4273. condition is true.
  4274. </p></dd></dl>
  4275. <dl>
  4276. <dt id="index-close_002dinput_002dport">procedure: <strong>close-input-port</strong> <em>port --&gt; unspecified</em></dt>
  4277. <dt id="index-close_002doutput_002dport">procedure: <strong>close-output-port</strong> <em>port --&gt; unspecified</em></dt>
  4278. <dd><p>Closes <var>port</var>, which must be an input port or an output port,
  4279. respectively.
  4280. </p></dd></dl>
  4281. <dl>
  4282. <dt id="index-char_002dready_003f">procedure: <strong>char-ready?</strong> <em>[port] --&gt; boolean</em></dt>
  4283. <dt id="index-output_002dport_002dready_003f">procedure: <strong>output-port-ready?</strong> <em>port --&gt; boolean</em></dt>
  4284. <dd><p><code>Char-ready?</code> returns a true value if there is a character ready
  4285. to be read from <var>port</var> and <code>#f</code> if there is no character
  4286. ready. <var>Port</var> defaults to the current input port if absent; see
  4287. below on current ports. <code>Output-port-ready?</code> returns a true value
  4288. if <var>port</var> is ready to receive a single written character and
  4289. <code>#f</code> if not.
  4290. </p></dd></dl>
  4291. <span id="index-block-input-and-output"></span>
  4292. <span id="index-input-and-output-of-blocks"></span>
  4293. <dl>
  4294. <dt id="index-read_002dblock">procedure: <strong>read-block</strong> <em>block start count port [wait?] --&gt; count-read or EOF</em></dt>
  4295. <dt id="index-write_002dblock">procedure: <strong>write-block</strong> <em>block start count port --&gt; count-written</em></dt>
  4296. <dt id="index-write_002dstring">procedure: <strong>write-string</strong> <em>string port --&gt; char-count-written</em></dt>
  4297. <dd><p><code>Read-block</code> attempts to read <var>count</var> elements from <var>port</var>
  4298. into <var>block</var>, which may be a string or a byte vector, starting at
  4299. <var>start</var>. If fewer than <var>count</var> characters or bytes are
  4300. available to read from <var>port</var>, and <var>wait?</var> is a true value or
  4301. absent, <code>read-block</code> will wait until <var>count</var> characters are
  4302. available and read into <var>block</var>; if <var>wait?</var> is <code>#f</code>,
  4303. <code>read-block</code> immediately returns. <code>Read-block</code> returns the
  4304. number of elements read into <var>block</var>, or an end of file object if
  4305. the stream&rsquo;s end is immediately encountered. <code>Write-block</code> writes
  4306. <var>count</var> elements from <var>block</var>, which may be a string or a byte
  4307. vector, starting at <var>start</var> to <var>port</var>. <code>Write-string</code> is
  4308. a convenience atop <code>write-block</code> for writing the entirety of a
  4309. string to a port.
  4310. </p></dd></dl>
  4311. <dl>
  4312. <dt id="index-newline">procedure: <strong>newline</strong> <em>[port] --&gt; unspecified</em></dt>
  4313. <dd><p>Writes a newline character or character sequence to the output port
  4314. <var>port</var>. <var>Port</var> defaults to the current output port; see below
  4315. on current ports.
  4316. </p></dd></dl>
  4317. <dl>
  4318. <dt id="index-disclose_002dport">procedure: <strong>disclose-port</strong> <em>port --&gt; disclosed</em></dt>
  4319. <dd><p>Returns a disclosed representation of <var>port</var>; see <a href="#Writer">Writer</a>.
  4320. </p></dd></dl>
  4321. <span id="index-forcing-buffered-output-1"></span>
  4322. <span id="index-output-port-buffer-forcing-1"></span>
  4323. <span id="index-buffered-output-forcing-1"></span>
  4324. <span id="index-flushing-output-buffers-1"></span>
  4325. <dl>
  4326. <dt id="index-force_002doutput-1">procedure: <strong>force-output</strong> <em>port --&gt; unspecified</em></dt>
  4327. <dd><p>Forces all buffered output in the output port <var>port</var> to be sent.
  4328. </p></dd></dl>
  4329. <dl>
  4330. <dt id="index-make_002dnull_002doutput_002dport">procedure: <strong>make-null-output-port</strong> <em>--&gt; output-port</em></dt>
  4331. <dd><p>Returns an output port that will ignore any output it receives.
  4332. </p></dd></dl>
  4333. <span id="Current-ports"></span><h4 class="subsubsection">4.5.1.2 Current ports</h4>
  4334. <p>Scheme48 keeps in its <a href="#Fluid_002fdynamic-bindings">dynamic
  4335. environment</a> a set of &lsquo;current&rsquo; ports. These include R5RS&rsquo;s current
  4336. input and output ports, as well as ports for general noise produced by
  4337. the system, and ports for where error messages are printed. These
  4338. procedures are exported by the <code>i/o</code> structure.
  4339. </p>
  4340. <dl>
  4341. <dt id="index-current_002dinput_002dport">procedure: <strong>current-input-port</strong> <em>--&gt; input-port</em></dt>
  4342. <dt id="index-current_002doutput_002dport">procedure: <strong>current-output-port</strong> <em>--&gt; output-port</em></dt>
  4343. <dt id="index-current_002dnoise_002dport-1">procedure: <strong>current-noise-port</strong> <em>--&gt; output-port</em></dt>
  4344. <dt id="index-current_002derror_002dport">procedure: <strong>current-error-port</strong> <em>--&gt; output-port</em></dt>
  4345. <dd><p>These return the values in the current dynamic environment of the
  4346. respective ports. <code>Current-input-port</code> and
  4347. <code>current-output-port</code> are also exported by the <code>scheme</code>
  4348. structure.
  4349. </p></dd></dl>
  4350. <dl>
  4351. <dt id="index-input_002dport_002doption">procedure: <strong>input-port-option</strong> <em>arguments --&gt; input-port</em></dt>
  4352. <dt id="index-output_002dport_002doption">procedure: <strong>output-port-option</strong> <em>arguments --&gt; output-port</em></dt>
  4353. <dd><p>These are utilities for retrieving optional input and output port
  4354. arguments from rest argument lists, defaulting to the current input or
  4355. output ports. For example, assuming the newline character sequence is
  4356. simply <code>#\newline</code>, <code>newline</code> might be written as:
  4357. </p>
  4358. <div class="lisp">
  4359. <pre class="lisp">(define (newline . maybe-port)
  4360. (write-char #\newline (output-port-option maybe-port)))</pre></div>
  4361. </dd></dl>
  4362. <span id="index-noise-output-1"></span>
  4363. <dl>
  4364. <dt id="index-silently">procedure: <strong>silently</strong> <em>thunk --&gt; values</em></dt>
  4365. <dd><p>This stifles output from the current noise port in the dynamic extent
  4366. of <var>thunk</var>, which is applied to zero arguments. <code>Silently</code>
  4367. returns the values that <var>thunk</var> returns.
  4368. </p></dd></dl>
  4369. <dl>
  4370. <dt id="index-with_002dcurrent_002dports">procedure: <strong>with-current-ports</strong> <em>input output error thunk --&gt; values</em></dt>
  4371. <dd><p><code>With-current-ports</code> dynamically binds the current input, output,
  4372. and error ports to <var>input</var>, <var>output</var>, and <var>error</var>,
  4373. respectively, in the dynamic extent of <var>thunk</var>, which is applied
  4374. to zero arguments. The current noise port is also bound to
  4375. <var>error</var>. <code>With-current-ports</code> returns the values that
  4376. <var>thunk</var> returns.
  4377. </p></dd></dl>
  4378. <span id="index-i_002fo_002dinternal"></span>
  4379. <p>Similarly to <code>with-current-ports</code>, the <code>i/o-internal</code>
  4380. structure also exports these procedures:
  4381. </p>
  4382. <dl>
  4383. <dt id="index-call_002dwith_002dcurrent_002dinput_002dport">procedure: <strong>call-with-current-input-port</strong> <em>port thunk --&gt; values</em></dt>
  4384. <dt id="index-call_002dwith_002dcurrent_002doutput_002dport">procedure: <strong>call-with-current-output-port</strong> <em>port thunk --&gt; values</em></dt>
  4385. <dt id="index-call_002dwith_002dcurrent_002dnoise_002dport">procedure: <strong>call-with-current-noise-port</strong> <em>port thunk --&gt; values</em></dt>
  4386. <dd><p>These bind individual current ports for the dynamic extent of each
  4387. <var>thunk</var>, which is applied to zero arguments. These all return the
  4388. values that <var>thunk</var> returns.
  4389. </p></dd></dl>
  4390. <hr>
  4391. <span id="Programmatic-ports"></span><div class="header">
  4392. <p>
  4393. Next: <a href="#Miscellaneous-I_002fO-internals" accesskey="n" rel="next">Miscellaneous I/O internals</a>, Previous: <a href="#Ports" accesskey="p" rel="prev">Ports</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4394. </div>
  4395. <span id="Programmatic-ports-1"></span><h4 class="subsection">4.5.2 Programmatic ports</h4>
  4396. <p>Ports are user-extensible; all primitive port operations on them &mdash;
  4397. <code>read-char</code>, <code>write-block</code>, <i>&amp;c.</i> &mdash; are completely
  4398. generalized. Abstractions for buffered ports are also available.
  4399. </p>
  4400. <table class="menu" border="0" cellspacing="0">
  4401. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  4402. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Port-data-type" accesskey="1">Port data type</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  4403. </td></tr>
  4404. <tr><td align="left" valign="top">&bull; <a href="#Port-handlers" accesskey="2">Port handlers</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  4405. </td></tr>
  4406. <tr><td align="left" valign="top">&bull; <a href="#Buffered-ports-_0026-handlers" accesskey="3">Buffered ports &amp; handlers</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  4407. </td></tr>
  4408. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  4409. </pre></th></tr></table>
  4410. <hr>
  4411. <span id="Port-data-type"></span><div class="header">
  4412. <p>
  4413. Next: <a href="#Port-handlers" accesskey="n" rel="next">Port handlers</a>, Up: <a href="#Programmatic-ports" accesskey="u" rel="up">Programmatic ports</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4414. </div>
  4415. <span id="Port-data-type-1"></span><h4 class="subsubsection">4.5.2.1 Port data type</h4>
  4416. <span id="index-ports"></span>
  4417. <p>The <code>ports</code> structure defines the basis of the port data type and
  4418. exports the following procedures.
  4419. </p>
  4420. <dl>
  4421. <dt id="index-make_002dport">procedure: <strong>make-port</strong> <em>handler status lock data buffer index limit pending-eof? --&gt; port</em></dt>
  4422. <dd><p>Port constructor. The arguments are all the fields of ports, which are
  4423. described below. Note that <code>make-port</code> is rarely called directly;
  4424. usually one will use one of the buffered port constructors instead.
  4425. </p></dd></dl>
  4426. <dl>
  4427. <dt id="index-port_002dhandler">procedure: <strong>port-handler</strong> <em>port --&gt; port-handler</em></dt>
  4428. <dt id="index-port_002dbuffer">procedure: <strong>port-buffer</strong> <em>port --&gt; buffer or <code>#f</code></em></dt>
  4429. <dt id="index-port_002dlock">procedure: <strong>port-lock</strong> <em>port --&gt; value</em></dt>
  4430. <dt id="index-port_002dstatus">procedure: <strong>port-status</strong> <em>port --&gt; integer-status</em></dt>
  4431. <dt id="index-port_002ddata">procedure: <strong>port-data</strong> <em>port --&gt; value</em></dt>
  4432. <dt id="index-port_002dindex">procedure: <strong>port-index</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  4433. <dt id="index-port_002dlimit">procedure: <strong>port-limit</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  4434. <dt id="index-port_002dpending_002deof_003f">procedure: <strong>port-pending-eof?</strong> <em>port --&gt; boolean</em></dt>
  4435. <dd><p>Accessors for the port fields:
  4436. </p>
  4437. <dl compact="compact">
  4438. <dt><code>handler</code></dt>
  4439. <dd><p>The handler is the functional parameterization mechanism: it provides
  4440. all the port&rsquo;s operations, such as reading/writing blocks, disclosing
  4441. (see <a href="#Writer">Writer</a>) the port, closing the port, <i>&amp;c</i>.
  4442. See <a href="#Port-handlers">Port handlers</a>.
  4443. </p>
  4444. </dd>
  4445. <dt><code>buffer</code></dt>
  4446. <dd><p>The buffer is used for buffered ports, where it is a <a href="#Bitwise-manipulation">byte vector</a>. It may be any value for unbuffered ports.
  4447. </p>
  4448. </dd>
  4449. <dt><code>lock</code></dt>
  4450. <dd><p>This misnamed field was originally used for a mutual exclusion lock,
  4451. before optimistic concurrency was made the native synchronization
  4452. mechanism in Scheme48. It is now used as a &lsquo;timestamp&rsquo; for buffered
  4453. ports: it is provisionally written to with a unique value when a thread
  4454. resets the <code>index</code> to re&uuml;se the buffer, and it is provisionally
  4455. read from when reading from the buffer. In this way, if the buffer is
  4456. reset while another thread is reading from it, the other thread&rsquo;s
  4457. proposal is invalidated by the different value in memory than what was
  4458. there when it logged the old timestamp in its proposal.
  4459. </p>
  4460. </dd>
  4461. <dt><code>status</code></dt>
  4462. <dd><p>A mask from the <code>port-status-options</code> enumeration;
  4463. see <a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a>.
  4464. </p>
  4465. </dd>
  4466. <dt><code>data</code></dt>
  4467. <dd><p>Arbitrary data for particular kinds of ports. For example, for a port
  4468. that tracks line &amp; column information (see <a href="#I_002fO-extensions">I/O extensions</a>), this
  4469. might be a record containing the underlying port, the line number, and
  4470. the column number.
  4471. </p>
  4472. </dd>
  4473. <dt><code>index</code></dt>
  4474. <dd><p>The current index into a buffered port&rsquo;s buffer. If the port is not
  4475. buffered, this is <code>#f</code>.
  4476. </p>
  4477. </dd>
  4478. <dt><code>limit</code></dt>
  4479. <dd><p>The limit of the <code>index</code> field for a buffered port&rsquo;s buffer. When
  4480. the <code>index</code> field is equal to the <code>limit</code> field, the buffer
  4481. is full. If the port is not buffered, this is <code>#f</code>.
  4482. </p>
  4483. </dd>
  4484. <dt><code>pending-eof?</code></dt>
  4485. <dd><p>For output ports, this is a boolean flag indicating whether the buffer
  4486. has been forced to output recently. For input ports, this is a boolean
  4487. flag indicating whether an end of file is pending after reading through
  4488. the current buffer.
  4489. </p></dd>
  4490. </dl>
  4491. </dd></dl>
  4492. <dl>
  4493. <dt id="index-set_002dport_002dlock_0021">procedure: <strong>set-port-lock!</strong> <em>port value --&gt; unspecified</em></dt>
  4494. <dt id="index-set_002dport_002dstatus_0021">procedure: <strong>set-port-status!</strong> <em>port status --&gt; unspecified</em></dt>
  4495. <dt id="index-set_002dport_002ddata_0021">procedure: <strong>set-port-data!</strong> <em>port data --&gt; unspecified</em></dt>
  4496. <dt id="index-set_002dport_002dindex_0021">procedure: <strong>set-port-index!</strong> <em>port index --&gt; unspecified</em></dt>
  4497. <dt id="index-set_002dport_002dlimit_0021">procedure: <strong>set-port-limit!</strong> <em>port index --&gt; unspecified</em></dt>
  4498. <dt id="index-set_002dport_002dpending_002deof_003f_0021">procedure: <strong>set-port-pending-eof?!</strong> <em>port pending-eof? --&gt; unspecified</em></dt>
  4499. <dd><p>These assign respective fields of ports. The <code>buffer</code> and
  4500. <code>handler</code> fields, however, are immutable.
  4501. </p></dd></dl>
  4502. <span id="index-logging-operations"></span>
  4503. <span id="index-optimistic-concurrency-logging-operations"></span>
  4504. <dl>
  4505. <dt id="index-provisional_002dport_002dhandler">procedure: <strong>provisional-port-handler</strong> <em>port --&gt; port-handler</em></dt>
  4506. <dt id="index-provisional_002dport_002dlock">procedure: <strong>provisional-port-lock</strong> <em>port --&gt; value</em></dt>
  4507. <dt id="index-provisional_002dport_002dstatus">procedure: <strong>provisional-port-status</strong> <em>port --&gt; integer-status</em></dt>
  4508. <dt id="index-provisional_002dport_002ddata">procedure: <strong>provisional-port-data</strong> <em>port --&gt; value</em></dt>
  4509. <dt id="index-provisional_002dport_002dindex">procedure: <strong>provisional-port-index</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  4510. <dt id="index-provisional_002dport_002dlimit">procedure: <strong>provisional-port-limit</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  4511. <dt id="index-provisional_002dport_002dpending_002deof_003f">procedure: <strong>provisional-port-pending-eof?</strong> <em>port --&gt; boolean</em></dt>
  4512. <dt id="index-provisional_002dset_002dport_002dlock_0021">procedure: <strong>provisional-set-port-lock!</strong> <em>port value --&gt; unspecified</em></dt>
  4513. <dt id="index-provisional_002dset_002dport_002dstatus_0021">procedure: <strong>provisional-set-port-status!</strong> <em>port status --&gt; unspecified</em></dt>
  4514. <dt id="index-provisional_002dset_002dport_002ddata_0021">procedure: <strong>provisional-set-port-data!</strong> <em>port data --&gt; unspecified</em></dt>
  4515. <dt id="index-provisional_002dset_002dport_002dindex_0021">procedure: <strong>provisional-set-port-index!</strong> <em>port index --&gt; unspecified</em></dt>
  4516. <dt id="index-provisional_002dset_002dport_002dlimit_0021">procedure: <strong>provisional-set-port-limit!</strong> <em>port index --&gt; unspecified</em></dt>
  4517. <dt id="index-provisional_002dset_002dport_002dpending_002deof_003f_0021">procedure: <strong>provisional-set-port-pending-eof?!</strong> <em>port pending-eof? --&gt; unspecified</em></dt>
  4518. <dd><p>Provisional versions of the above port accessors &amp; modifiers; that is,
  4519. accessors &amp; modifiers that log in the current proposal, if there is
  4520. one.
  4521. </p></dd></dl>
  4522. <hr>
  4523. <span id="Port-handlers"></span><div class="header">
  4524. <p>
  4525. Next: <a href="#Buffered-ports-_0026-handlers" accesskey="n" rel="next">Buffered ports &amp; handlers</a>, Previous: <a href="#Port-data-type" accesskey="p" rel="prev">Port data type</a>, Up: <a href="#Programmatic-ports" accesskey="u" rel="up">Programmatic ports</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4526. </div>
  4527. <span id="Port-handlers-1"></span><h4 class="subsubsection">4.5.2.2 Port handlers</h4>
  4528. <span id="index-i_002fo_002dinternal-1"></span>
  4529. <p><em>Port handlers</em> store a port&rsquo;s specific operations for the general
  4530. port operations, such as block reads and writes, buffer flushing,
  4531. <i>&amp;c</i>. Port handler constructors, including <code>make-port-handler</code>
  4532. &amp; the buffered port handlers in the next section, are available from
  4533. the <code>i/o-internal</code> structure.
  4534. </p>
  4535. <dl>
  4536. <dt id="index-make_002dport_002dhandler">procedure: <strong>make-port-handler</strong> <em>discloser closer char-reader/writer block-reader/writer readiness-tester buffer-forcer --&gt; port-handler</em></dt>
  4537. <dd><p>Basic port handler constructor. The arguments are used for the port
  4538. handler fields. Each field contains a procedure. The expected
  4539. semantics of each procedure depend on whether the port is for input or
  4540. output. Input ports do not use the <code>buffer-forcer</code> field. The
  4541. first two fields are independent of the type of port:
  4542. </p>
  4543. <dl compact="compact">
  4544. <dt><strong>discloser</strong> <em>port &ndash;&gt; disclosed</em></dt>
  4545. <dd><p>Returns a disclosed representation of the port, <i>i.e.</i> a list whose
  4546. <code>car</code> is the &lsquo;type name&rsquo; of this handler (usually with a suffix of
  4547. either <code>-input-port</code> or <code>-output-port</code>) followed by a list of
  4548. all of the components to be printed; see <a href="#Writer">Writer</a>.
  4549. </p>
  4550. </dd>
  4551. <dt><strong>closer</strong> <em>port &ndash;&gt; ignored</em></dt>
  4552. <dd><p>Closes <var>port</var>. This operation corresponds with the
  4553. <code>close-input-port</code> &amp; <code>close-output-port</code> procedures.
  4554. </p></dd>
  4555. </dl>
  4556. <p>For input ports, the remaining fields are:
  4557. </p>
  4558. <dl compact="compact">
  4559. <dt><strong>char-reader</strong> <em>port consume? &ndash;&gt; char</em></dt>
  4560. <dd><p>Reads a single character from <var>port</var>. If <var>consume?</var> is true,
  4561. the character should be consumed from <var>port</var>; if <var>consume?</var> is
  4562. <code>#f</code>, however, the character should be left in <var>port</var>&rsquo;s input
  4563. stream. If <var>consume?</var> is true, this operation corresponds with
  4564. <code>read-char</code>; if it is <code>#f</code>, this operation corresponds with
  4565. <code>peek-char</code>.
  4566. </p>
  4567. </dd>
  4568. <dt><strong>block-reader</strong> <em>port block start count wait? &ndash;&gt; count-written or EOF</em></dt>
  4569. <dd><p>Attempts to read <var>count</var> characters from <var>port</var>&rsquo;s input stream
  4570. into the string or byte vector <var>block</var>, starting at <var>start</var>.
  4571. In the case that an insufficient number of characters is available, if
  4572. <var>wait?</var> is true, the procedure should wait until all of the wanted
  4573. characters are available; otherwise, if <var>wait?</var> is <code>#f</code>, the
  4574. block reader should immediately return. In either case, it returns the
  4575. number of characters that were read into <var>block</var>, or an end of file
  4576. object if it immediately reached the end of the stream. Buffered ports
  4577. will typically just copy elements from the buffer into <var>block</var>,
  4578. rather than reading from any internal I/O channel in <var>port</var>. This
  4579. operation corresponds with <code>read-block</code>.
  4580. </p>
  4581. </dd>
  4582. <dt><strong>readiness-tester</strong> <em>port &ndash;&gt; boolean</em></dt>
  4583. <dd><p>Returns a true value if there is a character available to be read in
  4584. <var>port</var> or <code>#f</code> if not. This operation corresponds with the
  4585. <code>char-ready?</code> procedure.
  4586. </p></dd>
  4587. </dl>
  4588. <p>For output ports, the remaining fields are:
  4589. </p>
  4590. <dl compact="compact">
  4591. <dt><strong>char-writer</strong> <em>port char &ndash;&gt; ignored</em></dt>
  4592. <dd><p>Writes the single character <var>char</var> to <var>port</var>. This operation
  4593. corresponds with <code>write-char</code>.
  4594. </p>
  4595. </dd>
  4596. <dt><strong>block-writer</strong> <em>port block start count &ndash;&gt; count-written</em></dt>
  4597. <dd><p>Writes <var>count</var> characters to <var>port</var> from <var>block</var>, starting
  4598. at <var>start</var>. <var>Block</var> may be a string or a byte vector. This
  4599. will usually involve copying contents of <var>block</var> to <var>port</var>&rsquo;s
  4600. buffer, if it is buffered. This operation corresponds with
  4601. <code>write-block</code>.
  4602. </p>
  4603. </dd>
  4604. <dt><strong>readiness-tester</strong> <em>port &ndash;&gt; boolean</em></dt>
  4605. <dd><p>Returns a true value if <var>port</var> is ready to receive a character and
  4606. <code>#f</code> if not.
  4607. </p>
  4608. </dd>
  4609. <dt><strong>buffer-forcer</strong> <em>port necessary? &ndash;&gt; ignored</em></dt>
  4610. <dd><p>For buffered ports, this is intended to force all buffered output to
  4611. the actual internal I/O channel of <var>port</var>. <var>Necessary?</var> tells
  4612. whether or not it is absolutely necessary to force all the output
  4613. immediately; if it is <code>#t</code>, the buffer forcer is required to force
  4614. all output in the buffer before it returns. If <var>necessary?</var> is
  4615. <code>#f</code>, not only may it just register an I/O transaction without
  4616. waiting for it to complete, but it also should <em>not</em> signal an
  4617. error if <var>port</var> is already closed. For unbuffered ports, this
  4618. operation need not do anything at all.
  4619. </p></dd>
  4620. </dl>
  4621. </dd></dl>
  4622. <hr>
  4623. <span id="Buffered-ports-_0026-handlers"></span><div class="header">
  4624. <p>
  4625. Previous: <a href="#Port-handlers" accesskey="p" rel="prev">Port handlers</a>, Up: <a href="#Programmatic-ports" accesskey="u" rel="up">Programmatic ports</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4626. </div>
  4627. <span id="Buffered-ports-_0026-handlers-1"></span><h4 class="subsubsection">4.5.2.3 Buffered ports &amp; handlers</h4>
  4628. <span id="index-buffered-input-and-output"></span>
  4629. <span id="index-i_002fo_002dinternal-2"></span>
  4630. <p>Along with bare port handlers, Scheme48 provides conveniences for many
  4631. patterns of buffered ports &amp; port handlers. These names are exported
  4632. by the <code>i/o-internal</code> structure. Buffered ports are integrated
  4633. with Scheme48&rsquo;s <a href="#Optimistic-concurrency">optimistic
  4634. concurrency</a> facilities.
  4635. </p>
  4636. <p><strong>Note:</strong> Although internally buffered ports are integrated with
  4637. optimistic concurrency, operations on buffered ports, like operations
  4638. on channels, cannot be reliably fusibly atomic.
  4639. </p>
  4640. <dl>
  4641. <dt id="index-make_002dbuffered_002dinput_002dport">procedure: <strong>make-buffered-input-port</strong> <em>handler data buffer index limit --&gt; input-port</em></dt>
  4642. <dt id="index-make_002dbuffered_002doutput_002dport">procedure: <strong>make-buffered-output-port</strong> <em>handler data buffer index limit --&gt; output-port</em></dt>
  4643. <dd><p>Constructors for buffered ports. <var>Handler</var> is the port&rsquo;s handler,
  4644. which is usually constructed with one of the buffered port handler
  4645. constructors (see below). <var>Data</var> is arbitrary data to go in the
  4646. port&rsquo;s <code>data</code> field. <var>Buffer</var> is a byte vector whose length
  4647. is greater than or equal to both <var>index</var> &amp; <var>limit</var>.
  4648. <var>Index</var> is the initial index into <var>buffer</var> to go in the port&rsquo;s
  4649. <code>index</code> field. <var>Limit</var> is the limit in the port&rsquo;s buffer, to
  4650. go into the port&rsquo;s <code>limit</code> field; nothing will be written into
  4651. <var>buffer</var> at or past <var>limit</var>.
  4652. </p></dd></dl>
  4653. <dl>
  4654. <dt id="index-make_002dunbuffered_002dinput_002dport">procedure: <strong>make-unbuffered-input-port</strong> <em>handler data --&gt; input-port</em></dt>
  4655. <dt id="index-make_002dunbuffered_002doutput_002dport">procedure: <strong>make-unbuffered-output-port</strong> <em>handler data --&gt; output-port</em></dt>
  4656. <dd><p>Conveniences for ports that are explicitly <em>not</em> buffered. Only
  4657. the relevant fields are passed; all fields pertaining to buffering are
  4658. initialized with <code>#f</code>.
  4659. </p></dd></dl>
  4660. <dl>
  4661. <dt id="index-make_002dbuffered_002dinput_002dport_002dhandler">procedure: <strong>make-buffered-input-port-handler</strong> <em>discloser closer buffer-filler readiness-tester --&gt; port-handler</em></dt>
  4662. <dd><p>This creates a port handler for buffered input ports. The arguments
  4663. are as follows:
  4664. </p>
  4665. <dl compact="compact">
  4666. <dt><strong>discloser</strong> <em>port-data &ndash;&gt; disclosed</em></dt>
  4667. <dt><strong>closer</strong> <em>port-data &ndash;&gt; ignored</em></dt>
  4668. <dd><p><var>Discloser</var> &amp; <var>closer</var> are like the similarly named regular
  4669. port handler fields, but they are applied directly to the port&rsquo;s data,
  4670. not to the port itself.
  4671. </p>
  4672. </dd>
  4673. <dt><strong>buffer-filler</strong> <em>port wait? &ndash;&gt; committed?</em></dt>
  4674. <dd><p>Used to fill <var>port</var>&rsquo;s buffer when it no longer has contents from
  4675. which to read in its current buffer. <var>Wait?</var> is a boolean flag,
  4676. <code>#t</code> if the operation should wait until the I/O transaction
  4677. necessary to fill the buffer completes, or <code>#f</code> if it may simply
  4678. initiate an I/O transaction but not wait until it completes (<i>e.g.</i>, use
  4679. <code>channel-maybe-commit-and-read</code>, but not wait on the condition
  4680. variable passed to <code>channel-maybe-commit-and-read</code>).
  4681. <var>Buffer-filler</var> is called with a fresh proposal in place, and it is
  4682. the responsibility of <var>buffer-filler</var> to commit it. It returns a
  4683. boolean flag denoting whether the proposal was committed. The last call
  4684. in <var>buffer-filler</var> is usually either <code>(maybe-commit)</code> or a
  4685. call to a procedure that causes that effect (<i>e.g.</i>, one of the
  4686. operation on condition variables that commits the current proposal.
  4687. See <a href="#Higher_002dlevel-synchronization">condition variables</a>.)
  4688. </p>
  4689. </dd>
  4690. <dt><strong>readiness-tester</strong> <em>port &ndash;&gt; [committed? ready?]</em></dt>
  4691. <dd><p>Called when <code>char-ready?</code> is applied to <var>port</var> and the buffer
  4692. of <var>port</var> is empty. Like <var>buffer-filler</var>,
  4693. <var>readiness-tester</var> is applied with a fresh proposal in place, which
  4694. it should attempt to commit. <var>Readiness-tester</var> should return two
  4695. values, each a boolean flag: the first denotes whether or not the
  4696. current proposal was successfully committed, and, if it was successful,
  4697. whether or not a character is ready.
  4698. </p></dd>
  4699. </dl>
  4700. </dd></dl>
  4701. <dl>
  4702. <dt id="index-make_002dbuffered_002doutput_002dport_002dhandler">procedure: <strong>make-buffered-output-port-handler</strong> <em>discloser buffer-emptier readiness-tester --&gt; port-handler</em></dt>
  4703. <dd><p>This creates a port handler for buffered output ports. <var>Discloser</var>
  4704. &amp; <var>closer</var> are as with buffered input ports. The remaining fields
  4705. are as follows:
  4706. </p>
  4707. <dl compact="compact">
  4708. <dt><strong>buffer-emptier</strong> <em>port necessary? &ndash;&gt; committed?</em></dt>
  4709. <dd><p><var>Buffer-emptier</var> is used when <var>port</var>&rsquo;s buffer is full and needs
  4710. to be emptied. It is called with a fresh proposal in place. It should
  4711. reset <var>port</var>&rsquo;s <code>index</code> field, call <code>note-buffer-reuse!</code>
  4712. to invalidate other threads&rsquo; transactions on the recycled buffer, and
  4713. attempt to commit the new proposal installed. It returns a boolean
  4714. flag indicating whether or not the commit succeeded.
  4715. </p>
  4716. </dd>
  4717. <dt><strong>readiness-tester</strong> <em>port &ndash;&gt; [committed? ready?]</em></dt>
  4718. <dd><p><var>Readiness-tester</var> is applied to <var>port</var> when its buffer is full
  4719. (<i>i.e.</i> its <code>index</code> &amp; <code>limit</code> fields are equal) and
  4720. <code>output-port-ready?</code> is applied to <var>port</var>. After performing
  4721. the test, it should attempt to commit the current proposal and then
  4722. return two values: whether it succeeded in committing the current
  4723. proposal, and, if it was successful, whether or not a character is
  4724. ready to be outputted.
  4725. </p></dd>
  4726. </dl>
  4727. </dd></dl>
  4728. <dl>
  4729. <dt id="index-default_002dbuffer_002dsize">constant: <strong>default-buffer-size</strong> <em>--&gt; integer</em></dt>
  4730. <dd><p>The default size for port buffers. This happens to be 4096 in the
  4731. current version of Scheme48.
  4732. </p></dd></dl>
  4733. <dl>
  4734. <dt id="index-note_002dbuffer_002dreuse_0021">procedure: <strong>note-buffer-reuse!</strong> <em>port --&gt; unspecified</em></dt>
  4735. <dt id="index-check_002dbuffer_002dtimestamp_0021">procedure: <strong>check-buffer-timestamp!</strong> <em>port --&gt; unspecified</em></dt>
  4736. <dd><p>These are used to signal the resetting of a buffer between multiple
  4737. threads. <code>Note-buffer-reuse!</code> is called &mdash; in the case of an
  4738. output port &mdash; when a buffer fills up, is emptied, and flushed; or &mdash;
  4739. in the case of an input port &mdash; when a buffer is emptied and needs to
  4740. be refilled. <code>Note-buffer-reuse!</code> logs in the current proposal a
  4741. fresh value to store in <var>port</var>. When that proposal is committed,
  4742. this fresh value is stored in the port. Other threads that were using
  4743. <var>port</var>&rsquo;s buffer call <code>check-buffer-timestamp!</code>, which logs a
  4744. read in the current proposal. If another thread commits a buffer
  4745. re&uuml;se to memory, that read will be invalidated, invalidating the
  4746. whole transaction.
  4747. </p></dd></dl>
  4748. <hr>
  4749. <span id="Miscellaneous-I_002fO-internals"></span><div class="header">
  4750. <p>
  4751. Next: <a href="#Channels" accesskey="n" rel="next">Channels</a>, Previous: <a href="#Programmatic-ports" accesskey="p" rel="prev">Programmatic ports</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4752. </div>
  4753. <span id="Miscellaneous-I_002fO-internals-1"></span><h4 class="subsection">4.5.3 Miscellaneous I/O internals</h4>
  4754. <span id="index-i_002fo_002dinternal-3"></span>
  4755. <span id="index-architecture"></span>
  4756. <p>All of these but <code>port-status-options</code> are exported by the
  4757. <code>i/o-internal</code> structure; the <code>port-status-options</code>
  4758. enumeration is exported by the <code>architecture</code> structure, but it
  4759. deserves mention in this section.
  4760. </p>
  4761. <dl>
  4762. <dt id="index-port_002dstatus_002doptions">enumeration: <strong>port-status-options</strong></dt>
  4763. <dd><div class="lisp">
  4764. <pre class="lisp">(define-enumeration port-status-options
  4765. (input
  4766. output
  4767. open-for-input
  4768. open-for-output))</pre></div>
  4769. <p>Enumeration of indices into a port&rsquo;s <code>status</code> field bit set.
  4770. </p></dd></dl>
  4771. <dl>
  4772. <dt id="index-open_002dinput_002dport_003f">procedure: <strong>open-input-port?</strong> <em>port --&gt; boolean</em></dt>
  4773. <dt id="index-open_002doutput_002dport_003f">procedure: <strong>open-output-port?</strong> <em>port --&gt; boolean</em></dt>
  4774. <dd><p>These return true values if <var>port</var> is both an input or output port,
  4775. respectively, and open.
  4776. </p></dd></dl>
  4777. <dl>
  4778. <dt id="index-open_002dinput_002dport_002dstatus">constant: <strong>open-input-port-status</strong> <em>--&gt; integer-status</em></dt>
  4779. <dt id="index-open_002doutput_002dport_002dstatus">constant: <strong>open-output-port-status</strong> <em>--&gt; integer-status</em></dt>
  4780. <dd><p>The bitwise masks of enumerands from the <code>port-status-options</code>
  4781. enumeration signifying an open input or output port, respectively.
  4782. </p></dd></dl>
  4783. <dl>
  4784. <dt id="index-make_002dinput_002dport_002dclosed_0021">procedure: <strong>make-input-port-closed!</strong> <em>port --&gt; unspecified</em></dt>
  4785. <dt id="index-make_002doutput_002dport_002dclosed_0021">procedure: <strong>make-output-port-closed!</strong> <em>port --&gt; unspecified</em></dt>
  4786. <dd><p>These set the status of <var>port</var>, which must be an input or output
  4787. port, respectively, to indicate that it is closed.
  4788. </p></dd></dl>
  4789. <dl>
  4790. <dt id="index-eof_002dobject">procedure: <strong>eof-object</strong> <em>--&gt; eof-object</em></dt>
  4791. <dd><p>Returns the EOF object token. This is the only value that will answer
  4792. true to R5RS&rsquo;s <code>eof-object?</code> predicate.
  4793. </p></dd></dl>
  4794. <dl>
  4795. <dt id="index-force_002doutput_002dif_002dopen">procedure: <strong>force-output-if-open</strong> <em>port --&gt; unspecified</em></dt>
  4796. <dd><p>This forces <var>port</var>&rsquo;s output if it is an open output port, and does
  4797. not block.
  4798. </p></dd></dl>
  4799. <dl>
  4800. <dt id="index-periodically_002dforce_002doutput_0021">procedure: <strong>periodically-force-output!</strong> <em>port --&gt; unspecified</em></dt>
  4801. <dt id="index-periodically_002dflushed_002dports">procedure: <strong>periodically-flushed-ports</strong> <em>--&gt; port-list</em></dt>
  4802. <dd><p><code>Periodically-force-output!</code> registers <var>port</var> to be forced
  4803. periodically. Only a weak reference to <var>port</var> in this registry is
  4804. held, however, so this cannot cause accidental space leaks.
  4805. <code>Periodically-flushed-ports</code> returns a list of all ports in this
  4806. registry. Note that the returned list holds strong references to all
  4807. of its elements. <code>Periodically-flushed-ports</code> does not permit
  4808. thread context switches, or interrupts of any sort, while it runs.
  4809. </p></dd></dl>
  4810. <hr>
  4811. <span id="Channels"></span><div class="header">
  4812. <p>
  4813. Next: <a href="#Channel-ports" accesskey="n" rel="next">Channel ports</a>, Previous: <a href="#Miscellaneous-I_002fO-internals" accesskey="p" rel="prev">Miscellaneous I/O internals</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4814. </div>
  4815. <span id="Channels-1"></span><h4 class="subsection">4.5.4 Channels</h4>
  4816. <span id="index-channels"></span>
  4817. <p><em>Channels</em> represent the OS&rsquo;s native I/O transmission channels. On
  4818. Unix, channels are essentially boxed file descriptors, for example.
  4819. The only operations on channels are block reads &amp; writes. Blocks in
  4820. this sense may be either strings or <a href="#Bitwise-manipulation">byte vectors</a>.
  4821. </p>
  4822. <span id="Low_002dlevel-channel-operations"></span><h4 class="subsubsection">4.5.4.1 Low-level channel operations</h4>
  4823. <span id="index-channels-3"></span>
  4824. <p>The low-level base of the interface to channels described here is
  4825. exported from the <code>channels</code> structure.
  4826. </p>
  4827. <dl>
  4828. <dt id="index-channel_003f">procedure: <strong>channel?</strong> <em>--&gt; boolean</em></dt>
  4829. <dd><p>Disjoint type predicate for channels.
  4830. </p></dd></dl>
  4831. <dl>
  4832. <dt id="index-channel_002did">procedure: <strong>channel-id</strong> <em>channel --&gt; value</em></dt>
  4833. <dt id="index-channel_002dstatus">procedure: <strong>channel-status</strong> <em>channel --&gt; integer-enumerand</em></dt>
  4834. <dt id="index-channel_002dos_002dindex">procedure: <strong>channel-os-index</strong> <em>channel --&gt; integer</em></dt>
  4835. <dd><p><code>Channel-id</code> returns <var>channel</var>&rsquo;s id. The id is some
  4836. identifying characteristic of channels. For example, file channels&rsquo;
  4837. ids are usually the corresponding filenames; channels such as the
  4838. standard input, output, or error output channels have names like
  4839. <code>&quot;standard input&quot;</code> and <code>&quot;standard output&quot;</code>.
  4840. <code>Channel-status</code> returns the current status of <var>channel</var>; see
  4841. the <code>channel-status-option</code> enumeration below.
  4842. <code>Channel-os-index</code> returns the OS-specific integer index of
  4843. <var>channel</var>. On Unix, for example, this is the channel&rsquo;s file
  4844. descriptor.
  4845. </p></dd></dl>
  4846. <span id="index-file-channels"></span>
  4847. <dl>
  4848. <dt id="index-open_002dchannel">procedure: <strong>open-channel</strong> <em>filename option close-silently? --&gt; channel</em></dt>
  4849. <dd><p><code>Open-channel</code> opens a channel for a file given its filename.
  4850. <var>Option</var> specifies what type of channel this is; see the
  4851. <code>channel-status-option</code> enumeration below. <var>Close-silently?</var>
  4852. is a boolean that specifies whether a message should be printed (on
  4853. Unix, to <code>stderr</code>) when the resulting channel is closed after a
  4854. garbage collector finds it unreachable.
  4855. </p></dd></dl>
  4856. <span id="index-closing-channels"></span>
  4857. <dl>
  4858. <dt id="index-close_002dchannel">procedure: <strong>close-channel</strong> <em>channel --&gt; unspecified</em></dt>
  4859. <dd><p>Closes <var>channel</var> after aborting any potential pending I/O
  4860. transactions it may have been involved with.
  4861. </p></dd></dl>
  4862. <dl>
  4863. <dt id="index-channel_002dready_003f">procedure: <strong>channel-ready?</strong> <em>channel --&gt; boolean</em></dt>
  4864. <dd><p>If <var>channel</var> is an input channel: returns <code>#t</code> if there is
  4865. input ready to be read from <var>channel</var> or <code>#f</code> if not; if
  4866. <var>channel</var> is an output channel: returns <code>#t</code> if a write would
  4867. immediately take place upon calling <code>channel-maybe-write</code>, <i>i.e.</i>
  4868. <code>channel-maybe-write</code> would not return <code>#f</code>, or <code>#f</code> if
  4869. not.
  4870. </p></dd></dl>
  4871. <dl>
  4872. <dt id="index-channel_002dmaybe_002dread">procedure: <strong>channel-maybe-read</strong> <em>channel buffer start-index octet-count wait? --&gt; octet count read, error status cell, EOF object, or <code>#f</code></em></dt>
  4873. <dt id="index-channel_002dmaybe_002dwrite">procedure: <strong>channel-maybe-write</strong> <em>channel buffer start-index octet-count --&gt; octet count written, error status cell, or <code>#f</code></em></dt>
  4874. <dt id="index-channel_002dabort">procedure: <strong>channel-abort</strong> <em>channel --&gt; unspecified</em></dt>
  4875. <dd><p><code>Channel-maybe-read</code> attempts to read <var>octet-count</var> octets
  4876. from <var>channel</var> into <var>buffer</var>, starting at <var>start-index</var>.
  4877. If a low-level I/O error occurs, it returns a cell containing a token
  4878. given by the operating system indicating what kind of error occurred.
  4879. If <var>wait?</var> is <code>#t</code>, and <var>channel</var> is not ready to be read
  4880. from, <var>channel</var> is registered for the VM&rsquo;s event polling mechanism,
  4881. and <code>channel-maybe-read</code> returns <code>#f</code>. Otherwise, it returns
  4882. either the number of octets read, or an EOF object if <var>channel</var> was
  4883. was at the end.
  4884. </p>
  4885. <p><code>Channel-maybe-write</code> attempts to write <var>octet-count</var> octets
  4886. to <var>channel</var> from <var>buffer</var>, starting at <var>start-index</var>. If
  4887. a low-level I/O error occurs, it returns a cell indicating a token
  4888. given by the operating system indicating what kind of error occurred.
  4889. If no such low-level error occurs, it registers <var>channel</var> for the
  4890. VM&rsquo;s event polling mechanism and returns <code>#f</code> iff zero octets were
  4891. immediately written or the number of octets immediately written if any
  4892. were.
  4893. </p>
  4894. <p><code>Channel-abort</code> aborts any pending operation registered for the
  4895. VM&rsquo;s event polling mechanism.
  4896. </p></dd></dl>
  4897. <dl>
  4898. <dt id="index-open_002dchannels_002dlist">procedure: <strong>open-channels-list</strong> <em>--&gt; channel-list</em></dt>
  4899. <dd><p>Returns a list of all open channels in order of the <code>os-index</code>
  4900. field.
  4901. </p></dd></dl>
  4902. <dl>
  4903. <dt id="index-channel_002dstatus_002doption">enumeration: <strong>channel-status-option</strong></dt>
  4904. <dd><div class="lisp">
  4905. <pre class="lisp">(define-enumeration channel-status-option
  4906. (closed
  4907. input
  4908. output
  4909. special-input
  4910. special-output))</pre></div>
  4911. <p>Enumeration for a channel&rsquo;s status. The <code>closed</code> enumerand is
  4912. used only after a channel has been closed. Note that this is
  4913. <em>not</em> suitable for a bit mask; that is, one may choose exactly
  4914. one of the enumerands, not use a bit mask of status options. For
  4915. example, to open a file <samp>frob</samp> for input that one wishes the
  4916. garbage collector to be silent about on closing it:
  4917. </p>
  4918. <div class="lisp">
  4919. <pre class="lisp">(open-channel &quot;frob&quot;
  4920. (enum channel-status-option input)
  4921. #t)
  4922. &rArr; #{Input-channel &quot;frob&quot;}</pre></div>
  4923. </dd></dl>
  4924. <span id="Higher_002dlevel-channel-operations"></span><h4 class="subsubsection">4.5.4.2 Higher-level channel operations</h4>
  4925. <span id="index-channel-utilities_002c-higher_002dlevel"></span>
  4926. <span id="index-higher_002dlevel-channel-utilities"></span>
  4927. <span id="index-channel_002di_002fo"></span>
  4928. <p>More convenient abstractions for operating on channels, based on
  4929. <a href="#Higher_002dlevel-synchronization">condition variables</a>, are
  4930. provided from the <code>channel-i/o</code> structure. They are integrated
  4931. with Scheme48&rsquo;s <a href="#Optimistic-concurrency">optimistic
  4932. concurrency</a> facilities.
  4933. </p>
  4934. <p><strong>Note:</strong> Transactions on channels can <em>not</em> be atomic in the
  4935. sense of optimistic concurrency. Since they involve communication with
  4936. the outside world, they are irrevocable transactions, and thus an
  4937. invalidated proposal cannot retract the transaction on the channel.
  4938. </p>
  4939. <dl>
  4940. <dt id="index-channel_002dmaybe_002dcommit_002dand_002dread">procedure: <strong>channel-maybe-commit-and-read</strong> <em>channel buffer start-index octet-count condvar wait? --&gt; committed?</em></dt>
  4941. <dt id="index-channel_002dmaybe_002dcommit_002dand_002dwrite">procedure: <strong>channel-maybe-commit-and-write</strong> <em>channel buffer start-index octet-count condvar --&gt; committed?</em></dt>
  4942. <dd><p>These attempt to commit the current proposal. If they fail, they
  4943. immediately return <code>#f</code>; otherwise, they proceed, and return
  4944. <code>#t</code>. If the commit succeeded, these procedures attempt an I/O
  4945. transaction, without blocking. <code>Channel-maybe-commit-and-read</code>
  4946. attempts to read <var>octet-count</var> octets into <var>buffer</var>, starting
  4947. at <var>start-index</var>, from <var>channel</var>.
  4948. <code>Channel-maybe-commit-and-write</code> attempts to write
  4949. <var>octet-count</var> octets from <var>buffer</var>, starting at
  4950. <var>start-index</var>, to <var>channel</var>. <var>Condvar</var> is noted as waiting
  4951. for the completion of the I/O transaction. When the I/O transaction
  4952. finally completes &mdash; in the case of a read, there are octets ready to
  4953. be read into <var>buffer</var> from <var>channel</var> or the end of the file was
  4954. struck; in the case of a write, <var>channel</var> is ready to receive some
  4955. octets &mdash;, <var>condvar</var> is set to the result of the I/O transaction:
  4956. the number of octets read, an I/O error condition, or an EOF object,
  4957. for reads; and the number of octets written or an I/O error condition,
  4958. for writes.
  4959. </p></dd></dl>
  4960. <dl>
  4961. <dt id="index-channel_002dmaybe_002dcommit_002dand_002dclose">procedure: <strong>channel-maybe-commit-and-close</strong> <em>channel closer --&gt; committed?</em></dt>
  4962. <dd><p>Attempts to commit the current proposal; if successful, this aborts any
  4963. wait on <var>channel</var>, sets the result of any condvars waiting on
  4964. <var>channel</var> to the EOF object, closes <var>channel</var> by applying
  4965. <var>closer</var> to <var>channel</var> (in theory, <var>closer</var> could be
  4966. anything; usually, however, it is <code>close-channel</code> from the
  4967. <code>channels</code> structure or some wrapper around it), and returns
  4968. <code>#t</code>. If the commit failed, <code>channel-maybe-commit-and-close</code>
  4969. immediately returns <code>#f</code>.
  4970. </p></dd></dl>
  4971. <dl>
  4972. <dt id="index-channel_002dwrite">procedure: <strong>channel-write</strong> <em>channel buffer start-index octet-count --&gt; octet-count-written</em></dt>
  4973. <dd><p>Atomically attempts to write <var>octet-count</var> octets to <var>channel</var>
  4974. from <var>buffer</var>, starting at <var>start-index</var> in <var>buffer</var>. If
  4975. no I/O transaction immediately occurs &mdash; what would result in
  4976. <code>channel-maybe-write</code> returning <code>#f</code> &mdash;,
  4977. <code>channel-write</code> blocks until something does happen. It returns
  4978. the number of octets written to <var>channel</var>.
  4979. </p></dd></dl>
  4980. <dl>
  4981. <dt id="index-wait_002dfor_002dchannel">procedure: <strong>wait-for-channel</strong> <em>channel condvar --&gt; unspecified</em></dt>
  4982. <dd><p>Registers <var>condvar</var> so that it will be set to the result of some
  4983. prior I/O transaction when some I/O event regarding <var>channel</var>
  4984. occurs. (Contrary to the name, this does not actually wait or block.
  4985. One must still use <code>maybe-commit-and-wait-for-condvar</code> on
  4986. <var>condvar</var>; see <a href="#Higher_002dlevel-synchronization">condition
  4987. variables</a>.) This is useful primarily in conjunction with calling
  4988. foreign I/O routines that register channels with the VM&rsquo;s event polling
  4989. system.
  4990. </p>
  4991. <p><strong>Note:</strong> <code>wait-for-channel</code> must be called with interrupts
  4992. disabled.
  4993. </p></dd></dl>
  4994. <hr>
  4995. <span id="Channel-ports"></span><div class="header">
  4996. <p>
  4997. Previous: <a href="#Channels" accesskey="p" rel="prev">Channels</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  4998. </div>
  4999. <span id="Channel-ports-1"></span><h4 class="subsection">4.5.5 Channel ports</h4>
  5000. <span id="index-channel_002dports"></span>
  5001. <p>Built-in to Scheme48 are ports made atop channels. These are what are
  5002. created by R5RS&rsquo;s standard file operations. The following names are
  5003. exported by the <code>channel-ports</code> structure.
  5004. </p>
  5005. <dl>
  5006. <dt id="index-call_002dwith_002dinput_002dfile">procedure: <strong>call-with-input-file</strong> <em>filename receiver --&gt; values</em></dt>
  5007. <dt id="index-call_002dwith_002doutput_002dfile">procedure: <strong>call-with-output-file</strong> <em>filename receiver --&gt; values</em></dt>
  5008. <dt id="index-with_002dinput_002dfrom_002dfile">procedure: <strong>with-input-from-file</strong> <em>filename thunk --&gt; values</em></dt>
  5009. <dt id="index-with_002doutput_002dto_002dfile">procedure: <strong>with-output-to-file</strong> <em>filename thunk --&gt; values</em></dt>
  5010. <dt id="index-open_002dinput_002dfile">procedure: <strong>open-input-file</strong> <em>filename --&gt; input-port</em></dt>
  5011. <dt id="index-open_002doutput_002dfile">procedure: <strong>open-output-file</strong> <em>filename --&gt; output-port</em></dt>
  5012. <dd><p>Standard R5RS file I/O operations. (These are also exported by the
  5013. <code>scheme</code> structure.) The <code>call-with-...put-file</code> operations
  5014. open the specified type of port and apply <var>receiver</var> to it; after
  5015. <var>receiver</var> returns normally (<i>i.e.</i> nothing is done if there is a
  5016. throw out of <var>receiver</var>), they close the port and return the
  5017. values that <var>receiver</var> returned. <code>With-input-from-file</code> &amp;
  5018. <code>with-output-to-file</code> do similarly, but, rather than applying
  5019. <var>thunk</var> to the port, they dynamically bind the current input &amp;
  5020. output ports, respectively, to the newly opened ports.
  5021. <code>Call-with-input-file</code>, <code>call-with-output-file</code>,
  5022. <code>with-input-from-file</code>, and <code>with-output-to-file</code> return the
  5023. values that <var>thunk</var> returns. <code>Open-input-file</code> &amp;
  5024. <code>open-output-file</code> just open input &amp; output ports; users of these
  5025. operations must close them manually.
  5026. </p></dd></dl>
  5027. <dl>
  5028. <dt id="index-input_002dchannel_002d_003eport">procedure: <strong>input-channel-&gt;port</strong> <em>channel [buffer-size] --&gt; port</em></dt>
  5029. <dt id="index-output_002dchannel_002d_003eport">procedure: <strong>output-channel-&gt;port</strong> <em>channel [buffer-size] --&gt; port</em></dt>
  5030. <dd><p>These create input &amp; output ports atop the given channels and optional
  5031. buffer sizes. The default buffer size is 4096 bytes.
  5032. </p></dd></dl>
  5033. <dl>
  5034. <dt id="index-input_002dchannel_002bcloser_002d_003eport">procedure: <strong>input-channel+closer-&gt;port</strong> <em>channel closer [buffer-size] --&gt; port</em></dt>
  5035. <dt id="index-output_002dchannel_002bcloser_002d_003eport">procedure: <strong>output-channel+closer-&gt;port</strong> <em>channel closer [buffer-size] --&gt; port</em></dt>
  5036. <dd><p>Similarly, these create input &amp; output ports atop the given channels
  5037. and optional buffer sizes, but they allow for extra cleanup when the
  5038. resulting ports are closed.
  5039. </p></dd></dl>
  5040. <span id="index-port-to-channel-conversion"></span>
  5041. <span id="index-accessing-file-ports_0027-channels"></span>
  5042. <dl>
  5043. <dt id="index-port_002d_003echannel">procedure: <strong>port-&gt;channel</strong> <em>port --&gt; channel or <code>#f</code></em></dt>
  5044. <dd><p>If <var>port</var> is a port created by the system&rsquo;s channel ports facility,
  5045. <code>port-&gt;channel</code> returns the channel it was created atop; otherwise
  5046. <code>port-&gt;channel</code> returns <code>#f</code>.
  5047. </p></dd></dl>
  5048. <dl>
  5049. <dt id="index-force_002dchannel_002doutput_002dports_0021">procedure: <strong>force-channel-output-ports!</strong> <em>--&gt; unspecified</em></dt>
  5050. <dd><p>This attempts to force as much output as possible from all of the ports
  5051. based on channels. This is used by Scheme48&rsquo;s POSIX libraries before
  5052. forking the current process.
  5053. </p></dd></dl>
  5054. <hr>
  5055. <span id="Reader-_0026-writer"></span><div class="header">
  5056. <p>
  5057. Next: <a href="#Records" accesskey="n" rel="next">Records</a>, Previous: <a href="#I_002fO-system" accesskey="p" rel="prev">I/O system</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5058. </div>
  5059. <span id="Reader-_0026-writer-1"></span><h3 class="section">4.6 Reader &amp; writer</h3>
  5060. <p>Scheme48 has simple S-expression reader &amp; writer libraries, with some
  5061. facilities beyond R5RS&rsquo;s <code>read</code> &amp; <code>write</code> procedures.
  5062. </p>
  5063. <table class="menu" border="0" cellspacing="0">
  5064. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  5065. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Reader" accesskey="1">Reader</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5066. </td></tr>
  5067. <tr><td align="left" valign="top">&bull; <a href="#Writer" accesskey="2">Writer</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5068. </td></tr>
  5069. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  5070. </pre></th></tr></table>
  5071. <hr>
  5072. <span id="Reader"></span><div class="header">
  5073. <p>
  5074. Next: <a href="#Writer" accesskey="n" rel="next">Writer</a>, Up: <a href="#Reader-_0026-writer" accesskey="u" rel="up">Reader &amp; writer</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5075. </div>
  5076. <span id="Reader-1"></span><h4 class="subsection">4.6.1 Reader</h4>
  5077. <span id="index-reading"></span>
  5078. <p>Scheme48&rsquo;s reader facility is exported by the <code>reading</code>
  5079. structure. The <code>read</code> binding thereby exported is identical to
  5080. that of the <code>scheme</code> structure, which is the binding that R5RS
  5081. specifies under the name <code>read</code>.
  5082. </p>
  5083. <dl>
  5084. <dt id="index-read">procedure: <strong>read</strong> <em>[port] --&gt; readable-value</em></dt>
  5085. <dd><p>Reads a single S-expression from <var>port</var>, whose default value is the
  5086. current input port. If the end of the stream is encountered before the
  5087. beginning of an S-expression, <code>read</code> will return an EOF object.
  5088. It will signal a read error if text read from <var>port</var> does not
  5089. constitute a complete, well-formed S-expression.
  5090. </p></dd></dl>
  5091. <dl>
  5092. <dt id="index-define_002dsharp_002dmacro">procedure: <strong>define-sharp-macro</strong> <em>char proc --&gt; unspecified</em></dt>
  5093. <dd><p>Defines a sharp/pound/hash/octothorpe (<code>#</code>) reader macro. The
  5094. next time the reader is invoked, if it encounters an octothorpe/sharp
  5095. followed by <var>char</var>, it applies <var>proc</var> to <var>char</var> and the
  5096. input port being read from. <var>Char</var> is <em>not</em> consumed in the
  5097. input port. If <var>char</var> is alphabetic, it should be lowercase;
  5098. otherwise the reader will not recognize it, since the reader converts
  5099. the character following octothorpes to lowercase.
  5100. </p></dd></dl>
  5101. <dl>
  5102. <dt id="index-reading_002derror">procedure: <strong>reading-error</strong> <em>port message irritant &hellip; --&gt; unspecified</em></dt>
  5103. <dd><p>Signals an error while reading, for custom sharp macros. It is not
  5104. likely that calls to <code>reading-error</code> will return.
  5105. </p></dd></dl>
  5106. <dl>
  5107. <dt id="index-gobble_002dline">procedure: <strong>gobble-line</strong> <em>port --&gt; unspecified</em></dt>
  5108. <dd><p>Reads until a newline from <var>port</var>. The newline character sequence
  5109. is consumed.
  5110. </p></dd></dl>
  5111. <hr>
  5112. <span id="Writer"></span><div class="header">
  5113. <p>
  5114. Previous: <a href="#Reader" accesskey="p" rel="prev">Reader</a>, Up: <a href="#Reader-_0026-writer" accesskey="u" rel="up">Reader &amp; writer</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5115. </div>
  5116. <span id="Writer-1"></span><h4 class="subsection">4.6.2 Writer</h4>
  5117. <span id="index-writing"></span>
  5118. <p>Scheme48&rsquo;s <code>writing</code> structure exports its writer facility. The
  5119. <code>write</code> and <code>display</code> bindings from it are identical to those
  5120. from the <code>scheme</code> structure, which are the same bindings that R5RS
  5121. specifies.
  5122. </p>
  5123. <dl>
  5124. <dt id="index-write">procedure: <strong>write</strong> <em>object [port] --&gt; unspecified</em></dt>
  5125. <dd><p>Writes <var>object</var> to <var>port</var>, which defaults to the current output
  5126. port, in a machine-readable manner. Strings are written with
  5127. double- quotes; characters are prefixed by <code>#\</code>. Any object that
  5128. is unreadable &mdash; anything that does not have a written representation
  5129. as an S-expression &mdash; is written based on its <em>disclosed</em>
  5130. representation. Such unreadable objects are converted to a disclosed
  5131. representation by the <code>disclose</code> generic procedure (see below).
  5132. </p></dd></dl>
  5133. <dl>
  5134. <dt id="index-display">procedure: <strong>display</strong> <em>object [port] --&gt; unspecified</em></dt>
  5135. <dd><p>Displays <var>object</var> to <var>port</var>, which defaults to the value of the
  5136. current output port, in a more human-readable manner. Strings are
  5137. written without surrounding double-quotes; characters are written as
  5138. themselves with no prefix.
  5139. </p></dd></dl>
  5140. <span id="index-customized-writer"></span>
  5141. <span id="index-writer_002c-customized"></span>
  5142. <dl>
  5143. <dt id="index-recurring_002dwrite">procedure: <strong>recurring-write</strong> <em>object port recur --&gt; unspecified</em></dt>
  5144. <dd><p>Writes <var>object</var> to <var>port</var>. Every time this recurs upon a new
  5145. object, rather than calling itself or its own looping procedure, it
  5146. calls <var>recur</var>. This allows customized printing routines that still
  5147. take advantage of the existence of Scheme48&rsquo;s writer. For example,
  5148. <code>display</code> simply calls <code>recurring-write</code> with a recurring
  5149. procedure that prints strings and characters specially and lets
  5150. <code>recurring-write</code> handle everything else.
  5151. </p></dd></dl>
  5152. <dl>
  5153. <dt id="index-display_002dtype_002dname">procedure: <strong>display-type-name</strong> <em>name port --&gt; unspecified</em></dt>
  5154. <dd><p>If <var>name</var> is a symbol with an alphabetic initial character, this
  5155. writes <var>name</var> to <var>port</var> with the first character uppercased and
  5156. the remaining character lowercased; otherwise, <code>display-type-name</code>
  5157. simply writes <var>name</var> to <var>port</var> with <code>display</code>.
  5158. </p>
  5159. <div class="lisp">
  5160. <pre class="lisp">(display-type-name 'foo)
  5161. -| Foo
  5162. (display-type-name (string-&gt;symbol &quot;42foo&quot;))
  5163. -| 42foo
  5164. (display-type-name (cons &quot;foo&quot; &quot;bar&quot;))
  5165. -| (foo . bar)
  5166. (display-type-name (string-&gt;symbol &quot;fOo-BaR&quot;))
  5167. -| Foo-bar</pre></div>
  5168. <p>This is used when printing disclosed representations (see below).
  5169. </p></dd></dl>
  5170. <span id="Object-disclosure"></span><h4 class="subsubsection">4.6.2.1 Object disclosure</h4>
  5171. <span id="index-customized-writer-1"></span>
  5172. <span id="index-writer_002c-customized-1"></span>
  5173. <span id="index-methods-1"></span>
  5174. <p>The <a href="#Generic-dispatch-system"><code>methods</code> structure</a>
  5175. exports the generic procedure <code>disclose</code> and its method table
  5176. <code>&amp;disclose</code>. When <code>recurring-write</code> encounters an object it
  5177. is unable to write in a rereadable manner, it applies <code>disclose</code>
  5178. to the unreadable object to acquire a <em>disclosed representation.</em>
  5179. (If <code>disclose</code> returns <code>#f</code>, <i>i.e.</i> the object has no
  5180. disclosed representation, the writer will write <code>#{Random
  5181. object}</code>.) After converting a value to its disclosed representation,
  5182. <i>e.g.</i> a list consisting of the symbol <code>foo</code>, the symbol
  5183. <code>bar</code>, a byte vector, and a pair <code>(1 . 2)</code>, the writer will
  5184. write <code>#{Foo #{Byte-vector} bar (1 . 2)}</code>. That is: contents
  5185. of the list are surrounded by <code>#{</code> and <code>}</code>, the first
  5186. element of the list (the &lsquo;type name&rsquo;) is written with
  5187. <code>display-type-name</code>, and then the remaining elements of the list
  5188. are recursively printed out with the <var>recur</var> argument.
  5189. </p>
  5190. <p>Typically, when a programmer creates an abstract data type by using
  5191. Scheme48&rsquo;s record facility, he will not add methods to <code>&amp;disclose</code>
  5192. but instead define the record type&rsquo;s discloser with the
  5193. <code>define-record-discloser</code> procedure; see <a href="#Records">Records</a>.
  5194. </p>
  5195. <p>Example:
  5196. </p>
  5197. <div class="lisp">
  5198. <pre class="lisp">(define-record-type pare rtd/pare
  5199. (kons a d)
  5200. pare?
  5201. (a kar set-kar!)
  5202. (d kdr set-kdr!))
  5203. (define-record-discloser rtd/pare
  5204. (lambda (pare)
  5205. `(pare ,(kar pare) *dot* ,(kdr pare))))
  5206. (write (kons (kons 5 3) (kons 'a 'b)))
  5207. -| #{Pare #{Pare 5 *dot* 3} *dot* #{Pare a *dot* b}}</pre></div>
  5208. <hr>
  5209. <span id="Records"></span><div class="header">
  5210. <p>
  5211. Next: <a href="#Suspending-and-resuming-heap-images" accesskey="n" rel="next">Suspending and resuming heap images</a>, Previous: <a href="#Reader-_0026-writer" accesskey="p" rel="prev">Reader &amp; writer</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5212. </div>
  5213. <span id="Records-1"></span><h3 class="section">4.7 Records</h3>
  5214. <span id="index-abstract-data-types"></span>
  5215. <span id="index-opaque-data-types"></span>
  5216. <p>Scheme48 provides several different levels of a record facility. Most
  5217. programmers will probably not care about the two lower levels; the
  5218. syntactic record type definers are sufficient for abstract data types.
  5219. </p>
  5220. <span id="index-defining-record-types"></span>
  5221. <span id="index-record-types_002c-defining"></span>
  5222. <span id="index-define_002drecord_002dtypes"></span>
  5223. <span id="index-defrecord"></span>
  5224. <span id="index-srfi_002d9"></span>
  5225. <p>At the highest level, there are two different record type definition
  5226. macros. Richard Kelsey&rsquo;s is exported from the <code>defrecord</code>
  5227. structure; Jonathan Rees&rsquo;s is exported from <code>define-record-types</code>.
  5228. They both export a <code>define-record-type</code> macro and the same
  5229. <code>define-record-discloser</code> procedure; however, the macros are
  5230. dramatically different. Scheme48 also provides [SRFI 9], which is
  5231. essentially Jonathan Rees&rsquo;s record type definition macro with a slight
  5232. syntactic difference, in the <code>srfi-9</code> structure. Note, however,
  5233. that <code>srfi-9</code> does not export <code>define-record-discloser</code>. The
  5234. difference between Jonathan Rees&rsquo;s and Richard Kelsey&rsquo;s record type
  5235. definition macros is merely syntactic convenience; Jonathan Rees&rsquo;s more
  5236. conveniently allows for arbitrary naming of the generated variables,
  5237. whereas Richard Kelsey&rsquo;s is more convenient if the naming scheme varies
  5238. little.
  5239. </p>
  5240. <span id="Jonathan-Rees_0027s-define_002drecord_002dtype-macro"></span><h4 class="subsection">4.7.1 Jonathan Rees&rsquo;s <code>define-record-type</code> macro</h4>
  5241. <dl>
  5242. <dt id="index-define_002drecord_002dtype">syntax: <strong>define-record-type</strong></dt>
  5243. <dd><div class="lisp">
  5244. <pre class="lisp">(define-record-type <var>record-type-name</var> <var>record-type-variable</var>
  5245. (<var>constructor</var> <var>constructor-argument</var> &hellip;)
  5246. [<var>predicate</var>]
  5247. (<var>field-tag</var> <var>field-accessor</var> [<var>field-modifier</var>])
  5248. &hellip;)</pre></div>
  5249. <p>This defines <var>record-type-variable</var> to be a record type descriptor.
  5250. <var>Constructor</var> is defined to be a procedure that accepts the listed
  5251. field arguments and creates a record of the newly defined type with
  5252. those fields initialized to the corresponding arguments.
  5253. <var>Predicate</var>, if present, is defined to be the disjoint (as long as
  5254. abstraction is not violated by the lower-level record interface) type
  5255. predicate for the new record type. Each <var>field-accessor</var> is
  5256. defined to be a unary procedure that accepts a record type and returns
  5257. the value of the field named by the corresponding <var>field-tag</var>.
  5258. Each <var>field-modifier</var>, if present, is defined to be a binary
  5259. procedure that accepts a record of the new type and a value, which it
  5260. assigns the field named by the corresponding <var>field-tag</var> to. Every
  5261. <var>constructor-argument</var> must have a corresponding <var>field-tag</var>,
  5262. though <var>field-tag</var>s that are not used as arguments to the record
  5263. type&rsquo;s constructor are simply uninitialized when created. They should
  5264. have modifiers: otherwise they will never be initialized.
  5265. </p>
  5266. <p>It is worth noting that Jonathan Rees&rsquo;s <code>define-record-type</code> macro
  5267. does not introduce identifiers that were not in the original macro&rsquo;s
  5268. input form.
  5269. </p>
  5270. <p>For example:
  5271. </p>
  5272. <div class="lisp">
  5273. <pre class="lisp">(define-record-type pare rtd/pare
  5274. (kons a d)
  5275. pare?
  5276. (a kar)
  5277. (d kdr set-kdr!))
  5278. (kar (kons 5 3))
  5279. &rArr; 5
  5280. (let ((p (kons 'a 'c)))
  5281. (set-kdr! p 'b)
  5282. (kdr p))
  5283. &rArr; b
  5284. (pare? (kons 1 2))
  5285. &rArr; #t
  5286. (pare? (cons 1 2))
  5287. &rArr; #f</pre></div>
  5288. </dd></dl>
  5289. <p>There is also a variant of Jonathan Rees&rsquo;s <code>define-record-type</code>
  5290. macro for defining record types with fields whose accessors and
  5291. modifiers respect <a href="#Optimistic-concurrency">optimistic
  5292. concurrency</a> by logging in the current proposal.
  5293. </p>
  5294. <span id="Richard-Kelsey_0027s-define_002drecord_002dtype-macro"></span><h4 class="subsection">4.7.2 Richard Kelsey&rsquo;s <code>define-record-type</code> macro</h4>
  5295. <dl>
  5296. <dt id="index-define_002drecord_002dtype-1">syntax: <strong>define-record-type</strong></dt>
  5297. <dd><div class="lisp">
  5298. <pre class="lisp">(define-record-type <var>type-name</var>
  5299. (<var>argument-field-specifier</var> &hellip;)
  5300. (<var>nonargument-field-specifier</var> &hellip;))
  5301. <var>argument-field-specifier</var> --&gt;
  5302. <var>field-tag</var> Immutable field
  5303. | (<var>field-tag</var>) Mutable field
  5304. <var>nonargument-field-specifier</var> --&gt;
  5305. <var>field-tag</var> Uninitialized field
  5306. | (<var>field-tag</var> <var>exp</var>) Initialized with <var>exp</var>'s value</pre></div>
  5307. <p>This defines <code>type/<var>type-name</var></code> to be a record type descriptor
  5308. for the newly defined record type, <code><var>type-name</var>-maker</code> to be
  5309. a constructor for the new record type that accepts arguments for every
  5310. field in the argument field specifier list, <code><var>type-name</var>?</code> to
  5311. be the disjoint type predicate for the new record type, accessors for
  5312. each field tag <var>field-tag</var> by constructing an identifier
  5313. <code><var>type-name</var>-<var>field-tag</var></code>, and modifiers for each argument
  5314. field tag that was specified to be mutable as well as each nonargument
  5315. field tag. The name of the modifier for a field tag <var>field-tag</var> is
  5316. constructed to be
  5317. <code>set-<var>type-name</var>-<var>field-tag</var>!</code>.
  5318. </p>
  5319. <p>Note that Richard Kelsey&rsquo;s <code>define-record-type</code> macro <em>does</em>
  5320. concatenate &amp; introduce new identifiers, unlike Jonathan Rees&rsquo;s.
  5321. </p>
  5322. <p>For example, a use of Richard Kelsey&rsquo;s <code>define-record-type</code> macro
  5323. </p>
  5324. <div class="lisp">
  5325. <pre class="lisp">(define-record-type pare
  5326. (kar
  5327. (kdr))
  5328. (frob
  5329. (mumble 5)))</pre></div>
  5330. <p>is equivalent to the following use of Jonathan Rees&rsquo;s macro
  5331. </p>
  5332. <div class="lisp">
  5333. <pre class="lisp">(define-record-type pare type/pare
  5334. (%pare-maker kar kdr mumble)
  5335. pare?
  5336. (kar pare-kar)
  5337. (kdr pare-kdr set-pare-kdr!)
  5338. (frob pare-frob set-pare-frob!)
  5339. (mumble pare-mumble set-pare-mumble!))
  5340. (define (pare-maker kar kdr)
  5341. (%pare-maker kar kdr 5))</pre></div>
  5342. </dd></dl>
  5343. <span id="Record-types"></span><h4 class="subsection">4.7.3 Record types</h4>
  5344. <span id="index-programmatic-record-types"></span>
  5345. <span id="index-record-types_002c-programmatic"></span>
  5346. <span id="index-record_002dtypes"></span>
  5347. <p>Along with two general record type definition facilities, there are
  5348. operations directly on the record type descriptors themselves, exported
  5349. by the <code>record-types</code> structure. (Record type descriptors are
  5350. actually records themselves.)
  5351. </p>
  5352. <dl>
  5353. <dt id="index-make_002drecord_002dtype">procedure: <strong>make-record-type</strong> <em>name field-tags --&gt; record-type-descriptor</em></dt>
  5354. <dt id="index-record_002dtype_003f">procedure: <strong>record-type?</strong> <em>object --&gt; boolean</em></dt>
  5355. <dd><p><code>Make-record-type</code> makes a record type descriptor with the given
  5356. name and field tags. <code>Record-type?</code> is the disjoint type
  5357. predicate for record types.
  5358. </p></dd></dl>
  5359. <dl>
  5360. <dt id="index-record_002dtype_002dname">procedure: <strong>record-type-name</strong> <em>rtype-descriptor --&gt; symbol</em></dt>
  5361. <dt id="index-record_002dtype_002dfield_002dnames">procedure: <strong>record-type-field-names</strong> <em>rtype-descriptor --&gt; symbol-list</em></dt>
  5362. <dd><p>Accessors for the two record type descriptor fields.
  5363. </p></dd></dl>
  5364. <dl>
  5365. <dt id="index-record_002dconstructor">procedure: <strong>record-constructor</strong> <em>rtype-descriptor argument-field-tags --&gt; constructor-procedure</em></dt>
  5366. <dt id="index-record_002dpredicate">procedure: <strong>record-predicate</strong> <em>rtype-descriptor --&gt; predicate-procedure</em></dt>
  5367. <dt id="index-record_002daccessor">procedure: <strong>record-accessor</strong> <em>rtype-descriptor field-tag --&gt; accessor-procedure</em></dt>
  5368. <dt id="index-record_002dmodifier">procedure: <strong>record-modifier</strong> <em>rtype-descriptor field-tag --&gt; modifier-procedure</em></dt>
  5369. <dd><p>Constructors for the various procedures relating to record types.
  5370. <code>Record-constructor</code> returns a procedure that accepts arguments
  5371. for each field in <var>argument-field-tags</var> and constructs a record
  5372. whose record type descriptor is <var>rtype-descriptor</var>, initialized
  5373. with its arguments. <code>Record-predicate</code> returns a disjoint type
  5374. predicate for records whose record type descriptor is
  5375. <var>rtype-descriptor</var>. <code>Record-accessor</code> and
  5376. <code>record-modifier</code> return accessors and modifiers for records
  5377. whose record type descriptor is <var>rtype-descriptor</var> for the given
  5378. fields.
  5379. </p></dd></dl>
  5380. <dl>
  5381. <dt id="index-define_002drecord_002ddiscloser">procedure: <strong>define-record-discloser</strong> <em>rtype-descriptor discloser --&gt; unspecific</em></dt>
  5382. <dd><p>Defines the method by which records of type <var>rtype-descriptor</var> are
  5383. disclosed (see <a href="#Writer">Writer</a>). This is also exported by
  5384. <code>define-record-types</code> and <code>defrecord</code>.
  5385. </p></dd></dl>
  5386. <dl>
  5387. <dt id="index-define_002drecord_002dresumer">procedure: <strong>define-record-resumer</strong> <em>rtype-descriptor resumer --&gt; unspecified</em></dt>
  5388. <dd><p>Sets <var>rtype-descriptor</var>&rsquo;s record resumer to be <var>resumer</var>. If
  5389. <var>resumer</var> is <code>#t</code> (the default), records of this type require
  5390. no particular reinitialization when found in <a href="#Suspending-and-resuming-heap-images">dumped heap images</a>; if <var>resumer</var> is
  5391. <code>#f</code>, records of the type <var>rtype-descriptor</var> may not be
  5392. dumped in heap images; finally, if it is a procedure, and the heap
  5393. image is resumed with the <a href="#Suspending-and-resuming-heap-images">usual image resumer</a>, it is applied to each record whose
  5394. record type descriptor is <var>rtype-descriptor</var> after the run-time
  5395. system has been initialized and before the argument to
  5396. <code>usual-resumer</code> is called.
  5397. </p></dd></dl>
  5398. <span id="index-records_002dinternal"></span>
  5399. <p>The <code>records-internal</code> structure also exports these:
  5400. </p>
  5401. <dl>
  5402. <dt id="index-_003arecord_002dtype">record type: <strong>:record-type</strong></dt>
  5403. <dd><p>The record type of record types.
  5404. </p></dd></dl>
  5405. <dl>
  5406. <dt id="index-disclose_002drecord">procedure: <strong>disclose-record</strong> <em>record --&gt; disclosed</em></dt>
  5407. <dd><p>This applies <var>record</var>&rsquo;s record type descriptor&rsquo;s discloser procedure
  5408. to <var>record</var> to acquire a disclosed representation; see <a href="#Writer">Writer</a>.
  5409. </p></dd></dl>
  5410. <p>For expository purposes, the record type record type might have been
  5411. defined like so with Jonathan Rees&rsquo;s <code>define-record-type</code> macro:
  5412. </p>
  5413. <div class="lisp">
  5414. <pre class="lisp">(define-record-type record-type :record-type
  5415. (make-record-type name field-names)
  5416. record-type?
  5417. (name record-type-name)
  5418. (field-names record-type-field-names))</pre></div>
  5419. <p>or like so with Richard Kelsey&rsquo;s <code>define-record-type</code> macro:
  5420. </p>
  5421. <div class="lisp">
  5422. <pre class="lisp">(define-record-type record-type
  5423. (name field-names)
  5424. ())</pre></div>
  5425. <p>Of course, in reality, these definitions would have severe problems
  5426. with circularity of definition.
  5427. </p>
  5428. <span id="Low_002dlevel-record-manipulation"></span><h4 class="subsection">4.7.4 Low-level record manipulation</h4>
  5429. <span id="index-records_002c-low_002dlevel-access-to"></span>
  5430. <span id="index-low_002dlevel-access-to-records"></span>
  5431. <span id="index-records"></span>
  5432. <p>Internally, records are represented very similarly to vectors, and as
  5433. such have low-level operations on them similar to vectors, exported by
  5434. the <code>records</code> structure. Records usually reserve the slot at
  5435. index 0 for their record type descriptor.
  5436. </p>
  5437. <p><strong>Warning:</strong> The procedures described here can be very easily
  5438. misused to horribly break abstractions. Use them very carefully, only
  5439. in very limited &amp; extreme circumstances!
  5440. </p>
  5441. <dl>
  5442. <dt id="index-make_002drecord">procedure: <strong>make-record</strong> <em>length init --&gt; record</em></dt>
  5443. <dt id="index-record">procedure: <strong>record</strong> <em>elt &hellip; --&gt; record</em></dt>
  5444. <dt id="index-record_003f">procedure: <strong>record?</strong> <em>object --&gt; boolean</em></dt>
  5445. <dt id="index-record_002dlength">procedure: <strong>record-length</strong> <em>record --&gt; integer</em></dt>
  5446. <dt id="index-record_002dref">procedure: <strong>record-ref</strong> <em>record index --&gt; value</em></dt>
  5447. <dt id="index-record_002dset_0021">procedure: <strong>record-set!</strong> <em>record index object --&gt; unspecified</em></dt>
  5448. <dd><p>Exact analogues of similarly named vector operation procedures.
  5449. </p></dd></dl>
  5450. <dl>
  5451. <dt id="index-record_002dtype">procedure: <strong>record-type</strong> <em>record --&gt; value</em></dt>
  5452. <dd><p>This returns the record type descriptor of <var>record</var>, <i>i.e.</i> the
  5453. value of the slot at index 0 in <var>record</var>.
  5454. </p></dd></dl>
  5455. <hr>
  5456. <span id="Suspending-and-resuming-heap-images"></span><div class="header">
  5457. <p>
  5458. Previous: <a href="#Records" accesskey="p" rel="prev">Records</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5459. </div>
  5460. <span id="Suspending-and-resuming-heap-images-1"></span><h3 class="section">4.8 Suspending and resuming heap images</h3>
  5461. <span id="index-dumping-heap-images-1"></span>
  5462. <span id="index-heap-image-dumping-1"></span>
  5463. <span id="index-image-dumping-1"></span>
  5464. <span id="index-writing-heap-images-1"></span>
  5465. <span id="index-heap-image-writing-1"></span>
  5466. <span id="index-image-writing-1"></span>
  5467. <p>Scheme48&rsquo;s virtual machine operates by loading a heap image into memory
  5468. and calling the initialization procedure specified in the image dump.
  5469. Heap images can be produced in several different ways: programmatically
  5470. with <code>write-image</code>, using the <a href="#Image_002dbuilding-commands">command processor&rsquo;s facilities</a>, or with the static linker. This
  5471. section describes only <code>write-image</code> and the related system
  5472. resumption &amp; initialization.
  5473. </p>
  5474. <p>Heap image dumps begin with a sequence of characters terminated by an
  5475. ASCII form-feed/page character (codepoint 12). This content may be
  5476. anything; for example, it might be a Unix <code>#!</code> line that invokes
  5477. <code>scheme48vm</code> on the file, or it might be a silly message to
  5478. whomever reads the top of the heap image dump file. (The command
  5479. processor&rsquo;s <code>,dump</code> &amp; <code>,build</code> commands
  5480. (see <a href="#Image_002dbuilding-commands">Image-building commands</a>) write a blank line at the top; the
  5481. static linker
  5482. puts a message stating that the
  5483. image was built by the static linker.)
  5484. </p>
  5485. <span id="index-write_002dimages"></span>
  5486. <p><code>Write-image</code> is exported by the <code>write-images</code> structure.
  5487. </p>
  5488. <dl>
  5489. <dt id="index-write_002dimage">procedure: <strong>write-image</strong> <em>filename startup-proc message --&gt; unspecified</em></dt>
  5490. <dd><p>Writes a heap image whose startup procedure is <var>startup-proc</var> and
  5491. that consists of every object accessible in some way from
  5492. <var>startup-proc</var>. <var>Message</var> is put at the start of the heap
  5493. image file before the ASCII form-feed/page character. When the image
  5494. is resumed, <var>startup-proc</var> is passed a vector of program arguments,
  5495. an input channel for standard input, an output channel for standard
  5496. output, an output channel for standard error, and a vector of records
  5497. to be resumed. This is typically simplified by <code>usual-resumer</code>
  5498. (see below). On Unix, <var>startup-proc</var> must return an integer exit
  5499. code; otherwise the program will crash and burn with a very low-level
  5500. VM error message when <var>startup-proc</var> returns.
  5501. </p></dd></dl>
  5502. <span id="System-initialization"></span><h4 class="subsection">4.8.1 System initialization</h4>
  5503. <span id="index-usual-resumer"></span>
  5504. <span id="index-heap-image-resumption-1"></span>
  5505. <span id="index-resuming-heap-images-1"></span>
  5506. <span id="index-usual_002dresumer-1"></span>
  5507. <p>When suspended heap images are resumed by the VM, the startup procedure
  5508. specified in the heap image is applied to five arguments: a vector of
  5509. command-line arguments (passed after the <code>-a</code> argument to the VM),
  5510. an input channel for standard input, an output channel for standard
  5511. output, an output channel for standard error, and a vector of records
  5512. to be resumed. The startup procedure is responsible for performing any
  5513. initialization necessary &mdash; including initializing the Scheme48
  5514. run-time system &mdash; as well as simply running the program. Typically,
  5515. this procedure is not written manually: resumers are ordinarily created
  5516. using the <em>usual resumer</em> abstraction, exported from the structure
  5517. <code>usual-resumer</code>.
  5518. </p>
  5519. <dl>
  5520. <dt id="index-usual_002dresumer">procedure: <strong>usual-resumer</strong> <em>startup-proc --&gt; resumer-proc</em></dt>
  5521. <dd><p>This returns a procedure that is suitable as a heap image resumer
  5522. procedure. When the heap image is resumed, it initializes the run-time
  5523. system &mdash; it resumes all the records, initializes the thread system,
  5524. the dynamic state, the interrupt system, I/O system, <i>&amp;c.</i> &mdash; and
  5525. applies <var>startup-proc</var> to a list (not a vector) of the command-line
  5526. arguments.
  5527. </p></dd></dl>
  5528. <p>Some records may contain machine-, OS-, or other session-specific data.
  5529. When suspended in heap images and later resumed, this data may be
  5530. invalidated, and it may be necessary to reinitialize this data upon
  5531. resumption of suspended heap images. For this reason Scheme48 provides
  5532. <em>record resumers</em>; see <code>define-record-resumer</code> from the
  5533. <a href="#Records"><code>record-types</code> structure</a>.
  5534. </p>
  5535. <span id="Manual-system-initialization"></span><h4 class="subsection">4.8.2 Manual system initialization</h4>
  5536. <p>If a programmer chooses not to use <code>usual-resumer</code> &mdash; which is
  5537. <em>not</em> a very common thing to do &mdash;, he is responsible for manual
  5538. initialization of the run-time system, including the I/O system,
  5539. resumption of records, the thread system and the root thread scheduler,
  5540. the interrupt system, and the condition system.
  5541. </p>
  5542. <p><strong>Warning:</strong> Manual initialization of the run-time system is a
  5543. <em>very</em> delicate operation. Although one can potentially vastly
  5544. decrease the size of dumped heap images by doing it manually,
  5545. <a id="DOCF19" href="#FOOT19"><sup>19</sup></a> it is very error-prone and
  5546. difficult to do without exercising great care, which is why the usual
  5547. resumer facility exists. Unless you <em><strong>really</strong></em> know what
  5548. you are doing, you should just use the usual resumer.
  5549. </p>
  5550. <p>At the present, documentation of manual system initialization is
  5551. absent. However, if the reader knows enough about what he is doing
  5552. that he desires to manually initialize the run-time system, he is
  5553. probably sufficiently familiar with it already to be able to find the
  5554. necessary information directly from Scheme48&rsquo;s source code and module
  5555. descriptions.
  5556. </p><hr>
  5557. <span id="Multithreading"></span><div class="header">
  5558. <p>
  5559. Next: <a href="#Libraries" accesskey="n" rel="next">Libraries</a>, Previous: <a href="#System-facilities" accesskey="p" rel="prev">System facilities</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5560. </div>
  5561. <span id="Multithreading-1"></span><h2 class="chapter">5 Multithreading</h2>
  5562. <p>This chapter describes Scheme48&rsquo;s fully pre&euml;mptive and sophisticated
  5563. user-level thread system. Scheme48 supports customized and nested
  5564. thread schedulers, user-designed synchronization mechanisms, optimistic
  5565. concurrency, useful thread synchronization libraries, a high-level
  5566. event algebra based on Reppy&rsquo;s Concurrent ML [Reppy 99], and common
  5567. pessimistic concurrency/mutual-exclusion-based thread synchronization
  5568. facilities.
  5569. </p>
  5570. <table class="menu" border="0" cellspacing="0">
  5571. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Basic-thread-operations" accesskey="1">Basic thread operations</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5572. </td></tr>
  5573. <tr><td align="left" valign="top">&bull; <a href="#Optimistic-concurrency" accesskey="2">Optimistic concurrency</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5574. </td></tr>
  5575. <tr><td align="left" valign="top">&bull; <a href="#Higher_002dlevel-synchronization" accesskey="3">Higher-level synchronization</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5576. </td></tr>
  5577. <tr><td align="left" valign="top">&bull; <a href="#Concurrent-ML" accesskey="4">Concurrent ML</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">High-level event synchronization
  5578. </td></tr>
  5579. <tr><td align="left" valign="top">&bull; <a href="#Pessimistic-concurrency" accesskey="5">Pessimistic concurrency</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Mutual exclusion/locking
  5580. </td></tr>
  5581. <tr><td align="left" valign="top">&bull; <a href="#Custom-thread-synchronization" accesskey="6">Custom thread synchronization</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  5582. </td></tr>
  5583. </table>
  5584. <hr>
  5585. <span id="Basic-thread-operations"></span><div class="header">
  5586. <p>
  5587. Next: <a href="#Optimistic-concurrency" accesskey="n" rel="next">Optimistic concurrency</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5588. </div>
  5589. <span id="Basic-thread-operations-1"></span><h3 class="section">5.1 Basic thread operations</h3>
  5590. <span id="index-threads"></span>
  5591. <p>This section describes the <code>threads</code> structure.
  5592. </p>
  5593. <span id="index-spawning-threads"></span>
  5594. <span id="index-threads_002c-spawning"></span>
  5595. <dl>
  5596. <dt id="index-spawn">procedure: <strong>spawn</strong> <em>thunk [name] --&gt; thread</em></dt>
  5597. <dd><p><code>Spawn</code> constructs a new thread and instructs the current thread
  5598. scheduler to commence running the new thread. <var>Name</var>, if present,
  5599. is used for debugging. The new thread has a fresh
  5600. <a href="#Fluid_002fdynamic-bindings">dynamic environment</a>.
  5601. </p></dd></dl>
  5602. <p>There are several miscellaneous facilities for thread operations.
  5603. </p>
  5604. <span id="index-yielding-threads"></span>
  5605. <span id="index-thread-yielding"></span>
  5606. <span id="index-sleeping-threads"></span>
  5607. <span id="index-thread-sleeping"></span>
  5608. <dl>
  5609. <dt id="index-relinquish_002dtimeslice">procedure: <strong>relinquish-timeslice</strong> <em>--&gt; unspecified</em></dt>
  5610. <dt id="index-sleep">procedure: <strong>sleep</strong> <em>count --&gt; unspecified</em></dt>
  5611. <dd><p><code>Relinquish-timeslice</code> relinquishes the remaining quantum that the
  5612. current thread has to run; this allows the current scheduler run the
  5613. next thread immediately. <code>Sleep</code> suspends the current thread for
  5614. <var>count</var> milliseconds.
  5615. </p></dd></dl>
  5616. <span id="index-thread-termination"></span>
  5617. <span id="index-terminating-threads"></span>
  5618. <dl>
  5619. <dt id="index-terminate_002dcurrent_002dthread">procedure: <strong>terminate-current-thread</strong> <em>--&gt; (does not return)</em></dt>
  5620. <dd><p>Terminates the current thread, running all <code>dynamic-wind</code> exit
  5621. points. <code>Terminate-current-thread</code> obviously does not return.
  5622. </p></dd></dl>
  5623. <span id="index-thread-descriptors"></span>
  5624. <p>Threads may be represented and manipulated in first-class thread
  5625. descriptor objects.
  5626. </p>
  5627. <dl>
  5628. <dt id="index-current_002dthread">procedure: <strong>current-thread</strong> <em>--&gt; thread</em></dt>
  5629. <dt id="index-thread_003f">procedure: <strong>thread?</strong> <em>object --&gt; boolean</em></dt>
  5630. <dt id="index-thread_002dname">procedure: <strong>thread-name</strong> <em>thread --&gt; value</em></dt>
  5631. <dt id="index-thread_002duid">procedure: <strong>thread-uid</strong> <em>thread --&gt; unique-integer-id</em></dt>
  5632. <dd><p><code>Current-thread</code> returns the thread descriptor for the currently
  5633. running thread. <code>Thread?</code> is the thread descriptor disjoint type
  5634. predicate. <code>Thread-name</code> returns the name that was passed to
  5635. <code>spawn</code> when spawning <var>thread</var>, or <code>#f</code> if no name was
  5636. passed. <code>Thread-uid</code> returns a thread descriptor&rsquo;s unique integer
  5637. identifier, assigned by the thread system.
  5638. </p></dd></dl>
  5639. <hr>
  5640. <span id="Optimistic-concurrency"></span><div class="header">
  5641. <p>
  5642. Next: <a href="#Higher_002dlevel-synchronization" accesskey="n" rel="next">Higher-level synchronization</a>, Previous: <a href="#Basic-thread-operations" accesskey="p" rel="prev">Basic thread operations</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5643. </div>
  5644. <span id="Optimistic-concurrency-1"></span><h3 class="section">5.2 Optimistic concurrency</h3>
  5645. <p>Scheme48&rsquo;s fundamental thread synchronization mechanism is based on a
  5646. device often used in high-performance database systems: optimistic
  5647. concurrency. The basic principle of optimistic concurrency is that,
  5648. rather than mutually excluding other threads from data involved in one
  5649. thread&rsquo;s transaction, a thread keeps a log of its transaction, not
  5650. actually modifying the data involved, only touching the log. When the
  5651. thread is ready to commit its changes, it checks that all of the reads
  5652. from memory retained their integrity &mdash; that is, all of the memory
  5653. that was read from during the transaction has remained the same, and is
  5654. consistent with what is there at the time of the commit. If, and only
  5655. if, all of the reads remained valid, the logged writes are committed;
  5656. otherwise, the transaction has been invalidated. While a thread is
  5657. transacting, any number of other threads may be also transacting on the
  5658. same resource. All that matters is that the values each transaction
  5659. read are consistent with every write that was committed during the
  5660. transaction. This synchronization mechanism allows for wait-free,
  5661. lockless systems that easily avoid confusing problems involving careful
  5662. sequences of readily deadlock-prone mutual exclusion.
  5663. </p>
  5664. <span id="index-proposals"></span>
  5665. <span id="index-logs"></span>
  5666. <span id="index-transaction-logs"></span>
  5667. <span id="index-optimistic-concurrency-proposals"></span>
  5668. <span id="index-optimistic-concurrency-logs"></span>
  5669. <p>In the Scheme48 system, every thread has its own log of transactions,
  5670. called a <em>proposal</em>. There are variants of all data accessors &amp;
  5671. modifiers that operate on the current thread&rsquo;s proposal, rather than
  5672. actual memory: after the initial read of a certain part of memory &mdash;
  5673. which <em>does</em> perform a real read &mdash;, the value from that location
  5674. in memory is cached in the proposal, and thenceforth reads from that
  5675. location in memory will actually read the cache; modifications touch
  5676. only the proposal, until the proposal is committed.
  5677. </p>
  5678. <span id="index-proposals-2"></span>
  5679. <p>All of the names described in this section are exported by the
  5680. <code>proposals</code> structure.
  5681. </p>
  5682. <span id="High_002dlevel-optimistic-concurrency"></span><h4 class="subsection">5.2.1 High-level optimistic concurrency</h4>
  5683. <span id="index-atomic-regions"></span>
  5684. <p>There are several high-level operations that abstract the manipulation
  5685. of the current thread&rsquo;s proposal.
  5686. </p>
  5687. <dl>
  5688. <dt id="index-call_002densuring_002datomicity">procedure: <strong>call-ensuring-atomicity</strong> <em>thunk --&gt; values</em></dt>
  5689. <dt id="index-call_002densuring_002datomicity_0021">procedure: <strong>call-ensuring-atomicity!</strong> <em>thunk --&gt; unspecified</em></dt>
  5690. <dd><p>These ensure that the operation of <var>thunk</var> is atomic. If there is
  5691. already a current proposal in place, these are equivalent to calling
  5692. <var>thunk</var>. If there is not a current proposal in place, these
  5693. install a new proposal, call <var>thunk</var>, and attempt to commit the new
  5694. proposal. If the commit succeeded, these return. If it failed, these
  5695. retry with a new proposal until they do succeed.
  5696. <code>Call-ensuring-atomicity</code> returns the values that <var>thunk</var>
  5697. returned when the commit succeeded; <code>call-ensuring-atomicity!</code>
  5698. returns zero values &mdash; it is intended for when <var>thunk</var> is used for
  5699. its effects only.
  5700. </p></dd></dl>
  5701. <dl>
  5702. <dt id="index-call_002datomically">procedure: <strong>call-atomically</strong> <em>thunk --&gt; values</em></dt>
  5703. <dt id="index-call_002datomically_0021">procedure: <strong>call-atomically!</strong> <em>thunk --&gt; unspecified</em></dt>
  5704. <dd><p>These are like <var>call-ensuring-atomicity</var> and
  5705. <var>call-ensuring-atomicity!</var>, respectively, except that they always
  5706. install a new proposal (saving the old one and restoring it when they
  5707. are done).
  5708. </p></dd></dl>
  5709. <dl>
  5710. <dt id="index-ensure_002datomicity">syntax: <strong>ensure-atomicity</strong> <em>body --&gt; values</em></dt>
  5711. <dt id="index-ensure_002datomicity_0021">syntax: <strong>ensure-atomicity!</strong> <em>body --&gt; unspecified</em></dt>
  5712. <dt id="index-atomically">syntax: <strong>atomically</strong> <em>body --&gt; values</em></dt>
  5713. <dt id="index-atomically_0021">syntax: <strong>atomically!</strong> <em>body --&gt; unspecified</em></dt>
  5714. <dd><p>These are syntactic sugar over <code>call-ensuring-atomicity</code>,
  5715. <code>call-ensuring-atomicity!</code>, <code>call-atomically</code>, and
  5716. <code>call-atomically!</code>, respectively.
  5717. </p></dd></dl>
  5718. <p>Use these high-level optimistic concurrency operations to make the
  5719. body atomic. <code>Call-ensuring-atomicity</code> <i>&amp;c.</i> simply ensure that
  5720. the transaction will be atomic, and may &lsquo;fuse&rsquo; it with an enclosing
  5721. atomic transaction if there already is one, <i>i.e.</i> use the proposal for
  5722. that transaction already in place, creating one only if there is not
  5723. already one. <code>Call-atomically</code> <i>&amp;c.</i> are for what might be
  5724. called &lsquo;subatomic&rsquo; transactions, which cannot be fused with other
  5725. atomic transactions, and for which there is always created a new
  5726. proposal.
  5727. </p>
  5728. <p>However, code within <code>call-ensuring-atomicity</code> <i>&amp;c.</i> or
  5729. <code>call-atomically</code> <i>&amp;c.</i> should <em>not</em> explicitly commit the
  5730. current proposal; those operations above <em>automatically</em> commit
  5731. the current proposal when the atomic transaction is completed. (In
  5732. the case of <code>call-atomically</code> <i>&amp;c.</i>, this is when the procedure
  5733. passed returns; in the case of <code>call-ensuring-atomicity</code> <i>&amp;c.</i>,
  5734. this is when the outermost enclosing atomic transaction completes, or
  5735. the same as <code>call-atomically</code> if there was no enclosing atomic
  5736. transaction.) To explicitly commit the current proposal &mdash; for
  5737. example, to perform some particular action if the commit fails rather
  5738. than just to repeatedly retry the transaction, or to use operations
  5739. from the <a href="#Custom-thread-synchronization">customized thread
  5740. synchronization</a> facilities that commit the current proposal after
  5741. their regular function, or the operations on <a href="#Higher_002dlevel-synchronization">condition variables</a> that operate on the condition
  5742. variable and then commit the current proposal &mdash;, one must use the
  5743. <code>with-new-proposal</code> syntax as described below, not these
  5744. operations.
  5745. </p>
  5746. <span id="Logging-variants-of-Scheme-procedures"></span><h4 class="subsection">5.2.2 Logging variants of Scheme procedures</h4>
  5747. <span id="index-logging-operations-1"></span>
  5748. <span id="index-optimistic-concurrency-logging-operations-1"></span>
  5749. <dl>
  5750. <dt id="index-provisional_002dcar">procedure: <strong>provisional-car</strong> <em>pair --&gt; value</em></dt>
  5751. <dt id="index-provisional_002dcdr">procedure: <strong>provisional-cdr</strong> <em>pair --&gt; value</em></dt>
  5752. <dt id="index-provisional_002dset_002dcar_0021">procedure: <strong>provisional-set-car!</strong> <em>pair value --&gt; unspecified</em></dt>
  5753. <dt id="index-provisional_002dset_002dcdr_0021">procedure: <strong>provisional-set-cdr!</strong> <em>pair value --&gt; unspecified</em></dt>
  5754. <dt id="index-provisional_002dcell_002dref">procedure: <strong>provisional-cell-ref</strong> <em>cell --&gt; value</em></dt>
  5755. <dt id="index-provisional_002dcell_002dset_0021">procedure: <strong>provisional-cell-set!</strong> <em>cell value --&gt; unspecified</em></dt>
  5756. <dt id="index-provisional_002dvector_002dref">procedure: <strong>provisional-vector-ref</strong> <em>vector index --&gt; value</em></dt>
  5757. <dt id="index-provisional_002dvector_002dset_0021">procedure: <strong>provisional-vector-set!</strong> <em>vector index value --&gt; unspecified</em></dt>
  5758. <dt id="index-provisional_002dstring_002dref">procedure: <strong>provisional-string-ref</strong> <em>string index --&gt; char</em></dt>
  5759. <dt id="index-provisional_002dstring_002dset_0021">procedure: <strong>provisional-string-set!</strong> <em>string index value --&gt; unspecified</em></dt>
  5760. <dt id="index-provisional_002dbyte_002dvector_002dref">procedure: <strong>provisional-byte-vector-ref</strong> <em>byte-vector index --&gt; char</em></dt>
  5761. <dt id="index-provisional_002dbyte_002dvector_002dset_0021">procedure: <strong>provisional-byte-vector-set!</strong> <em>byte-vector index byte --&gt; unspecified</em></dt>
  5762. <dt id="index-attempt_002dcopy_002dbytes_0021">procedure: <strong>attempt-copy-bytes!</strong> <em>from fstart to tstart count --&gt; unspecified</em></dt>
  5763. <dd><p>These are variants of most basic Scheme memory accessors &amp; modifiers
  5764. that log in the current proposal, rather than performing the actual
  5765. memory access/modification. All of these do perform the actual memory
  5766. access/modification, however, if there is no current proposal in place
  5767. when they are called. <code>Attempt-copy-bytes!</code> copies a sequence of
  5768. <var>count</var> bytes from the byte vector or string <var>from</var>, starting
  5769. at the index <var>fstart</var>, to the byte vector or string <var>to</var>,
  5770. starting at the index <var>tstart</var>.
  5771. </p></dd></dl>
  5772. <span id="Synchronized-records"></span><h4 class="subsection">5.2.3 Synchronized records</h4>
  5773. <span id="index-optimistically-concurrent-record-types"></span>
  5774. <dl>
  5775. <dt id="index-define_002dsynchronized_002drecord_002dtype">syntax: <strong>define-synchronized-record-type</strong></dt>
  5776. <dd><div class="lisp">
  5777. <pre class="lisp">(define-synchronized-record-type <var>tag</var> <var>type-name</var>
  5778. (<var>constructor-name</var> <var>parameter-field-tag</var> &hellip;)
  5779. [(<var>sync-field-tag</var> &hellip;)]
  5780. <var>predicate-name</var>
  5781. (<var>field-tag</var> <var>accessor-name</var> [<var>modifier-name</var>])
  5782. &hellip;)</pre></div>
  5783. <p>This is exactly like <code>define-record-type</code> from the
  5784. <code>define-record-types</code> structure, except that the accessors &amp;
  5785. modifiers for each field in <var>sync-field-tag</var> &hellip; are defined to
  5786. be provisional, <i>i.e.</i> to log in the current proposal. If the list of
  5787. synchronized fields is absent, all of the fields are synchronized,
  5788. <i>i.e.</i> it is as if all were specified in that list.
  5789. </p></dd></dl>
  5790. <span id="index-define_002dsync_002drecord_002dtypes"></span>
  5791. <p>The <code>proposals</code> structure also exports
  5792. <code>define-record-discloser</code> (see <a href="#Records">Records</a>). Moreover, the
  5793. <code>define-sync-record-types</code> structure, too, exports
  5794. <code>define-synchronized-record-type</code>, though it does not export
  5795. <code>define-record-discloser</code>.
  5796. </p>
  5797. <span id="Optimistic-concurrency-example"></span><h4 class="subsection">5.2.4 Optimistic concurrency example</h4>
  5798. <p>Here is a basic example of using optimistic concurrency to ensure the
  5799. synchronization of memory. We first present a simple mechanism for
  5800. counting integers by maintaining internal state, which is expressed
  5801. easily with closures:
  5802. </p>
  5803. <div class="lisp">
  5804. <pre class="lisp">(define (make-counter value)
  5805. (lambda ()
  5806. (let ((v value))
  5807. (set! value (+ v 1))
  5808. v)))</pre></div>
  5809. <p>This has a problem: between obtaining the value of the closure&rsquo;s slot
  5810. for <code>value</code> and updating that slot, another thread might be given
  5811. control and modify the counter, producing unpredictable results in
  5812. threads in the middle of working with the counter. To remedy this, we
  5813. might add a mutual exclusion lock to counters to prevent threads from
  5814. simultaneously accessing the cell:
  5815. </p>
  5816. <div class="lisp">
  5817. <pre class="lisp">(define (make-counter value)
  5818. (let ((lock (make-lock)))
  5819. (lambda ()
  5820. (dynamic-wind
  5821. (lambda () (obtain-lock lock))
  5822. (lambda ()
  5823. (let ((v value))
  5824. (set! value (+ v 1))
  5825. v))
  5826. (lambda () (release-lock lock))))))</pre></div>
  5827. <p>This poses another problem, however. Suppose we wish to write an
  5828. atomic <code>(step-counters! <var>counter &hellip;</var>)</code> procedure that
  5829. increments each of the supplied counters by one; supplying a counter
  5830. <var>n</var> times should have the effect of incrementing it by <var>n</var>.
  5831. The na&iuml;ve definition of it is this:
  5832. </p>
  5833. <div class="lisp">
  5834. <pre class="lisp">(define (step-counters! . counters)
  5835. (for-each (lambda (counter) (counter))
  5836. counters))</pre></div>
  5837. <p>Obviously, though, this is not atomic, because each individual counter
  5838. is locked when it is used, but not the whole iteration across them.
  5839. To work around this, we might use an obfuscated control structure to
  5840. allow nesting the locking of counters:
  5841. </p>
  5842. <div class="lisp">
  5843. <pre class="lisp">(define (make-counter value)
  5844. (let ((lock (make-lock)))
  5845. (lambda args
  5846. (dynamic-wind
  5847. (lambda () (obtain-lock lock))
  5848. (lambda ()
  5849. (if (null? args)
  5850. (let ((v value))
  5851. (set! value (+ v 1))
  5852. v)
  5853. ((car args))))
  5854. (lambda () (release-lock lock))))))
  5855. (define (step-counters! . counters)
  5856. (let loop ((cs counters))
  5857. (if (null? cs)
  5858. (for-each (lambda (counter) (counter))
  5859. counters)
  5860. ((car cs) (lambda () (loop (cdr cs)))))))</pre></div>
  5861. <p>Aside from the obvious matter of the obfuscation of the control
  5862. structures used here, however, this has another problem: we cannot
  5863. step one counter multiple times atomically. Though different locks
  5864. can be nested, nesting is very dangerous, because accidentally
  5865. obtaining a lock that is already obtained can cause deadlock, and
  5866. there is no modular, transparent way to avoid this in the general
  5867. case.
  5868. </p>
  5869. <p>Instead, we can implement counters using optimistic concurrency to
  5870. synchronize the shared data. The state of counters is kept explicitly
  5871. in a <a href="#Cells">cell</a>, in order to use a provisional accessor &amp;
  5872. modifier, as is necessary to make use of optimistic concurrency, and
  5873. we surround with <code>call-ensuring-atomicity</code> any regions we wish to
  5874. be atomic:
  5875. </p>
  5876. <div class="lisp">
  5877. <pre class="lisp">(define (make-counter initial)
  5878. (let ((cell (make-cell initial)))
  5879. (lambda ()
  5880. (call-ensuring-atomicity
  5881. (lambda ()
  5882. (let ((value (provisional-cell-ref cell)))
  5883. (provisional-cell-set! cell (+ value 1))
  5884. value))))))
  5885. (define (step-counters! . counters)
  5886. (call-ensuring-atomicity!
  5887. (lambda ()
  5888. (for-each (lambda (counter) (counter))
  5889. counters))))</pre></div>
  5890. <p>This approach has a number of advantages:
  5891. </p>
  5892. <ul>
  5893. <li> The original control structure is preserved, only with
  5894. provisional operators for shared memory access that we explicitly wish
  5895. to be synchronized and with <code>call-ensuring-atomicity</code> wrapping
  5896. the portions of code that we explicitly want to be atomic.
  5897. </li><li> Composition of transactions is entirely transparent; it is
  5898. accomplished automatically simply by <code>call-ensuring-atomicity</code>.
  5899. </li><li> Transactions can be nested arbitrarily deeply, and there is no
  5900. problem of accidentally locking the same resource again at a deeper
  5901. nesting level to induce deadlock.
  5902. </li><li> No explicit mutual exclusion or blocking is necessary. Threads
  5903. proceed without heed to others, but do not actually write data to the
  5904. shared memory until its validity is ensured. There is no deadlock at
  5905. all.
  5906. </li></ul>
  5907. <span id="Low_002dlevel-optimistic-concurrency"></span><h4 class="subsection">5.2.5 Low-level optimistic concurrency</h4>
  5908. <p>Along with the higher-level operations described above, there are some
  5909. lower-level primitives for finer control over optimistic concurrency.
  5910. </p>
  5911. <span id="index-proposals-1"></span>
  5912. <dl>
  5913. <dt id="index-make_002dproposal">procedure: <strong>make-proposal</strong> <em>--&gt; proposal</em></dt>
  5914. <dt id="index-current_002dproposal">procedure: <strong>current-proposal</strong> <em>--&gt; proposal</em></dt>
  5915. <dt id="index-set_002dcurrent_002dproposal_0021">procedure: <strong>set-current-proposal!</strong> <em>proposal --&gt; unspecified</em></dt>
  5916. <dt id="index-remove_002dcurrent_002dproposal_0021">procedure: <strong>remove-current-proposal!</strong> <em>--&gt; unspecified</em></dt>
  5917. <dd><p><code>Make-proposal</code> creates a fresh proposal. <code>Current-proposal</code>
  5918. returns the current thread&rsquo;s proposal. <code>Set-current-proposal!</code>
  5919. sets the current thread&rsquo;s proposal to <var>proposal</var>.
  5920. <code>Remove-current-proposal!</code> sets the current thread&rsquo;s proposal to
  5921. <code>#f</code>.
  5922. </p></dd></dl>
  5923. <span id="index-committing-proposals"></span>
  5924. <span id="index-proposals_002c-committing"></span>
  5925. <dl>
  5926. <dt id="index-maybe_002dcommit">procedure: <strong>maybe-commit</strong> <em>--&gt; boolean</em></dt>
  5927. <dt id="index-invalidate_002dcurrent_002dproposal_0021">procedure: <strong>invalidate-current-proposal!</strong> <em>--&gt; unspecified</em></dt>
  5928. <dd><p><code>Maybe-commit</code> checks that the current thread&rsquo;s proposal is still
  5929. valid. If it is, the proposal&rsquo;s writes are committed, and
  5930. <code>maybe-commit</code> returns <code>#t</code>; if not, the current thread&rsquo;s
  5931. proposal is set to <code>#f</code> and <code>maybe-commit</code> returns <code>#f</code>.
  5932. <code>Invalidate-current-proposal!</code> causes an inconsistency in the
  5933. current proposal by caching a read and then directly writing to the
  5934. place that read was from.
  5935. </p></dd></dl>
  5936. <span id="index-installing-proposals"></span>
  5937. <span id="index-proposals_002c-installing"></span>
  5938. <dl>
  5939. <dt id="index-with_002dnew_002dproposal">syntax: <strong>with-new-proposal</strong> <em>(lose) body --&gt; values</em></dt>
  5940. <dd><p>Convenience for repeating a transaction. <code>With-new-proposal</code>
  5941. saves the current proposal and will reinstates it when everything is
  5942. finished. After saving the current proposal, it binds <var>lose</var> to a
  5943. nullary procedure that installs a fresh proposal and that evaluates
  5944. <var>body</var>; it then calls <var>lose</var>. Typically, the last thing, or
  5945. close to last thing, that <var>body</var> will do is attempt to commit the
  5946. current proposal, and, if that fails, call <var>lose</var> to retry.
  5947. <code>With-new-proposal</code> expands to a form that returns the values
  5948. that <var>body</var> returns.
  5949. </p>
  5950. <p>This <code>retry-at-most</code> example tries running the transaction of
  5951. <var>thunk</var>, and, if it fails to commit, retries at most <var>n</var>
  5952. times. If the transaction is successfully committed before <var>n</var>
  5953. repeated attempts, it returns true; otherwise, it returns false.
  5954. </p>
  5955. <div class="lisp">
  5956. <pre class="lisp">(define (retry-at-most n thunk)
  5957. (with-new-proposal (lose)
  5958. (thunk)
  5959. (cond ((maybe-commit) #t)
  5960. ((zero? n) #f)
  5961. (else (set! n (- n 1))
  5962. (lose)))))</pre></div>
  5963. </dd></dl>
  5964. <hr>
  5965. <span id="Higher_002dlevel-synchronization"></span><div class="header">
  5966. <p>
  5967. Next: <a href="#Concurrent-ML" accesskey="n" rel="next">Concurrent ML</a>, Previous: <a href="#Optimistic-concurrency" accesskey="p" rel="prev">Optimistic concurrency</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  5968. </div>
  5969. <span id="Higher_002dlevel-synchronization-1"></span><h3 class="section">5.3 Higher-level synchronization</h3>
  5970. <p>This section details the various higher-level thread synchronization
  5971. devices that Scheme48 provides.
  5972. </p>
  5973. <span id="Condition-variables"></span><h4 class="subsection">5.3.1 Condition variables</h4>
  5974. <span id="index-condvars"></span>
  5975. <p><em>Condition variables</em> are multiple-assignment cells on which
  5976. readers block. Threads may wait on condition variables; when some
  5977. other thread assigns a condition variable, all threads waiting on it
  5978. are revived. The <code>condvars</code> structure exports all of these
  5979. condition-variable-related names.
  5980. </p>
  5981. <p>In many concurrency systems, condition variables are operated in
  5982. conjunction with mutual exclusion locks. On the other hand, in
  5983. Scheme48, they are used in conjunction with its optimistic concurrency
  5984. devices.
  5985. </p>
  5986. <dl>
  5987. <dt id="index-make_002dcondvar">procedure: <strong>make-condvar</strong> <em>[id] --&gt; condvar</em></dt>
  5988. <dt id="index-condvar_003f">procedure: <strong>condvar?</strong> <em>object --&gt; boolean</em></dt>
  5989. <dd><p>Condition variable constructor &amp; disjoint type predicate. <var>Id</var> is
  5990. used purely for debugging.
  5991. </p></dd></dl>
  5992. <dl>
  5993. <dt id="index-maybe_002dcommit_002dand_002dwait_002dfor_002dcondvar">procedure: <strong>maybe-commit-and-wait-for-condvar</strong> <em>condvar --&gt; boolean</em></dt>
  5994. <dt id="index-maybe_002dcommit_002dand_002dset_002dcondvar_0021">procedure: <strong>maybe-commit-and-set-condvar!</strong> <em>condvar value --&gt; boolean</em></dt>
  5995. <dd><p><code>Maybe-commit-and-wait-for-condvar</code> attempts to commit the current
  5996. proposal. If the commit succeeded, the current thread is blocked on
  5997. <var>condvar</var>, and when the current thread is woken up,
  5998. <code>maybe-commit-and-wait-for-condvar</code> returns <code>#t</code>. If the
  5999. commit did not succeed, <code>maybe-commit-and-wait-for-condvar</code>
  6000. immediately returns <code>#f</code>. <code>Maybe-commit-and-set-condvar!</code>
  6001. attempts to commit the current proposal as well. If it succeeds, it is
  6002. noted that <var>condvar</var> has a value, <var>condvar</var>&rsquo;s value is set to
  6003. be <var>value</var>, and all threads waiting on <var>condvar</var> are woken up.
  6004. </p>
  6005. <p><strong>Note:</strong> Do not use these in atomic transactions as delimited by
  6006. <code>call-ensuring-atomicity</code> <i>&amp;c.</i>; see the note in <a href="#Optimistic-concurrency">Optimistic concurrency</a> on this matter for details.
  6007. </p></dd></dl>
  6008. <dl>
  6009. <dt id="index-condvar_002dhas_002dvalue_003f">procedure: <strong>condvar-has-value?</strong> <em>condvar --&gt; boolean</em></dt>
  6010. <dt id="index-condvar_002dvalue">procedure: <strong>condvar-value</strong> <em>condvar --&gt; value</em></dt>
  6011. <dd><p><code>Condvar-has-value?</code> tells whether or not <var>condvar</var> has been
  6012. assigned. If it has been assigned, <code>condvar-value</code> accesses the
  6013. value to which it was assigned.
  6014. </p></dd></dl>
  6015. <dl>
  6016. <dt id="index-set_002dcondvar_002dhas_002dvalue_003f_0021">procedure: <strong>set-condvar-has-value?!</strong> <em>condvar boolean --&gt; unspecified</em></dt>
  6017. <dt id="index-set_002dcondvar_002dvalue_0021">procedure: <strong>set-condvar-value!</strong> <em>condvar value --&gt; unspecified</em></dt>
  6018. <dd><p><code>Set-condvar-has-value?!</code> is used to tell whether or not
  6019. <var>condvar</var> is assigned. <code>Set-condvar-value!</code> sets
  6020. <var>condvar</var>&rsquo;s value.
  6021. </p>
  6022. <p><strong>Note:</strong> <code>Set-condvar-has-value?!</code> should be used only with
  6023. a second argument of <code>#f</code>. <code>Set-condvar-value!</code> is a very
  6024. dangerous routine, and <code>maybe-commit-and-set-condvar!</code> is what one
  6025. should almost always use, except if one wishes to clean up after
  6026. unassigning a condition variable.
  6027. </p></dd></dl>
  6028. <span id="Placeholders"></span><h4 class="subsection">5.3.2 Placeholders</h4>
  6029. <span id="index-placeholders"></span>
  6030. <p><em>Placeholders</em> are similar to condition variables, except that they
  6031. may be assigned only once; they are in general a much simpler mechanism
  6032. for throw-away temporary synchronization devices. They are provided by
  6033. the <code>placeholders</code> structure.
  6034. </p>
  6035. <dl>
  6036. <dt id="index-make_002dplaceholder">procedure: <strong>make-placeholder</strong> <em>[id] --&gt; placeholder</em></dt>
  6037. <dt id="index-placeholder_003f">procedure: <strong>placeholder?</strong> <em>object --&gt; boolean</em></dt>
  6038. <dd><p>Placeholder constructor &amp; disjoint type predicate. <var>Id</var> is used
  6039. only for debugging purposes when printing placeholders.
  6040. </p></dd></dl>
  6041. <dl>
  6042. <dt id="index-placeholder_002dvalue">procedure: <strong>placeholder-value</strong> <em>placeholder --&gt; value</em></dt>
  6043. <dt id="index-placeholder_002dset_0021">procedure: <strong>placeholder-set!</strong> <em>placeholder value --&gt; unspecified</em></dt>
  6044. <dd><p><code>Placeholder-value</code> blocks until <var>placeholder</var> is assigned, at
  6045. which point it returns the value assigned. <code>Placeholder-set!</code>
  6046. assigns <var>placeholder</var>&rsquo;s value to <var>value</var>, awakening all threads
  6047. waiting for <var>placeholder</var>. It is an error to assign a placeholder
  6048. with <code>placeholder-set!</code> that has already been assigned.
  6049. </p></dd></dl>
  6050. <span id="Value-pipes"></span><h4 class="subsection">5.3.3 Value pipes</h4>
  6051. <span id="index-thread-communication-channels_002c-asynchronous"></span>
  6052. <span id="index-asynchronous-thread-communication-channels"></span>
  6053. <p><em>Value pipes</em> are asynchronous communication pipes between threads.
  6054. The <code>value-pipes</code> structure exports these value pipe operations.
  6055. </p>
  6056. <dl>
  6057. <dt id="index-make_002dpipe">procedure: <strong>make-pipe</strong> <em>[size [id]] --&gt; value-pipe</em></dt>
  6058. <dt id="index-pipe_003f">procedure: <strong>pipe?</strong> <em>object --&gt; boolean</em></dt>
  6059. <dd><p><code>Make-pipe</code> is the value pipe constructor. <var>Size</var> is a limit
  6060. on the number of elements the pipe can hold at one time. <var>Id</var> is
  6061. used for debugging purposes only in printing pipes. <code>Pipe?</code> is
  6062. the disjoint type predicate for value pipes.
  6063. </p></dd></dl>
  6064. <dl>
  6065. <dt id="index-empty_002dpipe_003f">procedure: <strong>empty-pipe?</strong> <em>pipe --&gt; boolean</em></dt>
  6066. <dt id="index-empty_002dpipe_0021">procedure: <strong>empty-pipe!</strong> <em>pipe --&gt; unspecified</em></dt>
  6067. <dd><p><code>Empty-pipe?</code> returns <code>#t</code> if <var>pipe</var> has no elements in
  6068. it and <code>#f</code> if not. <code>Empty-pipe!</code> removes all elements from
  6069. <code>pipe</code>.
  6070. </p></dd></dl>
  6071. <dl>
  6072. <dt id="index-pipe_002dread_0021">procedure: <strong>pipe-read!</strong> <em>pipe --&gt; value</em></dt>
  6073. <dt id="index-pipe_002dmaybe_002dread_0021">procedure: <strong>pipe-maybe-read!</strong> <em>pipe --&gt; value or <code>#f</code></em></dt>
  6074. <dt id="index-pipe_002dmaybe_002dread_003f_0021">procedure: <strong>pipe-maybe-read?!</strong> <em>pipe --&gt; [boolean value]</em></dt>
  6075. <dd><p><code>Pipe-read!</code> reads a value from <var>pipe</var>, removing it from the
  6076. queue. It blocks if there are no elements available in the queue.
  6077. <code>Pipe-maybe-read!</code> attempts to read &amp; return a single value from
  6078. <var>pipe</var>; if no elements are available in its queue, it instead
  6079. returns <code>#f</code>. <code>Pipe-maybe-read?!</code> does similarly, but it
  6080. returns two values: a boolean, signifying whether or not a value was
  6081. read; and the value, or <code>#f</code> if no value was read.
  6082. <code>Pipe-maybe-read?!</code> is useful when <var>pipe</var> may contain the
  6083. value <code>#f</code>.
  6084. </p></dd></dl>
  6085. <dl>
  6086. <dt id="index-pipe_002dwrite_0021">procedure: <strong>pipe-write!</strong> <em>pipe value --&gt; unspecified</em></dt>
  6087. <dt id="index-pipe_002dpush_0021">procedure: <strong>pipe-push!</strong> <em>pipe value --&gt; unspecified</em></dt>
  6088. <dt id="index-pipe_002dmaybe_002dwrite_0021">procedure: <strong>pipe-maybe-write!</strong> <em>pipe value --&gt; boolean</em></dt>
  6089. <dd><p><code>Pipe-write!</code> attempts to add <var>value</var> to <var>pipe</var>&rsquo;s queue.
  6090. If <var>pipe</var>&rsquo;s maximum size, as passed to <code>make-pipe</code> when
  6091. constructing the pipe, is either <code>#f</code> or greater than the number
  6092. of elements in <var>pipe</var>&rsquo;s queue, <code>pipe-write!</code> will not block;
  6093. otherwise it will block until a space has been made available in the
  6094. pipe&rsquo;s queue by another thread reading from it. <code>Pipe-push!</code> does
  6095. similarly, but, in the case where the pipe is full, it pushes the first
  6096. element to be read out of the pipe. <code>Pipe-maybe-write!</code> is also
  6097. similar to <code>pipe-write!</code>, but it returns <code>#t</code> if the pipe was
  6098. not full, and it <em>immediately</em> returns <code>#f</code> if the pipe was
  6099. full.
  6100. </p></dd></dl>
  6101. <hr>
  6102. <span id="Concurrent-ML"></span><div class="header">
  6103. <p>
  6104. Next: <a href="#Pessimistic-concurrency" accesskey="n" rel="next">Pessimistic concurrency</a>, Previous: <a href="#Higher_002dlevel-synchronization" accesskey="p" rel="prev">Higher-level synchronization</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6105. </div>
  6106. <span id="Concurrent-ML-1"></span><h3 class="section">5.4 Concurrent ML</h3>
  6107. <span id="index-rendezvous"></span>
  6108. <span id="index-event"></span>
  6109. <p>Scheme48 provides a high-level event synchronization facility based on
  6110. on Reppy&rsquo;s <em>Concurrent ML</em> [Reppy 99]. The primary object in CML
  6111. is the <em>rendezvous</em><a id="DOCF20" href="#FOOT20"><sup>20</sup></a>, which represents a point of
  6112. process synchronization. A rich library for manipulating rendezvous
  6113. and several useful, high-level synchronization abstractions are built
  6114. atop rendezvous.
  6115. </p>
  6116. <table class="menu" border="0" cellspacing="0">
  6117. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  6118. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Rendezvous-concepts" accesskey="1">Rendezvous concepts</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6119. </td></tr>
  6120. <tr><td align="left" valign="top">&bull; <a href="#Rendezvous-base-combinators" accesskey="2">Rendezvous base combinators</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6121. </td></tr>
  6122. <tr><td align="left" valign="top">&bull; <a href="#Rendezvous-communication-channels" accesskey="3">Rendezvous communication channels</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6123. </td></tr>
  6124. <tr><td align="left" valign="top">&bull; <a href="#Rendezvous_002dsynchronized-cells" accesskey="4">Rendezvous-synchronized cells</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6125. </td></tr>
  6126. <tr><td align="left" valign="top">&bull; <a href="#Concurrent-ML-to-Scheme-correspondence" accesskey="5">Concurrent ML to Scheme correspondence</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6127. </td></tr>
  6128. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  6129. </pre></th></tr></table>
  6130. <hr>
  6131. <span id="Rendezvous-concepts"></span><div class="header">
  6132. <p>
  6133. Next: <a href="#Rendezvous-base-combinators" accesskey="n" rel="next">Rendezvous base combinators</a>, Up: <a href="#Concurrent-ML" accesskey="u" rel="up">Concurrent ML</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6134. </div>
  6135. <span id="Rendezvous-concepts-1"></span><h4 class="subsection">5.4.1 Rendezvous concepts</h4>
  6136. <p>When access to a resource must be synchronized between multiple
  6137. processes, for example to transmit information from one process to
  6138. another over some sort of communication channel, the resource provides
  6139. a <em>rendezvous</em> to accomplish this, which represents a potential
  6140. point of synchronization between processes. The use of rendezvous
  6141. occurs in two stages: <em>synchronization</em> and <em>enablement</em>. Note
  6142. that creation of rendezvous is an unrelated matter, and it does not (or
  6143. should not) itself result in any communication or synchronization
  6144. between processes.
  6145. </p>
  6146. <p>When a process requires an external resource for which it has a
  6147. rendezvous, it <em>synchronizes</em> that rendezvous. This first polls
  6148. whether the resource is immediately available; if so, the rendezvous is
  6149. already <em>enabled</em>, and a value from the resource is immediately
  6150. produced from the synchronization. Otherwise, the synchronization of
  6151. the rendezvous is recorded somehow externally, and the process is
  6152. blocked until the rendezvous is enabled by an external entity, usually
  6153. one that made the resource available. Rendezvous may be re&uuml;sed
  6154. arbitrarily many times; the value produced by an enabled, synchronized
  6155. rendezvous is not cached. Note, however, that the construction of a
  6156. rendezvous does not (or should not) have destructive effect, such as
  6157. sending a message to a remote server or locking a mutex; the only
  6158. destructive effects should be incurred at synchronization or enablement
  6159. time. For effecting initialization prior to the synchronization of a
  6160. rendezvous, see below on <em>delayed rendezvous</em>.
  6161. </p>
  6162. <p>Rendezvous may consist of multiple rendezvous choices, any of which may
  6163. be taken when enabled but only one of which actually is. If, when a
  6164. composite rendezvous is initially synchronized, several components are
  6165. immediately enabled, each one has a particular numeric priority which
  6166. is used to choose among them. If several are tied for the highest
  6167. priority, a random one is chosen. If none is enabled when the choice
  6168. is synchronized, however, the synchronizer process is suspended until
  6169. the first one is enabled and revives the process. When this happens,
  6170. any or all of the other rendezvous components may receive a negative
  6171. acknowledgement; see below on <em>delayed rendezvous with negative
  6172. acknowledgement</em>.
  6173. </p>
  6174. <p>A rendezvous may also be a rendezvous <em>wrapped</em> with a procedure,
  6175. which means that, when the internal rendezvous becomes enabled, the
  6176. wrapper one also becomes enabled, and the value it produces is the
  6177. result of applying its procedure to the value that the internal
  6178. rendezvous produced. This allows the easy composition of complex
  6179. rendezvous from simpler ones, and it also provides a simple mechanism
  6180. for performing different actions following the enablement of different
  6181. rendezvous, rather than conflating the results of several possible
  6182. rendezvous choices into one value and operating on that (though this,
  6183. too, can be a useful operation).
  6184. </p>
  6185. <span id="Delayed-rendezvous"></span><h4 class="subsection">5.4.2 Delayed rendezvous</h4>
  6186. <p>A rendezvous may be <em>delayed</em>, which means that its synchronization
  6187. requires some processing that could not or would not be reasonable to
  6188. perform at its construction. It consists of a nullary procedure to
  6189. generate the actual rendezvous to synchronize when the delayed
  6190. rendezvous is itself synchronized.
  6191. </p>
  6192. <p>For example, a rendezvous for generating unique identifiers, by sending
  6193. a request over a network to some server and waiting for a response,
  6194. could not be constructed by waiting for a response from the server,
  6195. because that may block, which should not occur until synchronization.
  6196. It also could not be constructed by first sending a request to the
  6197. server at all, because that would have a destructive effect, which is
  6198. not meant to happen when creating a rendezvous, only when synchronizing
  6199. or enabling one.
  6200. </p>
  6201. <p>Instead, the unique identifier rendezvous would be implemented as a
  6202. delayed rendezvous that, when synchronized, would send a request to
  6203. the server and generate a rendezvous for the actual synchronization
  6204. that would become enabled on receiving the server&rsquo;s response.
  6205. </p>
  6206. <span id="Negative-acknowledgements"></span><h4 class="subsubsection">5.4.2.1 Negative acknowledgements</h4>
  6207. <p>Delayed rendezvous may also receive negative acknowledgements. Rather
  6208. than a simple nullary procedure being used to generate the actual
  6209. rendezvous for synchronization, the procedure is unary, and it is
  6210. passed a <em>negative acknowledgement rendezvous</em>, or <em>nack</em> for
  6211. short. This nack is enabled if the actual rendezvous was not chosen
  6212. among a composite group of rendezvous being synchronized. This allows
  6213. not only delaying initialization of rendezvous until necessary but also
  6214. aborting or rescinding initialized transactions if their rendezvous are
  6215. unchosen and therefore unused.
  6216. </p>
  6217. <p>For example, a complex database query might be the object of some
  6218. rendezvous, but it is pointless to continue constructing the result if
  6219. that rendezvous is not chosen. A nack can be used to prematurely abort
  6220. the query to the database if another rendezvous was chosen in the stead
  6221. of that for the database query.
  6222. </p>
  6223. <hr>
  6224. <span id="Rendezvous-base-combinators"></span><div class="header">
  6225. <p>
  6226. Next: <a href="#Rendezvous-communication-channels" accesskey="n" rel="next">Rendezvous communication channels</a>, Previous: <a href="#Rendezvous-concepts" accesskey="p" rel="prev">Rendezvous concepts</a>, Up: <a href="#Concurrent-ML" accesskey="u" rel="up">Concurrent ML</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6227. </div>
  6228. <span id="Rendezvous-combinators"></span><h4 class="subsection">5.4.3 Rendezvous combinators</h4>
  6229. <span id="index-rendezvous-1"></span>
  6230. <p>The <code>rendezvous</code> structure exports several basic rendezvous
  6231. combinators.
  6232. </p>
  6233. <dl>
  6234. <dt id="index-never_002drv">Constant: <strong>never-rv</strong> <em>--&gt; rendezvous</em></dt>
  6235. <dd><p>A rendezvous that is never enabled. If synchronized, this will block
  6236. the synchronizing thread indefinitely.
  6237. </p></dd></dl>
  6238. <dl>
  6239. <dt id="index-always_002drv">procedure: <strong>always-rv</strong> <em>value --&gt; rendezvous</em></dt>
  6240. <dd><p>Returns a rendezvous that is always enabled with the given value. This
  6241. rendezvous will never block the synchronizing thread.
  6242. </p></dd></dl>
  6243. <dl>
  6244. <dt id="index-guard">procedure: <strong>guard</strong> <em>rv-generator --&gt; rendezvous</em></dt>
  6245. <dt id="index-with_002dnack">procedure: <strong>with-nack</strong> <em>rv-generator --&gt; rendezvous</em></dt>
  6246. <dd><p><code>Guard</code> returns a delayed rendezvous, generated by the given
  6247. procedure <var>rv-generator</var>, which is passed zero arguments whenever
  6248. the resultant rendezvous is synchronized. <code>With-nack</code> returns a
  6249. delayed rendezvous for which a negative acknowledgement rendezvous is
  6250. constructed. If the resultant rendezvous is synchronized as a part of
  6251. a composite rendezvous, the procedure <code>rv-generator</code> is passed a
  6252. nack for the synchronization, and it returns the rendezvous to actually
  6253. synchronize. If the delayed rendezvous was synchronized as part of a
  6254. composite group of rendezvous, and another rendezvous among that group
  6255. is enabled and chosen first, the nack is enabled.
  6256. </p></dd></dl>
  6257. <dl>
  6258. <dt id="index-choose">procedure: <strong>choose</strong> <em>rendezvous &hellip; --&gt; composite-rendezvous</em></dt>
  6259. <dd><p>Returns a rendezvous that, when synchronized, synchronizes all of the
  6260. given components, and chooses only the first one to become enabled, or
  6261. the highest priority one if there are any that are already enabled. If
  6262. any of the rendezvous that were not chosen when the composite became
  6263. enabled were delayed rendezvous with nacks, their nacks are enabled.
  6264. </p></dd></dl>
  6265. <dl>
  6266. <dt id="index-wrap">procedure: <strong>wrap</strong> <em>rendezvous procedure --&gt; rendezvous</em></dt>
  6267. <dd><p>Returns a rendezvous equivalent to <var>rendezvous</var> but wrapped with
  6268. <var>procedure</var>, so that, when the resultant rendezvous is
  6269. synchronized, <var>rendezvous</var> is transitively synchronized, and when
  6270. <var>rendezvous</var> is enabled, the resultant rendezvous is also enabled,
  6271. with the value that <var>procedure</var> returns when passed the value
  6272. produced by <var>rendezvous</var>.
  6273. </p>
  6274. <div class="lisp">
  6275. <pre class="lisp">(sync (wrap (always-rv 4)
  6276. (lambda (x) (* x x)))) --&gt; 16</pre></div>
  6277. </dd></dl>
  6278. <dl>
  6279. <dt id="index-sync">procedure: <strong>sync</strong> <em>rendezvous --&gt; value (may block)</em></dt>
  6280. <dt id="index-select">procedure: <strong>select</strong> <em>rendezvous &hellip; --&gt; value (may block)</em></dt>
  6281. <dd><p><code>Sync</code> and <code>select</code> synchronize rendezvous. <code>Sync</code>
  6282. synchronizes a single one; <code>select</code> synchronizes any from the
  6283. given set of them. <code>Select</code> is equivalent to <code>(sync (apply
  6284. choose <var>rendezvous &hellip;</var>))</code>, but it may be implemented more
  6285. efficiently.
  6286. </p></dd></dl>
  6287. <span id="Timing-rendezvous"></span><h4 class="subsubsection">5.4.3.1 Timing rendezvous</h4>
  6288. <span id="index-time"></span>
  6289. <span id="index-rendezvous_002dtime"></span>
  6290. <p>The <code>rendezvous-time</code> structure exports two constructors for
  6291. rendezvous that become enabled only at a specific time or after a delay
  6292. in time.
  6293. </p>
  6294. <dl>
  6295. <dt id="index-at_002dreal_002dtime_002drv">procedure: <strong>at-real-time-rv</strong> <em>milliseconds --&gt; rendezvous</em></dt>
  6296. <dt id="index-after_002dtime_002drv">procedure: <strong>after-time-rv</strong> <em>milliseconds --&gt; rendezvous</em></dt>
  6297. <dd><p><code>At-real-time-rv</code> returns a rendezvous that becomes enabled at the
  6298. time <var>milliseconds</var> relative to the start of the Scheme program.
  6299. <code>After-time-rv</code> returns a rendezvous that becomes enabled at least
  6300. <var>milliseconds</var> after synchronization (<em>not</em> construction).
  6301. </p></dd></dl>
  6302. <hr>
  6303. <span id="Rendezvous-communication-channels"></span><div class="header">
  6304. <p>
  6305. Next: <a href="#Rendezvous_002dsynchronized-cells" accesskey="n" rel="next">Rendezvous-synchronized cells</a>, Previous: <a href="#Rendezvous-base-combinators" accesskey="p" rel="prev">Rendezvous base combinators</a>, Up: <a href="#Concurrent-ML" accesskey="u" rel="up">Concurrent ML</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6306. </div>
  6307. <span id="Rendezvous-communication-channels-1"></span><h4 class="subsection">5.4.4 Rendezvous communication channels</h4>
  6308. <span id="Synchronous-channels"></span><h4 class="subsubsection">5.4.4.1 Synchronous channels</h4>
  6309. <span id="index-channels-1"></span>
  6310. <span id="index-synchronous-channels"></span>
  6311. <span id="index-message_002dpassing"></span>
  6312. <span id="index-rendezvous_002dchannels"></span>
  6313. <p>The <code>rendezvous-channels</code> structure provides a facility for
  6314. <em>synchronous channels</em>: channels for communication between threads
  6315. such that any receiver blocks until another thread sends a message, or
  6316. any sender blocks until another thread receives the sent message. In
  6317. CML, synchronous channels are also called merely &lsquo;channels.&rsquo;
  6318. </p>
  6319. <dl>
  6320. <dt id="index-make_002dchannel">procedure: <strong>make-channel</strong> <em>--&gt; channel</em></dt>
  6321. <dt id="index-channel_003f-1">procedure: <strong>channel?</strong> <em>object --&gt; boolean</em></dt>
  6322. <dd><p><code>Make-channel</code> creates and returns a new channel. <code>Channel?</code>
  6323. is the disjoint type predicate for channels.
  6324. </p></dd></dl>
  6325. <dl>
  6326. <dt id="index-send_002drv">procedure: <strong>send-rv</strong> <em>channel message --&gt; rendezvous</em></dt>
  6327. <dt id="index-send">procedure: <strong>send</strong> <em>channel message --&gt; unspecified (may block)</em></dt>
  6328. <dd><p><code>Send-rv</code> returns a rendezvous that, when synchronized, becomes
  6329. enabled when a reception rendezvous for <var>channel</var> is synchronized,
  6330. at which point that reception rendezvous is enabled with a value of
  6331. <var>message</var>. When enabled, the rendezvous returned by <code>send-rv</code>
  6332. produces an unspecified value. <code>Send</code> is like <code>send-rv</code>, but
  6333. it has the effect of immediately synchronizing the rendezvous, so it
  6334. therefore may block, and it does not return a rendezvous; <code>(send
  6335. <var>channel</var> <var>message</var>)</code> is equivalent to <code>(sync (send-rv
  6336. <var>channel</var> <var>message</var>))</code>.
  6337. </p></dd></dl>
  6338. <dl>
  6339. <dt id="index-receive_002drv">procedure: <strong>receive-rv</strong> <em>channel --&gt; rendezvous</em></dt>
  6340. <dt id="index-receive-1">procedure: <strong>receive</strong> <em>channel --&gt; value (may block)</em></dt>
  6341. <dd><p><code>Receive-rv</code> returns a rendezvous that, when synchronized, and
  6342. when a sender rendezvous for <var>channel</var> with some message is
  6343. synchronized, becomes enabled with that message, at which point the
  6344. sender rendezvous is enabled with an unspecified value. <code>Receive</code>
  6345. is like <code>receive-rv</code>, but it has the effect of immediately
  6346. synchronizing the reception rendezvous, so it therefore may block, and
  6347. it does not return the rendezvous but rather the message that was sent;
  6348. <code>(receive <var>channel</var>)</code> is equivalent to <code>(sync (receive-rv
  6349. <var>channel</var>))</code>.
  6350. </p></dd></dl>
  6351. <span id="Asynchronous-channels"></span><h4 class="subsubsection">5.4.4.2 Asynchronous channels</h4>
  6352. <span id="index-channels-2"></span>
  6353. <span id="index-asynchronous-channels"></span>
  6354. <span id="index-message_002dpassing-1"></span>
  6355. <span id="index-rendezvous_002dasync_002dchannels"></span>
  6356. <p>The <code>rendezvous-async-channels</code> provides an <em>asynchronous
  6357. channel</em><a id="DOCF21" href="#FOOT21"><sup>21</sup></a>
  6358. facility. Like synchronous channels, any attempts to read from an
  6359. asynchronous channel will block if there are no messages waiting to be
  6360. read. Unlike synchronous channels, however, sending a message will
  6361. never block. Instead, a queue of messages or a queue of recipients is
  6362. maintained: if a message is sent and there is a waiting recipient, the
  6363. message is delivered to that recipient; otherwise it is added to the
  6364. queue of messages. If a thread attempts to receive a message from an
  6365. asynchronous channel and there is a pending message, it receives that
  6366. message; otherwise it adds itself to the list of waiting recipients and
  6367. then blocks.
  6368. </p>
  6369. <p><strong>Note:</strong> Operations on synchronous channels from the structure
  6370. <code>rendezvous-channels</code> do not work on asynchronous channels.
  6371. </p>
  6372. <dl>
  6373. <dt id="index-make_002dasync_002dchannel">procedure: <strong>make-async-channel</strong> <em>--&gt; async-channel</em></dt>
  6374. <dt id="index-async_002dchannel_003f">procedure: <strong>async-channel?</strong> <em>obj --&gt; boolean</em></dt>
  6375. <dd><p><code>Make-async-channel</code> creates and returns an asynchronous channel.
  6376. <code>Async-channel?</code> is the disjoint type predicate for asynchronous
  6377. channels.
  6378. </p></dd></dl>
  6379. <dl>
  6380. <dt id="index-receive_002dasync_002drv">procedure: <strong>receive-async-rv</strong> <em>channel --&gt; rendezvous</em></dt>
  6381. <dt id="index-receive_002dasync">procedure: <strong>receive-async</strong> <em>channel --&gt; value (may block)</em></dt>
  6382. <dd><p><code>Receive-async-rv</code> returns a rendezvous that, when synchronized,
  6383. becomes enabled when a message is available in <var>channel</var>&rsquo;s queue of
  6384. messages. <code>Receive-async</code> has the effect of immediately
  6385. synchronizing such a rendezvous and, when the rendezvous becomes
  6386. enabled, returning the value itself, rather than the rendezvous;
  6387. <code>(receive-async <var>channel</var>)</code> is equivalent to <code>(sync
  6388. (receive-async-rv <var>channel</var>))</code>.
  6389. </p></dd></dl>
  6390. <dl>
  6391. <dt id="index-send_002dasync">procedure: <strong>send-async</strong> <em>channel message --&gt; unspecified</em></dt>
  6392. <dd><p>Sends a message to the asynchronous channel <var>channel</var>. Unlike the
  6393. synchronous channel <code>send</code> operation, this procedure never blocks
  6394. arbitrarily long.<a id="DOCF22" href="#FOOT22"><sup>22</sup></a> There is, therefore,
  6395. no need for a <code>send-async-rv</code> like the <code>send-rv</code> for
  6396. synchronous channels. If there is a waiting message recipient, the
  6397. message is delivered to that recipient; otherwise, it is added to the
  6398. channel&rsquo;s message queue.
  6399. </p></dd></dl>
  6400. <hr>
  6401. <span id="Rendezvous_002dsynchronized-cells"></span><div class="header">
  6402. <p>
  6403. Next: <a href="#Concurrent-ML-to-Scheme-correspondence" accesskey="n" rel="next">Concurrent ML to Scheme correspondence</a>, Previous: <a href="#Rendezvous-communication-channels" accesskey="p" rel="prev">Rendezvous communication channels</a>, Up: <a href="#Concurrent-ML" accesskey="u" rel="up">Concurrent ML</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6404. </div>
  6405. <span id="Rendezvous_002dsynchronized-cells-1"></span><h4 class="subsection">5.4.5 Rendezvous-synchronized cells</h4>
  6406. <span id="Placeholders_003a-single_002dassignment-cells"></span><h4 class="subsubsection">5.4.5.1 Placeholders: single-assignment cells</h4>
  6407. <span id="index-rendezvous_002dplaceholders"></span>
  6408. <p><em>Placeholders</em><a id="DOCF23" href="#FOOT23"><sup>23</sup></a> are single-assignment cells on which
  6409. readers block until they are assigned.
  6410. </p>
  6411. <p><strong>Note:</strong> These placeholders are disjoint from and incompatible
  6412. with the placeholder mechanism provided in the <code>placeholders</code>
  6413. structure, and attempts to apply operations on one to values of the
  6414. other are errors.
  6415. </p>
  6416. <dl>
  6417. <dt id="index-make_002dplaceholder-1">procedure: <strong>make-placeholder</strong> <em>[id] --&gt; empty placeholder</em></dt>
  6418. <dt id="index-placeholder_003f-1">procedure: <strong>placeholder?</strong> <em>object --&gt; boolean</em></dt>
  6419. <dd><p><code>Make-placeholder</code> creates and returns a new, empty placeholder.
  6420. <var>Id</var> is used only for debugging purposes; it is included in the
  6421. printed representation of the placeholder. <code>Placeholder?</code> is the
  6422. disjoint type predicate for placeholders.
  6423. </p></dd></dl>
  6424. <dl>
  6425. <dt id="index-placeholder_002dvalue_002drv">procedure: <strong>placeholder-value-rv</strong> <em>placeholder --&gt; rendezvous</em></dt>
  6426. <dt id="index-placeholder_002dvalue-1">procedure: <strong>placeholder-value</strong> <em>placeholder --&gt; value (may block)</em></dt>
  6427. <dd><p><code>Placeholder-value-rv</code> returns a rendezvous that, when
  6428. synchronized, becomes enabled when <var>placeholder</var> has a value, with
  6429. that value. <code>Placeholder-value</code> has the effect of immediately
  6430. synchronizing such a rendezvous, and it returns the value directly, but
  6431. possibly after blocking.
  6432. </p></dd></dl>
  6433. <dl>
  6434. <dt id="index-placeholder_002dset_0021-1">procedure: <strong>placeholder-set!</strong> <em>placeholder value --&gt; unspecified</em></dt>
  6435. <dd><p>Sets <var>placeholder</var>&rsquo;s value to be <var>value</var>, and enables all
  6436. rendezvous for <var>placeholder</var>&rsquo;s value with that value. It is an
  6437. error if <var>placeholder</var> has already been assigned.
  6438. </p></dd></dl>
  6439. <span id="Jars_003a-multiple_002dassignment-cells"></span><h4 class="subsubsection">5.4.5.2 Jars: multiple-assignment cells</h4>
  6440. <span id="index-rendezvous_002djars"></span>
  6441. <p><em>Jars</em><a id="DOCF24" href="#FOOT24"><sup>24</sup></a> are
  6442. multiple-assignment cells on which readers block. Reading from a full
  6443. jar has the effect of emptying it, enabling the possibility of
  6444. subsequent assignment, unlike placeholders; and jars may be assigned
  6445. multiple times, but, like placeholders, only jars that are empty may be
  6446. assigned.
  6447. </p>
  6448. <dl>
  6449. <dt id="index-make_002djar">procedure: <strong>make-jar</strong> <em>[id] --&gt; empty jar</em></dt>
  6450. <dt id="index-jar_003f">procedure: <strong>jar?</strong> <em>object --&gt; boolean</em></dt>
  6451. <dd><p><code>Make-jar</code> creates and returns a new, empty jar. <var>Id</var> is used
  6452. only for debugging purposes; it is included in the printed
  6453. representation of the jar. <code>Jar?</code> is the disjoint type predicate
  6454. for jars.
  6455. </p></dd></dl>
  6456. <dl>
  6457. <dt id="index-jar_002dtake_002drv">procedure: <strong>jar-take-rv</strong> <em>jar --&gt; rendezvous</em></dt>
  6458. <dt id="index-jar_002dtake">procedure: <strong>jar-take</strong> <em>jar --&gt; value (may block)</em></dt>
  6459. <dd><p><code>Jar-take-rv</code> returns a rendezvous that, when synchronized,
  6460. becomes enabled when <var>jar</var> has a value, which is what value the
  6461. rendezvous becomes enabled with; when that rendezvous is enabled, it
  6462. also removes the value from <var>jar</var>, putting the jar into an empty
  6463. state. <code>Jar-take</code> has the effect of synchronizing such a
  6464. rendezvous, may block because of that, and returns the value of the jar
  6465. directly, not a rendezvous.
  6466. </p></dd></dl>
  6467. <dl>
  6468. <dt id="index-jar_002dput_0021">procedure: <strong>jar-put!</strong> <em>jar value --&gt; unspecified</em></dt>
  6469. <dd><p><code>Jar-put!</code> puts <var>value</var> into the empty jar <var>jar</var>. If any
  6470. taker rendezvous are waiting, the first is enabled with the value, and
  6471. the jar is returned to its empty state; otherwise, the jar is put in
  6472. the full state. <code>Jar-put!</code> is an error if applied to a full jar.
  6473. </p></dd></dl>
  6474. <hr>
  6475. <span id="Concurrent-ML-to-Scheme-correspondence"></span><div class="header">
  6476. <p>
  6477. Previous: <a href="#Rendezvous_002dsynchronized-cells" accesskey="p" rel="prev">Rendezvous-synchronized cells</a>, Up: <a href="#Concurrent-ML" accesskey="u" rel="up">Concurrent ML</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6478. </div>
  6479. <span id="Concurrent-ML-to-Scheme-correspondence-1"></span><h4 class="subsection">5.4.6 Concurrent ML to Scheme correspondence</h4>
  6480. <table>
  6481. <tr><td>CML name</td><td>Scheme name</td></tr>
  6482. <tr><td>structure <code>CML</code></td><td>structure <code>threads</code></td></tr>
  6483. <tr><td><code>version</code></td><td>(no equivalent)</td></tr>
  6484. <tr><td><code>banner</code></td><td>(no equivalent)</td></tr>
  6485. <tr><td><code>spawnc</code></td><td>(no equivalent; use <code>spawn</code> and <code>lambda</code>)</td></tr>
  6486. <tr><td><code>spawn</code></td><td><code>spawn</code></td></tr>
  6487. <tr><td><code>yield</code></td><td><code>relinquish-timeslice</code></td></tr>
  6488. <tr><td><code>exit</code></td><td><code>terminate-current-thread</code></td></tr>
  6489. <tr><td><code>getTid</code></td><td><code>current-thread</code></td></tr>
  6490. <tr><td><code>sameTid</code></td><td><code>eq?</code> (R5RS)</td></tr>
  6491. <tr><td><code>tidToString</code></td><td>(no equivalent; use the writer)</td></tr>
  6492. <tr><td></td><td>structure <code>threads-internal</code></td></tr>
  6493. <tr><td><code>hashTid</code></td><td><code>thread-uid</code></td></tr>
  6494. <tr><td></td><td>structure <code>rendezvous</code></td></tr>
  6495. <tr><td><code>wrap</code></td><td><code>wrap</code></td></tr>
  6496. <tr><td><code>guard</code></td><td><code>guard</code></td></tr>
  6497. <tr><td><code>withNack</code></td><td><code>with-nack</code></td></tr>
  6498. <tr><td><code>choose</code></td><td><code>choose</code></td></tr>
  6499. <tr><td><code>sync</code></td><td><code>sync</code></td></tr>
  6500. <tr><td><code>select</code></td><td><code>select</code></td></tr>
  6501. <tr><td><code>never</code></td><td><code>never-rv</code></td></tr>
  6502. <tr><td><code>alwaysEvt</code></td><td><code>always-rv</code></td></tr>
  6503. <tr><td><code>joinEvt</code></td><td>(no equivalent)</td></tr>
  6504. <tr><td></td><td>structure <code>rendezvous-channels</code></td></tr>
  6505. <tr><td><code>channel</code></td><td><code>make-channel</code></td></tr>
  6506. <tr><td><code>sameChannel</code></td><td><code>eq?</code> (R5RS)</td></tr>
  6507. <tr><td><code>send</code></td><td><code>send</code></td></tr>
  6508. <tr><td><code>recv</code></td><td><code>receive</code></td></tr>
  6509. <tr><td><code>sendEvt</code></td><td><code>send-rv</code></td></tr>
  6510. <tr><td><code>recvEvt</code></td><td><code>receive-rv</code></td></tr>
  6511. <tr><td><code>sendPoll</code></td><td>(no equivalent)</td></tr>
  6512. <tr><td><code>recvPoll</code></td><td>(no equivalent)</td></tr>
  6513. <tr><td></td><td>structure <code>rendezvous-time</code></td></tr>
  6514. <tr><td><code>timeOutEvt</code></td><td><code>after-time-rv</code></td></tr>
  6515. <tr><td><code>atTimeEvt</code></td><td><code>at-real-time-rv</code></td></tr>
  6516. <tr><td>structure <code>SyncVar</code></td><td>structure <code>rendezvous-placeholders</code></td></tr>
  6517. <tr><td>exception <code>Put</code></td><td>(no equivalent)</td></tr>
  6518. <tr><td><code>iVar</code></td><td><code>make-placeholder</code></td></tr>
  6519. <tr><td><code>iPut</code></td><td><code>placeholder-set!</code></td></tr>
  6520. <tr><td><code>iGet</code></td><td><code>placeholder-value</code></td></tr>
  6521. <tr><td><code>iGetEvt</code></td><td><code>placeholder-value-rv</code></td></tr>
  6522. <tr><td><code>iGetPoll</code></td><td>(no equivalent)</td></tr>
  6523. <tr><td><code>sameIVar</code></td><td><code>eq?</code> (R5RS)</td></tr>
  6524. <tr><td></td><td>structure <code>jars</code></td></tr>
  6525. <tr><td><code>mVar</code></td><td><code>make-jar</code></td></tr>
  6526. <tr><td><code>mVarInit</code></td><td>(no equivalent)</td></tr>
  6527. <tr><td><code>mPut</code></td><td><code>jar-put!</code></td></tr>
  6528. <tr><td><code>mTake</code></td><td><code>jar-take</code></td></tr>
  6529. <tr><td><code>mTakeEvt</code></td><td><code>jar-take-rv</code></td></tr>
  6530. <tr><td><code>mGet</code></td><td>(no equivalent)</td></tr>
  6531. <tr><td><code>mGetEvt</code></td><td>(no equivalent)</td></tr>
  6532. <tr><td><code>mTakePoll</code></td><td>(no equivalent)</td></tr>
  6533. <tr><td><code>mGetPoll</code></td><td>(no equivalent)</td></tr>
  6534. <tr><td><code>mSwap</code></td><td>(no equivalent)</td></tr>
  6535. <tr><td><code>mSwapEvt</code></td><td>(no equivalent)</td></tr>
  6536. <tr><td><code>sameMVar</code></td><td><code>eq?</code> (R5RS)</td></tr>
  6537. <tr><td>structure <code>Mailbox</code></td><td>structure <code>rendezvous-async-channels</code></td></tr>
  6538. <tr><td><code>mailbox</code></td><td><code>make-async-channel</code></td></tr>
  6539. <tr><td><code>sameMailbox</code></td><td><code>eq?</code> (R5RS)</td></tr>
  6540. <tr><td><code>send</code></td><td><code>send-async</code></td></tr>
  6541. <tr><td><code>recv</code></td><td><code>receive-async</code></td></tr>
  6542. <tr><td><code>recvEvt</code></td><td><code>receive-async-rv</code></td></tr>
  6543. <tr><td><code>recvPoll</code></td><td>(no equivalent)</td></tr>
  6544. </table>
  6545. <hr>
  6546. <span id="Pessimistic-concurrency"></span><div class="header">
  6547. <p>
  6548. Next: <a href="#Custom-thread-synchronization" accesskey="n" rel="next">Custom thread synchronization</a>, Previous: <a href="#Concurrent-ML" accesskey="p" rel="prev">Concurrent ML</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6549. </div>
  6550. <span id="Pessimistic-concurrency-1"></span><h3 class="section">5.5 Pessimistic concurrency</h3>
  6551. <span id="index-mutual-exclusion"></span>
  6552. <span id="index-mutex-locks"></span>
  6553. <span id="index-locks-for-mutual-exclusion"></span>
  6554. <p>While Scheme48&rsquo;s primitive thread synchronization mechanisms revolve
  6555. around optimistic concurrency, Scheme48 still provides the more
  6556. well-known mechanism of pessimistic concurrency, or mutual exclusion,
  6557. with locks. Note that Scheme48&rsquo;s pessimistic concurrency facilities
  6558. are discouraged, and very little of the system uses them (at the time
  6559. this documentation was written, none of the system uses locks), and the
  6560. pessimistic concurrency libraries are limited to just locks; condition
  6561. variables are integrated only with optimistic concurrency. Except for
  6562. inherent applications of pessimistic concurrency, it is usually better
  6563. to use optimistic concurrency in Scheme48.
  6564. </p>
  6565. <span id="index-locks"></span>
  6566. <p>These names are exported by the <code>locks</code> structure.
  6567. </p>
  6568. <dl>
  6569. <dt id="index-make_002dlock">procedure: <strong>make-lock</strong> <em>--&gt; lock</em></dt>
  6570. <dt id="index-lock_003f">procedure: <strong>lock?</strong> <em>--&gt; boolean</em></dt>
  6571. <dt id="index-obtain_002dlock">procedure: <strong>obtain-lock</strong> <em>lock --&gt; unspecified</em></dt>
  6572. <dt id="index-maybe_002dobtain_002dlock">procedure: <strong>maybe-obtain-lock</strong> <em>lock --&gt; boolean</em></dt>
  6573. <dt id="index-release_002dlock">procedure: <strong>release-lock</strong> <em>lock --&gt; unspecified</em></dt>
  6574. <dd><p><code>Make-lock</code> creates a new lock in the &lsquo;released&rsquo; lock state.
  6575. <code>Lock?</code> is the disjoint type predicate for locks.
  6576. <code>Obtain-lock</code> atomically checks to see if <var>lock</var> is in the
  6577. &lsquo;released&rsquo; state: if it is, <var>lock</var> is put into the &lsquo;obtained&rsquo; lock
  6578. state; otherwise, <code>obtain-lock</code> waits until <var>lock</var> is ready to
  6579. be obtained, at which point it is put into the &lsquo;obtained&rsquo; lock state.
  6580. <code>Maybe-obtain-lock</code> atomically checks to see if <var>lock</var> is in
  6581. the &lsquo;released&rsquo; state: if it is, <var>lock</var> is put into the &lsquo;obtained&rsquo;
  6582. lock state, and <code>maybe-obtain-lock</code> returns <code>#t</code>; if it is in
  6583. the &lsquo;obtained&rsquo; state, <code>maybe-obtain-lock</code> immediately returns
  6584. <code>#f</code>. <code>Release-lock</code> sets <var>lock</var>&rsquo;s state to be
  6585. &lsquo;released,&rsquo; letting the next thread waiting to obtain it do so.
  6586. </p></dd></dl>
  6587. <hr>
  6588. <span id="Custom-thread-synchronization"></span><div class="header">
  6589. <p>
  6590. Previous: <a href="#Pessimistic-concurrency" accesskey="p" rel="prev">Pessimistic concurrency</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6591. </div>
  6592. <span id="Custom-thread-synchronization-1"></span><h3 class="section">5.6 Custom thread synchronization</h3>
  6593. <span id="index-suspending-threads"></span>
  6594. <span id="index-resuming-suspended-threads"></span>
  6595. <span id="index-threads_002dinternal"></span>
  6596. <p>Along with several useful thread synchronization abstraction facilities
  6597. built-in to Scheme48, there is also a simple and lower-level mechanism
  6598. for suspending &amp; resuming threads. The following bindings are exported
  6599. from the <code>threads-internal</code> structure.
  6600. </p>
  6601. <span id="index-thread-cells"></span>
  6602. <span id="index-thread-queues"></span>
  6603. <p>Threads have a field for a <a href="#Cells">cell</a> that is used when the
  6604. thread is suspended. When it is ready to run, it is simply <code>#f</code>.
  6605. Suspending a thread involves setting its cell to a cell accessible
  6606. outside, so the thread can later be awoken. When the thread is awoken,
  6607. its cell field and the contents of the cell are both set to <code>#f</code>.
  6608. Often, objects involved in the synchronization of threads will have a
  6609. <a href="#Queues">queue</a> of thread cells. There are two specialized
  6610. operations on thread cell queues that simplify filtering out cells of
  6611. threads that have already been awoken.
  6612. </p>
  6613. <dl>
  6614. <dt id="index-maybe_002dcommit_002dand_002dblock">procedure: <strong>maybe-commit-and-block</strong> <em>cell --&gt; boolean</em></dt>
  6615. <dt id="index-maybe_002dcommit_002dand_002dblock_002don_002dqueue">procedure: <strong>maybe-commit-and-block-on-queue</strong> <em>--&gt; boolean</em></dt>
  6616. <dd><p>These attempt to commit the current proposal. If the commit fails,
  6617. they immediately return <code>#f</code>. Otherwise, they suspend the current
  6618. thread. <code>Maybe-commit-and-block</code> first sets the current thread&rsquo;s
  6619. cell to <var>cell</var>, which should contain the current thread.
  6620. <code>Maybe-commit-and-block-on-queue</code> adds a cell containing the
  6621. current thread to <var>queue</var> first. When the current thread is
  6622. finally resumed, these return <code>#t</code>.
  6623. </p></dd></dl>
  6624. <dl>
  6625. <dt id="index-maybe_002dcommit_002dand_002dmake_002dready">procedure: <strong>maybe-commit-and-make-ready</strong> <em>thread-or-queue --&gt; boolean</em></dt>
  6626. <dd><p>Attempts to commit the current proposal. If the commit fails, this
  6627. returns <code>#f</code>. Otherwise, <code>maybe-commit-and-make-ready</code>
  6628. awakens the specified thread[s] by clearing the thread/each thread&rsquo;s
  6629. cell and sending a message to the relevant scheduler[s] and returns
  6630. <code>#t</code>. If <var>thread-or-queue</var> is a thread, it simply awakens
  6631. that; if it is a queue, it empties the queue and awakens each thread in
  6632. it.
  6633. </p></dd></dl>
  6634. <dl>
  6635. <dt id="index-maybe_002ddequeue_002dthread_0021">procedure: <strong>maybe-dequeue-thread!</strong> <em>thread-cell-queue --&gt; thread or boolean</em></dt>
  6636. <dt id="index-thread_002dqueue_002dempty_003f">procedure: <strong>thread-queue-empty?</strong> <em>thread-cell-queue --&gt; boolean</em></dt>
  6637. <dd><p><code>Maybe-dequeue-thread!</code> returns the next thread cell&rsquo;s contents in
  6638. the queue of thread cells <var>thread-cell-queue</var>. It removes cells
  6639. that have been emptied, <i>i.e.</i> whose threads have already been awoken.
  6640. <code>Thread-queue-empty?</code> returns <code>#t</code> if there are no cells in
  6641. <var>thread-cell-queue</var> that contain threads, <i>i.e.</i> threads that are
  6642. still suspended. It too removes cells that have been emptied.
  6643. </p></dd></dl>
  6644. <p>For example, the definition of <a href="#Higher_002dlevel-synchronization">placeholders</a> is presented here. Placeholders contain two fields: the
  6645. cached value (set when the placeholder is set) &amp; a queue of threads
  6646. waiting (set to <code>#f</code> when the placeholder is assigned).
  6647. </p>
  6648. <div class="lisp">
  6649. <pre class="lisp">(define-synchronized-record-type placeholder :placeholder
  6650. (really-make-placeholder queue)
  6651. (value queue) ; synchronized fields
  6652. placeholder?
  6653. (queue placeholder-queue set-placeholder-queue!)
  6654. (value placeholder-real-value set-placeholder-value!))
  6655. (define (make-placeholder)
  6656. (really-make-placeholder (make-queue)))
  6657. (define (placeholder-value placeholder)
  6658. ;; Set up a new proposal for the transaction.
  6659. (with-new-proposal (lose)
  6660. (cond ((placeholder-queue placeholder)
  6661. ;; There's a queue of waiters. Attempt to commit the
  6662. ;; proposal and block. We'll be added to the queue if the
  6663. ;; commit succeeds; if it fails, retry.
  6664. =&gt; (lambda (queue)
  6665. (or (maybe-commit-and-block-on-queue queue)
  6666. (lose))))))
  6667. ;; Once our thread has been awoken, the placeholder will be set.
  6668. (placeholder-real-value placeholder))
  6669. (define (placeholder-set! placeholder value)
  6670. ;; Set up a new proposal for the transaction.
  6671. (with-new-proposal (lose)
  6672. (cond ((placeholder-queue placeholder)
  6673. =&gt; (lambda (queue)
  6674. ;; Clear the queue, set the value field.
  6675. (set-placeholder-queue! placeholder #f)
  6676. (set-placeholder-value! placeholder value)
  6677. ;; Attempt to commit our changes and awaken all of the
  6678. ;; waiting threads. If the commit fails, retry.
  6679. (if (not (maybe-commit-and-make-ready queue))
  6680. (lose))))
  6681. (else
  6682. ;; Someone assigned it first. Since placeholders are
  6683. ;; single-assignment cells, this is an error.
  6684. (error &quot;placeholder is already assigned&quot;
  6685. placeholder
  6686. (placeholder-real-value placeholder))))))</pre></div>
  6687. <hr>
  6688. <span id="Libraries"></span><div class="header">
  6689. <p>
  6690. Next: <a href="#C-interface" accesskey="n" rel="next">C interface</a>, Previous: <a href="#Multithreading" accesskey="p" rel="prev">Multithreading</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6691. </div>
  6692. <span id="Libraries-1"></span><h2 class="chapter">6 Libraries</h2>
  6693. <p>This chapter details a number of useful libraries built-in to Scheme48.
  6694. </p>
  6695. <table class="menu" border="0" cellspacing="0">
  6696. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Boxed-bitwise_002dinteger-masks" accesskey="1">Boxed bitwise-integer masks</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6697. </td></tr>
  6698. <tr><td align="left" valign="top">&bull; <a href="#Enumerated_002ffinite-types-and-sets" accesskey="2">Enumerated/finite types and sets</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6699. </td></tr>
  6700. <tr><td align="left" valign="top">&bull; <a href="#Macros-for-writing-loops" accesskey="3">Macros for writing loops</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6701. </td></tr>
  6702. <tr><td align="left" valign="top">&bull; <a href="#Library-data-structures" accesskey="4">Library data structures</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6703. </td></tr>
  6704. <tr><td align="left" valign="top">&bull; <a href="#I_002fO-extensions" accesskey="5">I/O extensions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6705. </td></tr>
  6706. <tr><td align="left" valign="top">&bull; <a href="#TCP-_0026-UDP-sockets" accesskey="6">TCP &amp; UDP sockets</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6707. </td></tr>
  6708. <tr><td align="left" valign="top">&bull; <a href="#Common_002dLisp_002dstyle-formatting" accesskey="7">Common-Lisp-style formatting</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6709. </td></tr>
  6710. <tr><td align="left" valign="top">&bull; <a href="#Library-utilities" accesskey="8">Library utilities</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6711. </td></tr>
  6712. </table>
  6713. <hr>
  6714. <span id="Boxed-bitwise_002dinteger-masks"></span><div class="header">
  6715. <p>
  6716. Next: <a href="#Enumerated_002ffinite-types-and-sets" accesskey="n" rel="next">Enumerated/finite types and sets</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6717. </div>
  6718. <span id="Boxed-bitwise_002dinteger-masks-1"></span><h3 class="section">6.1 Boxed bitwise-integer masks</h3>
  6719. <span id="index-mask_002dtypes"></span>
  6720. <span id="index-masks"></span>
  6721. <p>Scheme48 provides a facility for generalized boxed bitwise-integer
  6722. masks. Masks represent sets of elements. An element is any arbitrary
  6723. object that represents an index into a bit mask; mask types are
  6724. parameterized by an isomorphism between elements and their integer
  6725. indices. Usual abstract set operations are available on masks. The
  6726. mask facility is divided into two parts: the <code>mask-types</code>
  6727. structure, which provides the operations on the generalized mask type
  6728. descriptors; and the <code>masks</code> structure, for the operations on
  6729. masks themselves.
  6730. </p>
  6731. <span id="Mask-types"></span><h4 class="subsection">6.1.1 Mask types</h4>
  6732. <dl>
  6733. <dt id="index-make_002dmask_002dtype">procedure: <strong>make-mask-type</strong> <em>name elt? index-&gt;elt elt-&gt;index size --&gt; mask-type</em></dt>
  6734. <dt id="index-mask_002dtype_003f">procedure: <strong>mask-type?</strong> <em>object --&gt; boolean</em></dt>
  6735. <dt id="index-mask_003f">procedure: <strong>mask?</strong> <em>object --&gt; boolean</em></dt>
  6736. <dd><p><code>Make-mask-type</code> constructs a mask type with the given name.
  6737. Elements of this mask type must satisfy the predicate <var>elt?</var>.
  6738. <var>Integer-&gt;elt</var> is a unary procedure that maps bit mask indices to
  6739. possible set elements; <var>elt-&gt;integer</var> maps possible set elements to
  6740. bit mask indices. <var>Size</var> is the number of possible elements of
  6741. masks of the new type, <i>i.e.</i> the number of bits needed to represent the
  6742. internal bit mask. <code>Mask?</code> is the disjoint type predicate for
  6743. mask objects.
  6744. </p></dd></dl>
  6745. <dl>
  6746. <dt id="index-mask_002dtype">procedure: <strong>mask-type</strong> <em>mask --&gt; mask-type</em></dt>
  6747. <dt id="index-mask_002dhas_002dtype_003f">procedure: <strong>mask-has-type?</strong> <em>mask type --&gt; boolean</em></dt>
  6748. <dd><p><code>Mask-type</code> returns <var>mask</var>&rsquo;s type. <code>Mask-has-type?</code>
  6749. returns <code>#t</code> if <var>mask</var>&rsquo;s type is the mask type <var>type</var> or
  6750. <code>#f</code> if not.
  6751. </p></dd></dl>
  6752. <p>The <code>mask-types</code> structure, not the <code>masks</code> structure,
  6753. exports <code>mask?</code> and <code>mask-has-type?</code>: it is expected that
  6754. programmers who implement mask types will define type predicates for
  6755. masks of their type based on <code>mask?</code> and <code>mask-has-type?</code>,
  6756. along with constructors <i>&amp;c.</i> for their masks.
  6757. </p>
  6758. <dl>
  6759. <dt id="index-integer_002d_003emask">procedure: <strong>integer-&gt;mask</strong> <em>type integer --&gt; mask</em></dt>
  6760. <dt id="index-list_002d_003emask">procedure: <strong>list-&gt;mask</strong> <em>type elts --&gt; mask</em></dt>
  6761. <dd><p><code>Integer-&gt;mask</code> returns a mask of type <var>type</var> that contains
  6762. all the possible elements <var>e</var> of the type <var>type</var> such that
  6763. the bit at <var>e</var>&rsquo;s index is set. <code>List-&gt;mask</code> returns a mask
  6764. whose type is <var>type</var> containing all of the elements in the list
  6765. <var>elts</var>.
  6766. </p></dd></dl>
  6767. <span id="Masks"></span><h4 class="subsection">6.1.2 Masks</h4>
  6768. <dl>
  6769. <dt id="index-mask_002d_003einteger">procedure: <strong>mask-&gt;integer</strong> <em>mask --&gt; integer</em></dt>
  6770. <dt id="index-mask_002d_003elist">procedure: <strong>mask-&gt;list</strong> <em>mask --&gt; element-list</em></dt>
  6771. <dd><p><code>Mask-&gt;integer</code> returns the integer bit set that <var>mask</var> uses
  6772. to represent the element set. <code>Mask-&gt;list</code> returns a list of all
  6773. the elements that <var>mask</var> contains.
  6774. </p></dd></dl>
  6775. <dl>
  6776. <dt id="index-mask_002dmember_003f">procedure: <strong>mask-member?</strong> <em>mask elt --&gt; boolean</em></dt>
  6777. <dt id="index-mask_002dset">procedure: <strong>mask-set</strong> <em>mask elt &hellip; --&gt; mask</em></dt>
  6778. <dt id="index-mask_002dclear">procedure: <strong>mask-clear</strong> <em>mask elt &hellip; --&gt; mask</em></dt>
  6779. <dd><p><code>Mask-member?</code> returns true if <var>elt</var> is a member of the mask
  6780. <var>mask</var>, or <code>#f</code> if not. <code>Mask-set</code> returns a mask with
  6781. all the elements in <var>mask</var> as well as each <var>elt</var> &hellip;.
  6782. <code>Mask-clear</code> returns a mask with all the elements in <var>mask</var>
  6783. but with none of <var>elt</var> &hellip;.
  6784. </p></dd></dl>
  6785. <dl>
  6786. <dt id="index-mask_002dunion">procedure: <strong>mask-union</strong> <em>mask<sub>1</sub> mask<sub>2</sub> &hellip; --&gt; mask</em></dt>
  6787. <dt id="index-mask_002dintersection">procedure: <strong>mask-intersection</strong> <em>mask<sub>1</sub> mask<sub>2</sub> &hellip; --&gt; mask</em></dt>
  6788. <dt id="index-mask_002dsubtract">procedure: <strong>mask-subtract</strong> <em>mask<sub>a</sub> mask<sub>b</sub> --&gt; mask</em></dt>
  6789. <dt id="index-mask_002dnegate">procedure: <strong>mask-negate</strong> <em>mask --&gt; mask</em></dt>
  6790. <dd><p>Set operations on masks. <code>Mask-union</code> returns a mask containing
  6791. every element that is a member of any one of its arguments.
  6792. <code>Mask-intersection</code> returns a mask containing every element that
  6793. is a member of every one of its arguments. <code>Mask-subtract</code>
  6794. returns a mask of every element that is in <var>mask<sub>a</sub></var> but not
  6795. also in <var>mask<sub>b</sub></var>. <code>Mask-negate</code> returns a mask whose
  6796. members are every possible element of <var>mask</var>&rsquo;s type that is not in
  6797. <var>mask</var>.
  6798. </p></dd></dl>
  6799. <hr>
  6800. <span id="Enumerated_002ffinite-types-and-sets"></span><div class="header">
  6801. <p>
  6802. Next: <a href="#Macros-for-writing-loops" accesskey="n" rel="next">Macros for writing loops</a>, Previous: <a href="#Boxed-bitwise_002dinteger-masks" accesskey="p" rel="prev">Boxed bitwise-integer masks</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6803. </div>
  6804. <span id="Enumerated_002ffinite-types-and-sets-1"></span><h3 class="section">6.2 Enumerated/finite types and sets</h3>
  6805. <p><i>(This section was derived from work copyrighted &copy;
  6806. 1993&ndash;2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
  6807. </p>
  6808. <span id="index-finite_002dtypes"></span>
  6809. <span id="index-enum_002dsets"></span>
  6810. <p>The structure <code>finite-types</code> has two macros for defining
  6811. <em>finite</em> or <em>enumerated record types</em>. These are record types
  6812. for which there is a fixed set of instances, all of which are created
  6813. at the same time as the record type itself. Also, the structure
  6814. <code>enum-sets</code> has several utilities for building sets of the
  6815. instances of those types, although it is generalized beyond the
  6816. built-in enumerated/finite type device. There is considerable overlap
  6817. between the <a href="#Boxed-bitwise_002dinteger-masks">boxed bitwise-integer
  6818. mask library</a> and the enumerated set facility.
  6819. </p>
  6820. <span id="Enumerated_002ffinite-types"></span><h4 class="subsection">6.2.1 Enumerated/finite types</h4>
  6821. <dl>
  6822. <dt id="index-define_002denumerated_002dtype">syntax: <strong>define-enumerated-type</strong></dt>
  6823. <dd><div class="lisp">
  6824. <pre class="lisp">(define-enumerated-type <var>dispatcher</var> <var>type</var>
  6825. <var>predicate</var>
  6826. <var>instance-vector</var>
  6827. <var>name-accessor</var>
  6828. <var>index-accessor</var>
  6829. (<var>instance-name</var>
  6830. &hellip;))</pre></div>
  6831. <p>This defines a new record type, to which <var>type</var> is bound, with as
  6832. many instances as there are <var>instance-name</var>s. <var>Predicate</var> is
  6833. defined to be the record type&rsquo;s predicate. <var>Instance-vector</var> is
  6834. defined to be a vector containing the instances of the type in the same
  6835. order as the <var>instance-name</var> list. <var>Dispatcher</var> is defined to
  6836. be a macro of the form (<var>dispatcher</var> <var>instance-name</var>); it
  6837. evaluates to the instance with the given name, which is resolved at
  6838. macro-expansion time. <var>Name-accessor</var> &amp; <var>index-accessor</var> are
  6839. defined to be unary procedures that return the symbolic name &amp; index
  6840. into the instance vector, respectively, of the new record type&rsquo;s
  6841. instances.
  6842. </p>
  6843. <p>For example,
  6844. </p>
  6845. <div class="lisp">
  6846. <pre class="lisp">(define-enumerated-type colour :colour
  6847. colour?
  6848. colours
  6849. colour-name
  6850. colour-index
  6851. (black white purple maroon))
  6852. (colour-name (vector-ref colours 0)) &rArr; black
  6853. (colour-name (colour white)) &rArr; white
  6854. (colour-index (colour purple)) &rArr; 2</pre></div>
  6855. </dd></dl>
  6856. <dl>
  6857. <dt id="index-define_002dfinite_002dtype">syntax: <strong>define-finite-type</strong></dt>
  6858. <dd><div class="lisp">
  6859. <pre class="lisp">(define-finite-type <var>dispatcher</var> <var>type</var>
  6860. (<var>field-tag</var> &hellip;)
  6861. <var>predicate</var>
  6862. <var>instance-vector</var>
  6863. <var>name-accessor</var>
  6864. <var>index-accessor</var>
  6865. (<var>field-tag</var> <var>accessor</var> [<var>modifier</var>])
  6866. &hellip;
  6867. ((<var>instance-name</var> <var>field-value</var> &hellip;)
  6868. &hellip;))</pre></div>
  6869. <p>This is like <code>define-enumerated-type</code>, but the instances can also
  6870. have added fields beyond the name and the accessor. The first list of
  6871. field tags lists the fields that each instance is constructed with, and
  6872. each instance is constructed by applying the unnamed constructor to the
  6873. initial field values listed. Fields not listed in the first field tag
  6874. list must be assigned later.
  6875. </p>
  6876. <p>For example,
  6877. </p>
  6878. <div class="lisp">
  6879. <pre class="lisp">(define-finite-type colour :colour
  6880. (red green blue)
  6881. colour?
  6882. colours
  6883. colour-name
  6884. colour-index
  6885. (red colour-red)
  6886. (green colour-green)
  6887. (blue colour-blue)
  6888. ((black 0 0 0)
  6889. (white 255 255 255)
  6890. (purple 160 32 240)
  6891. (maroon 176 48 96)))
  6892. (colour-name (colour black)) &rArr; black
  6893. (colour-name (vector-ref colours 1)) &rArr; white
  6894. (colour-index (colour purple)) &rArr; 2
  6895. (colour-red (colour maroon)) &rArr; 176</pre></div>
  6896. </dd></dl>
  6897. <span id="Sets-over-enumerated-types"></span><h4 class="subsection">6.2.2 Sets over enumerated types</h4>
  6898. <dl>
  6899. <dt id="index-define_002denum_002dset_002dtype">syntax: <strong>define-enum-set-type</strong></dt>
  6900. <dd><div class="lisp">
  6901. <pre class="lisp">(define-enum-set-type <var>set-syntax</var> <var>type</var>
  6902. <var>predicate</var>
  6903. <var>list-&gt;x-set</var>
  6904. <var>element-syntax</var>
  6905. <var>element-predicate</var>
  6906. <var>element-vector</var>
  6907. <var>element-index</var>)</pre></div>
  6908. <p>This defines <var>set-syntax</var> to be a syntax for constructing sets,
  6909. <var>type</var> to be an object that represents the type of enumerated sets,
  6910. <var>predicate</var> to be a predicate for those sets, and
  6911. <var>list-&gt;x-set</var> to be a procedure that converts a list of elements
  6912. into a set of the new type.
  6913. </p>
  6914. <p><var>Element-syntax</var> must be the name of a macro for constructing set
  6915. elements from names (akin to the <var>dispatcher</var> argument to the
  6916. <code>define-enumerated-type</code> &amp; <code>define-finite-type</code> forms).
  6917. <var>Element-predicate</var> must be a predicate for the element type,
  6918. <var>element-vector</var> a vector of all values of the element type, and
  6919. <var>element-index</var> a procedure that returns the index of an element
  6920. within <var>element-vector</var>.
  6921. </p></dd></dl>
  6922. <dl>
  6923. <dt id="index-enum_002dset_002d_003elist">procedure: <strong>enum-set-&gt;list</strong> <em>enum-set --&gt; element list</em></dt>
  6924. <dt id="index-enum_002dset_002dmember_003f">procedure: <strong>enum-set-member?</strong> <em>enum-set element --&gt; boolean</em></dt>
  6925. <dt id="index-enum_002dset_003d_003f">procedure: <strong>enum-set=?</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --&gt; boolean</em></dt>
  6926. <dt id="index-enum_002dset_002dunion">procedure: <strong>enum-set-union</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --&gt; enum-set</em></dt>
  6927. <dt id="index-enum_002dset_002dintersection">procedure: <strong>enum-set-intersection</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --&gt; enum-set</em></dt>
  6928. <dt id="index-enum_002dset_002dnegation">procedure: <strong>enum-set-negation</strong> <em>enum-set --&gt; enum-set</em></dt>
  6929. <dd><p><code>Enum-set-&gt;list</code> returns a list of elements within <var>enum-set</var>.
  6930. <code>Enum-set-member?</code> tests whether <var>element</var> is a member of
  6931. <var>enum-set</var>. <code>Enum-set=?</code> tests whether two enumerated sets
  6932. are equal, <i>i.e.</i> contain all the same elements. The other procedures
  6933. perform standard set algebra operations on enumerated sets. It is an
  6934. error to pass an element that does not satisfy <var>enum-set</var>&rsquo;s
  6935. predicate to <code>enum-set-member?</code> or to pass two enumerated sets of
  6936. different types to <code>enum-set=?</code> or the enumerated set algebra
  6937. operators.
  6938. </p></dd></dl>
  6939. <p>Here is a simple example of enumerated sets built atop the enumerated
  6940. types described in the previous section:
  6941. </p>
  6942. <div class="lisp">
  6943. <pre class="lisp">(define-enumerated-type colour :colour
  6944. colour?
  6945. colours
  6946. colour-name
  6947. colour-index
  6948. (red blue green))
  6949. (define-enum-set-type colour-set :colour-set
  6950. colour-set?
  6951. list-&gt;colour-set
  6952. colour colour? colours colour-index)
  6953. (enum-set-&gt;list (colour-set red blue))
  6954. &rArr; (#{Colour red} #{Colour blue})
  6955. (enum-set-&gt;list (enum-set-negation (colour-set red blue)))
  6956. &rArr; (#{Colour green})
  6957. (enum-set-member? (colour-set red blue) (colour blue))
  6958. &rArr; #t</pre></div>
  6959. <hr>
  6960. <span id="Macros-for-writing-loops"></span><div class="header">
  6961. <p>
  6962. Next: <a href="#Library-data-structures" accesskey="n" rel="next">Library data structures</a>, Previous: <a href="#Enumerated_002ffinite-types-and-sets" accesskey="p" rel="prev">Enumerated/finite types and sets</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6963. </div>
  6964. <span id="Macros-for-writing-loops-1"></span><h3 class="section">6.3 Macros for writing loops</h3>
  6965. <p><i>(This section was derived from work copyrighted &copy;
  6966. 1993&ndash;2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
  6967. </p>
  6968. <p><span id="index-reduce-2"></span>
  6969. <code>Iterate</code> &amp; <code>reduce</code> are extensions of named-<code>let</code> for
  6970. writing loops that walk down one or more sequences, such as the
  6971. elements of a list or vector, the characters read from a port, or an
  6972. arithmetic series. Additional sequences can be defined by the user.
  6973. <code>Iterate</code> &amp; <code>reduce</code> are exported by the structure
  6974. <code>reduce</code>.
  6975. </p>
  6976. <table class="menu" border="0" cellspacing="0">
  6977. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  6978. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Main-looping-macros" accesskey="1">Main looping macros</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6979. </td></tr>
  6980. <tr><td align="left" valign="top">&bull; <a href="#Sequence-types" accesskey="2">Sequence types</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6981. </td></tr>
  6982. <tr><td align="left" valign="top">&bull; <a href="#Synchronous-sequences" accesskey="3">Synchronous sequences</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6983. </td></tr>
  6984. <tr><td align="left" valign="top">&bull; <a href="#Examples" accesskey="4">Examples</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6985. </td></tr>
  6986. <tr><td align="left" valign="top">&bull; <a href="#Defining-sequence-types" accesskey="5">Defining sequence types</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6987. </td></tr>
  6988. <tr><td align="left" valign="top">&bull; <a href="#Loop-macro-expansion" accesskey="6">Loop macro expansion</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  6989. </td></tr>
  6990. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  6991. </pre></th></tr></table>
  6992. <hr>
  6993. <span id="Main-looping-macros"></span><div class="header">
  6994. <p>
  6995. Next: <a href="#Sequence-types" accesskey="n" rel="next">Sequence types</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  6996. </div>
  6997. <span id="Main-looping-macros-1"></span><h4 class="subsection">6.3.1 Main looping macros</h4>
  6998. <dl>
  6999. <dt id="index-iterate">syntax: <strong>iterate</strong></dt>
  7000. <dd><div class="lisp">
  7001. <pre class="lisp">(iterate <var>loop-name</var> ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> &hellip;)
  7002. &hellip;)
  7003. ((<var>state-var</var> <var>init</var>)
  7004. &hellip;)
  7005. <var>body</var>
  7006. [<var>tail-exp</var>])</pre></div>
  7007. <p><code>Iterate</code> steps the <var>elt-var</var>s in parallel through the
  7008. sequences, while each <var>state-var</var> has the corresponding <var>init</var>
  7009. for the first iteration and later values supplied by the body. If any
  7010. sequence has reached the limit, the value of the <code>iterate</code>
  7011. expression is the value of <var>tail-exp</var>, if present, or the current
  7012. values of the <var>state-var</var>s, returned as multiple values. If no
  7013. sequence has reached its limit, <var>body</var> is evaluated and either
  7014. calls <var>loop-name</var> with new values for the <var>state-var</var>s or
  7015. returns some other value(s).
  7016. </p>
  7017. <p>The <var>loop-name</var> and the <var>state-var</var>s &amp; <var>init</var>s behave
  7018. exactly as in named-<code>let</code>, in that <var>loop-name</var> is bound only
  7019. in the scope of <var>body</var>, and each <var>init</var> is evaluated parallel
  7020. in the enclosing scope of the whole expression. Also, the arguments
  7021. to the sequence constructors will be evaluated in the enclosing scope
  7022. of the whole expression, or in an extension of that scope peculiar to
  7023. the sequence type. The named-<code>let</code> expression
  7024. </p>
  7025. <div class="lisp">
  7026. <pre class="lisp">(let <var>loop-name</var> ((<var>state-var</var> <var>init</var>) &hellip;)
  7027. <var>body</var>
  7028. &hellip;)</pre></div>
  7029. <p>is equivalent to an iterate expression with no sequences (and with an
  7030. explicit <code>let</code> wrapped around the body expressions to take care of
  7031. any internal definitions):
  7032. </p>
  7033. <div class="lisp">
  7034. <pre class="lisp">(iterate <var>loop-name</var> ()
  7035. ((<var>state-var</var> <var>init</var>) &hellip;)
  7036. (let () <var>body</var> &hellip;))</pre></div>
  7037. <p>The <var>seq-type</var>s are keywords (actually, macros of a particular
  7038. form, which makes it easy to add additional types of sequences; see
  7039. below). Examples are <code>list*</code>, which walks down the elements of a
  7040. list, and <code>vector*</code>, which does the same for vectors. For each
  7041. iteration, each <var>elt-var</var> is bound to the next element of the
  7042. sequence. The <var>arg</var>s are supplied to the sequence processors as
  7043. other inputs, such as the list or vector to walk down.
  7044. </p>
  7045. <p>If there is a <var>tail-exp</var>, it is evaluated when the end of one or
  7046. more sequences is reached. If the body does not call <var>loop-name</var>,
  7047. however, the <var>tail-exp</var> is not evaluated. Unlike named-<code>let</code>,
  7048. the behaviour of a non-tail-recursive call to <var>loop-name</var> is
  7049. unspecified, because iterating down a sequence may involve side
  7050. effects, such as reading characters from a port.
  7051. </p></dd></dl>
  7052. <dl>
  7053. <dt id="index-reduce-1">syntax: <strong>reduce</strong></dt>
  7054. <dd><div class="lisp">
  7055. <pre class="lisp">(reduce ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> &hellip;)
  7056. &hellip;)
  7057. ((<var>state-var</var> <var>init</var>)
  7058. &hellip;)
  7059. <var>body</var>
  7060. [<var>tail-exp</var>])</pre></div>
  7061. <p>If an <code>iterate</code> expression is not meant to terminate before a
  7062. sequence has reached its end, the body will always end with a tail call
  7063. to <var>loop-name</var>. <code>Reduce</code> is a convenient macro that makes
  7064. this common case explicit. The syntax of <code>reduce</code> is the same as
  7065. that of <code>iterate</code>, except that there is no <var>loop-name</var>, and
  7066. the body updates the state variables by returning multiple values in
  7067. the stead of passing the new values to <var>loop-name</var>: the body must
  7068. return as many values as there are state variables. By special
  7069. dispension, if there are no state variables, then the body may return
  7070. any number of values, all of which are ignored.
  7071. </p>
  7072. <p>The value(s) returned by an instance of <code>reduce</code> is (are) the
  7073. value(s) returned by the <var>tail-exp</var>, if present, or the current
  7074. value(s) of the state variables when the end of one or more sequences
  7075. is reached.
  7076. </p>
  7077. <p>A <code>reduce</code> expression can be rewritten as an equivalent
  7078. <code>iterate</code> expression by adding a <var>loop-name</var> and a wrapper for
  7079. the body that calls the <var>loop-name</var>:
  7080. </p>
  7081. <div class="lisp">
  7082. <pre class="lisp">(iterate loop ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> &hellip;)
  7083. &hellip;)
  7084. ((<var>state-var</var> <var>init</var>)
  7085. &hellip;)
  7086. (call-with-values (lambda () <var>body</var>)
  7087. loop)
  7088. [<var>tail-exp</var>])</pre></div>
  7089. </dd></dl>
  7090. <hr>
  7091. <span id="Sequence-types"></span><div class="header">
  7092. <p>
  7093. Next: <a href="#Synchronous-sequences" accesskey="n" rel="next">Synchronous sequences</a>, Previous: <a href="#Main-looping-macros" accesskey="p" rel="prev">Main looping macros</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7094. </div>
  7095. <span id="Sequence-types-1"></span><h4 class="subsection">6.3.2 Sequence types</h4>
  7096. <dl>
  7097. <dt id="index-list_002a">sequence type: <strong>list*</strong> <em>elt-var list</em></dt>
  7098. <dt id="index-vector_002a">sequence type: <strong>vector*</strong> <em>elt-var vector</em></dt>
  7099. <dt id="index-string_002a">sequence type: <strong>string*</strong> <em>elt-var string</em></dt>
  7100. <dt id="index-count_002a">sequence type: <strong>count*</strong> <em>elt-var start [end [step]]</em></dt>
  7101. <dt id="index-input_002a">sequence type: <strong>input*</strong> <em>elt-var input-port reader-proc</em></dt>
  7102. <dt id="index-stream_002a">sequence type: <strong>stream*</strong> <em>elt-var proc initial-seed</em></dt>
  7103. <dd><p>For lists, vectors, &amp; strings, the <var>elt-var</var> is bound to the
  7104. successive elements of the list or vector, or the successive characters
  7105. of the string.
  7106. </p>
  7107. <p>For <code>count*</code>, the <var>elt-var</var> is bound to the elements of the
  7108. sequence <code>start, start + step, start + 2*step, &hellip;, end</code>,
  7109. inclusive of <var>start</var> and exclusive of <var>end</var>. The default
  7110. <var>step</var> is <code>1</code>, and the sequence does not terminate if no
  7111. <var>end</var> is given or if there is no <var>N</var> &gt; 0 such that <var>end</var> =
  7112. <var>start</var> + <var>N</var><var>step</var>. (<code>=</code> is used to test for
  7113. termination.) For example, <code>(count* i 0 -1)</code> does not terminate
  7114. because it begins past the <var>end</var> value, and <code>(count* i 0 1 2)</code>
  7115. does not terminate because it skips over the <var>end</var> value.
  7116. </p>
  7117. <p>For <code>input*</code>, the elements are the results of successive
  7118. applications of <var>reader-proc</var> to <var>input-port</var>. The sequence
  7119. ends when the <var>reader-proc</var> returns an end-of-file object, <i>i.e.</i>
  7120. a value that satisfies <code>eof-object?</code>.
  7121. </p>
  7122. <p>For <code>stream*</code>, the <var>proc</var> receives the current seed as an
  7123. argument and must return two values, the next value of the sequence &amp;
  7124. the next seed. If the new seed is <code>#f</code>, then the previous element
  7125. was the last one. For example, <code>(list* elt list)</code> is the same as
  7126. </p>
  7127. <div class="lisp">
  7128. <pre class="lisp">(stream* elt
  7129. (lambda (list)
  7130. (if (null? list)
  7131. (values 'ignored #f)
  7132. (values (car list) (cdr list))))
  7133. list)</pre></div>
  7134. </dd></dl>
  7135. <hr>
  7136. <span id="Synchronous-sequences"></span><div class="header">
  7137. <p>
  7138. Next: <a href="#Examples" accesskey="n" rel="next">Examples</a>, Previous: <a href="#Sequence-types" accesskey="p" rel="prev">Sequence types</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7139. </div>
  7140. <span id="Synchronous-sequences-1"></span><h4 class="subsection">6.3.3 Synchronous sequences</h4>
  7141. <p>When using the sequence types described above, a loop terminates when
  7142. any of its sequences terminate. To help detect bugs, it is useful to
  7143. also have sequence types that check whether two or more sequences end
  7144. on the same iteration. For this purpose, there is a second set of
  7145. sequence types called <em>synchronous sequences</em>. Synchronous
  7146. sequences are like ordinary asynchronous sequences in every respect
  7147. except that they cause an error to be signalled if a loop is terminated
  7148. by a synchronous sequence and some other synchronous sequence did not
  7149. reach its end on the same iteration.
  7150. </p>
  7151. <p>Sequences are checked for termination in order from left to right, and
  7152. if a loop is terminated by an asynchronous sequence no further checking
  7153. is done.
  7154. </p>
  7155. <dl>
  7156. <dt id="index-list_0025">synchronous sequence type: <strong>list%</strong> <em>elt-var list</em></dt>
  7157. <dt id="index-vector_0025">synchronous sequence type: <strong>vector%</strong> <em>elt-var vector</em></dt>
  7158. <dt id="index-string_0025">synchronous sequence type: <strong>string%</strong> <em>elt-var string</em></dt>
  7159. <dt id="index-count_0025">synchronous sequence type: <strong>count%</strong> <em>elt-var start end [step]</em></dt>
  7160. <dt id="index-input_0025">synchronous sequence type: <strong>input%</strong> <em>elt-var input-port reader-proc</em></dt>
  7161. <dt id="index-stream_0025">synchronous sequence type: <strong>stream%</strong> <em>elt-var proc initial-seed</em></dt>
  7162. <dd><p>These are all identical to their asynchronous equivalents above, except
  7163. that they are synchronous. Note that <code>count%</code>&rsquo;s <var>end</var>
  7164. argument is required, unlike <code>count*</code>&rsquo;s, because it would be
  7165. nonsensical to check for termination of a sequence that does not
  7166. terminate.
  7167. </p></dd></dl>
  7168. <hr>
  7169. <span id="Examples"></span><div class="header">
  7170. <p>
  7171. Next: <a href="#Defining-sequence-types" accesskey="n" rel="next">Defining sequence types</a>, Previous: <a href="#Synchronous-sequences" accesskey="p" rel="prev">Synchronous sequences</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7172. </div>
  7173. <span id="Examples-1"></span><h4 class="subsection">6.3.4 Examples</h4>
  7174. <p>Gathering the indices of list elements that answer true to some
  7175. predicate.
  7176. </p>
  7177. <div class="lisp">
  7178. <pre class="lisp">(define (select-matching-items list pred)
  7179. (reduce ((list* elt list)
  7180. (count* i 0))
  7181. ((hits '()))
  7182. (if (pred elt)
  7183. (cons i hits)
  7184. hits)
  7185. (reverse hits)))</pre></div>
  7186. <p>Finding the index of an element of a list that satisfies a predicate.
  7187. </p>
  7188. <div class="lisp">
  7189. <pre class="lisp">(define (find-matching-item list pred)
  7190. (iterate loop ((list* elt list)
  7191. (count* i 0))
  7192. () ; no state variables
  7193. (if (pred elt)
  7194. i
  7195. (loop))))</pre></div>
  7196. <p>Reading one line of text from an input port.
  7197. </p>
  7198. <div class="lisp">
  7199. <pre class="lisp">(define (read-line port)
  7200. (iterate loop ((input* c port read-char))
  7201. ((chars '()))
  7202. (if (char=? c #\newline)
  7203. (list-&gt;string (reverse chars))
  7204. (loop (cons c chars)))
  7205. (if (null? chars)
  7206. (eof-object) ; from the PRIMITIVES structure
  7207. (list-&gt;string (reverse chars)))))</pre></div>
  7208. <p>Counting the lines in a file. This must be written in a way other than
  7209. with <code>count*</code> because it needs the value of the count after the
  7210. loop has finished, but the count variable would not be bound then.
  7211. </p>
  7212. <div class="lisp">
  7213. <pre class="lisp">(define (line-count filename)
  7214. (call-with-input-file filename
  7215. (lambda (inport)
  7216. (reduce ((input* line inport read-line))
  7217. ((count 0))
  7218. (+ count 1)))))</pre></div>
  7219. <hr>
  7220. <span id="Defining-sequence-types"></span><div class="header">
  7221. <p>
  7222. Next: <a href="#Loop-macro-expansion" accesskey="n" rel="next">Loop macro expansion</a>, Previous: <a href="#Examples" accesskey="p" rel="prev">Examples</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7223. </div>
  7224. <span id="Defining-sequence-types-1"></span><h4 class="subsection">6.3.5 Defining sequence types</h4>
  7225. <p>The sequence types are object-oriented macros similar to enumerations.
  7226. An asynchronous sequence macro needs to supply three values: <code>#f</code>
  7227. to indicate that it is not synchronous, a list of state variables and
  7228. their initializers, and the code for one iteration. The first two
  7229. methods are written in continuation-passing style: they take another
  7230. macro and argument to which to pass their result. See [Friedman 00]
  7231. for more details on the theory behind how CPS macros work. The
  7232. <code>sync</code> method receives no extra arguments. The <code>state-vars</code>
  7233. method is passed a list of names that will be bound to the arguments of
  7234. the sequence. The final method, for stepping the sequence forward, is
  7235. passed the list of names bound to the arguments and the list of state
  7236. variables. In addition, there is a variable to be bound to the next
  7237. element of the sequence, the body expression for the loop, and an
  7238. expression for terminating the loop.
  7239. </p>
  7240. <p>As an example, the definition of <code>list*</code> is:
  7241. </p>
  7242. <div class="lisp">
  7243. <pre class="lisp">(define-syntax list*
  7244. (syntax-rules (SYNC STATE-VARS STEP)
  7245. ((LIST* SYNC (next more))
  7246. (next #F more))
  7247. ((LIST* STATE-VARS (start-list) (next more))
  7248. (next ((list-var start-list)) more))
  7249. ((LIST* STEP (start-list) (list-var) value-var loop-body tail-exp)
  7250. (IF (NULL? list-var)
  7251. tail-exp
  7252. (LET ((value-var (CAR list-var))
  7253. (list-var (CDR list-var)))
  7254. loop-body)))))</pre></div>
  7255. <p>Synchronized sequences are similar, except that they need to provide a
  7256. termination test to be used when some other synchronized method
  7257. terminates the loop. To continue the example:
  7258. </p>
  7259. <div class="lisp">
  7260. <pre class="lisp">(define-syntax list%
  7261. (syntax-rules (SYNC DONE)
  7262. ((LIST% SYNC (next more))
  7263. (next #T more))
  7264. ((LIST% DONE (start-list) (list-var))
  7265. (NULL? list-var))
  7266. ((LIST% . anything-else)
  7267. (LIST* . anything-else))))</pre></div>
  7268. <hr>
  7269. <span id="Loop-macro-expansion"></span><div class="header">
  7270. <p>
  7271. Previous: <a href="#Defining-sequence-types" accesskey="p" rel="prev">Defining sequence types</a>, Up: <a href="#Macros-for-writing-loops" accesskey="u" rel="up">Macros for writing loops</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7272. </div>
  7273. <span id="Loop-macro-expansion-1"></span><h4 class="subsection">6.3.6 Loop macro expansion</h4>
  7274. <p>Here is an example of the expansion of the <code>reduce</code> macro:
  7275. </p>
  7276. <div class="lisp">
  7277. <pre class="lisp">(reduce ((list* x '(1 2 3)))
  7278. ((r '()))
  7279. (cons x r))
  7280. &rarr;
  7281. (let ((final (lambda (r) (values r)))
  7282. (list '(1 2 3))
  7283. (r '()))
  7284. (let loop ((list list) (r r))
  7285. (if (null? list)
  7286. (final r)
  7287. (let ((x (car list))
  7288. (list (cdr list)))
  7289. (let ((continue (lambda (r)
  7290. (loop list r))))
  7291. (continue (cons x r)))))))</pre></div>
  7292. <p>The only mild inefficiencies in this code are the <code>final</code> &amp;
  7293. <code>continue</code> procedures, both of which could trivially be
  7294. substituted in-line. The macro expander could easily perform the
  7295. substitution for <code>continue</code> when there is no explicit proceed
  7296. variable, as in this case, but not in general.
  7297. </p><hr>
  7298. <span id="Library-data-structures"></span><div class="header">
  7299. <p>
  7300. Next: <a href="#I_002fO-extensions" accesskey="n" rel="next">I/O extensions</a>, Previous: <a href="#Macros-for-writing-loops" accesskey="p" rel="prev">Macros for writing loops</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7301. </div>
  7302. <span id="Library-data-structures-1"></span><h3 class="section">6.4 Library data structures</h3>
  7303. <p>Scheme48 includes several libraries for a variety of data structures.
  7304. </p>
  7305. <span id="Multi_002ddimensional-arrays"></span><h4 class="subsection">6.4.1 Multi-dimensional arrays</h4>
  7306. <span id="index-arrays"></span>
  7307. <span id="index-arrays-1"></span>
  7308. <p>The <code>arrays</code> structure exports a facility for multi-dimensional
  7309. arrays, based on Alan Bawden&rsquo;s interface.
  7310. </p>
  7311. <dl>
  7312. <dt id="index-make_002darray">procedure: <strong>make-array</strong> <em>value dimension &hellip; --&gt; array</em></dt>
  7313. <dt id="index-array">procedure: <strong>array</strong> <em>dimensions element &hellip; --&gt; array</em></dt>
  7314. <dt id="index-copy_002darray">procedure: <strong>copy-array</strong> <em>array &hellip; --&gt; array</em></dt>
  7315. <dd><p>Array constructors. <code>Make-array</code> constructs an array with the
  7316. given dimensions, each of which must be an exact, non-negative integer,
  7317. and fills all of the elements with <var>value</var>. <code>Array</code> creates
  7318. an array with the given list of dimensions, which must be a list of
  7319. exact, non-negative integers, and fills it with the given elements in
  7320. row-major order. The number of elements must be equal to the product
  7321. of <var>dimensions</var>. <code>Copy-array</code> constructs an array with the
  7322. same dimensions and contents as <var>array</var>.
  7323. </p></dd></dl>
  7324. <dl>
  7325. <dt id="index-array_003f">procedure: <strong>array?</strong> <em>object --&gt; boolean</em></dt>
  7326. <dd><p>Disjoint type predicate for arrays.
  7327. </p></dd></dl>
  7328. <dl>
  7329. <dt id="index-array_002dshape">procedure: <strong>array-shape</strong> <em>array --&gt; integer-list</em></dt>
  7330. <dd><p>Returns the list of dimensions of <var>array</var>.
  7331. </p></dd></dl>
  7332. <dl>
  7333. <dt id="index-array_002dref">procedure: <strong>array-ref</strong> <em>array index &hellip; --&gt; value</em></dt>
  7334. <dt id="index-array_002dset_0021">procedure: <strong>array-set!</strong> <em>array value index &hellip; --&gt; unspecified</em></dt>
  7335. <dd><p>Array element dereferencing and assignment. Each <var>index</var> must be
  7336. in the half-open interval [0,<var>d</var>), where <var>d</var> is the respective
  7337. dimension of <var>array</var> corresponding with that index.
  7338. </p></dd></dl>
  7339. <dl>
  7340. <dt id="index-array_002d_003evector">procedure: <strong>array-&gt;vector</strong> <em>array --&gt; vector</em></dt>
  7341. <dd><p>Creates a vector of the elements in <var>array</var> in row-major order.
  7342. </p></dd></dl>
  7343. <dl>
  7344. <dt id="index-make_002dshared_002darray">procedure: <strong>make-shared-array</strong> <em>array linear-map dimension &hellip; --&gt; array</em></dt>
  7345. <dd><p>Creates a new array that shares storage with <var>array</var> and uses the
  7346. procedure <var>linear-map</var> to map indices in the new array to indices in
  7347. <var>array</var>. <var>Linear-map</var> must accept as many arguments as
  7348. <var>dimension</var> &hellip;, each of which must be an exact, non-negative
  7349. integer; and must return a list of exact, non-negative integers equal
  7350. in length to the number of dimensions of <var>array</var>, and which must
  7351. be valid indices into <var>array</var>.
  7352. </p></dd></dl>
  7353. <span id="Red_002fblack-search-trees"></span><h4 class="subsection">6.4.2 Red/black search trees</h4>
  7354. <span id="index-binary-search-trees"></span>
  7355. <span id="index-search_002dtrees"></span>
  7356. <p>Along with hash tables for general object maps, Scheme48 also provides
  7357. red/black binary search trees generalized across key equality
  7358. comparison &amp; ordering functions, as opposed to key equality comparison
  7359. &amp; hash functions with hash tables. These names are exported by the
  7360. <code>search-trees</code> structure.
  7361. </p>
  7362. <dl>
  7363. <dt id="index-make_002dsearch_002dtree">procedure: <strong>make-search-tree</strong> <em>key= key&lt; --&gt; search-tree</em></dt>
  7364. <dt id="index-search_002dtree_003f">procedure: <strong>search-tree?</strong> <em>object --&gt; boolean</em></dt>
  7365. <dd><p><code>Make-search-tree</code> creates a new search tree with the given key
  7366. equality comparison &amp; ordering functions. <code>Search-tree?</code> is the
  7367. disjoint type predicate for red/black binary search trees.
  7368. </p></dd></dl>
  7369. <dl>
  7370. <dt id="index-search_002dtree_002dref">procedure: <strong>search-tree-ref</strong> <em>search-tree key --&gt; value or <code>#f</code></em></dt>
  7371. <dt id="index-search_002dtree_002dset_0021">procedure: <strong>search-tree-set!</strong> <em>search-tree key value --&gt; unspecified</em></dt>
  7372. <dt id="index-search_002dtree_002dmodify_0021">procedure: <strong>search-tree-modify!</strong> <em>search-tree key modifier --&gt; unspecified</em></dt>
  7373. <dd><p><code>Search-tree-ref</code> returns the value associated with <var>key</var> in
  7374. <var>search-tree</var>, or <code>#f</code> if no such association exists.
  7375. <code>Search-tree-set!</code> assigns the value of an existing association in
  7376. <var>search-tree</var> for <var>key</var> to be <var>value</var>, if the association
  7377. already exists; or, if not, it creates a new association with the given
  7378. key and value. If <var>value</var> is <code>#f</code>, however, any association
  7379. is removed. <code>Search-tree-modify!</code> modifies the association in
  7380. <var>search-tree</var> for <var>key</var> by applying <var>modifier</var> to the
  7381. previous value of the association. If no association previously
  7382. existed, one is created whose key is <var>key</var> and whose value is the
  7383. result of applying <var>modifier</var> to <code>#f</code>. If <var>modifier</var>
  7384. returns <code>#f</code>, the association is removed. This is equivalent to
  7385. <code>(search-tree-set! <var>search-tree</var> <var>key</var> (<var>modifier</var>
  7386. (search-tree-ref <var>search-tree</var> <var>key</var>)))</code>, but it is implemented
  7387. more efficiently.
  7388. </p></dd></dl>
  7389. <dl>
  7390. <dt id="index-search_002dtree_002dmax">procedure: <strong>search-tree-max</strong> <em>search-tree --&gt; value or <code>#f</code></em></dt>
  7391. <dt id="index-search_002dtree_002dmin">procedure: <strong>search-tree-min</strong> <em>search-tree --&gt; value or <code>#f</code></em></dt>
  7392. <dt id="index-pop_002dsearch_002dtree_002dmax_0021">procedure: <strong>pop-search-tree-max!</strong> <em>search-tree --&gt; value or <code>#f</code></em></dt>
  7393. <dt id="index-pop_002dsearch_002dtree_002dmin_0021">procedure: <strong>pop-search-tree-min!</strong> <em>search-tree --&gt; value or <code>#f</code></em></dt>
  7394. <dd><p>These all return two values: the key &amp; value for the association in
  7395. <var>search-tree</var> whose key is the maximum or minimum of the tree.
  7396. <code>Search-tree-max</code> and <code>search-tree-min</code> do not remove the
  7397. association from <var>search-tree</var>; <code>pop-search-tree-max!</code> and
  7398. <code>pop-search-tree-min!</code> do. If <var>search-tree</var> is empty, these
  7399. all return the two values <code>#f</code> and <code>#f</code>.
  7400. </p></dd></dl>
  7401. <dl>
  7402. <dt id="index-walk_002dsearch_002dtree">procedure: <strong>walk-search-tree</strong> <em>proc search-tree --&gt; unspecified</em></dt>
  7403. <dd><p>This applies <var>proc</var> to two arguments, the key &amp; value, for every
  7404. association in <var>search-tree</var>.
  7405. </p></dd></dl>
  7406. <span id="Sparse-vectors"></span><h4 class="subsection">6.4.3 Sparse vectors</h4>
  7407. <span id="index-resizable-vectors"></span>
  7408. <span id="index-growing-vectors"></span>
  7409. <span id="index-sparse_002dvectors"></span>
  7410. <p>Sparse vectors, exported by the structure <code>sparse-vectors</code>, are
  7411. vectors that grow as large as necessary without leaving large, empty
  7412. spaces in the vector. They are implemented as trees of subvectors.
  7413. </p>
  7414. <dl>
  7415. <dt id="index-make_002dsparse_002dvector">procedure: <strong>make-sparse-vector</strong> <em>--&gt; sparse-vector</em></dt>
  7416. <dd><p>Sparse vector constructor.
  7417. </p></dd></dl>
  7418. <dl>
  7419. <dt id="index-sparse_002dvector_002dref">procedure: <strong>sparse-vector-ref</strong> <em>sparse-vector index --&gt; value or <code>#f</code></em></dt>
  7420. <dt id="index-sparse_002dvector_002dset_0021">procedure: <strong>sparse-vector-set!</strong> <em>sparse-vector index value --&gt; unspecified</em></dt>
  7421. <dd><p>Sparse vector element accessor and modifier. In the case of
  7422. <code>sparse-vector-ref</code>, if <var>index</var> is beyond the highest index
  7423. that was inserted into <var>sparse-vector</var>, it returns <code>#f</code>; if
  7424. <code>sparse-vector-set!</code> is passed an index beyond what was already
  7425. assigned, it simply extends the vector.
  7426. </p></dd></dl>
  7427. <dl>
  7428. <dt id="index-sparse_002dvector_002d_003elist">procedure: <strong>sparse-vector-&gt;list</strong> <em>sparse-vector --&gt; list</em></dt>
  7429. <dd><p>Creates a list of the elements in <var>sparse-vector</var>. Elements that
  7430. uninitialized gaps comprise are denoted by <code>#f</code> in the list.
  7431. </p></dd></dl>
  7432. <hr>
  7433. <span id="I_002fO-extensions"></span><div class="header">
  7434. <p>
  7435. Next: <a href="#TCP-_0026-UDP-sockets" accesskey="n" rel="next">TCP &amp; UDP sockets</a>, Previous: <a href="#Library-data-structures" accesskey="p" rel="prev">Library data structures</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7436. </div>
  7437. <span id="I_002fO-extensions-1"></span><h3 class="section">6.5 I/O extensions</h3>
  7438. <span id="index-extended_002dports"></span>
  7439. <p>These facilities are all exported from the <code>extended-ports</code>
  7440. structure.
  7441. </p>
  7442. <span id="index-ports-with-line-_0026-column-numbers"></span>
  7443. <span id="index-line_002d-_0026-column_002dtracking-ports"></span>
  7444. <span id="index-ports-that-track-line-_0026-column-numbers"></span>
  7445. <p>Tracking ports track the line &amp; column number that they are on.
  7446. </p>
  7447. <dl>
  7448. <dt id="index-make_002dtracking_002dinput_002dport">procedure: <strong>make-tracking-input-port</strong> <em>sub-port --&gt; input-port</em></dt>
  7449. <dt id="index-make_002dtracking_002doutput_002dport">procedure: <strong>make-tracking-output-port</strong> <em>sub-port --&gt; output-port</em></dt>
  7450. <dd><p>Tracking port constructors. These simply create wrapper ports around
  7451. <var>sub-port</var> that track the line &amp; column numbers.
  7452. </p></dd></dl>
  7453. <dl>
  7454. <dt id="index-current_002drow">procedure: <strong>current-row</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  7455. <dt id="index-current_002dcolumn">procedure: <strong>current-column</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  7456. <dd><p>Accessors for line (row) &amp; column number information. If <var>port</var> is
  7457. a not a tracking port, these simply return <code>#f</code>.
  7458. </p></dd></dl>
  7459. <dl>
  7460. <dt id="index-fresh_002dline">procedure: <strong>fresh-line</strong> <em>port --&gt; unspecified</em></dt>
  7461. <dd><p>This writes a newline to port with <code>newline</code>, unless it can be
  7462. determined that the previous character was a newline &mdash; that is, if
  7463. <code>(current-column <var>port</var>)</code> does not evaluate to zero.
  7464. </p></dd></dl>
  7465. <span id="index-character-source-input-ports"></span>
  7466. <span id="index-character-sink-output-ports"></span>
  7467. <span id="index-simple-character-source-input-ports"></span>
  7468. <span id="index-simple-character-sink-output-ports"></span>
  7469. <p>These are ports based on procedures that produce and consume single
  7470. characters at a time.
  7471. </p>
  7472. <dl>
  7473. <dt id="index-char_002dsource_002d_003einput_002dport">procedure: <strong>char-source-&gt;input-port</strong> <em>char-producer [readiness-tester closer] --&gt; input-port</em></dt>
  7474. <dt id="index-char_002dsink_002d_003eoutput_002dport">procedure: <strong>char-sink-&gt;output-port</strong> <em>char-consumer --&gt; output-port</em></dt>
  7475. <dd><p><code>Char-source-&gt;input-port</code> creates an input port that calls
  7476. <var>char-producer</var> with zero arguments when a character is read from
  7477. it. If <var>readiness-tester</var> is present, it is used for the
  7478. <code>char-ready?</code> operation on the resulting port; likewise with
  7479. <var>closer</var> and <code>close-input-port</code>.
  7480. <code>Char-sink-&gt;output-port</code> creates an output port that calls
  7481. <var>char-consumer</var> for every character written to it.
  7482. </p></dd></dl>
  7483. <span id="index-string-ports"></span>
  7484. <span id="index-string-input-ports"></span>
  7485. <span id="index-string-output-ports"></span>
  7486. <span id="index-input-ports-from-strings"></span>
  7487. <span id="index-output-ports-to-strings"></span>
  7488. <p>Scheme48 also provides ports that collect and produce output to and
  7489. from strings.
  7490. </p>
  7491. <dl>
  7492. <dt id="index-make_002dstring_002dinput_002dport">procedure: <strong>make-string-input-port</strong> <em>string --&gt; input-port</em></dt>
  7493. <dd><p>Constructs an input port whose contents are read from <var>string</var>.
  7494. </p></dd></dl>
  7495. <dl>
  7496. <dt id="index-make_002dstring_002doutput_002dport">procedure: <strong>make-string-output-port</strong> <em>--&gt; output-port</em></dt>
  7497. <dt id="index-string_002doutput_002dport_002doutput">procedure: <strong>string-output-port-output</strong> <em>string-port --&gt; string</em></dt>
  7498. <dt id="index-call_002dwith_002dstring_002doutput_002dport">procedure: <strong>call-with-string-output-port</strong> <em>receiver --&gt; string</em></dt>
  7499. <dd><p><code>Make-string-output-port</code> makes an output port that collects its
  7500. output in a string. <code>String-output-port-output</code> returns the
  7501. string that <var>string-port</var> collected.
  7502. <code>Call-with-string-output-port</code> creates a string output port,
  7503. applies <var>receiver</var> to it, and returns the string that the string
  7504. output port collected.
  7505. </p></dd></dl>
  7506. <span id="index-limiting-output"></span>
  7507. <p>Finally, there is a facility for writing only a limited quantity of
  7508. output to a given port.
  7509. </p>
  7510. <dl>
  7511. <dt id="index-limit_002doutput">procedure: <strong>limit-output</strong> <em>port count receiver --&gt; unspecified</em></dt>
  7512. <dd><p><code>Limit-output</code> applies <var>receiver</var> to a port that will write at
  7513. most <var>count</var> characters to <var>port</var>.
  7514. </p></dd></dl>
  7515. <hr>
  7516. <span id="TCP-_0026-UDP-sockets"></span><div class="header">
  7517. <p>
  7518. Next: <a href="#Common_002dLisp_002dstyle-formatting" accesskey="n" rel="next">Common-Lisp-style formatting</a>, Previous: <a href="#I_002fO-extensions" accesskey="p" rel="prev">I/O extensions</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7519. </div>
  7520. <span id="TCP-_0026-UDP-sockets-1"></span><h3 class="section">6.6 TCP &amp; UDP sockets</h3>
  7521. <span id="index-networking"></span>
  7522. <span id="index-sockets"></span>
  7523. <span id="index-udp_002dsockets"></span>
  7524. <p>Scheme48 provides a simple facility for TCP &amp; UDP sockets. Both the
  7525. structures <code>sockets</code> and <code>udp-sockets</code> export several general
  7526. socket-related procedures:
  7527. </p>
  7528. <dl>
  7529. <dt id="index-close_002dsocket">procedure: <strong>close-socket</strong> <em>socket --&gt; unspecified</em></dt>
  7530. <dt id="index-socket_002dport_002dnumber">procedure: <strong>socket-port-number</strong> <em>socket --&gt; integer</em></dt>
  7531. <dt id="index-get_002dhost_002dname">procedure: <strong>get-host-name</strong> <em>--&gt; string</em></dt>
  7532. <dd><p><code>Close-socket</code> closes <var>socket</var>, which may be any type of
  7533. socket. <code>Socket-port-number</code> returns the port number through
  7534. which <var>socket</var> is communicating. <code>Get-host-name</code> returns the
  7535. network name of the current machine.
  7536. </p>
  7537. <p><strong>Note:</strong> Programmers should be wary of storing the result of a
  7538. call to <code>get-host-name</code> in a dumped heap image, because the actual
  7539. machine&rsquo;s host name may vary from invocation to invocation of the
  7540. Scheme48 VM on that image, since heap images may be resumed on multiple
  7541. different machines.
  7542. </p></dd></dl>
  7543. <span id="TCP-sockets"></span><h4 class="subsection">6.6.1 TCP sockets</h4>
  7544. <span id="index-sockets-1"></span>
  7545. <p>The <code>sockets</code> structure provides simple TCP socket facilities.
  7546. </p>
  7547. <dl>
  7548. <dt id="index-open_002dsocket">procedure: <strong>open-socket</strong> <em>[port-number] --&gt; socket</em></dt>
  7549. <dt id="index-socket_002daccept">procedure: <strong>socket-accept</strong> <em>socket --&gt; [input-port output-port]</em></dt>
  7550. <dd><p>The server interface. <code>Open-socket</code> creates a socket that listens
  7551. on <var>port-number</var>, which defaults to a random number above 1024.
  7552. <code>Socket-accept</code> blocks until there is a client waiting to be
  7553. accepted, at which point it returns two values: an input port &amp; an
  7554. output port to send &amp; receive data to &amp; from the client.
  7555. </p></dd></dl>
  7556. <dl>
  7557. <dt id="index-socket_002dclient">procedure: <strong>socket-client</strong> <em>host-name port-number --&gt; [input-port output-port]</em></dt>
  7558. <dd><p>Connects to the server at <var>port-number</var> denoted by the machine name
  7559. <var>host-name</var> and returns an input port and an output port for
  7560. sending &amp; receiving data to &amp; from the server. <code>Socket-client</code>
  7561. blocks the current thread until the server accepts the connection
  7562. request.
  7563. </p></dd></dl>
  7564. <span id="UDP-sockets"></span><h4 class="subsection">6.6.2 UDP sockets</h4>
  7565. <span id="index-udp_002dsockets-1"></span>
  7566. <p>The <code>udp-sockets</code> structure defines a UDP socket facility.
  7567. </p>
  7568. <dl>
  7569. <dt id="index-open_002dudp_002dsocket">procedure: <strong>open-udp-socket</strong> <em>[port-number] --&gt; socket</em></dt>
  7570. <dd><p>Opens a UDP socket on <var>port-number</var>, or a random port number if
  7571. none was passed. <code>Open-udp-socket</code> returns two values: an input
  7572. UDP socket and an output UDP socket.
  7573. </p></dd></dl>
  7574. <dl>
  7575. <dt id="index-udp_002dsend">procedure: <strong>udp-send</strong> <em>socket address buffer count --&gt; count-sent</em></dt>
  7576. <dt id="index-udp_002dreceive">procedure: <strong>udp-receive</strong> <em>socket buffer --&gt; [count-received remote-address]</em></dt>
  7577. <dd><p><code>Udp-send</code> attempts to send <var>count</var> elements from the string
  7578. or byte vector <var>buffer</var> from the output UDP socket <var>socket</var> to
  7579. the UDP address <var>address</var>, and returns the number of octets it
  7580. successfully sent. <code>Udp-receive</code> receives a UDP message from
  7581. <var>socket</var>, reading it into <var>buffer</var> destructively. It returns
  7582. two values: the number of octets read into <var>buffer</var> and the address
  7583. whence the octets came.
  7584. </p></dd></dl>
  7585. <dl>
  7586. <dt id="index-lookup_002dudp_002daddress">procedure: <strong>lookup-udp-address</strong> <em>name port --&gt; udp-address</em></dt>
  7587. <dt id="index-udp_002daddress_003f">procedure: <strong>udp-address?</strong> <em>object --&gt; boolean</em></dt>
  7588. <dt id="index-udp_002daddress_002daddress">procedure: <strong>udp-address-address</strong> <em>address --&gt; c-byte-vector</em></dt>
  7589. <dt id="index-udp_002daddress_002dport">procedure: <strong>udp-address-port</strong> <em>address --&gt; port-number</em></dt>
  7590. <dt id="index-udp_002daddress_002dhostname">procedure: <strong>udp-address-hostname</strong> <em>address --&gt; string-address</em></dt>
  7591. <dd><p><code>Lookup-udp-address</code> returns a UDP address for the machine name
  7592. <var>name</var> at the port number <var>port</var>. <code>Udp-address?</code> is the
  7593. disjoint type predicate for UDP addresses. <code>Udp-address-address</code>
  7594. returns a byte vector that contains the C representation of
  7595. <var>address</var>, suitable for passing to C with Scheme48&rsquo;s C FFI.
  7596. <code>Udp-address-port</code> returns the port number of <var>address</var>.
  7597. <code>Udp-address-hostname</code> returns a string representation of the IP
  7598. address of <var>address</var>.
  7599. </p></dd></dl>
  7600. <hr>
  7601. <span id="Common_002dLisp_002dstyle-formatting"></span><div class="header">
  7602. <p>
  7603. Next: <a href="#Library-utilities" accesskey="n" rel="next">Library utilities</a>, Previous: <a href="#TCP-_0026-UDP-sockets" accesskey="p" rel="prev">TCP &amp; UDP sockets</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7604. </div>
  7605. <span id="Common_002dLisp_002dstyle-formatting-1"></span><h3 class="section">6.7 Common-Lisp-style formatting</h3>
  7606. <span id="index-formats"></span>
  7607. <p>Scheme48 provides a simple Common-Lisp-style <code>format</code> facility in
  7608. the <code>formats</code> structure. It does not provide nearly as much
  7609. functionality as Common Lisp, however: the considerable complexity of
  7610. Common Lisp&rsquo;s <code>format</code> was deliberately avoided because it was
  7611. deemed inconsistent with Scheme48&rsquo;s design goals. Scheme48&rsquo;s
  7612. <code>format</code> is suitable for most simple purposes, anyhow.
  7613. </p>
  7614. <dl>
  7615. <dt id="index-format">procedure: <strong>format</strong> <em>port control-string argument &hellip; --&gt; unspecified or string</em></dt>
  7616. <dd><p>Prints <var>control-string</var> to <var>port</var>. If, anywhere in
  7617. <var>control-string</var>, the character <code>~</code> (tilde) occurs, the
  7618. following character determines what to print in the place of the tilde
  7619. and following character. Some formatting directives consume arguments
  7620. from <var>argument</var> &hellip;. Formatting directive characters are
  7621. case-insensitive. If <var>port</var> is <code>#t</code>, the output is printed to
  7622. to the value of <code>(current-output-port)</code>; if <var>port</var> is false,
  7623. the output is collected in a string and returned.
  7624. </p>
  7625. <p>The complete list of formatting directives:
  7626. </p>
  7627. <dl compact="compact">
  7628. <dt><code>~~</code></dt>
  7629. <dd><p>Prints a single <code>~</code> (tilde), and does not consume an argument.
  7630. </p>
  7631. </dd>
  7632. <dt><code>~A</code></dt>
  7633. <dd><p>Consumes and prints the first remaining argument with <code>display</code>.
  7634. (&lsquo;A&rsquo;ny)
  7635. </p>
  7636. </dd>
  7637. <dt><code>~D</code></dt>
  7638. <dd><p>Consumes and prints the first remaining argument as a decimal number
  7639. using <code>number-&gt;string</code>. (&lsquo;D&rsquo;ecimal)
  7640. </p>
  7641. </dd>
  7642. <dt><code>~S</code></dt>
  7643. <dd><p>Consumes and prints the first remaining argument with <code>write</code>.
  7644. (&lsquo;S&rsquo;-expression)
  7645. </p>
  7646. </dd>
  7647. <dt><code>~%</code></dt>
  7648. <dd><p>Prints a newline with <code>newline</code>.
  7649. </p>
  7650. </dd>
  7651. <dt><code>~&amp;</code></dt>
  7652. <dd><p>Prints a newline with <code>newline</code>, unless it can be determined that
  7653. a newline was immediately previously printed to <var>port</var>
  7654. (see <a href="#I_002fO-extensions">I/O extensions</a>).
  7655. </p>
  7656. </dd>
  7657. <dt><code>~?</code></dt>
  7658. <dd><p>Recursively formats. The first remaining argument is consumed and must
  7659. be another control string; the argument directly thereafter is also
  7660. consumed, and it must be a list of arguments corresponding with that
  7661. control string. The control string is formatted with those arguments
  7662. using <code>format</code>.
  7663. </p>
  7664. </dd>
  7665. </dl>
  7666. <p><code>Format</code> examples:
  7667. </p>
  7668. <div class="lisp">
  7669. <pre class="lisp">(format #t &quot;Hello, ~A!~%&quot; &quot;world&quot;)
  7670. -| Hello, world!
  7671. -|
  7672. (format #t &quot;Hello~?~S~%&quot; &quot;~A world&quot; '(#\,) '!)
  7673. -| Hello, world!
  7674. -|
  7675. (format #f &quot;~A~A ~A.&quot; &quot;cH&quot; &quot;uMBLE&quot; &quot;spuZz&quot;)
  7676. &rArr; &quot;cHuMBLE spuZz.&quot;
  7677. (let ((x 10) (y .1))
  7678. (format #t &quot;x: ~D~%~&amp;y: ~D~%~&amp;&quot; x y))
  7679. -| x: 10
  7680. -| y: .1</pre></div>
  7681. </dd></dl>
  7682. <hr>
  7683. <span id="Library-utilities"></span><div class="header">
  7684. <p>
  7685. Previous: <a href="#Common_002dLisp_002dstyle-formatting" accesskey="p" rel="prev">Common-Lisp-style formatting</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  7686. </div>
  7687. <span id="Library-utilities-1"></span><h3 class="section">6.8 Library utilities</h3>
  7688. <p>Scheme48 provides various miscellaneous library utilities for common
  7689. general-purpose tasks.
  7690. </p>
  7691. <span id="Destructuring"></span><h4 class="subsection">6.8.1 Destructuring</h4>
  7692. <span id="index-S_002dexpression-destructuring"></span>
  7693. <span id="index-destructuring-S_002dexpressions"></span>
  7694. <span id="index-destructuring"></span>
  7695. <p>The <code>destructuring</code> structure exports a form for destructuring
  7696. S-expressions.
  7697. </p>
  7698. <dl>
  7699. <dt id="index-destructure">syntax: <strong>destructure</strong> <em>((pattern value) &hellip;) body</em></dt>
  7700. <dd><p>For each <code>(<var>pattern</var> <var>value</var>)</code> pair, binds every name in
  7701. <var>pattern</var> to the corresponding location in the S-expression
  7702. <var>value</var>. For example,
  7703. </p>
  7704. <div class="lisp">
  7705. <pre class="lisp">(destructure (((x . y) (cons 5 3))
  7706. ((#(a b) c) '(#((1 2) 3) (4 5))))
  7707. <var>body</var>)</pre></div>
  7708. <p>binds <var>x</var> to <code>5</code>, <var>y</var> to <code>3</code>, <var>a</var> to
  7709. <code>(1 2)</code>, <var>b</var> to <code>3</code>, and <var>c</var> to <code>(4 5)</code>, in
  7710. <var>body</var>.
  7711. </p></dd></dl>
  7712. <span id="Pretty_002dprinting"></span><h4 class="subsection">6.8.2 Pretty-printing</h4>
  7713. <span id="index-pretty_002dprinting"></span>
  7714. <span id="index-printing"></span>
  7715. <span id="index-pp"></span>
  7716. <p>The <code>pp</code> structure exports a simple pretty-printer.
  7717. </p>
  7718. <dl>
  7719. <dt id="index-p">procedure: <strong>p</strong> <em>object [port] --&gt; unspecified</em></dt>
  7720. <dt id="index-pretty_002dprint">procedure: <strong>pretty-print</strong> <em>object port position --&gt; unspecified</em></dt>
  7721. <dd><p><code>P</code> is a convenient alias for <code>pretty-print</code>; it passes 0 for
  7722. <var>position</var> and the value of <code>(current-output-port)</code> if
  7723. <var>port</var> is not passed. <code>Pretty-print</code> pretty-prints
  7724. <var>object</var> to <var>port</var>, using a left margin of <var>position</var>. For
  7725. example:
  7726. </p>
  7727. <div class="lisp">
  7728. <pre class="lisp">(p '(define (fact n)
  7729. (let loop ((p 1) (c 1))
  7730. (if (&gt; c n) p (loop (* p c) (+ c 1))))))
  7731. -| (define (fact n)
  7732. -| (let loop ((p 1) (c 1))
  7733. -| (if (&gt; c n)
  7734. -| p
  7735. -| (loop (* p c) (+ c 1)))))</pre></div>
  7736. </dd></dl>
  7737. <p>The pretty-printer is somewhat extensible as well:
  7738. </p>
  7739. <dl>
  7740. <dt id="index-define_002dindentation">procedure: <strong>define-indentation</strong> <em>name count --&gt; unspecified</em></dt>
  7741. <dd><p>Sets the number of subforms to be indented past <var>name</var> in
  7742. pretty-printed output to be <var>count</var>. For example:
  7743. </p>
  7744. <div class="lisp">
  7745. <pre class="lisp">(define-indentation 'frobozz 3)
  7746. (p '(frobozz (foo bar baz quux zot) (zot quux baz bar foo)
  7747. (mumble frotz gargle eek) (froomble zargle hrumph)))
  7748. -| (frobozz (foo bar baz quux zot)
  7749. -| (zot quux baz bar foo)
  7750. -| (mumble frotz gargle eek)
  7751. -| (froomble zargle hrumph))</pre></div>
  7752. </dd></dl>
  7753. <span id="Strongly-connected-graph-components"></span><h4 class="subsection">6.8.3 Strongly connected graph components</h4>
  7754. <span id="index-strongly_002dconnected-graph-components"></span>
  7755. <span id="index-graph-algorithms"></span>
  7756. <span id="index-strong"></span>
  7757. <p>The <code>strong</code> structure exports a routine for finding a list of the
  7758. strongly connected components in a graph.
  7759. </p>
  7760. <dl>
  7761. <dt id="index-strongly_002dconnected_002dcomponents">procedure: <strong>strongly-connected-components</strong> <em>vertices to slot set-slot! --&gt; sorted-strong-vertices</em></dt>
  7762. <dd><p>Returns the components of a graph containing vertices from the list
  7763. <var>vertices</var> that are strongly connected, in a reversed topologically
  7764. sorted list. <var>To</var> should be a procedure of one argument, a vertex,
  7765. that returns a list of all vertices that have an edge to its argument.
  7766. <var>Slot</var> &amp; <var>set-slot!</var> should be procedures of one &amp; two
  7767. arguments, respectively, that access &amp; modify arbitrary slots used by
  7768. the algorithm. The slot for every vertex should initially be <code>#f</code>
  7769. before calling <code>strongly-connected-components</code>, and the slots are
  7770. reverted to <code>#f</code> before <code>strongly-connected-components</code>
  7771. returns.
  7772. </p></dd></dl>
  7773. <span id="Nondeterminism"></span><h4 class="subsection">6.8.4 Nondeterminism</h4>
  7774. <span id="index-nondeterminism"></span>
  7775. <span id="index-backtracking"></span>
  7776. <span id="index-amb-operator"></span>
  7777. <span id="index-nondeterminism-1"></span>
  7778. <p>The <code>nondeterminism</code> structure provides a simple nondeterministic
  7779. ambivalence operator, like McCarthy&rsquo;s <code>AMB</code>, and a couple utilities
  7780. atop it, built with Scheme&rsquo;s <code>call-with-current-continuation</code>.
  7781. </p>
  7782. <dl>
  7783. <dt id="index-with_002dnondeterminism">procedure: <strong>with-nondeterminism</strong> <em>thunk --&gt; values</em></dt>
  7784. <dd><p>Initializes the nondeterminism system and calls <var>thunk</var>; this
  7785. returns the values <var>thunk</var> returns after then tearing down what was
  7786. set up.
  7787. </p></dd></dl>
  7788. <dl>
  7789. <dt id="index-either">syntax: <strong>either</strong> <em>option &hellip; --&gt; value</em></dt>
  7790. <dt id="index-one_002dvalue">syntax: <strong>one-value</strong> <em>exp --&gt; value</em></dt>
  7791. <dt id="index-all_002dvalues">syntax: <strong>all-values</strong> <em>exp --&gt; list</em></dt>
  7792. <dd><p><code>Either</code> evaluates to the value of any one of the options. It is
  7793. equivalent to McCarthy&rsquo;s <code>AMB</code>. It may return any number of times.
  7794. <code>One-value</code> returns the only value that <var>exp</var> could produce; it
  7795. will return only once, although it may actually return any number of
  7796. values (if <var>exp</var> contains a call to <code>values</code>).
  7797. <code>All-values</code> returns a list of all of the single values, not
  7798. multiple values, that <var>exp</var> could nondeterministically evaluate to.
  7799. </p></dd></dl>
  7800. <dl>
  7801. <dt id="index-fail">procedure: <strong>fail</strong> <em>--&gt; does not return</em></dt>
  7802. <dd><p>Signals a nondeterministic failure. This is invalid outside of a
  7803. <code>with-nondeterminism</code>-protected dynamic extent.
  7804. </p></dd></dl>
  7805. <span id="Miscellaneous-utilities"></span><h4 class="subsection">6.8.5 Miscellaneous utilities</h4>
  7806. <span id="index-big_002dutil"></span>
  7807. <p>The <code>big-util</code> structure exports a variety of miscellaneous
  7808. utilities.
  7809. </p>
  7810. <dl>
  7811. <dt id="index-concatenate_002dsymbol">procedure: <strong>concatenate-symbol</strong> <em>elt &hellip; --&gt; symbol</em></dt>
  7812. <dd><p>Returns a symbol containing the contents of the sequence <var>elt</var>
  7813. &hellip;. Each <var>elt</var> may be another symbol, a string, or a number.
  7814. Numbers are converted to strings in base ten.
  7815. </p></dd></dl>
  7816. <dl>
  7817. <dt id="index-error-1">procedure: <strong>error</strong> <em>format-string argument &hellip; --&gt; values (may not return)</em></dt>
  7818. <dt id="index-breakpoint">procedure: <strong>breakpoint</strong> <em>format-string argument &hellip; --&gt; values (may not return)</em></dt>
  7819. <dd><p><code>Error</code> signals an error whose message is formatted by
  7820. <a href="#Common_002dLisp_002dstyle-formatting"><code>format</code></a> with the given
  7821. formatting template string and arguments. <code>Breakpoint</code> signals a
  7822. breakpoint with a message similarly constructed and causes the command
  7823. processor to push a new <a href="#Command-levels">command level</a>.
  7824. </p></dd></dl>
  7825. <dl>
  7826. <dt id="index-atom_003f">procedure: <strong>atom?</strong> <em>x --&gt; boolean</em></dt>
  7827. <dd><p>Returns true if <var>x</var> is not a pair or false if it is.
  7828. </p></dd></dl>
  7829. <dl>
  7830. <dt id="index-neq_003f">procedure: <strong>neq?</strong> <em>x y --&gt; boolean</em></dt>
  7831. <dt id="index-n_003d">procedure: <strong>n=</strong> <em>x y --&gt; boolean</em></dt>
  7832. <dd><p>Negations of the <code>eq?</code> and <code>=</code> predicates.
  7833. </p></dd></dl>
  7834. <dl>
  7835. <dt id="index-identity">procedure: <strong>identity</strong> <em>value --&gt; value</em></dt>
  7836. <dt id="index-no_002dop">procedure: <strong>no-op</strong> <em>value --&gt; value</em></dt>
  7837. <dd><p>These simply return their arguments. The difference between them is
  7838. that <code>no-op</code> is guaranteed not to be integrated by the compiler,
  7839. whereas <code>identity</code> may be.
  7840. </p></dd></dl>
  7841. <dl>
  7842. <dt id="index-null_002dlist_003f">procedure: <strong>null-list?</strong> <em>object --&gt; boolean</em></dt>
  7843. <dd><p>Returns <code>#t</code> if <var>object</var> is the null list, returns <code>#f</code>
  7844. if <var>object</var> is a pair, or signals an error if <var>object</var> is
  7845. neither the null list nor a pair.
  7846. </p></dd></dl>
  7847. <dl>
  7848. <dt id="index-reverse_0021">procedure: <strong>reverse!</strong> <em>list --&gt; reversed-list</em></dt>
  7849. <dd><p>Returns a list containing the reverse elements of <var>list</var>. Note
  7850. that the original <var>list</var> is <em>not</em> reversed; it becomes
  7851. garbage. <code>Reverse!</code> simply re-uses its structure.
  7852. </p></dd></dl>
  7853. <dl>
  7854. <dt id="index-memq_003f">procedure: <strong>memq?</strong> <em>object list --&gt; boolean</em></dt>
  7855. <dd><p>Returns <code>#t</code> if <var>object</var> is a member of <var>list</var>, as
  7856. determined by <code>eq?</code>; or <code>#f</code> if not.
  7857. </p></dd></dl>
  7858. <dl>
  7859. <dt id="index-first">procedure: <strong>first</strong> <em>predicate list --&gt; elt or <code>#f</code></em></dt>
  7860. <dt id="index-any-1">procedure: <strong>any</strong> <em>predicate list --&gt; elt or <code>#f</code></em></dt>
  7861. <dd><p><code>First</code> returns the first element of <var>list</var> that satisfies
  7862. <var>predicate</var>, or <code>#f</code> if no element does. <code>Any</code> returns
  7863. an element of <var>list</var> that satisfies <var>predicate</var>. Note that
  7864. <code>any</code> may choose any element of the list, whereas <code>first</code>
  7865. explicitly returns the <em>first</em> element that satisfies
  7866. <var>predicate</var>.
  7867. </p></dd></dl>
  7868. <dl>
  7869. <dt id="index-any_003f">procedure: <strong>any?</strong> <em>predicate list --&gt; boolean</em></dt>
  7870. <dt id="index-every_003f">procedure: <strong>every?</strong> <em>predicate list --&gt; boolean</em></dt>
  7871. <dd><p><code>Any?</code> returns <code>#t</code> if any element of <var>list</var> satisfies
  7872. <var>predicate</var>, or <code>#f</code> if none do. <code>Every?</code> returns
  7873. <code>#t</code> if every element of <var>list</var> satisfies <var>predicate</var>, or
  7874. <code>#f</code> if there exists an element that does not.
  7875. </p></dd></dl>
  7876. <dl>
  7877. <dt id="index-filter-1">procedure: <strong>filter</strong> <em>predicate list --&gt; filtered-list</em></dt>
  7878. <dt id="index-filter_0021">procedure: <strong>filter!</strong> <em>predicate list --&gt; filtered-list</em></dt>
  7879. <dd><p>These return a list of all elements in <var>list</var> that satisfy
  7880. <var>predicate</var>. <code>Filter</code> is not allowed to modify <var>list</var>&rsquo;s
  7881. structure; <code>filter!</code> may, however.
  7882. </p></dd></dl>
  7883. <dl>
  7884. <dt id="index-filter_002dmap">procedure: <strong>filter-map</strong> <em>proc list --&gt; list</em></dt>
  7885. <dd><p>This is a combination of <code>filter</code> and <code>map</code>. For each
  7886. element <var>e</var> in <var>list</var>: if <code>(<var>proc</var> <var>e</var>)</code> returns a
  7887. true value, that true value is collected in the output list.
  7888. <code>Filter-map</code> does not modify <var>list</var>&rsquo;s structure.
  7889. </p></dd></dl>
  7890. <dl>
  7891. <dt id="index-remove_002dduplicates">procedure: <strong>remove-duplicates</strong> <em>list --&gt; uniquified-list</em></dt>
  7892. <dd><p>Returns a unique list of all elements in <var>list</var>; that is, if there
  7893. were any duplicates of any element <var>e</var> in <var>list</var>, only a single
  7894. <var>e</var> will occur in the returned list. <code>Remove-duplicates</code> does
  7895. not modify <var>list</var>&rsquo;s structure.
  7896. </p></dd></dl>
  7897. <dl>
  7898. <dt id="index-partition_002dlist">procedure: <strong>partition-list</strong> <em>predicate list --&gt; [satisfied unsatisfied]</em></dt>
  7899. <dt id="index-partition_002dlist_0021">procedure: <strong>partition-list!</strong> <em>predicate list --&gt; [satisfied unsatisfied]</em></dt>
  7900. <dd><p>These return two values: a list of all elements in <var>list</var> that do
  7901. satisfy <var>predicate</var> and a list of all elements that do not.
  7902. <code>Partition-list</code> is not allowed to modify <var>list</var>&rsquo;s structure;
  7903. <code>partition-list!</code> is.
  7904. </p></dd></dl>
  7905. <dl>
  7906. <dt id="index-delq">procedure: <strong>delq</strong> <em>object list --&gt; list</em></dt>
  7907. <dt id="index-delq_0021">procedure: <strong>delq!</strong> <em>object list --&gt; list</em></dt>
  7908. <dd><p>These return a list containing all elements of <var>list</var> except for
  7909. <var>object</var>. <code>Delq</code> is not allowed to modify <var>list</var>&rsquo;s
  7910. structure; <code>delq!</code> is.
  7911. </p></dd></dl>
  7912. <dl>
  7913. <dt id="index-delete">procedure: <strong>delete</strong> <em>predicate list --&gt; list</em></dt>
  7914. <dd><p>Returns a list of all elements in <var>list</var> that do not satisfy
  7915. <var>predicate</var>. Note that, despite the lack of exclamation mark in
  7916. the name, this <em>may</em> modify <var>list</var>&rsquo;s structure.
  7917. </p></dd></dl>
  7918. <dl>
  7919. <dt id="index-string_002d_003eimmutable_002dstring">procedure: <strong>string-&gt;immutable-string</strong> <em>string --&gt; immutable-string</em></dt>
  7920. <dd><p>Returns an immutable string with <var>string</var>&rsquo;s contents. If
  7921. <var>string</var> is already immutable, it is returned; otherwise, an
  7922. immutable copy is returned.
  7923. </p></dd></dl>
  7924. <span id="Multiple-value-binding"></span><h4 class="subsection">6.8.6 Multiple value binding</h4>
  7925. <span id="index-binding-multiple-values"></span>
  7926. <span id="index-multiple-value-binding"></span>
  7927. <span id="index-receiving"></span>
  7928. <p>The <code>receiving</code> structure exports the <code>receive</code> macro, a
  7929. convenient syntax atop R5RS&rsquo;s <code>call-with-values</code>.
  7930. </p>
  7931. <dl>
  7932. <dt id="index-receive-2">syntax: <strong>receive</strong> <em>formals producer body</em></dt>
  7933. <dd><p>Binds the variables in the lambda parameter list <var>formals</var> to the
  7934. return values of <var>producer</var> in <var>body</var>.
  7935. </p>
  7936. <div class="lisp">
  7937. <pre class="lisp">(receive <var>formals</var>
  7938. <var>producer</var>
  7939. <var>body</var>)
  7940. &equiv;
  7941. (call-with-values
  7942. (lambda () <var>producer</var>)
  7943. (lambda <var>formals</var> <var>body</var>))</pre></div>
  7944. </dd></dl>
  7945. <span id="index-mvlet-1"></span>
  7946. <p>For sequences of multiple value bindings, the <code>mvlet</code> structure
  7947. exports two convenient macros.
  7948. </p>
  7949. <dl>
  7950. <dt id="index-mvlet_002a">syntax: <strong>mvlet*</strong></dt>
  7951. <dt id="index-mvlet">syntax: <strong>mvlet</strong></dt>
  7952. <dd><p><code>Mvlet*</code> is a multiple-value version of <code>let</code> or a linearly
  7953. nested version of <code>receive</code>:
  7954. </p>
  7955. <div class="lisp">
  7956. <pre class="lisp">(mvlet* ((<var>formals<sub>0</sub></var> <var>producer<sub>0</sub></var>)
  7957. (<var>formals<sub>1</sub></var> <var>producer<sub>1</sub></var>)
  7958. &hellip;)
  7959. <var>body</var>)
  7960. &equiv;
  7961. (call-with-values
  7962. (lambda () <var>producer<sub>0</sub></var>)
  7963. (lambda <var>formals<sub>0</sub></var>
  7964. (call-with-values
  7965. (lambda () <var>producer<sub>1</sub></var>)
  7966. (lambda <var>formals<sub>1</sub></var>
  7967. &hellip;<var>body</var>&hellip;))))</pre></div>
  7968. <p><code>Mvlet</code> is similar, but each <var>producer</var> is evaluated in an
  7969. environment where none of the variables in any of the <var>formals</var> is
  7970. bound, and the order in which each producer expression is evaluated is
  7971. unspecified.
  7972. </p></dd></dl>
  7973. <span id="Object-dumper"></span><h4 class="subsection">6.8.7 Object dumper</h4>
  7974. <span id="index-serialization"></span>
  7975. <span id="index-marshalling"></span>
  7976. <span id="index-object-dumping"></span>
  7977. <span id="index-dump_002frestore"></span>
  7978. <p>Scheme48 has a rudimentary object dumper and retriever in the structure
  7979. <code>dump/restore</code>. It is not a &lsquo;real&rsquo; object dumper in the sense that
  7980. it will not handle cycles in object graphs correctly; it simply performs
  7981. a recursive descent and will diverge if it reaches a cycle or stop after
  7982. a recursive depth parameter.
  7983. </p>
  7984. <p>The types of objects that the dumper supports are: several miscellaneous
  7985. constants (<code>()</code>, <code>#t</code>, <code>#f</code>, &amp; the unspecific token),
  7986. pairs, vectors, symbols, numbers, strings, characters, and byte vectors.
  7987. </p>
  7988. <dl>
  7989. <dt id="index-dump">procedure: <strong>dump</strong> <em>object char-writer depth --&gt; unspecified</em></dt>
  7990. <dd><p>Dumps <var>object</var> by repeatedly calling <var>char-writer</var>, which must
  7991. be a procedure that accepts exactly one character argument, on the
  7992. characters of the serialized representation. If the dumper descends
  7993. into the object graph whose root is <var>object</var> for more than
  7994. <var>depth</var> recursions, an ellipsis token is dumped in the place of the
  7995. vertex at <var>depth</var>.
  7996. </p></dd></dl>
  7997. <dl>
  7998. <dt id="index-restore">procedure: <strong>restore</strong> <em>char-reader --&gt; object</em></dt>
  7999. <dd><p>Restores the object whose serialized components are retrieved by
  8000. repeatedly calling <var>char-reader</var>, which must be a procedure that
  8001. accepts zero arguments and returns a character.
  8002. </p></dd></dl>
  8003. <span id="Simple-time-access"></span><h4 class="subsection">6.8.8 Simple time access</h4>
  8004. <span id="index-time-1"></span>
  8005. <span id="index-run-time"></span>
  8006. <span id="index-real-time"></span>
  8007. <span id="index-time-2"></span>
  8008. <p>The <code>time</code> structure exports a simple facility for accessing time
  8009. offsets in two different flavours.
  8010. </p>
  8011. <dl>
  8012. <dt id="index-real_002dtime">procedure: <strong>real-time</strong> <em>--&gt; milliseconds</em></dt>
  8013. <dd><p>Returns the real time in milliseconds that has passed since some
  8014. unspecified moment in time.<a id="DOCF25" href="#FOOT25"><sup>25</sup></a> Though not suitable
  8015. for measurements relative to entities outside the Scheme48 image, the
  8016. real time is useful for measuring time differences within the Scheme
  8017. image with reasonable precision; for example, thread sleep timing is
  8018. implemented with this real time primitive.
  8019. </p></dd></dl>
  8020. <dl>
  8021. <dt id="index-run_002dtime">procedure: <strong>run-time</strong> <em>--&gt; ticks</em></dt>
  8022. <dd><p>Returns the run time as an integer representing processor clock ticks
  8023. since the start of the Scheme48 process. This is much less precise
  8024. than the real time, but it is useful for measuring time actually spent
  8025. in the Scheme48 process, as opposed to time in general.
  8026. </p></dd></dl>
  8027. <hr>
  8028. <span id="C-interface"></span><div class="header">
  8029. <p>
  8030. Next: <a href="#POSIX-interface" accesskey="n" rel="next">POSIX interface</a>, Previous: <a href="#Libraries" accesskey="p" rel="prev">Libraries</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8031. </div>
  8032. <span id="C-interface-1"></span><h2 class="chapter">7 C interface</h2>
  8033. <p><i>(This chapter was derived from work copyrighted &copy;
  8034. 1993&ndash;2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
  8035. </p>
  8036. <p>This chapter describes an interface for calling C functions from
  8037. Scheme, calling Scheme procedures from C, and working with the Scheme
  8038. heap in C. Scheme48 manages stub functions in C that negotiate between
  8039. the calling conventions of Scheme &amp; C and the memory allocation
  8040. policies of both worlds. No stub generator is available yet, but
  8041. writing stubs is a straightforward task.
  8042. </p>
  8043. <table class="menu" border="0" cellspacing="0">
  8044. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Shared-bindings-between-Scheme-and-C" accesskey="1">Shared bindings between Scheme and C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8045. </td></tr>
  8046. <tr><td align="left" valign="top">&bull; <a href="#Calling-C-functions-from-Scheme" accesskey="2">Calling C functions from Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8047. </td></tr>
  8048. <tr><td align="left" valign="top">&bull; <a href="#Dynamic-loading-of-C-modules" accesskey="3">Dynamic loading of C modules</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8049. </td></tr>
  8050. <tr><td align="left" valign="top">&bull; <a href="#Accessing-Scheme-data-from-C" accesskey="4">Accessing Scheme data from C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8051. </td></tr>
  8052. <tr><td align="left" valign="top">&bull; <a href="#Calling-Scheme-procedures-from-C" accesskey="5">Calling Scheme procedures from C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8053. </td></tr>
  8054. <tr><td align="left" valign="top">&bull; <a href="#Interacting-with-the-Scheme-heap-in-C" accesskey="6">Interacting with the Scheme heap in C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8055. </td></tr>
  8056. <tr><td align="left" valign="top">&bull; <a href="#Using-Scheme-records-in-C" accesskey="7">Using Scheme records in C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8057. </td></tr>
  8058. <tr><td align="left" valign="top">&bull; <a href="#Raising-exceptions-from-C" accesskey="8">Raising exceptions from C</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8059. </td></tr>
  8060. <tr><td align="left" valign="top">&bull; <a href="#Unsafe-C-macros" accesskey="9">Unsafe C macros</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  8061. </td></tr>
  8062. </table>
  8063. <span id="Overview-of-the-C-interface"></span><h3 class="section">7.1 Overview of the C interface</h3>
  8064. <p>The following facilities are available for interfacing between Scheme48
  8065. &amp; C:
  8066. </p>
  8067. <ul>
  8068. <li> Scheme code can call C functions.
  8069. </li><li> The external interface provides full introspection for all Scheme
  8070. objects. External code may inspect, modify, and allocate Scheme
  8071. objects arbitrarily.
  8072. </li><li> External code may raise exceptions back to Scheme48 to signal
  8073. errors.
  8074. </li><li> External code may call back into Scheme. Scheme48 correctly
  8075. unrolls the process stack on non-local exits.
  8076. </li><li> External modules may register bindings of names to values with a
  8077. central registry accessible from Scheme. Conversely, Scheme code can
  8078. register shared bindings for access by C code.
  8079. </li></ul>
  8080. <span id="Scheme-structures"></span><h4 class="subsection">7.1.1 Scheme structures</h4>
  8081. <span id="index-external_002dcalls"></span>
  8082. <span id="index-load_002ddynamic_002dexternals-1"></span>
  8083. <span id="index-shared_002dbindings"></span>
  8084. <span id="index-dynamic_002dexternals"></span>
  8085. <p>On the Scheme side of the C interface, there are three pertinent
  8086. structures: <a href="#Shared-bindings-between-Scheme-and-C"><code>shared-bindings</code></a>, which provides the Scheme side of the
  8087. facility for sharing data between Scheme and C; <a href="#Calling-C-functions-from-Scheme"><code>external-calls</code></a>, which exports several
  8088. ways to call C functions from Scheme, along with some useful
  8089. facilities, such as object finalizers, which are also available from
  8090. elsewhere; and <a href="#Dynamic-loading-of-C-modules"><code>load-dynamic-externals</code></a>, which provides a dynamic external
  8091. object loading facility. Also, the old dynamic loading facility is
  8092. still available from the <code>dynamic-externals</code> structure, but its
  8093. use is deprecated, and it will most likely vanish in a later release.
  8094. </p>
  8095. <span id="C-naming-conventions"></span><h4 class="subsection">7.1.2 C naming conventions</h4>
  8096. <span id="index-C-naming-conventions"></span>
  8097. <p>Scheme48&rsquo;s C bindings all have strict naming conventions. Variables
  8098. &amp; procedures have <code>s48_</code> prefixed to them; macros, <code>S48_</code>.
  8099. Whenever a C name is derived from a Scheme identifier, hyphens are
  8100. replaced with underscores. Also, procedures or variables are converted
  8101. to lowercase, while macros are converted to uppercase. The <code>?</code>
  8102. suffix, generally appended to predicates, is converted to <code>_p</code> (or
  8103. <code>_P</code> in macro names). Trailing <code>!</code> is dropped. For example,
  8104. the C macro that corresponds with Scheme&rsquo;s <code>pair?</code> predicate is
  8105. named <code>S48_PAIR_P</code>, and the C macro to assign the car of a pair is
  8106. named <code>S48_SET_CAR</code>. Procedures and macros that do not verify the
  8107. types of their arguments have &lsquo;unsafe&rsquo; in their names.
  8108. </p>
  8109. <p>All of the C functions and macros described have prototypes or
  8110. definitions in the file <samp>c/scheme48.h</samp> of Scheme48&rsquo;s standard
  8111. distribution. The C type for Scheme values is defined there to be
  8112. <code>s48_value</code>.
  8113. </p>
  8114. <span id="Garbage-collection"></span><h4 class="subsection">7.1.3 Garbage collection</h4>
  8115. <p>Scheme48 uses a copying garbage collector. The collector must be able
  8116. to locate all references to objects allocated in the Scheme48 heap in
  8117. order to ensure that storage is not reclaimed prematurely and to
  8118. update references to objects moved by the collector. The garbage
  8119. collector may run whenever an object is allocated in the heap. C
  8120. variables whose values are Scheme48 objects and which are live across
  8121. heap allocation calls need to be registered with the garbage
  8122. collector. For more information, see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
  8123. </p>
  8124. <hr>
  8125. <span id="Shared-bindings-between-Scheme-and-C"></span><div class="header">
  8126. <p>
  8127. Next: <a href="#Calling-C-functions-from-Scheme" accesskey="n" rel="next">Calling C functions from Scheme</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8128. </div>
  8129. <span id="Shared-bindings-between-Scheme-and-C-1"></span><h3 class="section">7.2 Shared bindings between Scheme and C</h3>
  8130. <span id="index-sharing-data-between-Scheme-and-C"></span>
  8131. <span id="index-shared_002dbindings-1"></span>
  8132. <p>Shared bindings are the means by which named values are shared between
  8133. Scheme &amp; C code. There are two separate tables of shared bindings, one
  8134. for values defined in Scheme and accessed from C and the other for the
  8135. opposite direction. Shared bindings actually bind names to cells, to
  8136. allow a name to be resolved before it has been assigned. This is
  8137. necessary because C initialization code may run before or after the
  8138. corresponding Scheme code, depending on whether the Scheme code is in
  8139. the resumed image or run in the current session. The Scheme bindings
  8140. described here are available from the <code>shared-bindings</code>
  8141. structure.
  8142. </p>
  8143. <span id="Scheme-shared-binding-interface"></span><h4 class="subsection">7.2.1 Scheme shared binding interface</h4>
  8144. <dl>
  8145. <dt id="index-shared_002dbinding_003f">Scheme procedure: <strong>shared-binding?</strong> <em>object --&gt; boolean</em></dt>
  8146. <dt id="index-shared_002dbinding_002dis_002dimport_003f">Scheme procedure: <strong>shared-binding-is-import?</strong> <em>shared-binding --&gt; boolean</em></dt>
  8147. <dd><p><code>Shared-binding?</code> is the disjoint type predicate for all shared
  8148. bindings, imported or exported; <code>shared-binding-is-import?</code>
  8149. returns true if <var>shared-binding</var> was imported into Scheme from C,
  8150. and false if it has the converse direction.
  8151. </p></dd></dl>
  8152. <dl>
  8153. <dt id="index-shared_002dbinding_002dref">Scheme procedure: <strong>shared-binding-ref</strong> <em>shared-binding --&gt; value</em></dt>
  8154. <dt id="index-shared_002dbinding_002dset_0021">Scheme procedure: <strong>shared-binding-set!</strong> <em>shared-binding value --&gt; unspecified</em></dt>
  8155. <dd><p><code>Shared-binding-ref</code> returns the value of <var>shared-binding</var>;
  8156. <code>shared-binding-set!</code> sets the value of <var>shared-binding</var> to
  8157. be <var>value</var>.
  8158. </p></dd></dl>
  8159. <span id="index-importing-bindings-into-Scheme-from-C"></span>
  8160. <dl>
  8161. <dt id="index-lookup_002dimported_002dbinding">Scheme procedure: <strong>lookup-imported-binding</strong> <em>name --&gt; shared-binding</em></dt>
  8162. <dt id="index-define_002dimported_002dbinding">Scheme procedure: <strong>define-imported-binding</strong> <em>name value --&gt; unspecified</em></dt>
  8163. <dt id="index-undefine_002dimported_002dbinding">Scheme procedure: <strong>undefine-imported-binding</strong> <em>name --&gt; unspecified</em></dt>
  8164. <dd><p><code>Lookup-imported-binding</code> returns the binding imported from C to
  8165. Scheme with the given name; a binding is created if none exists.
  8166. <code>Define-imported-binding</code> creates a new such binding, anomalously
  8167. from within Scheme; such bindings are usually created instead from
  8168. within C using the C <code>s48_define_exported_binding</code> function.
  8169. <code>Undefine-imported-binding</code> removes the shared binding whose name
  8170. is <var>name</var> from the table of imported bindings.
  8171. </p></dd></dl>
  8172. <span id="index-exporting-bindings-from-Scheme-to-C"></span>
  8173. <dl>
  8174. <dt id="index-lookup_002dexported_002dbinding">Scheme procedure: <strong>lookup-exported-binding</strong> <em>name --&gt; shared-binding</em></dt>
  8175. <dt id="index-define_002dexported_002dbinding">Scheme procedure: <strong>define-exported-binding</strong> <em>name value --&gt; unspecified</em></dt>
  8176. <dt id="index-undefine_002dexported_002dbinding">Scheme procedure: <strong>undefine-exported-binding</strong> <em>name --&gt; unspecified</em></dt>
  8177. <dd><p>Equivalents of the above three procedures, but for bindings exported
  8178. from Scheme to C. <code>Define-imported-binding</code>, unlike
  8179. <code>define-exported-binding</code>, is customary to use in Scheme, as its
  8180. intended use is to make a Scheme value available to C code from within
  8181. Scheme.
  8182. </p></dd></dl>
  8183. <dl>
  8184. <dt id="index-find_002dundefined_002dimported_002dbindings">Scheme procedure: <strong>find-undefined-imported-bindings</strong> <em>--&gt; vector</em></dt>
  8185. <dd><p>Returns a vector of all bindings imported into Scheme from C with
  8186. undefined values, <i>i.e.</i> those created implicitly by lookups that have
  8187. not yet been assigned rather than those created explicitly by the
  8188. shared binding definers (<code>define-exported-binding</code>, <i>&amp;c.</i>).
  8189. </p></dd></dl>
  8190. <span id="C-shared-binding-interface"></span><h4 class="subsection">7.2.2 C shared binding interface</h4>
  8191. <dl>
  8192. <dt id="index-S48_005fSHARED_005fBINDING_005fP">C macro: <em>s48_value</em> <strong>S48_SHARED_BINDING_P</strong> <em>(s48_value <var>obj</var>)</em></dt>
  8193. <dt id="index-S48_005fSHARED_005fBINDING_005fNAME">C macro: <em>s48_value</em> <strong>S48_SHARED_BINDING_NAME</strong> <em>(s48_value <var>shared_binding</var>)</em></dt>
  8194. <dt id="index-S48_005fSHARED_005fBINDING_005fIS_005fIMPORTP">C macro: <em>s48_value</em> <strong>S48_SHARED_BINDING_IS_IMPORTP</strong> <em>(s48_value <var>shared-binding</var>)</em></dt>
  8195. <dt id="index-S48_005fSHARED_005fBINDING_005fREF">C macro: <em>s48_value</em> <strong>S48_SHARED_BINDING_REF</strong> <em>(s48_value <var>shared_binding</var>)</em></dt>
  8196. <dt id="index-S48_005fSHARED_005fBINDING_005fSET">C macro: <em>void</em> <strong>S48_SHARED_BINDING_SET</strong> <em>(s48_value <var>shared_binding</var>, s48_value <var>value</var>)</em></dt>
  8197. <dd><p>These macros are C counterparts to Scheme&rsquo;s <code>shared-binding?</code>,
  8198. <code>shared-binding-name</code>, <code>shared-binding-is-import?</code>,
  8199. <code>shared-binding-ref</code>, and <code>shared-binding-set!</code>,
  8200. respectively.
  8201. </p></dd></dl>
  8202. <dl>
  8203. <dt id="index-S48_005fSHARED_005fBINDING_005fCHECK">C macro: <em><i>statement</i></em> <strong>S48_SHARED_BINDING_CHECK</strong> <em>(s48_value <var>binding</var>)</em></dt>
  8204. <dd><p>Signals an exception if and only if <var>binding</var>&rsquo;s value is
  8205. Scheme48&rsquo;s &lsquo;unspecific&rsquo; value.
  8206. </p>
  8207. <p><strong>Huh?:</strong> Undefined shared bindings are not initialized with the
  8208. &lsquo;unspecific&rsquo; value, but rather with an entirely different special
  8209. token referred to internally as &lsquo;undefined,&rsquo; used in circumstances
  8210. such as this &mdash; yet <code>S48_SHARED_BINDING_CHECK</code>, as defined in
  8211. <samp>scheme48.h</samp>, definitely checks whether <var>binding</var>&rsquo;s value is
  8212. the &lsquo;unspecific&rsquo; value.
  8213. </p></dd></dl>
  8214. <span id="index-importing-bindings-into-C-from-Scheme"></span>
  8215. <dl>
  8216. <dt id="index-s48_005fget_005fimported_005fbinding">C function: <em>s48_value</em> <strong>s48_get_imported_binding</strong> <em>(char *<var>name</var>)</em></dt>
  8217. <dd><p>Returns the shared binding defined in Scheme for <var>name</var>, creating
  8218. it if necessary.
  8219. </p></dd></dl>
  8220. <span id="index-exporting-bindings-from-C-to-Scheme"></span>
  8221. <dl>
  8222. <dt id="index-s48_005fdefine_005fexported_005fbinding">C function: <em>void</em> <strong>s48_define_exported_binding</strong> <em>(char *<var>name</var>, s48_value <var>value</var>)</em></dt>
  8223. <dd><p>Defines a shared binding named <var>name</var> with the value <var>value</var>
  8224. that can be accessed from Scheme.
  8225. </p></dd></dl>
  8226. <span id="index-exporting-C-functions-to-Scheme"></span>
  8227. <dl>
  8228. <dt id="index-S48_005fEXPORT_005fFUNCTION">C macro: <em>void</em> <strong>S48_EXPORT_FUNCTION</strong> <em>(<var>fn</var>)</em></dt>
  8229. <dd><p>This is a convenience for the common case of exporting a C function to
  8230. Scheme. This expands into
  8231. </p>
  8232. <div class="example">
  8233. <pre class="example">s48_define_exported_binding(&quot;<var>fn</var>&quot;,
  8234. s48_enter_pointer(<var>fn</var>))</pre></div>
  8235. <p>which boxes the function into a Scheme48 byte vector and then exports
  8236. it as a shared binding. Note that <code>s48_enter_pointer</code> allocates
  8237. space in the Scheme heap and may trigger a garbage collection;
  8238. see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
  8239. </p></dd></dl>
  8240. <hr>
  8241. <span id="Calling-C-functions-from-Scheme"></span><div class="header">
  8242. <p>
  8243. Next: <a href="#Dynamic-loading-of-C-modules" accesskey="n" rel="next">Dynamic loading of C modules</a>, Previous: <a href="#Shared-bindings-between-Scheme-and-C" accesskey="p" rel="prev">Shared bindings between Scheme and C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8244. </div>
  8245. <span id="Calling-C-functions-from-Scheme-1"></span><h3 class="section">7.3 Calling C functions from Scheme</h3>
  8246. <span id="index-importing-C-functions-to-Scheme"></span>
  8247. <span id="index-external_002dcalls-1"></span>
  8248. <p>The <code>external-calls</code> structure exports several ways to call C
  8249. functions from Scheme, along with several other related utilities,
  8250. many of which are also available from other structures. There are two
  8251. different ways to call C functions from Scheme, depending on how the C
  8252. function was obtained:
  8253. </p>
  8254. <dl>
  8255. <dt id="index-call_002dimported_002dbinding">Scheme procedure: <strong>call-imported-binding</strong> <em>binding argument &hellip; --&gt; value</em></dt>
  8256. <dt id="index-call_002dexternal_002dvalue">Scheme procedure: <strong>call-external-value</strong> <em>byte-vector name argument &hellip; --&gt; value</em></dt>
  8257. <dd><p>Each of these applies its first argument, a C function, to the rest of
  8258. the arguments. For <code>call-imported-binding</code>, the function argument
  8259. must be an imported binding. For <code>call-external-value</code>, the
  8260. function argument must be a byte vector that contains a pointer to a C
  8261. function, and <var>name</var> should be a string that names the function.
  8262. The <var>name</var> argument is used only for printing error messages.
  8263. </p>
  8264. <p>For both of these, the C function is passed the argument values, and
  8265. the value returned is that returned by the C function. No automatic
  8266. representation conversion occurs for either arguments or return
  8267. values. Up to twelve arguments may be passed. There is no method
  8268. supplied for returning multiple values to Scheme from C or vice versa
  8269. (mainly because C does not have multiple return values).
  8270. </p>
  8271. <p>Keyboard interrupts that occur during a call to a C function are
  8272. ignored until the function returns to Scheme.<a id="DOCF26" href="#FOOT26"><sup>26</sup></a>
  8273. </p></dd></dl>
  8274. <span id="index-importing-C-functions-to-Scheme-1"></span>
  8275. <dl>
  8276. <dt id="index-import_002ddefinition">Scheme syntax: <strong>import-definition</strong> <em>name [c-string]</em></dt>
  8277. <dt id="index-import_002dlambda_002ddefinition">Scheme syntax: <strong>import-lambda-definition</strong> <em>name formals [c-string]</em></dt>
  8278. <dd><p>These macros simplify importing bindings from C into Scheme and
  8279. wrapping such bindings in Scheme procedures. <code>Import-definition</code>
  8280. defines <var>name</var> to be the shared binding named by <var>c-string</var>,
  8281. whose value, if it is not supplied, is by default a string of
  8282. <var>name</var>, downcased and with all hyphens translated to underscores.
  8283. </p>
  8284. <div class="lisp">
  8285. <pre class="lisp">(define <var>name</var> (lookup-imported-binding <var>c-string</var>))</pre></div>
  8286. <p>For example,
  8287. </p>
  8288. <div class="lisp">
  8289. <pre class="lisp">(import-definition my-foo)
  8290. &rarr; (define my-foo (lookup-imported-binding &quot;my_foo&quot;))</pre></div>
  8291. <p><code>Import-lambda-definition</code> imports the named C binding, using
  8292. either the provided C binding name or by translating the Scheme name
  8293. as with <code>import-definition</code>, and defines <var>name</var> to be a
  8294. procedure with the given formal parameter list that calls the imported
  8295. C binding with its arguments:
  8296. </p>
  8297. <div class="lisp">
  8298. <pre class="lisp">(define <var>binding</var> (lookup-imported-binding <var>c-string</var>))
  8299. (define (<var>name</var> <var>formal</var> &hellip;)
  8300. (call-imported-binding <var>binding</var> <var>formal</var> &hellip;))</pre></div>
  8301. <p>Examples:
  8302. </p>
  8303. <div class="lisp">
  8304. <pre class="lisp">(import-lambda-definition integer-&gt;process-id (int)
  8305. &quot;posix_getpid&quot;)
  8306. &rarr;
  8307. (define <var>binding<sub>0</sub></var>
  8308. (lookup-imported-binding &quot;posix_getpid&quot;))
  8309. (define (integer-&gt;process-id int)
  8310. (call-imported-binding <var>binding<sub>0</sub></var> int))
  8311. (import-lambda-definition s48-system (string))
  8312. &rarr;
  8313. (define <var>binding<sub>1</sub></var>
  8314. (lookup-imported-binding &quot;s48_system&quot;))
  8315. (define (s48-system string)
  8316. (call-imported-binding <var>binding<sub>1</sub></var> string))</pre></div>
  8317. <p>where <var>binding<sub>0</sub></var> and <var>binding<sub>1</sub></var> are fresh, unused
  8318. variable names.
  8319. </p>
  8320. <p><strong>Warning:</strong> <code>Import-lambda-definition</code>, as presently
  8321. implemented, requires a fixed parameter list; it does not allow &lsquo;rest
  8322. list&rsquo; arguments.
  8323. </p></dd></dl>
  8324. <dl>
  8325. <dt id="index-lookup_002dimported_002dbinding-1">Scheme procedure: <strong>lookup-imported-binding</strong> <em>name --&gt; shared-binding</em></dt>
  8326. <dt id="index-define_002dexported_002dbinding-1">Scheme procedure: <strong>define-exported-binding</strong> <em>shared-binding --&gt; unspecified</em></dt>
  8327. <dt id="index-shared_002dbinding_002dref-1">Scheme procedure: <strong>shared-binding-ref</strong> <em>shared-binding --&gt; value</em></dt>
  8328. <dd><p>These are identical to the procedures accessible with the same names
  8329. from the <a href="#Shared-bindings-between-Scheme-and-C"><code>shared-bindings</code> structure</a>.
  8330. </p></dd></dl>
  8331. <dl>
  8332. <dt id="index-add_002dfinalizer_0021">Scheme procedure: <strong>add-finalizer!</strong> <em>object procedure --&gt; unspecified</em></dt>
  8333. <dd><p>Registers <var>procedure</var> as the finalizer for <var>object</var>. When
  8334. <var>object</var> is later about to be reclaimed by the garbage collector,
  8335. <var>procedure</var> is applied to one argument, <var>object</var>. All
  8336. finalizers are applied in a child of the root scheduler thread that is
  8337. spawned after every garbage collection. If an error occurs in any
  8338. finalizer, it will be printed to the standard error output port, and
  8339. all other finalizers will be aborted before they are given a chance to
  8340. run. Because of this, and the fact that finalizers are collected and
  8341. run after every garbage collection, they should perform as little
  8342. computation as possible. <var>Procedure</var> may also create new
  8343. references to <var>object</var> elsewhere in the heap, in which case the
  8344. object will not be reclaimed, but its associated finalizer will be
  8345. forgotten.
  8346. </p>
  8347. <p><strong>Warning:</strong> Finalizers are expensive. Use sparingly.
  8348. </p></dd></dl>
  8349. <dl>
  8350. <dt id="index-define_002drecord_002dresumer-1">Scheme procedure: <strong>define-record-resumer</strong> <em>record-type resumer --&gt; unspecified</em></dt>
  8351. <dd><p>Identical to the procedure accessible with the same name from the
  8352. <a href="#Records"><code>record-types</code> structure</a>. Record resumers
  8353. are often useful in working with foreign C data, which is in many
  8354. cases specific to the program image within the operating system, and
  8355. which cannot straightforwardly be relocated to a different address
  8356. space.
  8357. </p></dd></dl>
  8358. <hr>
  8359. <span id="Dynamic-loading-of-C-modules"></span><div class="header">
  8360. <p>
  8361. Next: <a href="#Accessing-Scheme-data-from-C" accesskey="n" rel="next">Accessing Scheme data from C</a>, Previous: <a href="#Calling-C-functions-from-Scheme" accesskey="p" rel="prev">Calling C functions from Scheme</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8362. </div>
  8363. <span id="Dynamic-loading-of-C-modules-1"></span><h3 class="section">7.4 Dynamic loading of C modules</h3>
  8364. <span id="index-C-dynamic-loading"></span>
  8365. <span id="index-C-shared-objects"></span>
  8366. <span id="index-load_002ddynamic_002dexternals-2"></span>
  8367. <p>External code can be loaded into a running Scheme48 on most Unices and
  8368. on Windows. Such external code must be stored in shared objects; see
  8369. below on details of the C side. The relevant Scheme procedures are
  8370. available in the <code>load-dynamic-externals</code> structure:
  8371. </p>
  8372. <dl>
  8373. <dt id="index-load_002ddynamic_002dexternals">procedure: <strong>load-dynamic-externals</strong> <em>filename add-file-type? reload-on-repeat? reload-on-resume? --&gt; dynamic-externals</em></dt>
  8374. <dt id="index-import_002ddynamic_002dexternals">procedure: <strong>import-dynamic-externals</strong> <em>filename --&gt; dynamic-externals</em></dt>
  8375. <dt id="index-unload_002ddynamic_002dexternals">procedure: <strong>unload-dynamic-externals</strong> <em>dynamic-externals --&gt; unspecified</em></dt>
  8376. <dd><p><code>Load-dynamic-external</code> loads a shared object from
  8377. <var>filename</var>, with an appropriate file type appended if
  8378. <var>add-file-type?</var> is true (<code>.so</code> on Unix and <code>.dll</code> on
  8379. Windows), and returns a <em>dynamic externals</em> object representing
  8380. the loaded shared object. If the shared object was already loaded,
  8381. then if <var>reload-on-repeat?</var> is true, it is reloaded; otherwise,
  8382. the <code>load-dynamic-externals</code> call has no effect. If the dynamic
  8383. externals descriptor is stored in a dumped heap image, when that heap
  8384. image is resumed, if <code>reload-on-resume?</code> is true, the shared
  8385. object corresponding with that dynamic external descriptor is
  8386. reloaded. <code>Unload-dynamic-externals</code> unloads the given dynamic
  8387. externals object.
  8388. </p>
  8389. <p><code>Import-dynamic-externals</code> is a convenient wrapper for the common
  8390. case of <code>load-dynamic-externals</code>; it is equivalent to
  8391. <code>(load-dynamic-externals #t #f #t)</code>, <i>i.e.</i> it will append a file
  8392. type, it will not reload the shared object if it was already loaded,
  8393. and the shared object will be loaded if part of a resumed heap image.
  8394. </p></dd></dl>
  8395. <dl>
  8396. <dt id="index-reload_002ddynamic_002dexternals">procedure: <strong>reload-dynamic-externals</strong> <em>filename --&gt; unspecified</em></dt>
  8397. <dd><p>Reloads the shared object named by <var>filename</var>. This is intended
  8398. as an interactive utility, which is why it accepts the filename of the
  8399. shared object and not a dynamic externals descriptor.
  8400. </p></dd></dl>
  8401. <p>Shared objects intended to be loaded into Scheme48 must define two
  8402. functions:
  8403. </p>
  8404. <dl>
  8405. <dt id="index-s48_005fon_005fload">C function: <em>void</em> <strong>s48_on_load</strong> <em>(void)</em></dt>
  8406. <dt id="index-s48_005fon_005freload">C function: <em>void</em> <strong>s48_on_reload</strong> <em>(void)</em></dt>
  8407. <dd><p><code>s48_on_load</code> is called when the shared object is initially
  8408. loaded by Scheme48. It typically consists of a number of invocations
  8409. of <code>S48_EXPORT_FUNCTION</code> to make C functions available to
  8410. Scheme48 code. <code>s48_on_reload</code> is called when the shared object
  8411. is reloaded after it has been initially loaded once; it typically just
  8412. calls <code>s48_on_load</code>, but it may perform other reinitializations.
  8413. </p></dd></dl>
  8414. <p>On Linux, the following commands compile the C source file
  8415. <samp>foo.c</samp> into a shared object <samp>foo.so</samp> that can be loaded
  8416. dynamically by Scheme48:
  8417. </p>
  8418. <div class="example">
  8419. <pre class="example">% gcc -c -o foo.o foo.c
  8420. % ld -shared -o foo.so foo.o</pre></div>
  8421. <span id="Old-dynamic-loading-interface"></span><h4 class="subsection">7.4.1 Old dynamic loading interface</h4>
  8422. <p>The old <code>dynamic-externals</code> structures, which exported
  8423. <code>dynamic-load</code>, <code>get-external</code>, <code>lookup-external</code>,
  8424. <code>lookup-all-externals</code>, <code>external?</code>, <code>external-name</code>,
  8425. <code>external-value</code>, and <code>call-external</code>, is still supported,
  8426. but it will not work on Windows, its use is deprecated, and it is
  8427. likely to vanish in a future release. The old documentation is
  8428. preserved to aid updating of old code:
  8429. </p>
  8430. <span id="index-dynamic_002dexternals-1"></span>
  8431. <p>On architectures that support it, external code can be loaded into a
  8432. running Scheme48 process, and C object file bindings can be accessed
  8433. at runtime &amp; their values called. These Scheme procedures are exported
  8434. by the structure <code>dynamic-externals</code>.
  8435. </p>
  8436. <p>In some Unices, retrieving a value from the current process may require
  8437. a non-trivial amount of computation. We recommend that a dynamically
  8438. loaded file contain a single initialization function that creates
  8439. shared bindings for the values exported by the file.
  8440. </p>
  8441. <dl>
  8442. <dt id="index-dynamic_002dload">Scheme procedure: <strong>dynamic-load</strong> <em>string --&gt; unspecified</em></dt>
  8443. <dd><p>Loads the filename named by <var>string</var> into the current process.
  8444. An exception is raised if the file cannot be found or if dynamic
  8445. loading is not supported by the host operating system. The file must
  8446. have been compiled &amp; linked appropriately. For Linux, for example,
  8447. the following commands compile <samp>foo.c</samp> into a file <samp>foo.so</samp>
  8448. that can be loaded dynamically:
  8449. </p>
  8450. <div class="example">
  8451. <pre class="example">% gcc -c -o foo.o foo.c
  8452. % ld -shared -o foo.so foo.o</pre></div>
  8453. </dd></dl>
  8454. <dl>
  8455. <dt id="index-get_002dexternal">Scheme procedure: <strong>get-external</strong> <em>string --&gt; external</em></dt>
  8456. <dt id="index-external_003f">Scheme procedure: <strong>external?</strong> <em>object --&gt; boolean</em></dt>
  8457. <dt id="index-external_002dname">Scheme procedure: <strong>external-name</strong> <em>external --&gt; string</em></dt>
  8458. <dt id="index-external_002dvalue">Scheme procedure: <strong>external-value</strong> <em>external --&gt; byte-vector</em></dt>
  8459. <dd><p>These procedures access external values bound in the current process.
  8460. <code>Get-external</code> returns a <em>external</em> object that contains the
  8461. value of the C binding with the name <var>string</var>. It signals a
  8462. warning if there is no such binding in the current process.
  8463. <code>External?</code> is the disjoint type predicate for externals, and
  8464. <code>external-name</code> &amp; <code>external-value</code> return the name &amp; value of
  8465. an external. The value is represented as a <a href="#Bitwise-manipulation">byte vector</a> of length four on 32-bit architectures. The
  8466. value is that of the C binding from when <code>get-external</code> (or
  8467. <code>lookup-external</code>, as described below) was called.
  8468. </p></dd></dl>
  8469. <dl>
  8470. <dt id="index-lookup_002dexternal">Scheme procedure: <strong>lookup-external</strong> <em>external --&gt; boolean</em></dt>
  8471. <dt id="index-lookup_002dall_002dexternals">Scheme procedure: <strong>lookup-all-externals</strong> <em>--&gt; boolean</em></dt>
  8472. <dd><p><code>Lookup-external</code> updates the value of <var>external</var> by looking
  8473. up its binding in the current process. It returns <code>#t</code> if the
  8474. external is bound and <code>#f</code> if not. <code>Lookup-all-externals</code>
  8475. calls <code>lookup-external</code> on all externals in the current Scheme48
  8476. image. It returns <code>#t</code> if all were bound and <code>#f</code> if there
  8477. was at least one unbound external.
  8478. </p></dd></dl>
  8479. <dl>
  8480. <dt id="index-call_002dexternal">Scheme procedure: <strong>call-external</strong> <em>external argument &hellip; --&gt; value</em></dt>
  8481. <dd><p>Calls the C function pointed to by <var>external</var> with the given
  8482. arguments, and returns the value that the C function returned. This
  8483. is like <code>call-imported-binding</code> and <code>call-external-value</code>
  8484. except that the function argument is represented as an external, not as
  8485. an imported binding or byte vector containing a pointer. For more
  8486. details, see <a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a>.
  8487. </p></dd></dl>
  8488. <hr>
  8489. <span id="Accessing-Scheme-data-from-C"></span><div class="header">
  8490. <p>
  8491. Next: <a href="#Calling-Scheme-procedures-from-C" accesskey="n" rel="next">Calling Scheme procedures from C</a>, Previous: <a href="#Dynamic-loading-of-C-modules" accesskey="p" rel="prev">Dynamic loading of C modules</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8492. </div>
  8493. <span id="Accessing-Scheme-data-from-C-1"></span><h3 class="section">7.5 Accessing Scheme data from C</h3>
  8494. <span id="index-s48_005fvalue"></span>
  8495. <span id="index-scheme48_002eh"></span>
  8496. <p>The C header file <samp>scheme48.h</samp> provides access to Scheme48 data
  8497. structures. The type <code>s48_value</code> is used for Scheme values. When
  8498. the type of a value is known, such as the integer returned by the
  8499. Scheme procedure <code>vector-length</code> or the boolean returned by
  8500. <code>pair</code>, the corresponding C function returns a C value of the
  8501. appropriate type, not an <code>s48_value</code>. Predicates return <code>1</code>
  8502. for true and <code>0</code> for false.
  8503. </p>
  8504. <span id="index-Scheme-constants-in-C"></span>
  8505. <span id="index-C-macros-for-Scheme-constants"></span>
  8506. <dl>
  8507. <dt id="index-S48_005fFALSE">C macro: <em>s48_value</em> <strong>S48_FALSE</strong></dt>
  8508. <dt id="index-S48_005fTRUE">C macro: <em>s48_value</em> <strong>S48_TRUE</strong></dt>
  8509. <dt id="index-S48_005fNULL">C macro: <em>s48_value</em> <strong>S48_NULL</strong></dt>
  8510. <dt id="index-S48_005fUNSPECIFIC">C macro: <em>s48_value</em> <strong>S48_UNSPECIFIC</strong></dt>
  8511. <dt id="index-S48_005fEOF">C macro: <em>s48_value</em> <strong>S48_EOF</strong></dt>
  8512. <dt id="index-S48_005fMAX_005fFIXNUM_005fVALUE">C macro: <em>long</em> <strong>S48_MAX_FIXNUM_VALUE</strong></dt>
  8513. <dt id="index-S48_005fMIN_005fFIXNUM_005fVALUE">C macro: <em>long</em> <strong>S48_MIN_FIXNUM_VALUE</strong></dt>
  8514. <dd><p>These C macros denote various Scheme constants. <code>S48_FALSE</code> is
  8515. the boolean false value, written in Scheme as <code>#f</code>.
  8516. <code>S48_TRUE</code> is the boolean true value, or <code>#t</code>.
  8517. <code>S48_NULL</code> is the empty list <code>()</code>. <code>S48_UNSPECIFIC</code> is
  8518. a miscellaneous value returned by procedures that have no meaningful
  8519. return value (accessed in Scheme48 by the nullary procedure
  8520. <code>unspecific</code> in the <code>util</code> structure). <code>S48_EOF</code> is
  8521. the end-of-file object (which the Scheme procedure <code>eof-object?</code>
  8522. answers true for). <code>S48_MAX_FIXNUM_VALUE</code> is the maximum integer
  8523. as a <code>long</code> that can be represented in a Scheme48 fixnum.
  8524. <code>S48_MIN_FIXNUM_VALUE</code> is similar, but the minimum integer.
  8525. </p></dd></dl>
  8526. <span id="index-C-and-Scheme-data-conversion"></span>
  8527. <span id="index-Scheme-and-C-data-conversion"></span>
  8528. <dl>
  8529. <dt id="index-S48_005fEXTRACT_005fBOOLEAN">C macro: <em>int</em> <strong>S48_EXTRACT_BOOLEAN</strong> <em>(s48_value <var>boolean</var>)</em></dt>
  8530. <dt id="index-s48_005fextract_005fchar">C function: <em>unsigned char</em> <strong>s48_extract_char</strong> <em>(s48_value <var>char</var>)</em></dt>
  8531. <dt id="index-s48_005fextract_005fstring">C function: <em>char *</em> <strong>s48_extract_string</strong> <em>(s48_value <var>string</var>)</em></dt>
  8532. <dt id="index-s48_005fextract_005fbyte_005fvector">C function: <em>char *</em> <strong>s48_extract_byte_vector</strong> <em>(s48_value <var>bytev</var>)</em></dt>
  8533. <dt id="index-s48_005fextract_005finteger">C function: <em>long</em> <strong>s48_extract_integer</strong> <em>(s48_value <var>integer</var>)</em></dt>
  8534. <dt id="index-s48_005fextract_005fdouble">C function: <em>double</em> <strong>s48_extract_double</strong> <em>(s48_value <var>double</var>)</em></dt>
  8535. <dt id="index-S48_005fENTER_005fBOOLEAN">C macro: <em>s48_value</em> <strong>S48_ENTER_BOOLEAN</strong> <em>(int <var>boolean</var>)</em></dt>
  8536. <dt id="index-s48_005fenter_005fchar">C function: <em>s48_value</em> <strong>s48_enter_char</strong> <em>(unsigned char <var>char</var>)</em></dt>
  8537. <dt id="index-s48_005fenter_005fstring">C function: <em>s48_value</em> <strong>s48_enter_string</strong> <em>(char *<var>string</var>)</em></dt>
  8538. <dt id="index-s48_005fenter_005fbyte_005fvector">C function: <em>s48_value</em> <strong>s48_enter_byte_vector</strong> <em>(char *<var>bytev</var>, long <var>length</var>)</em></dt>
  8539. <dt id="index-s48_005fenter_005finteger">C function: <em>s48_value</em> <strong>s48_enter_integer</strong> <em>(long <var>integer</var>)</em></dt>
  8540. <dt id="index-s48_005fenter_005fdouble">C function: <em>s48_value</em> <strong>s48_enter_double</strong> <em>(double <var>double</var>)</em></dt>
  8541. <dd><p>These functions &amp; macros convert values between their respective Scheme
  8542. &amp; C representations.
  8543. </p>
  8544. <p><code>S48_EXTRACT_BOOLEAN</code> returns <code>0</code> if <var>boolean</var> is
  8545. <code>#f</code> and <code>1</code> otherwise. <code>S48_ENTER_BOOLEAN</code> returns the
  8546. Scheme value <code>#f</code> if its argument is zero and <code>#t</code> otherwise.
  8547. </p>
  8548. <p><code>s48_extract_char</code> &amp; <code>s48_enter_char</code> convert between Scheme
  8549. characters and C <code>char</code>s.
  8550. </p>
  8551. <p><code>s48_extract_string</code> &amp; <code>s48_extract_byte_vector</code> return
  8552. pointers to the actual storage used by <var>string</var> or <var>bytev</var>.
  8553. These pointers are valid only until the next garbage collection,
  8554. however; see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
  8555. <code>s48_enter_string</code> &amp; <code>s48_enter_byte_vector</code> allocate
  8556. space on the Scheme48 heap for the given strings or byte vectors.
  8557. <code>s48_enter_string</code> copies the data starting from the pointer it
  8558. is given up to the first ASCII <code>NUL</code> character, whereas
  8559. <code>s48_enter_byte_vector</code> is given the number of bytes to copy into
  8560. the Scheme heap.
  8561. </p>
  8562. <p><code>s48_extract_integer</code> returns a C <code>long</code> that represents the
  8563. Scheme integer as input. If the Scheme integer is too large to be
  8564. represented in a long, an exception is signalled. (The Scheme integer
  8565. may be a fixnum or a bignum.) <code>s48_enter_integer</code> converts back
  8566. to Scheme integers, and it will never signal an exception.
  8567. </p>
  8568. <p><code>s48_extract_double</code> &amp; <code>s48_enter_double</code> convert between
  8569. Scheme &amp; C double-precision floating point representations.
  8570. </p>
  8571. <p>Of these, <code>s48_enter_string</code>, <code>s48_enter_byte_vector</code>,
  8572. <code>s48_enter_integer</code>, &amp; <code>s48_enter_double</code> may cause the
  8573. garbage collector to be invoked: the former two copy the string or
  8574. byte vector onto the Scheme heap first, <code>s48_enter_integer</code> may
  8575. need to allocate a bignum (since C <code>long</code>s are wider than Scheme48
  8576. fixnums), and floats are heap-allocated in Scheme48.
  8577. </p></dd></dl>
  8578. <span id="index-Scheme-boolean-testing-in-C"></span>
  8579. <span id="index-C-macros-on-Scheme-booleans"></span>
  8580. <dl>
  8581. <dt id="index-S48_005fTRUE_005fP">C macro: <em>int</em> <strong>S48_TRUE_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8582. <dt id="index-S48_005fFALSE_005fP">C macro: <em>int</em> <strong>S48_FALSE_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8583. <dd><p><code>S48_TRUE_P</code> returns true if <var>object</var> is the true constant
  8584. <code>S48_TRUE</code> and false if otherwise. <code>S48_FALSE_P</code> returns
  8585. true if its argument is the false constant <code>S48_FALSE</code> and false
  8586. if otherwise.
  8587. </p></dd></dl>
  8588. <span id="index-Scheme-fixnums-from-C"></span>
  8589. <span id="index-C-access-to-Scheme-fixnums"></span>
  8590. <dl>
  8591. <dt id="index-S48_005fFIXNUM_005fP">C macro: <em>int</em> <strong>S48_FIXNUM_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8592. <dt id="index-s48_005fextract_005ffixnum">C function: <em>long</em> <strong>s48_extract_fixnum</strong> <em>(s48_value <var>fixnum</var>)</em></dt>
  8593. <dt id="index-s48_005fenter_005ffixnum">C function: <em>s48_value</em> <strong>s48_enter_fixnum</strong> <em>(long <var>integer</var>)</em></dt>
  8594. <dd><p><code>S48_FIXNUM_P</code> is the C predicate for Scheme48 fixnums, delimited
  8595. in range by <code>S48_MIN_FIXNUM_VALUE</code> &amp; <code>S48_MAX_FIXNUM_VALUE</code>.
  8596. <code>s48_extract_fixnum</code> returns the C <code>long</code> representation of
  8597. the Scheme fixnum, and <code>s48_enter_fixnum</code> returns the Scheme
  8598. fixnum representation of the C <code>long</code>. These are identical to
  8599. <code>s48_extract_integer</code> &amp; <code>s48_enter_integer</code>, except that
  8600. <code>s48_extract_fixnum</code> will never raise a range exception, but
  8601. <code>s48_enter_fixnum</code> may, and <code>s48_enter_fixnum</code> will never
  8602. return a bignum; this is due to the fact that C <code>long</code>s have a
  8603. wider range than Scheme48 fixnums.
  8604. </p></dd></dl>
  8605. <span id="index-Scheme-data-predicates-in-C"></span>
  8606. <span id="index-C-predicates-for-Scheme-data"></span>
  8607. <dl>
  8608. <dt id="index-S48_005fEQ_005fP">C macro: <em>int</em> <strong>S48_EQ_P</strong> <em>(s48_value <var>a</var>, s48_value <var>b</var>)</em></dt>
  8609. <dt id="index-S48_005fCHAR_005fP">C macro: <em>int</em> <strong>S48_CHAR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8610. <dt id="index-S48_005fPAIR_005fP">C macro: <em>int</em> <strong>S48_PAIR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8611. <dt id="index-S48_005fVECTOR_005fP">C macro: <em>int</em> <strong>S48_VECTOR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8612. <dt id="index-S48_005fSTRING_005fP">C macro: <em>int</em> <strong>S48_STRING_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8613. <dt id="index-S48_005fSYMBOL_005fP">C macro: <em>int</em> <strong>S48_SYMBOL_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8614. <dt id="index-S48_005fBYTE_005fVECTOR_005fP">C macro: <em>int</em> <strong>S48_BYTE_VECTOR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8615. <dd><span id="index-Scheme-pair-operations-in-C"></span>
  8616. <span id="index-C-access-to-Scheme-pairs"></span>
  8617. </dd><dt id="index-S48_005fCAR">C macro: <em>s48_value</em> <strong>S48_CAR</strong> <em>(s48_value <var>pair</var>)</em></dt>
  8618. <dt id="index-S48_005fCDR">C macro: <em>s48_value</em> <strong>S48_CDR</strong> <em>(s48_value <var>pair</var>)</em></dt>
  8619. <dt id="index-S48_005fSET_005fCAR">C macro: <em>void</em> <strong>S48_SET_CAR</strong> <em>(s48_value <var>pair</var>, s48_value <var>object</var>)</em></dt>
  8620. <dt id="index-S48_005fSET_005fCDR">C macro: <em>void</em> <strong>S48_SET_CDR</strong> <em>(s48_value <var>pair</var>, s48_value <var>object</var>)</em></dt>
  8621. <dt id="index-s48_005fcons">C function (may GC): <em>s48_value</em> <strong>s48_cons</strong> <em>(s48_value <var>car</var>, s48_value <var>cdr</var>)</em></dt>
  8622. <dt id="index-s48_005flength">C function: <em>s48_value</em> <strong>s48_length</strong> <em>(s48_value <var>list</var>)</em></dt>
  8623. <dd><span id="index-Scheme-vector-operations-in-C"></span>
  8624. <span id="index-C-access-to-Scheme-vectors"></span>
  8625. </dd><dt id="index-S48_005fVECTOR_005fLENGTH">C macro: <em>long</em> <strong>S48_VECTOR_LENGTH</strong> <em>(s48_value <var>vector</var>)</em></dt>
  8626. <dt id="index-S48_005fVECTOR_005fREF">C macro: <em>s48_value</em> <strong>S48_VECTOR_REF</strong> <em>(s48_value <var>vector</var>, long <var>index</var>)</em></dt>
  8627. <dt id="index-S48_005fVECTOR_005fSET">C macro: <em>void</em> <strong>S48_VECTOR_SET</strong> <em>(s48_value <var>vector</var>, long <var>index</var>, s48_value <var>object</var>)</em></dt>
  8628. <dt id="index-s48_005fmake_005fvector">C function (may GC): <em>s48_value</em> <strong>s48_make_vector</strong> <em>(long <var>length</var>, s48_value <var>fill</var>)</em></dt>
  8629. <dd><span id="index-Scheme-string-operations-in-C"></span>
  8630. <span id="index-C-access-to-Scheme-strings"></span>
  8631. </dd><dt id="index-S48_005fSTRING_005fLENGTH">C macro: <em>long</em> <strong>S48_STRING_LENGTH</strong> <em>(s48_value <var>string</var>)</em></dt>
  8632. <dt id="index-S48_005fSTRING_005fREF">C macro: <em>char</em> <strong>S48_STRING_REF</strong> <em>(s48_value <var>string</var>, long <var>index</var>)</em></dt>
  8633. <dt id="index-S48_005fSTRING_005fSET">C macro: <em>void</em> <strong>S48_STRING_SET</strong> <em>(s48_value <var>string</var>, long <var>index</var>, char <var>char</var>)</em></dt>
  8634. <dt id="index-s48_005fmake_005fstring">C function (may GC): <em>s48_value</em> <strong>s48_make_string</strong> <em>(long <var>length</var>, char <var>fill</var>)</em></dt>
  8635. <dt id="index-S48_005fSYMBOL_005fTO_005fSTRING">C macro: <em>s48_value</em> <strong>S48_SYMBOL_TO_STRING</strong> <em>(s48_value <var>symbol</var>)</em></dt>
  8636. <dd><span id="index-Scheme-byte-vector-operations-in-C"></span>
  8637. <span id="index-C-access-to-Scheme-byte-vectors"></span>
  8638. </dd><dt id="index-S48_005fBYTE_005fVECTOR_005fLENGTH">C macro: <em>long</em> <strong>S48_BYTE_VECTOR_LENGTH</strong> <em>(s48_value <var>bytev</var>)</em></dt>
  8639. <dt id="index-S48_005fBYTE_005fVECTOR_005fREF">C macro: <em>char</em> <strong>S48_BYTE_VECTOR_REF</strong> <em>(s48_value <var>bytev</var>, long <var>index</var>)</em></dt>
  8640. <dt id="index-S48_005fBYTE_005fVECTOR_005fSET">C macro: <em>void</em> <strong>S48_BYTE_VECTOR_SET</strong> <em>(s48_value <var>bytev</var>, long <var>index</var>, char <var>byte</var>)</em></dt>
  8641. <dt id="index-s48_005fmake_005fbyte_005fvector">C function (may GC): <em>s48_value</em> <strong>s48_make_byte_vector</strong> <em>(long <var>length</var>)</em></dt>
  8642. <dd><p>C versions of miscellaneous Scheme procedures. The names were derived
  8643. from their Scheme counterparts by replacing hyphens with underscores,
  8644. <code>?</code> suffixes with <code>_P</code>, and dropping <code>!</code> suffixes.
  8645. </p></dd></dl>
  8646. <hr>
  8647. <span id="Calling-Scheme-procedures-from-C"></span><div class="header">
  8648. <p>
  8649. Next: <a href="#Interacting-with-the-Scheme-heap-in-C" accesskey="n" rel="next">Interacting with the Scheme heap in C</a>, Previous: <a href="#Accessing-Scheme-data-from-C" accesskey="p" rel="prev">Accessing Scheme data from C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8650. </div>
  8651. <span id="Calling-Scheme-procedures-from-C-1"></span><h3 class="section">7.6 Calling Scheme procedures from C</h3>
  8652. <span id="index-Scheme-callbacks-in-C"></span>
  8653. <dl>
  8654. <dt id="index-s48_005fcall_005fscheme">C function: <em>s48_value</em> <strong>s48_call_scheme</strong> <em>(s48_value <var>proc</var>, long <var>nargs</var>, ...)</em></dt>
  8655. <dd><p>Calls the Scheme procedure <var>proc</var> on <var>nargs</var> arguments, which
  8656. are passed as additional arguments to <code>s48_call_scheme</code>. There
  8657. may be at most twelve arguments. The value returned by the Scheme
  8658. procedure is returned to the C procedure. Calling any Scheme procedure
  8659. may potentially cause a garbage collection.
  8660. </p></dd></dl>
  8661. <span id="index-callbacks-from-C-and-continuations"></span>
  8662. <span id="index-continuations-and-callbacks-from-C"></span>
  8663. <span id="index-callbacks-from-C-and-threads"></span>
  8664. <span id="index-threads-and-callbacks-from-C"></span>
  8665. <span id="index-interaction-between-continuations-and-C"></span>
  8666. <p>There are some complications that arise when mixing calls from C to
  8667. Scheme with continuations &amp; threads. C supports only downward
  8668. continuations (via <code>longjmp()</code>). Scheme continuations that
  8669. capture a portion of the C stack have to follow the same restriction.
  8670. For example, suppose Scheme procedure <code>s0</code> captures continuation
  8671. <code>a</code> and then calls C function <code>c0</code>, which in turn calls
  8672. Scheme procedure <code>s1</code>. <code>S1</code> can safely call the continuation
  8673. <code>a</code>, because that is a downward use. When <code>a</code> is called,
  8674. Scheme48 will remove the portion of the C stack used by the call to
  8675. <code>c0</code>. On the other hand, if <code>s1</code> captures a continuation,
  8676. that continuation cannot be used from <code>s0</code>, because, by the time
  8677. control returns to <code>s0</code>, the C stack used by <code>s0</code> will no
  8678. longer be valid. An attempt to invoke an upward continuation that is
  8679. closed over a portion of the C stack will raise an exception.
  8680. </p>
  8681. <p>In Scheme48, threads are implemented using continuations, so the
  8682. downward restriction applies to them as well. An attempt to return
  8683. from Scheme to C at a time when the appropriate C frame is not on the
  8684. top of the C stack will cause the current thread to block until the
  8685. frame is available. For example, suppose thread <code>t0</code> calls a C
  8686. function that calls back to Scheme, at which point control switches to
  8687. thread <code>t1</code>, which also calls C &amp; then back to Scheme. At this
  8688. point, both <code>t0</code> &amp; <code>t1</code> have active calls to C on the C
  8689. stack, with <code>t1</code>&rsquo;s C frame above <code>t0</code>&rsquo;s. If <code>t0</code>
  8690. attempts to return from Scheme to C, it will block, because the frame
  8691. is not yet accessible. Once <code>t1</code> has returned to C and from there
  8692. back to Scheme, <code>t0</code> will be able to resume. The return to Scheme
  8693. is required because context switches can occur only while Scheme code
  8694. is running. <code>T0</code> will also be able to resume if <code>t1</code> uses a
  8695. continuation to throw past its call out to C.
  8696. </p><hr>
  8697. <span id="Interacting-with-the-Scheme-heap-in-C"></span><div class="header">
  8698. <p>
  8699. Next: <a href="#Using-Scheme-records-in-C" accesskey="n" rel="next">Using Scheme records in C</a>, Previous: <a href="#Calling-Scheme-procedures-from-C" accesskey="p" rel="prev">Calling Scheme procedures from C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8700. </div>
  8701. <span id="Interacting-with-the-Scheme-heap-in-C-1"></span><h3 class="section">7.7 Interacting with the Scheme heap in C</h3>
  8702. <span id="index-GC-protection-in-C"></span>
  8703. <p>Scheme48 uses a precise copying garbage collector. Any code that
  8704. allocates objects within the Scheme48 heap may trigger a garbage
  8705. collection. Variables bound to values in the Scheme48 heap need to be
  8706. registered with the garbage collector so that the value will be safely
  8707. held and so that the variables will be updated if the garbage collector
  8708. moves the object. The garbage collector has no facility for updating
  8709. pointers to the interiors of objects, so such pointers, for example the
  8710. ones returned by <code>S48_EXTRACT_STRING</code>, will likely become invalid
  8711. when a garbage collection occurs.
  8712. </p>
  8713. <dl>
  8714. <dt id="index-S48_005fDECLARE_005fGC_005fPROTECT">C macro: <em></em> <strong>S48_DECLARE_GC_PROTECT</strong> <em>(<var>n</var>)</em></dt>
  8715. <dt id="index-S48_005fGC_005fPROTECT_005fn">C macro: <em>void</em> <strong>S48_GC_PROTECT_<var>n</var></strong> <em>(s48_value <var>var</var><sub>1</sub>, &hellip;, s48_value <var>var</var><sub><var>n</var></sub>)</em></dt>
  8716. <dt id="index-S48_005fGC_005fUNPROTECT">C macro: <em>void</em> <strong>S48_GC_UNPROTECT</strong> <em>()</em></dt>
  8717. <dd><p><code>S48_DECLARE_GC_PROTECT</code>, where 1 &lt;= <var>n</var> &lt;= 9, allocates
  8718. storage for registering <var>n</var> variables. At most one use of
  8719. <code>S48_DECLARE_GC_PROTECT</code> may occur in a block. After declaring a
  8720. GC protection, <code>S48_GC_PROTECT_<var>n</var></code> registers the <var>n</var>
  8721. variables with the garbage collector. It must be within the scope that
  8722. the <code>S48_DECLARE_GC_PROTECT</code> occurred in and before any code that
  8723. can cause a garbage collection. <code>S48_GC_UNPROTECT</code> removes the
  8724. current block&rsquo;s protected variables from the garbage collector&rsquo;s list.
  8725. It must be called at the end of the block after any code that may cause
  8726. a garbage collection. Omitting any of the three may cause serious and
  8727. hard-to-debug problems, because the garbage collector may relocate an
  8728. object and invalidate unprotected <code>s48_value</code> pointers. If not
  8729. <code>S48_DECLARE_GC_PROTECT</code> is matched with a <code>S48_GC_UNPROTECT</code>
  8730. or vice versa, a <code>gc-protection-mismatch</code> exception is raised when
  8731. a C procedure returns to Scheme.
  8732. </p></dd></dl>
  8733. <dl>
  8734. <dt id="index-S48_005fGC_005fPROTECT_005fGLOBAL">C macro: <em>void *</em> <strong>S48_GC_PROTECT_GLOBAL</strong> <em>(<var>global</var>)</em></dt>
  8735. <dt id="index-S48_005fGC_005fUNPROTECT_005fGLOBAL">C macro: <em>void</em> <strong>S48_GC_UNPROTECT_GLOBAL</strong> <em>(void *<var>handle</var>)</em></dt>
  8736. <dd><p><code>S48_GC_PROTECT_GLOBAL</code> permanently registers the l-value
  8737. <var>global</var> with the system as a garbage collection root. It returns
  8738. a pointer which may then be supplied to <code>S48_GC_UNPROTECT_GLOBAL</code>
  8739. to unregister the l-value as a root.
  8740. </p></dd></dl>
  8741. <span id="Keeping-C-data-structures-in-the-Scheme-heap"></span><h4 class="subsection">7.7.1 Keeping C data structures in the Scheme heap</h4>
  8742. <span id="index-storing-C-data-in-the-Scheme-heap"></span>
  8743. <p>C data structures can be stored within the Scheme heap by embedding
  8744. them inside <a href="#Bitwise-manipulation">byte vectors</a>. The
  8745. following macros can be used to create and access embedded C objects.
  8746. </p>
  8747. <dl>
  8748. <dt id="index-S48_005fMAKE_005fVALUE">C macro: <em>s48_value</em> <strong>S48_MAKE_VALUE</strong> <em>(<var>type</var>)</em></dt>
  8749. <dt id="index-S48_005fEXTRACT_005fVALUE">C macro: <em><var>type</var></em> <strong>S48_EXTRACT_VALUE</strong> <em>(s48_value <var>bytev</var>, <var>type</var>)</em></dt>
  8750. <dt id="index-S48_005fEXTRACT_005fVALUE_005fPOINTER">C macro: <em><var>type</var> *</em> <strong>S48_EXTRACT_VALUE_POINTER</strong> <em>(s48_value <var>bytev</var>, <var>type</var>)</em></dt>
  8751. <dt id="index-S48_005fSET_005fVALUE">C macro: <em>void</em> <strong>S48_SET_VALUE</strong> <em>(s48_value <var>bytev</var>, <var>type</var>, <var>type</var> <var>value</var>)</em></dt>
  8752. <dd><p><code>S48_MAKE_VALUE</code> allocates a byte vector large enough to hold a C
  8753. value whose type is <var>type</var>. <code>S48_EXTRACT_VALUE</code> returns the
  8754. contents of the byte vector <var>bytev</var> cast to <var>type</var>, and
  8755. <code>S48_EXTRACT_VALUE_POINTER</code> returns a pointer to the contents of
  8756. the byte vector, which is valid only until the next garbage collection.
  8757. <code>S48_SET_VALUE</code> stores a value into the byte vector.
  8758. </p></dd></dl>
  8759. <span id="C-code-and-heap-images"></span><h4 class="subsection">7.7.2 C code and heap images</h4>
  8760. <span id="index-restoring-C-data-after-resuming-images"></span>
  8761. <span id="index-dumping-Scheme-heap-images-with-C-data"></span>
  8762. <span id="index-record-resumers"></span>
  8763. <p>Scheme48 uses dumped heap images to restore a previous system state.
  8764. The Scheme48 heap is written into a file in a machine-independent and
  8765. operating-system-independent format. The procedures described above,
  8766. however, may be used to create objects in the Scheme heap that contain
  8767. information specific to the current machine, operating system, or
  8768. process. A heap image containing such objects may not work correctly
  8769. when resumed.
  8770. </p>
  8771. <p>To address this problem, a record type may be given a <em>resumer</em>
  8772. procedure. On startup, the resumer procedure for a record type is
  8773. applied to each record of that type in the image being restarted. This
  8774. procedure can update the record in a manner appropriate to the machine,
  8775. operating system, or process used to resume the image. Note, though,
  8776. that there is no reliable order in which record resumer procedures are
  8777. applied. To specify the resumer for a record type, use the
  8778. <code>define-record-resumer</code> procedure from the <a href="#Records"><code>record-types</code> structure</a>.
  8779. </p><hr>
  8780. <span id="Using-Scheme-records-in-C"></span><div class="header">
  8781. <p>
  8782. Next: <a href="#Raising-exceptions-from-C" accesskey="n" rel="next">Raising exceptions from C</a>, Previous: <a href="#Interacting-with-the-Scheme-heap-in-C" accesskey="p" rel="prev">Interacting with the Scheme heap in C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8783. </div>
  8784. <span id="Using-Scheme-records-in-C-1"></span><h3 class="section">7.8 Using Scheme records in C</h3>
  8785. <p>External C code can create records and access record slots positionally
  8786. using these functions &amp; macros. Note, however, that named access to
  8787. record fields is not supported, only indexed access, so C code must be
  8788. synchronized carefully with the corresponding Scheme that defines
  8789. record types.
  8790. </p>
  8791. <dl>
  8792. <dt id="index-s48_005fmake_005frecord">C function (may GC): <em>s48_value</em> <strong>s48_make_record</strong> <em>(s48_value <var>record-type</var>)</em></dt>
  8793. <dt id="index-S48_005fRECORD_005fP">C macro: <em>int</em> <strong>S48_RECORD_P</strong> <em>(s48_value <var>object</var>)</em></dt>
  8794. <dt id="index-S48_005fRECORD_005fTYPE">C macro: <em>s48_value</em> <strong>S48_RECORD_TYPE</strong> <em>(s48_value <var>record</var>)</em></dt>
  8795. <dt id="index-S48_005fRECORD_005fREF">C macro: <em>s48_value</em> <strong>S48_RECORD_REF</strong> <em>(s48_value <var>record</var>, long <var>index</var>)</em></dt>
  8796. <dt id="index-S48_005fRECORD_005fSET">C macro: <em>void</em> <strong>S48_RECORD_SET</strong> <em>(s48_value <var>record</var>, long <var>index</var>, s48_value <var>value</var>)</em></dt>
  8797. <dt id="index-s48_005fcheck_005frecord_005ftype">C function: <em>void</em> <strong>s48_check_record_type</strong> <em>(s48_value <var>record</var>, s48_value <var>type-binding</var>)</em></dt>
  8798. <dd><p><code>s48_make_record</code> allocates a record on Scheme&rsquo;s heap with the
  8799. given record type; its arguments must be a shared binding whose value
  8800. is a record type descriptor (see <a href="#Records">Records</a>). <code>S48_RECORD_P</code>
  8801. is the type predicate for records. <code>S48_RECORD_TYPE</code> returns the
  8802. record type descriptor of <var>record</var>. <code>S48_RECORD_REF</code> &amp;
  8803. <code>S48_RECORD_SET</code> operate on records similarly to how
  8804. <code>S48_VECTOR_REF</code> &amp; <code>S48_VECTOR_SET</code> work on vectors.
  8805. <code>s48_check_record_type</code> checks whether <var>record</var> is a record
  8806. whose type is the value of the shared binding <var>type_binding</var>. If
  8807. this is not the case, it signals an exception. (It also signals an
  8808. exception if <var>type_binding</var>&rsquo;s value is not a record.) Otherwise,
  8809. it returns normally.
  8810. </p></dd></dl>
  8811. <p>For example, with this record type definition:
  8812. </p>
  8813. <div class="lisp">
  8814. <pre class="lisp">(define-record-type thing :thing
  8815. (make-thing a b)
  8816. thing?
  8817. (a thing-a)
  8818. (b thing-b))</pre></div>
  8819. <p>the identifier <code>:thing</code> is bound to the record type and can be
  8820. exported to C thus:
  8821. </p>
  8822. <div class="lisp">
  8823. <pre class="lisp">(define-exported-binding &quot;thing-record-type&quot; :thing)</pre></div>
  8824. <p>and <code>thing</code> records can be made in C:
  8825. </p>
  8826. <div class="example">
  8827. <pre class="example">static s48_value thing_record_type = S48_FALSE;
  8828. void initialize_things(void)
  8829. {
  8830. S48_GC_PROTECT_GLOBAL(thing_record_type);
  8831. thing_record_type = s48_get_imported_binding(&quot;thing-record-type&quot;);
  8832. }
  8833. s48_value make_thing(s48_value a, s48_value b)
  8834. {
  8835. s48_value thing;
  8836. S48_DECLARE_GC_PROTECT(2);
  8837. S48_GC_PROTECT_2(a, b);
  8838. thing = s48_make_record(thing_record_type);
  8839. S48_RECORD_SET(thing, 0, a);
  8840. S48_RECORD_SET(thing, 1, b);
  8841. S48_GC_UNPROTECT();
  8842. return thing;
  8843. }</pre></div>
  8844. <p>Note that the variables <code>a</code> &amp; <code>b</code> must be protected against
  8845. the possibility of a garbage collection occurring during the call to
  8846. <code>s48_make_record</code>.
  8847. </p><hr>
  8848. <span id="Raising-exceptions-from-C"></span><div class="header">
  8849. <p>
  8850. Next: <a href="#Unsafe-C-macros" accesskey="n" rel="next">Unsafe C macros</a>, Previous: <a href="#Using-Scheme-records-in-C" accesskey="p" rel="prev">Using Scheme records in C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8851. </div>
  8852. <span id="Raising-exceptions-from-C-1"></span><h3 class="section">7.9 Raising exceptions from C</h3>
  8853. <p>The following macros raise certain errors, immediately returning to
  8854. Scheme48. Raising an exception performs all necessary clean-up actions
  8855. to properly return to Scheme48, including adjusting the stack of
  8856. protected variables.
  8857. </p>
  8858. <dl>
  8859. <dt id="index-s48_005fraise_005fscheme_005fexception">C function: <em></em> <strong>s48_raise_scheme_exception</strong> <em>(int <var>type</var>, int <var>nargs</var>, ...)</em></dt>
  8860. <dd><p>The base procedure for raising exceptions. <var>Type</var> is the type of
  8861. exception; it should be one of the <code>S48_EXCEPTION_&hellip;</code>
  8862. constants defined in <samp>scheme48.h</samp>. <var>Nargs</var> is the number of
  8863. additional values to be included in the exception; these follow the
  8864. <var>nargs</var> argument and should all have the type <code>s48_value</code>.
  8865. <var>Nargs</var> may not be greater than ten.
  8866. <code>s48_raise_scheme_exception</code> never returns.
  8867. </p></dd></dl>
  8868. <dl>
  8869. <dt id="index-s48_005fraise_005fargument_005ftype_005ferror">C function: <em></em> <strong>s48_raise_argument_type_error</strong> <em>(s48_value <var>arg</var>)</em></dt>
  8870. <dt id="index-s48_005fraise_005fargument_005fnumber_005ferror">C function: <em></em> <strong>s48_raise_argument_number_error</strong> <em>(s48_value <var>nargs</var>, s48_value <var>min</var>, s48_value <var>max</var>)</em></dt>
  8871. <dt id="index-s48_005fraise_005frange_005ferror">C function: <em></em> <strong>s48_raise_range_error</strong> <em>(s48_value <var>value</var>, s48_value <var>min</var>, s48_value <var>max</var>)</em></dt>
  8872. <dt id="index-s48_005fraise_005fclosed_005fchannel_005ferror">C function: <em></em> <strong>s48_raise_closed_channel_error</strong> <em>()</em></dt>
  8873. <dt id="index-s48_005fraise_005fos_005ferror">C function: <em></em> <strong>s48_raise_os_error</strong> <em>(int <var>errno</var>)</em></dt>
  8874. <dt id="index-s48_005fraise_005fout_005fof_005fmemory_005ferror">C function: <em></em> <strong>s48_raise_out_of_memory_error</strong> <em>()</em></dt>
  8875. <dd><p>Conveniences for raising certain kinds of exceptions. Argument type
  8876. errors are due to procedures receiving arguments of the incorrect type.
  8877. Argument number errors are due to the number of arguments being passed
  8878. to a procedure, <var>nargs</var>, not being between <var>min</var> or <var>max</var>,
  8879. inclusive. Range errors are similar, but they are intended for larger
  8880. ranges, not argument numbers. Closed channel errors occur when a
  8881. <a href="#Channels">channel</a> was operated upon with the expectation
  8882. that it would not be closed. OS errors originate from the OS, and they
  8883. are denoted with Unix <code>errno</code> values.
  8884. </p></dd></dl>
  8885. <dl>
  8886. <dt id="index-S48_005fCHECK_005fBOOLEAN">C macro: <em>void</em> <strong>S48_CHECK_BOOLEAN</strong> <em>(s48_value <var>object</var>)</em></dt>
  8887. <dt id="index-S48_005fCHECK_005fSYMBOL">C macro: <em>void</em> <strong>S48_CHECK_SYMBOL</strong> <em>(s48_value <var>object</var>)</em></dt>
  8888. <dt id="index-S48_005fCHECK_005fPAIR">C macro: <em>void</em> <strong>S48_CHECK_PAIR</strong> <em>(s48_value <var>object</var>)</em></dt>
  8889. <dt id="index-S48_005fCHECK_005fSTRING">C macro: <em>void</em> <strong>S48_CHECK_STRING</strong> <em>(s48_value <var>object</var>)</em></dt>
  8890. <dt id="index-S48_005fCHECK_005fINTEGER">C macro: <em>void</em> <strong>S48_CHECK_INTEGER</strong> <em>(s48_value <var>object</var>)</em></dt>
  8891. <dt id="index-S48_005fCHECK_005fCHANNEL">C macro: <em>void</em> <strong>S48_CHECK_CHANNEL</strong> <em>(s48_value <var>object</var>)</em></dt>
  8892. <dt id="index-S48_005fCHECK_005fBYTE_005fVECTOR">C macro: <em>void</em> <strong>S48_CHECK_BYTE_VECTOR</strong> <em>(s48_value <var>object</var>)</em></dt>
  8893. <dt id="index-S48_005fCHECK_005fRECORD">C macro: <em>void</em> <strong>S48_CHECK_RECORD</strong> <em>(s48_value <var>object</var>)</em></dt>
  8894. <dt id="index-S48_005fCHECK_005fSHARED_005fBINDING">C macro: <em>void</em> <strong>S48_CHECK_SHARED_BINDING</strong> <em>(s48_value <var>object</var>)</em></dt>
  8895. <dd><p>Conveniences for checking argument types. These signal argument type
  8896. errors with <code>s48_raise_argument_type_error</code> if their argument is
  8897. not of the type being tested.
  8898. </p></dd></dl>
  8899. <hr>
  8900. <span id="Unsafe-C-macros"></span><div class="header">
  8901. <p>
  8902. Previous: <a href="#Raising-exceptions-from-C" accesskey="p" rel="prev">Raising exceptions from C</a>, Up: <a href="#C-interface" accesskey="u" rel="up">C interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8903. </div>
  8904. <span id="Unsafe-C-macros-1"></span><h3 class="section">7.10 Unsafe C macros</h3>
  8905. <p>All of the C functions &amp; macros described previously verify that their
  8906. arguments have the appropriate types and lie in the appropriate ranges.
  8907. The following macros are identical to their safe counterparts, except
  8908. that the unsafe variants, by contrast, do <em>not</em> verify coherency
  8909. of their arguments. They are provided for the purpose of writing more
  8910. efficient code; their general use is not recommended.
  8911. </p>
  8912. <dl>
  8913. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fCHAR">C macro: <em>char</em> <strong>S48_UNSAFE_EXTRACT_CHAR</strong> <em>(s48_value <var>char</var>)</em></dt>
  8914. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fSTRING">C macro: <em>char *</em> <strong>S48_UNSAFE_EXTRACT_STRING</strong> <em>(s48_value <var>string</var>)</em></dt>
  8915. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fINTEGER">C macro: <em>long</em> <strong>S48_UNSAFE_EXTRACT_INTEGER</strong> <em>(s48_value <var>integer</var>)</em></dt>
  8916. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fDOUBLE">C macro: <em>double</em> <strong>S48_UNSAFE_EXTRACT_DOUBLE</strong> <em>(s48_value <var>double</var>)</em></dt>
  8917. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fFIXNUM">C macro: <em>long</em> <strong>S48_UNSAFE_EXTRACT_FIXNUM</strong> <em>(s48_value <var>fixnum</var>)</em></dt>
  8918. <dt id="index-S48_005fUNSAFE_005fENTER_005fFIXNUM">C macro: <em>s48_value</em> <strong>S48_UNSAFE_ENTER_FIXNUM</strong> <em>(long <var>integer</var>)</em></dt>
  8919. </dl>
  8920. <br>
  8921. <dl>
  8922. <dt id="index-S48_005fUNSAFE_005fCAR">C macro: <em>s48_value</em> <strong>S48_UNSAFE_CAR</strong> <em>(s48_value <var>pair</var>)</em></dt>
  8923. <dt id="index-S48_005fUNSAFE_005fCDR">C macro: <em>s48_value</em> <strong>S48_UNSAFE_CDR</strong> <em>(s48_value <var>pair</var>)</em></dt>
  8924. <dt id="index-S48_005fUNSAFE_005fSET_005fCAR">C macro: <em>void</em> <strong>S48_UNSAFE_SET_CAR</strong> <em>(s48_value <var>pair</var>, s48_value <var>value</var>)</em></dt>
  8925. <dt id="index-S48_005fUNSAFE_005fSET_005fCDR">C macro: <em>void</em> <strong>S48_UNSAFE_SET_CDR</strong> <em>(s48_value <var>pair</var>, s48_value <var>value</var>)</em></dt>
  8926. </dl>
  8927. <br>
  8928. <dl>
  8929. <dt id="index-S48_005fUNSAFE_005fVECTOR_005fLENGTH">C macro: <em>long</em> <strong>S48_UNSAFE_VECTOR_LENGTH</strong> <em>(s48_value <var>vector</var>)</em></dt>
  8930. <dt id="index-S48_005fUNSAFE_005fVECTOR_005fREF">C macro: <em>s48_value</em> <strong>S48_UNSAFE_VECTOR_REF</strong> <em>(s48_value <var>vector</var>, long <var>index</var>)</em></dt>
  8931. <dt id="index-S48_005fUNSAFE_005fVECTOR_005fSET">C macro: <em>void</em> <strong>S48_UNSAFE_VECTOR_SET</strong> <em>(s48_value <var>vector</var>, long <var>index</var>, s48_value <var>value</var>)</em></dt>
  8932. </dl>
  8933. <br>
  8934. <dl>
  8935. <dt id="index-S48_005fUNSAFE_005fSTRING_005fLENGTH">C macro: <em>long</em> <strong>S48_UNSAFE_STRING_LENGTH</strong> <em>(s48_value <var>string</var>)</em></dt>
  8936. <dt id="index-S48_005fUNSAFE_005fSTRING_005fREF">C macro: <em>char</em> <strong>S48_UNSAFE_STRING_REF</strong> <em>(s48_value <var>string</var>, long <var>index</var>)</em></dt>
  8937. <dt id="index-S48_005fUNSAFE_005fSTRING_005fSET">C macro: <em>void</em> <strong>S48_UNSAFE_STRING_SET</strong> <em>(s48_value <var>string</var>, long <var>index</var>, char <var>char</var>)</em></dt>
  8938. </dl>
  8939. <br>
  8940. <dl>
  8941. <dt id="index-S48_005fUNSAFE_005fSYMBOL_005fTO_005fSTRING">C macro: <em>void</em> <strong>S48_UNSAFE_SYMBOL_TO_STRING</strong> <em>(s48_value <var>symbol</var>)</em></dt>
  8942. </dl>
  8943. <br>
  8944. <dl>
  8945. <dt id="index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fLENGTH">C macro: <em>long</em> <strong>S48_UNSAFE_BYTE_VECTOR_LENGTH</strong> <em>(s48_value <var>bytev</var>)</em></dt>
  8946. <dt id="index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fREF">C macro: <em>char</em> <strong>S48_UNSAFE_BYTE_VECTOR_REF</strong> <em>(s48_value <var>bytev</var>, long <var>index</var>)</em></dt>
  8947. <dt id="index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fSET">C macro: <em>void</em> <strong>S48_UNSAFE_BYTE_VECTOR_SET</strong> <em>(s48_value <var>bytev</var>, long <var>index</var>, char <var>byte</var>)</em></dt>
  8948. </dl>
  8949. <br>
  8950. <dl>
  8951. <dt id="index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fREF">C macro: <em>s48_value</em> <strong>S48_UNSAFE_SHARED_BINDING_REF</strong> <em>(s48_value <var>shared_binding</var>)</em></dt>
  8952. <dt id="index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fIS_005fIMPORTP">C macro: <em>int</em> <strong>S48_UNSAFE_SHARED_BINDING_IS_IMPORTP</strong> <em>(s48_value <var>shared_binding</var>)</em></dt>
  8953. <dt id="index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fNAME">C macro: <em>s48_value</em> <strong>S48_UNSAFE_SHARED_BINDING_NAME</strong> <em>(s48_value <var>shared_binding</var>)</em></dt>
  8954. <dt id="index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fSET">C macro: <em>void</em> <strong>S48_UNSAFE_SHARED_BINDING_SET</strong> <em>(s48_value <var>shared_binding</var>, s48_value <var>value</var>)</em></dt>
  8955. </dl>
  8956. <br>
  8957. <dl>
  8958. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fVALUE">C macro: <em><var>type</var></em> <strong>S48_UNSAFE_EXTRACT_VALUE</strong> <em>(s48_value <var>bytev</var>, <var>type</var>)</em></dt>
  8959. <dt id="index-S48_005fUNSAFE_005fEXTRACT_005fVALUE_005fPOINTER">C macro: <em><var>type</var> *</em> <strong>S48_UNSAFE_EXTRACT_VALUE_POINTER</strong> <em>(s48_value <var>bytev</var>, <var>type</var>)</em></dt>
  8960. <dt id="index-S48_005fUNSAFE_005fSET_005fVALUE">C macro: <em>void</em> <strong>S48_UNSAFE_SET_VALUE</strong> <em>(s48_value <var>bytev</var>, <var>type</var>, <var>type</var> <var>value</var>)</em></dt>
  8961. </dl>
  8962. <hr>
  8963. <span id="POSIX-interface"></span><div class="header">
  8964. <p>
  8965. Next: <a href="#Pre_002dScheme" accesskey="n" rel="next">Pre-Scheme</a>, Previous: <a href="#C-interface" accesskey="p" rel="prev">C interface</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  8966. </div>
  8967. <span id="POSIX-interface-1"></span><h2 class="chapter">8 POSIX interface</h2>
  8968. <p><i>(This chapter was derived from work copyrighted &copy;
  8969. 1993&ndash;2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
  8970. </p>
  8971. <p>This chapter describes Scheme48&rsquo;s interface to POSIX C calls. Scheme
  8972. versions of most of the C functions in POSIX are provided. Both the
  8973. interface and implementation are new and likely to change significantly
  8974. in future releases. The implementation may also contain many bugs.
  8975. </p>
  8976. <p>The POSIX bindings are available in several structures:
  8977. </p>
  8978. <dl compact="compact">
  8979. <dd><span id="index-posix_002dprocesses"></span>
  8980. </dd>
  8981. <dt><code>posix-processes</code></dt>
  8982. <dd><p><code>fork</code>, <code>exec</code>, and other process manipulation procedures
  8983. </p>
  8984. <span id="index-posix_002dprocess_002ddata"></span>
  8985. </dd>
  8986. <dt><code>posix-process-data</code></dt>
  8987. <dd><p>procedures for accessing information about processes
  8988. </p>
  8989. <span id="index-posix_002dfiles"></span>
  8990. </dd>
  8991. <dt><code>posix-files</code></dt>
  8992. <dd><p>POSIX file system access procedures
  8993. </p>
  8994. <span id="index-posix_002di_002fo"></span>
  8995. </dd>
  8996. <dt><code>posix-i/o</code></dt>
  8997. <dd><p>pipes and various POSIX I/O controls
  8998. </p>
  8999. <span id="index-posix_002dtime"></span>
  9000. </dd>
  9001. <dt><code>posix-time</code></dt>
  9002. <dd><p>POSIX time operations
  9003. </p>
  9004. <span id="index-posix_002dusers"></span>
  9005. </dd>
  9006. <dt><code>posix-users</code></dt>
  9007. <dd><p>user and group manipulation procedures
  9008. </p>
  9009. <span id="index-posix_002dregexps"></span>
  9010. </dd>
  9011. <dt><code>posix-regexps</code></dt>
  9012. <dd><p>POSIX regular expression construction and matching
  9013. </p>
  9014. <span id="index-posix"></span>
  9015. </dd>
  9016. <dt><code>posix</code></dt>
  9017. <dd><p>all of the above
  9018. </p></dd>
  9019. </dl>
  9020. <p>Scheme48&rsquo;s POSIX interface differs from scsh [Shivers 94; Shivers 96;
  9021. Shivers <i>et al.</i> 04] in several ways. The interface here lacks scsh&rsquo;s
  9022. high-level constructs and utilities such as the process notation,
  9023. <code>awk</code> facility, and parsing utilities. Scheme48 uses disjoint
  9024. types for some values that scsh leaves as symbols or simple integers;
  9025. these include file types, file modes, and user &amp; group ids. Many of
  9026. the names and other interface details are different as well.
  9027. </p>
  9028. <table class="menu" border="0" cellspacing="0">
  9029. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#POSIX-processes" accesskey="1">POSIX processes</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9030. </td></tr>
  9031. <tr><td align="left" valign="top">&bull; <a href="#POSIX-signals" accesskey="2">POSIX signals</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9032. </td></tr>
  9033. <tr><td align="left" valign="top">&bull; <a href="#POSIX-process-environment" accesskey="3">POSIX process environment</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9034. </td></tr>
  9035. <tr><td align="left" valign="top">&bull; <a href="#POSIX-users-and-groups" accesskey="4">POSIX users and groups</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9036. </td></tr>
  9037. <tr><td align="left" valign="top">&bull; <a href="#POSIX-host-OS-and-machine-identification" accesskey="5">POSIX host OS and machine identification</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9038. </td></tr>
  9039. <tr><td align="left" valign="top">&bull; <a href="#POSIX-file-system-access" accesskey="6">POSIX file system access</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9040. </td></tr>
  9041. <tr><td align="left" valign="top">&bull; <a href="#POSIX-time" accesskey="7">POSIX time</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9042. </td></tr>
  9043. <tr><td align="left" valign="top">&bull; <a href="#POSIX-I_002fO-utilities" accesskey="8">POSIX I/O utilities</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9044. </td></tr>
  9045. <tr><td align="left" valign="top">&bull; <a href="#POSIX-regular-expressions" accesskey="9">POSIX regular expressions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9046. </td></tr>
  9047. <tr><td align="left" valign="top">&bull; <a href="#POSIX-C-to-Scheme-correspondence">POSIX C to Scheme correspondence</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  9048. </td></tr>
  9049. </table>
  9050. <hr>
  9051. <span id="POSIX-processes"></span><div class="header">
  9052. <p>
  9053. Next: <a href="#POSIX-signals" accesskey="n" rel="next">POSIX signals</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9054. </div>
  9055. <span id="Processes"></span><h3 class="section">8.1 Processes</h3>
  9056. <span id="index-posix_002dprocesses-1"></span>
  9057. <p>The procedures described in this section control the creation of
  9058. subprocesses and the execution of programs. They exported by both the
  9059. <code>posix-processes</code> and <code>posix</code> structures.
  9060. </p>
  9061. <span id="index-forking"></span>
  9062. <span id="index-process-forking"></span>
  9063. <span id="index-POSIX-fork"></span>
  9064. <dl>
  9065. <dt id="index-fork">procedure: <strong>fork</strong> <em>--&gt; process id or <code>#f</code></em></dt>
  9066. <dt id="index-fork_002dand_002dforget">procedure: <strong>fork-and-forget</strong> <em>thunk --&gt; unspecified</em></dt>
  9067. <dd><p><code>Fork</code> creates a new child process. In the parent process, it
  9068. returns the child&rsquo;s process id; in the child process, it returns
  9069. <code>#f</code>. <code>Fork-and-forget</code> calls <var>thunk</var> in a new process;
  9070. no process id is returned. <code>Fork-and-forget</code> uses an intermediate
  9071. process to avoid creating a zombie.
  9072. </p></dd></dl>
  9073. <span id="index-process-ids"></span>
  9074. <span id="index-POSIX-process-ids"></span>
  9075. <dl>
  9076. <dt id="index-process_002did_003f">procedure: <strong>process-id?</strong> <em>object --&gt; boolean</em></dt>
  9077. <dt id="index-process_002did_003d_003f">procedure: <strong>process-id=?</strong> <em>pid<sub>a</sub> pid<sub>b</sub> --&gt; boolean</em></dt>
  9078. <dt id="index-process_002did_002d_003einteger">procedure: <strong>process-id-&gt;integer</strong> <em>pid --&gt; integer</em></dt>
  9079. <dt id="index-integer_002d_003eprocess_002did">procedure: <strong>integer-&gt;process-id</strong> <em>integer --&gt; pid</em></dt>
  9080. <dd><p><code>Process-id?</code> is the disjoint type predicate for process ids.
  9081. <code>Process-id=?</code> tests whether two process ids are the same.
  9082. <code>Process-id-&gt;integer</code> &amp; <code>integer-&gt;process-id</code> convert between
  9083. Scheme48&rsquo;s opaque process id type and POSIX process id integers.
  9084. </p></dd></dl>
  9085. <span id="index-process-termination"></span>
  9086. <span id="index-POSIX-process-termination"></span>
  9087. <span id="index-waiting-for-POSIX-processes"></span>
  9088. <dl>
  9089. <dt id="index-process_002did_002dexit_002dstatus">procedure: <strong>process-id-exit-status</strong> <em>pid --&gt; integer or <code>#f</code></em></dt>
  9090. <dt id="index-process_002did_002dterminating_002dsignal">procedure: <strong>process-id-terminating-signal</strong> <em>pid --&gt; signal or <code>#f</code></em></dt>
  9091. <dt id="index-wait_002dfor_002dchild_002dprocess">procedure: <strong>wait-for-child-process</strong> <em>pid --&gt; unspecified</em></dt>
  9092. <dd><p>If the process identified by <var>pid</var> exited normally or is running,
  9093. <code>process-id-exit-status</code> and <code>process-id-terminating-signal</code>
  9094. will both return <code>#f</code>. If, however, it terminated abnormally,
  9095. <code>process-id-exit-status</code> returns its exit status, and if it exited
  9096. due to a signal then <code>process-id-terminating-signal</code> returns the
  9097. signal due to which it exited. <code>Wait-for-child-process</code> blocks
  9098. the current process until the process identified by <var>pid</var> has
  9099. terminated. Scheme48 may reap child processes before the user requests
  9100. their exit status, but it does not always do so.
  9101. </p></dd></dl>
  9102. <span id="index-exiting-processes"></span>
  9103. <span id="index-POSIX-process-exiting"></span>
  9104. <dl>
  9105. <dt id="index-exit">procedure: <strong>exit</strong> <em>status --&gt; does not return</em></dt>
  9106. <dd><p>Terminates the current process with the integer <var>status</var> as its
  9107. exit status.
  9108. </p></dd></dl>
  9109. <span id="index-executing-processes"></span>
  9110. <span id="index-POSIX-exec"></span>
  9111. <dl>
  9112. <dt id="index-exec">procedure: <strong>exec</strong> <em>program argument &hellip; --&gt; does not return</em></dt>
  9113. <dt id="index-exec_002dwith_002denvironment">procedure: <strong>exec-with-environment</strong> <em>program env argument &hellip; --&gt; does not return</em></dt>
  9114. <dt id="index-exec_002dfile">procedure: <strong>exec-file</strong> <em>filename argument &hellip; --&gt; does not return</em></dt>
  9115. <dt id="index-exec_002dfile_002dwith_002denvironment">procedure: <strong>exec-file-with-environment</strong> <em>filename env argument &hellip; --&gt; does not return</em></dt>
  9116. <dd><p>These all replace the current program with a new one. They differ in
  9117. how the program is found and what process environment the program
  9118. should receive. <code>Exec</code> &amp; <code>exec-with-environment</code> look up
  9119. the program in the search path (the <code>PATH</code> environment variable),
  9120. while <code>exec-file</code> &amp; <code>exec-file-with-environment</code> execute a
  9121. particular file. The environment is either inherited from the
  9122. current process, in the cases of <code>exec</code> &amp; <code>exec-file</code>, or
  9123. explicitly specified, in the cases of <code>exec-with-environment</code> &amp;
  9124. <code>exec-file-with-environment</code>. <var>Program</var>, <var>filename</var>, &amp;
  9125. all <var>argument</var>s should be strings. <var>Env</var> should be a list of
  9126. strings of the form <code>&quot;<var>name</var>=<var>value</var>&quot;</code>. When the new
  9127. program is invoked, its arguments consist of the program name prepended
  9128. to the remaining specified arguments.
  9129. </p></dd></dl>
  9130. <dl>
  9131. <dt id="index-exec_002dwith_002dalias">procedure: <strong>exec-with-alias</strong> <em>name lookup? maybe-env arguments --&gt; does not return</em></dt>
  9132. <dd><p>General omnibus procedure that subsumes the other <code>exec</code> variants.
  9133. <var>Name</var> is looked up in the search path if <var>lookup?</var> is true or
  9134. used as an ordinary filename if it is false. <var>Maybe-env</var> is either
  9135. <code>#f</code>, in which case the new program&rsquo;s environment should be
  9136. inherited from the current process, or a list of strings of the above
  9137. form for environments, which specifies the new program&rsquo;s environment.
  9138. <var>Arguments</var> is a list of <em>all</em> of the program&rsquo;s arguments;
  9139. <code>exec-with-alias</code> does <em>not</em> prepend <var>name</var> to that list
  9140. (hence <code>-with-alias</code>).
  9141. </p></dd></dl>
  9142. <hr>
  9143. <span id="POSIX-signals"></span><div class="header">
  9144. <p>
  9145. Next: <a href="#POSIX-process-environment" accesskey="n" rel="next">POSIX process environment</a>, Previous: <a href="#POSIX-processes" accesskey="p" rel="prev">POSIX processes</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9146. </div>
  9147. <span id="Signals"></span><h3 class="section">8.2 Signals</h3>
  9148. <span id="index-posix_002dsignals"></span>
  9149. <p>There are two varieties of signals available, named &amp; anonymous. A
  9150. <em>named</em> signal is one for which there is provided a symbolic name,
  9151. such as <code>kill</code> or <code>pipe</code>. Anonymous signals are those that
  9152. the operating system provided but for which POSIX does not define a
  9153. symbolic name, only a number, and which may not have meaning on other
  9154. operating systems. Named signals preserve their meaning through heap
  9155. image dumps; anonymous signals may not be dumped in heap images. (If
  9156. they are, a warning is signalled, and they are replaced with a special
  9157. token that denotes a non-portable signal.) Not all named signals are
  9158. available from all operating systems, and there may be multiple names
  9159. for a single operating system signal number.
  9160. </p>
  9161. <dl>
  9162. <dt id="index-signal-1">syntax: <strong>signal</strong> <em>name --&gt; signal</em></dt>
  9163. <dt id="index-name_002d_003esignal">procedure: <strong>name-&gt;signal</strong> <em>symbol --&gt; signal or <code>#f</code></em></dt>
  9164. <dt id="index-integer_002d_003esignal">procedure: <strong>integer-&gt;signal</strong> <em>integer --&gt; signal</em></dt>
  9165. <dt id="index-signal_003f">procedure: <strong>signal?</strong> <em>object --&gt; boolean</em></dt>
  9166. <dt id="index-signal_002dname">procedure: <strong>signal-name</strong> <em>signal --&gt; symbol or <code>#f</code></em></dt>
  9167. <dt id="index-signal_002dos_002dnumber">procedure: <strong>signal-os-number</strong> <em>signal --&gt; integer</em></dt>
  9168. <dt id="index-signal_003d_003f">procedure: <strong>signal=?</strong> <em>signal<sub>a</sub> signal<sub>b</sub> --&gt; boolean</em></dt>
  9169. <dd><p><code>Signal</code> evaluates to the signal object with the known symbolic
  9170. name <var>name</var>. It is an error if <var>name</var> is not recognized as any
  9171. signal&rsquo;s name. <code>Name-&gt;signal</code> returns the signal corresponding
  9172. with the given <var>name</var> or <code>#f</code> if no such signal is known.
  9173. <code>Integer-&gt;signal</code> returns a signal, named or anonymous, with the
  9174. given OS number. <code>Signal?</code> is the disjoint type predicate for
  9175. signal objects. <code>Signal-name</code> returns the symbolic name of
  9176. <var>signal</var> if it is a named signal or <code>#f</code> if it is an anonymous
  9177. signal. <code>Signal-OS-number</code> returns the operating system&rsquo;s integer
  9178. value of <var>signal</var>. <code>Signal=?</code> tests whether two signals are
  9179. the same, <i>i.e.</i> whether their OS numbers are equal equal.
  9180. </p>
  9181. <p>These are all of the symbols that POSIX defines.
  9182. </p>
  9183. <dl compact="compact">
  9184. <dt><code>abrt</code></dt>
  9185. <dd><p>abnormal termination (as by <code>abort(3)</code>)
  9186. </p></dd>
  9187. <dt><code>alrm</code></dt>
  9188. <dd><p>timeout signal (as by <code>alarm(2)</code>)
  9189. </p></dd>
  9190. <dt><code>fpe</code></dt>
  9191. <dd><p>floating point exception
  9192. </p></dd>
  9193. <dt><code>hup</code></dt>
  9194. <dd><p>hangup on controlling terminal or death of controlling process
  9195. </p></dd>
  9196. <dt><code>ill</code></dt>
  9197. <dd><p>illegal instruction
  9198. </p></dd>
  9199. <dt><code>int</code></dt>
  9200. <dd><p>interrupt &mdash; interaction attention
  9201. </p></dd>
  9202. <dt><code>kill</code></dt>
  9203. <dd><p>termination signal, cannot be caught or ignored
  9204. </p></dd>
  9205. <dt><code>pipe</code></dt>
  9206. <dd><p>write was attempted on a pipe with no readers
  9207. </p></dd>
  9208. <dt><code>quit</code></dt>
  9209. <dd><p>interaction termination
  9210. </p></dd>
  9211. <dt><code>segv</code></dt>
  9212. <dd><p>segmentation violation &mdash; invalid memory reference
  9213. </p></dd>
  9214. <dt><code>term</code></dt>
  9215. <dd><p>termination signal
  9216. </p></dd>
  9217. <dt><code>usr1</code></dt>
  9218. <dt><code>usr2</code></dt>
  9219. <dd><p>for use by applications
  9220. </p></dd>
  9221. <dt><code>chld</code></dt>
  9222. <dd><p>child process stopped or terminated
  9223. </p></dd>
  9224. <dt><code>cont</code></dt>
  9225. <dd><p>continue if stopped
  9226. </p></dd>
  9227. <dt><code>stop</code></dt>
  9228. <dd><p>stop immediately, cannot be caught or ignored
  9229. </p></dd>
  9230. <dt><code>tstp</code></dt>
  9231. <dd><p>interactive stop
  9232. </p></dd>
  9233. <dt><code>ttin</code></dt>
  9234. <dd><p>read from control terminal attempted by a background process
  9235. </p></dd>
  9236. <dt><code>ttou</code></dt>
  9237. <dd><p>write to control terminal attempted by a background process
  9238. </p></dd>
  9239. <dt><code>bus</code></dt>
  9240. <dd><p>bus error &mdash; access to undefined portion of memory
  9241. </p></dd>
  9242. </dl>
  9243. <p>There are also several other signals whose names are allowed to be
  9244. passed to <code>signal</code> that are not defined by POSIX, but that are
  9245. recognized by many operating systems.
  9246. </p>
  9247. <dl compact="compact">
  9248. <dt><code>trap</code></dt>
  9249. <dd><p>trace or breakpoint trap
  9250. </p></dd>
  9251. <dt><code>iot</code></dt>
  9252. <dd><p>synonym for <code>abrt</code>
  9253. </p></dd>
  9254. <dt><code>emt</code></dt>
  9255. <dt><code>sys</code></dt>
  9256. <dd><p>bad argument to routine (SVID)
  9257. </p></dd>
  9258. <dt><code>stkflt</code></dt>
  9259. <dd><p>stack fault on coprocessor
  9260. </p></dd>
  9261. <dt><code>urg</code></dt>
  9262. <dd><p>urgent condition on socket (4.2 BSD)
  9263. </p></dd>
  9264. <dt><code>io</code></dt>
  9265. <dd><p>I/O now possible (4.2 BSD)
  9266. </p></dd>
  9267. <dt><code>poll</code></dt>
  9268. <dd><p>synonym for <code>io</code> (System V)
  9269. </p></dd>
  9270. <dt><code>cld</code></dt>
  9271. <dd><p>synonym for <code>chld</code>
  9272. </p></dd>
  9273. <dt><code>xcpu</code></dt>
  9274. <dd><p>CPU time limit exceeded (4.2 BSD)
  9275. </p></dd>
  9276. <dt><code>xfsz</code></dt>
  9277. <dd><p>file size limit exceeded (4.2 BSD)
  9278. </p></dd>
  9279. <dt><code>vtalrm</code></dt>
  9280. <dd><p>virtual alarm clock (4.2 BSD)
  9281. </p></dd>
  9282. <dt><code>prof</code></dt>
  9283. <dd><p>profile alarm clock
  9284. </p></dd>
  9285. <dt><code>pwr</code></dt>
  9286. <dd><p>power failure (System V)
  9287. </p></dd>
  9288. <dt><code>info</code></dt>
  9289. <dd><p>synonym for <code>pwr</code>
  9290. </p></dd>
  9291. <dt><code>lock</code></dt>
  9292. <dd><p>file lock lost
  9293. </p></dd>
  9294. <dt><code>winch</code></dt>
  9295. <dd><p>Window resize signal (4.3 BSD, Sun)
  9296. </p></dd>
  9297. <dt><code>unused</code></dt>
  9298. </dl>
  9299. </dd></dl>
  9300. <span id="Sending-_0026-receiving-signals"></span><h4 class="subsection">8.2.1 Sending &amp; receiving signals</h4>
  9301. <dl>
  9302. <dt id="index-signal_002dprocess">procedure: <strong>signal-process</strong> <em>pid signal --&gt; unspecified</em></dt>
  9303. <dd><p>Sends a signal represented by <var>signal</var> to the process identified by
  9304. <var>pid</var>.
  9305. </p></dd></dl>
  9306. <span id="index-signal-queues"></span>
  9307. <p>Signals received by the Scheme process can be obtained via one or more
  9308. <em>signal queues</em>. Each signal queue has a list of monitored signals
  9309. and a queue of received signals that have yet to be consumed from the
  9310. queue. When the Scheme process receives a signal, that signal is added
  9311. to the signal queues that are currently monitoring the signal received.
  9312. </p>
  9313. <dl>
  9314. <dt id="index-make_002dsignal_002dqueue">procedure: <strong>make-signal-queue</strong> <em>signal-list --&gt; signal-queue</em></dt>
  9315. <dt id="index-signal_002dqueue_003f">procedure: <strong>signal-queue?</strong> <em>object --&gt; boolean</em></dt>
  9316. <dt id="index-signal_002dqueue_002dmonitored_002dsignals">procedure: <strong>signal-queue-monitored-signals</strong> <em>signal-queue --&gt; signal-list</em></dt>
  9317. <dt id="index-dequeue_002dsignal_0021">procedure: <strong>dequeue-signal!</strong> <em>signal-queue --&gt; signal (may block)</em></dt>
  9318. <dt id="index-maybe_002ddequeue_002dsignal_0021">procedure: <strong>maybe-dequeue-signal!</strong> <em>signal-queue --&gt; signal or <code>#f</code></em></dt>
  9319. <dd><p><code>Make-signal-queue</code> returns a new signal queue that will monitor
  9320. all of the signals in the given list. <code>Signal-queue?</code> is the
  9321. disjoint type predicate for signal queues.
  9322. <code>Signal-queue-monitored-signals</code> returns a freshly-allocated list
  9323. of the signals currently monitored by <var>signal-queue</var>.
  9324. <code>Dequeue-signal!</code> &amp; <code>maybe-dequeue-signal!</code> both access the
  9325. next signal ready to be read from <var>signal-queue</var>. If the signal
  9326. queue is empty, <code>dequeue-signal!</code> will block until a signal is
  9327. received, while <code>maybe-dequeue-signal!</code> will immediately return
  9328. <code>#f</code>.
  9329. </p></dd></dl>
  9330. <p><strong>Note:</strong> There is a bug in the current system that causes an
  9331. erroneous deadlock to occur if threads are blocked waiting for signals
  9332. and no other threads are available to run. A workaround is to create a
  9333. thread that sleeps for a long time, which prevents any deadlock errors
  9334. (including real ones):
  9335. </p>
  9336. <div class="lisp">
  9337. <pre class="lisp">&gt; ,open threads
  9338. &gt; (spawn (lambda ()
  9339. ;; Sleep for a year.
  9340. (sleep (* 1000 60 60 24 365))))</pre></div>
  9341. <dl>
  9342. <dt id="index-add_002dsignal_002dqueue_002dsignal_0021">procedure: <strong>add-signal-queue-signal!</strong> <em>signal-queue signal --&gt; unspecified</em></dt>
  9343. <dt id="index-remove_002dsignal_002dqueue_002dsignal_0021">procedure: <strong>remove-signal-queue-signal!</strong> <em>signal-queue signal --&gt; unspecified</em></dt>
  9344. <dd><p>These add &amp; remove signals from signal queues&rsquo; list of signals to
  9345. monitor. Note that <code>remove-signal-queue-signal!</code> also removes any
  9346. pending signals from the queue, so <code>dequeue-signal!</code> &amp;
  9347. <code>maybe-dequeue-signal!</code> will only ever return signals that are
  9348. on the queue&rsquo;s list of monitored signals when they are called.
  9349. </p></dd></dl>
  9350. <hr>
  9351. <span id="POSIX-process-environment"></span><div class="header">
  9352. <p>
  9353. Next: <a href="#POSIX-users-and-groups" accesskey="n" rel="next">POSIX users and groups</a>, Previous: <a href="#POSIX-signals" accesskey="p" rel="prev">POSIX signals</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9354. </div>
  9355. <span id="Process-environment"></span><h3 class="section">8.3 Process environment</h3>
  9356. <span id="index-posix_002dprocess_002ddata-1"></span>
  9357. <p>These procedures are exported by the structures <code>posix</code> &amp;
  9358. <code>posix-process-data</code>.
  9359. </p>
  9360. <span id="index-process-ids-1"></span>
  9361. <span id="index-POSIX-process-ids-1"></span>
  9362. <dl>
  9363. <dt id="index-get_002dprocess_002did">procedure: <strong>get-process-id</strong> <em>--&gt; process-id</em></dt>
  9364. <dt id="index-get_002dparent_002dprocess_002did">procedure: <strong>get-parent-process-id</strong> <em>--&gt; process-id</em></dt>
  9365. <dd><p>These return the <a href="#POSIX-processes">process id</a> of the current
  9366. process or the current process&rsquo;s parent, respectively.
  9367. </p></dd></dl>
  9368. <span id="index-user-ids"></span>
  9369. <span id="index-group-ids"></span>
  9370. <span id="index-POSIX-user-ids"></span>
  9371. <span id="index-POSIX-group-ids"></span>
  9372. <dl>
  9373. <dt id="index-get_002duser_002did">procedure: <strong>get-user-id</strong> <em>--&gt; user-id</em></dt>
  9374. <dt id="index-get_002deffective_002duser_002did">procedure: <strong>get-effective-user-id</strong> <em>--&gt; user-id</em></dt>
  9375. <dt id="index-set_002duser_002did_0021">procedure: <strong>set-user-id!</strong> <em>user-id --&gt; unspecified</em></dt>
  9376. <dt id="index-get_002dgroup_002did">procedure: <strong>get-group-id</strong> <em>--&gt; group-id</em></dt>
  9377. <dt id="index-get_002deffective_002dgroup_002did">procedure: <strong>get-effective-group-id</strong> <em>--&gt; group-id</em></dt>
  9378. <dt id="index-set_002dgroup_002did_0021">procedure: <strong>set-group-id!</strong> <em>group-id --&gt; unspecified</em></dt>
  9379. <dd><p>These access the original and effective <a href="#POSIX-users-and-groups">user &amp; group ids</a> of the current process. The effective ids
  9380. may be set, but not the original ones.
  9381. </p></dd></dl>
  9382. <dl>
  9383. <dt id="index-get_002dgroups">procedure: <strong>get-groups</strong> <em>--&gt; group-id list</em></dt>
  9384. <dt id="index-get_002dlogin_002dname">procedure: <strong>get-login-name</strong> <em>--&gt; string</em></dt>
  9385. <dd><p><code>Get-groups</code> returns a list of the supplementary groups of the
  9386. current process. <code>Get-login-name</code> returns a user name for the
  9387. current process.
  9388. </p></dd></dl>
  9389. <span id="index-environment-variables"></span>
  9390. <span id="index-POSIX-environment-variables"></span>
  9391. <dl>
  9392. <dt id="index-lookup_002denvironment_002dvariable">procedure: <strong>lookup-environment-variable</strong> <em>string --&gt; string or <code>#f</code></em></dt>
  9393. <dt id="index-environment_002dalist">procedure: <strong>environment-alist</strong> <em>--&gt; alist</em></dt>
  9394. <dd><p><code>Lookup-environment-variable</code> looks up its argument in the
  9395. environment list of the current process and returns the corresponding
  9396. string, or <code>#f</code> if there is none. <code>Environment-alist</code>
  9397. returns the entire environment as a list of <code>(<var>name-string</var> .
  9398. <var>value-string</var>)</code> pairs.
  9399. </p></dd></dl>
  9400. <hr>
  9401. <span id="POSIX-users-and-groups"></span><div class="header">
  9402. <p>
  9403. Next: <a href="#POSIX-host-OS-and-machine-identification" accesskey="n" rel="next">POSIX host OS and machine identification</a>, Previous: <a href="#POSIX-process-environment" accesskey="p" rel="prev">POSIX process environment</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9404. </div>
  9405. <span id="Users-and-groups"></span><h3 class="section">8.4 Users and groups</h3>
  9406. <span id="index-posix_002dusers-1"></span>
  9407. <span id="index-user-ids-1"></span>
  9408. <span id="index-group-ids-1"></span>
  9409. <p><em>User ids</em> &amp; <em>group ids</em> are boxed integers that represent Unix
  9410. users &amp; groups. Also, every user &amp; group has a corresponding <em>user
  9411. info</em> or <em>group info</em> record, which contains miscellaneous
  9412. information about the user or group. The procedures in this section
  9413. are exported by the structures <code>posix-users</code> &amp; <code>posix</code>.
  9414. </p>
  9415. <dl>
  9416. <dt id="index-user_002did_003f">procedure: <strong>user-id?</strong> <em>object --&gt; boolean</em></dt>
  9417. <dt id="index-user_002did_003d_003f">procedure: <strong>user-id=?</strong> <em>uid<sub>a</sub> uid<sub>b</sub> --&gt; boolean</em></dt>
  9418. <dt id="index-user_002did_002d_003einteger">procedure: <strong>user-id-&gt;integer</strong> <em>uid --&gt; integer</em></dt>
  9419. <dt id="index-integer_002d_003euser_002did">procedure: <strong>integer-&gt;user-id</strong> <em>integer --&gt; uid</em></dt>
  9420. <dt id="index-group_002did_003f">procedure: <strong>group-id?</strong> <em>object --&gt; boolean</em></dt>
  9421. <dt id="index-group_002did_003d_003f">procedure: <strong>group-id=?</strong> <em>gid<sub>a</sub> gid<sub>b</sub> --&gt; boolean</em></dt>
  9422. <dt id="index-group_002did_002d_003einteger">procedure: <strong>group-id-&gt;integer</strong> <em>gid --&gt; integer</em></dt>
  9423. <dt id="index-integer_002d_003egroup_002did">procedure: <strong>integer-&gt;group-id</strong> <em>integer --&gt; gid</em></dt>
  9424. <dd><p><code>User-id?</code> &amp; <code>group-id?</code> are the disjoint type predicates for
  9425. user &amp; group ids. <code>User-id=?</code> &amp; <code>group-id=?</code> test whether
  9426. two user or group ids, respectively, are the same, <i>i.e.</i> whether their
  9427. numbers are equal. <code>User-id-&gt;integer</code>, <code>group-id-&gt;integer</code>,
  9428. <code>integer-&gt;user-id</code>, &amp; <code>integer-&gt;group-id</code> convert between
  9429. user or group ids and integers.
  9430. </p></dd></dl>
  9431. <span id="index-POSIX-user-info"></span>
  9432. <span id="index-POSIX-group-info"></span>
  9433. <dl>
  9434. <dt id="index-user_002did_002d_003euser_002dinfo">procedure: <strong>user-id-&gt;user-info</strong> <em>uid --&gt; user-info</em></dt>
  9435. <dt id="index-name_002d_003euser_002dinfo">procedure: <strong>name-&gt;user-info</strong> <em>string --&gt; user-info</em></dt>
  9436. <dt id="index-group_002did_002d_003egroup_002dinfo">procedure: <strong>group-id-&gt;group-info</strong> <em>gid --&gt; group-info</em></dt>
  9437. <dt id="index-name_002d_003egroup_002dinfo">procedure: <strong>name-&gt;group-info</strong> <em>string --&gt; group-info</em></dt>
  9438. <dd><p>These provide access for the user or group info records that correspond
  9439. with the given user or group ids or names.
  9440. </p></dd></dl>
  9441. <dl>
  9442. <dt id="index-user_002dinfo_003f">procedure: <strong>user-info?</strong> <em>object --&gt; boolean</em></dt>
  9443. <dt id="index-user_002dinfo_002dname">procedure: <strong>user-info-name</strong> <em>user-info --&gt; string</em></dt>
  9444. <dt id="index-user_002dinfo_002did">procedure: <strong>user-info-id</strong> <em>user-info --&gt; user-id</em></dt>
  9445. <dt id="index-user_002dinfo_002dgroup">procedure: <strong>user-info-group</strong> <em>user-info --&gt; group-id</em></dt>
  9446. <dt id="index-user_002dinfo_002dhome_002ddirectory">procedure: <strong>user-info-home-directory</strong> <em>user-info --&gt; string</em></dt>
  9447. <dt id="index-user_002dinfo_002dshell">procedure: <strong>user-info-shell</strong> <em>user-info --&gt; string</em></dt>
  9448. <dt id="index-group_002dinfo_003f">procedure: <strong>group-info?</strong> <em>object --&gt; boolean</em></dt>
  9449. <dt id="index-group_002dinfo_002dname">procedure: <strong>group-info-name</strong> <em>group-info --&gt; string</em></dt>
  9450. <dt id="index-group_002dinfo_002did">procedure: <strong>group-info-id</strong> <em>group-info --&gt; group-id</em></dt>
  9451. <dt id="index-group_002dinfo_002dmembers">procedure: <strong>group-info-members</strong> <em>group-info --&gt; user-id-list</em></dt>
  9452. <dd><p><code>User-info?</code> &amp; <code>group-info?</code> are the disjoint type predicates
  9453. for user info &amp; group info records. The others are accessors for the
  9454. various data available in those records.
  9455. </p></dd></dl>
  9456. <hr>
  9457. <span id="POSIX-host-OS-and-machine-identification"></span><div class="header">
  9458. <p>
  9459. Next: <a href="#POSIX-file-system-access" accesskey="n" rel="next">POSIX file system access</a>, Previous: <a href="#POSIX-users-and-groups" accesskey="p" rel="prev">POSIX users and groups</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9460. </div>
  9461. <span id="Host-OS-and-machine-identification"></span><h3 class="section">8.5 Host OS and machine identification</h3>
  9462. <span id="index-posix_002dplatform_002dnames"></span>
  9463. <dl>
  9464. <dt id="index-host_002dname">procedure: <strong>host-name</strong> <em>--&gt; string</em></dt>
  9465. <dt id="index-os_002dnode_002dname">procedure: <strong>os-node-name</strong> <em>--&gt; string</em></dt>
  9466. <dt id="index-os_002drelease_002dname">procedure: <strong>os-release-name</strong> <em>--&gt; string</em></dt>
  9467. <dt id="index-os_002dversion_002dname">procedure: <strong>os-version-name</strong> <em>--&gt; string</em></dt>
  9468. <dt id="index-machine_002dname">procedure: <strong>machine-name</strong> <em>--&gt; string</em></dt>
  9469. <dd><p>These procedures return strings that are intended to identify various
  9470. aspects of the current operating system and physical machine. POSIX
  9471. does not specify the format of the strings. These procedures are
  9472. provided by both the structure <code>posix-platform-names</code> and the
  9473. structure <code>posix</code>.
  9474. </p></dd></dl>
  9475. <hr>
  9476. <span id="POSIX-file-system-access"></span><div class="header">
  9477. <p>
  9478. Next: <a href="#POSIX-time" accesskey="n" rel="next">POSIX time</a>, Previous: <a href="#POSIX-host-OS-and-machine-identification" accesskey="p" rel="prev">POSIX host OS and machine identification</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9479. </div>
  9480. <span id="File-system-access"></span><h3 class="section">8.6 File system access</h3>
  9481. <span id="index-posix_002dfiles-1"></span>
  9482. <p>These procedures operate on the file system via the facilities defined
  9483. by POSIX and offer more than standard &amp; portable R5RS operations. All
  9484. of these names are exported by the structures <code>posix-files</code> and
  9485. <code>posix</code>.
  9486. </p>
  9487. <span id="index-POSIX-directory-access"></span>
  9488. <span id="index-directory-streams"></span>
  9489. <dl>
  9490. <dt id="index-open_002ddirectory_002dstream">procedure: <strong>open-directory-stream</strong> <em>filename --&gt; dir-stream</em></dt>
  9491. <dt id="index-directory_002dstream_003f">procedure: <strong>directory-stream?</strong> <em>object --&gt; boolean</em></dt>
  9492. <dt id="index-read_002ddirectory_002dstream">procedure: <strong>read-directory-stream</strong> <em>dir-stream --&gt; filename or <code>#f</code></em></dt>
  9493. <dt id="index-close_002ddirectory_002dstream">procedure: <strong>close-directory-stream</strong> <em>dir-stream --&gt; unspecified</em></dt>
  9494. <dd><p>Directory streams are the low-level interface provided by POSIX to
  9495. enumerate the contents of a directory. <code>Open-directory-stream</code>
  9496. opens a new directory stream that will enumerate all of the files
  9497. within the directory named by <var>filename</var>. <code>Directory-stream?</code>
  9498. is the disjoint type predicate for directory streams.
  9499. <code>Read-directory-stream</code> consumes the next filename from
  9500. <var>dir-stream</var> and returns it, or returns <code>#f</code> if the stream has
  9501. finished. Note that <code>read-directory-stream</code> will return only
  9502. simple filenames, not full pathnames. <code>Close-directory-stream</code>
  9503. closes <var>dir-stream</var>, removing any storage it required in the
  9504. operating system. Closing an already closed directory stream has no
  9505. effect.
  9506. </p></dd></dl>
  9507. <span id="index-directory-listing"></span>
  9508. <span id="index-listing-directories"></span>
  9509. <dl>
  9510. <dt id="index-list_002ddirectory">procedure: <strong>list-directory</strong> <em>filename --&gt; string list</em></dt>
  9511. <dd><p>Returns the list of filenames in the directory named by <var>filename</var>.
  9512. This is equivalent to opening a directory stream, repeatedly reading
  9513. from it &amp; accumulating the list of filenames, and closing the stream.
  9514. </p></dd></dl>
  9515. <span id="index-POSIX-working-directory"></span>
  9516. <span id="index-working-directory"></span>
  9517. <dl>
  9518. <dt id="index-working_002ddirectory">procedure: <strong>working-directory</strong> <em>--&gt; string</em></dt>
  9519. <dt id="index-set_002dworking_002ddirectory_0021">procedure: <strong>set-working-directory!</strong> <em>string --&gt; unspecified</em></dt>
  9520. <dd><p>These access the working directory&rsquo;s filename of the current process.
  9521. </p></dd></dl>
  9522. <span id="index-POSIX-file-opening"></span>
  9523. <dl>
  9524. <dt id="index-open_002dfile">procedure: <strong>open-file</strong> <em>pathname file-options [file-mode] --&gt; port</em></dt>
  9525. <dd><p>Opens a port to the file named by the string <var>pathname</var>.
  9526. <var>File-options</var> specifies various aspects of the port. The optional
  9527. <var>file-mode</var> argument is used only if the file to be opened does not
  9528. already exist; it specifies the permissions to be assigned to the file
  9529. if it is created. The returned port is an input port if the given
  9530. options include <code>read-only</code>; otherwise <code>open-file</code> returns an
  9531. output port. Because Scheme48 does not support combined input/output
  9532. ports, <code>dup-switching-mode</code> can be used to open an input port for
  9533. output ports opened with the <code>read-write</code> option.
  9534. </p></dd></dl>
  9535. <p>File options are stored in a boxed mask representation. File option
  9536. sets are created with <code>file-options</code> and tested with
  9537. <code>file-options-on?</code>.
  9538. </p>
  9539. <dl>
  9540. <dt id="index-file_002doptions">syntax: <strong>file-options</strong> <em>name &hellip; --&gt; file-options</em></dt>
  9541. <dt id="index-file_002doptions_002don_003f">procedure: <strong>file-options-on?</strong> <em>options<sub>a</sub> options<sub>b</sub> --&gt; boolean</em></dt>
  9542. <dd><p><code>File-options</code> evaluates to a file option set, suitable for passing
  9543. to <code>open-file</code>, that includes all of the given named options.
  9544. <code>File-options-on?</code> returns true if <var>options<sub>a</sub></var> includes
  9545. all of the options in <var>options<sub>b</sub></var>, or false if otherwise.
  9546. </p>
  9547. <p>The following file option names are supported as arguments to the
  9548. <code>file-options</code> syntax:
  9549. </p>
  9550. <dl compact="compact">
  9551. <dt><code>create</code></dt>
  9552. <dd><p>create file if it does not already exist; a <var>file-mode</var> argument is
  9553. required to be passed to <code>open-file</code> if the <code>create</code> option
  9554. is specified
  9555. </p>
  9556. </dd>
  9557. <dt><code>exclusive</code></dt>
  9558. <dd><p>an error will be signalled if this option &amp; <code>create</code> are both set
  9559. and the file already exists
  9560. </p>
  9561. </dd>
  9562. <dt><code>no-controlling-tty</code></dt>
  9563. <dd><p>if the pathname being opened is a terminal device, the terminal will
  9564. not become the controlling terminal of the process
  9565. </p>
  9566. </dd>
  9567. <dt><code>truncate</code></dt>
  9568. <dd><p>file is truncated
  9569. </p>
  9570. </dd>
  9571. <dt><code>append</code></dt>
  9572. <dd><p>written data to the newly opened file will be appended to the existing
  9573. contents
  9574. </p>
  9575. </dd>
  9576. <dt><code>nonblocking</code></dt>
  9577. <dd><p>read &amp; write operations will not block
  9578. </p>
  9579. </dd>
  9580. <dt><code>read-only</code></dt>
  9581. <dd><p>file may not be written to, only read from
  9582. </p>
  9583. </dd>
  9584. <dt><code>read-write</code></dt>
  9585. <dd><p>file may be both read from &amp; written to
  9586. </p>
  9587. </dd>
  9588. <dt><code>write-only</code></dt>
  9589. <dd><p>file may not be read from, only written to
  9590. </p></dd>
  9591. </dl>
  9592. <p>The last three are all mutually exclusive.
  9593. </p></dd></dl>
  9594. <p>Examples:
  9595. </p>
  9596. <div class="lisp">
  9597. <pre class="lisp">(open-file &quot;some-file.txt&quot;
  9598. (file-options create write-only)
  9599. (file-mode read owner-write))</pre></div>
  9600. <p>returns an output port that writes to a newly-created file that can be
  9601. read from by anyone but written to only by the owner. Once the file
  9602. <samp>some-file.txt</samp> exists,
  9603. </p>
  9604. <div class="lisp">
  9605. <pre class="lisp">(open-file &quot;some-file.txt&quot;
  9606. (file-options append write-only))</pre></div>
  9607. <p>will open an output port that appends to the file.
  9608. </p>
  9609. <p><a href="#POSIX-I_002fO-utilities"><code>I/o-flags</code> &amp; <code>set-i/o-flags!</code></a>
  9610. can be used to access the <code>append</code>, <code>nonblocking</code>, and
  9611. read/write file options of ports, as well as modify the <code>append</code> &amp;
  9612. <code>nonblocking</code> options.
  9613. </p>
  9614. <span id="index-nonblocking-I_002fO"></span>
  9615. <span id="index-blocking-I_002fO"></span>
  9616. <p>To keep port operations from blocking in the Scheme48 process, output
  9617. ports are set to be nonblocking at the time of creation. (Input ports
  9618. are managed using <code>select(2)</code>.) <code>Set-i/o-flags!</code> can be used
  9619. to make an output port blocking, for example directly before forking,
  9620. but care should be exercised, because the Scheme48 run-time system may
  9621. be confused if an I/O operation blocks.
  9622. </p>
  9623. <span id="index-POSIX-file-creation-masks"></span>
  9624. <dl>
  9625. <dt id="index-set_002dfile_002dcreation_002dmask_0021">procedure: <strong>set-file-creation-mask!</strong> <em>file-mode --&gt; file-mode</em></dt>
  9626. <dd><p>Sets the file creation mask to be <var>file-mode</var>. Bits set in
  9627. <var>file-mode</var> are cleared in the modes of any files or directories
  9628. subsequently created by the current process.
  9629. </p></dd></dl>
  9630. <span id="index-POSIX-links"></span>
  9631. <span id="index-creating-POSIX-links"></span>
  9632. <span id="index-creating-directories"></span>
  9633. <span id="index-making-directories"></span>
  9634. <span id="index-directory-creation"></span>
  9635. <span id="index-POSIX-FIFOs"></span>
  9636. <span id="index-creating-POSIX-FIFOs"></span>
  9637. <dl>
  9638. <dt id="index-link">procedure: <strong>link</strong> <em>existing-pathname new-pathname --&gt; unspecified</em></dt>
  9639. <dt id="index-make_002ddirectory">procedure: <strong>make-directory</strong> <em>pathname file-mode --&gt; unspecified</em></dt>
  9640. <dt id="index-make_002dfifo">procedure: <strong>make-fifo</strong> <em>pathname file-mode --&gt; unspecified</em></dt>
  9641. <dd><p><code>Link</code> creates a hard link for the file at <var>existing-pathname</var>
  9642. at <var>new-pathname</var>. <code>Make-directory</code> creates a new directory
  9643. at the locations specified by <var>pathname</var> with the the file mode
  9644. <var>file-mode</var>. <code>Make-fifo</code> does similarly, but it creates a
  9645. FIFO (first-in first-out) file instead of a directory.
  9646. </p></dd></dl>
  9647. <span id="index-deleting-files"></span>
  9648. <span id="index-file-deletion"></span>
  9649. <span id="index-removing-files"></span>
  9650. <span id="index-deleting-directories"></span>
  9651. <span id="index-directory-deletion"></span>
  9652. <span id="index-removing-directories"></span>
  9653. <span id="index-renaming-files"></span>
  9654. <dl>
  9655. <dt id="index-unlink">procedure: <strong>unlink</strong> <em>pathname --&gt; unspecified</em></dt>
  9656. <dt id="index-remove_002ddirectory">procedure: <strong>remove-directory</strong> <em>pathname --&gt; unspecified</em></dt>
  9657. <dt id="index-rename-1">procedure: <strong>rename</strong> <em>old-pathname new-pathname --&gt; unspecified</em></dt>
  9658. <dd><p><code>Unlink</code> removes a link at the location <var>pathname</var>.
  9659. <code>Remove-directory</code> removes a directory at the location specified
  9660. by <var>pathname</var>. The directory must be empty; an exception is
  9661. signalled if it is not. <code>Rename</code> moves the file at the location
  9662. <var>old-pathname</var> to the new location <var>new-pathname</var>.
  9663. </p></dd></dl>
  9664. <span id="index-file-access-probing"></span>
  9665. <dl>
  9666. <dt id="index-accessible_003f">procedure: <strong>accessible?</strong> <em>pathname access-mode more-modes &hellip; --&gt; boolean</em></dt>
  9667. <dt id="index-access_002dmode">syntax: <strong>access-mode</strong> <em>name --&gt; access mode</em></dt>
  9668. <dd><p><code>Accessible?</code> returns true if <var>pathname</var> is accessible by all
  9669. of the given access modes. (There must be at least one access mode
  9670. argument.) <code>Access-mode</code> evaluates to an access mode, suitable for
  9671. passing to <code>accessible?</code>, from the given name. The allowed names
  9672. are <code>read</code>, <code>write</code>, <code>execute</code>, &amp; <code>exists</code>.
  9673. </p></dd></dl>
  9674. <span id="index-file-info"></span>
  9675. <p>Information about files can be queried using the <em>file info</em>
  9676. abstraction. Every file has a corresponding file info record, which
  9677. contains various data about the file including its name, its type,
  9678. its device &amp; inode numbers, the number of links to it, its size in
  9679. bytes, its owner, its group, its file mode, and its access times.
  9680. </p>
  9681. <dl>
  9682. <dt id="index-get_002dfile_002dinfo">procedure: <strong>get-file-info</strong> <em>pathname --&gt; file-info</em></dt>
  9683. <dt id="index-get_002dfile_002flink_002dinfo">procedure: <strong>get-file/link-info</strong> <em>pathname --&gt; file-info</em></dt>
  9684. <dt id="index-get_002dport_002dinfo">procedure: <strong>get-port-info</strong> <em>fd-port --&gt; file-info</em></dt>
  9685. <dd><p><code>Get-file-info</code> &amp; <code>get-file/link-info</code> return a file info
  9686. record for the files named by <var>pathname</var>. <code>Get-file-info</code>
  9687. follows symbolic links, however, while <code>get-file/link</code> info does
  9688. not. <code>Get-port-info</code> returns a file info record for the file that
  9689. <var>fd-port</var> is a port atop a file descriptor for. If <var>fd-port</var>
  9690. does not read from or write to a file descriptor, an error is
  9691. signalled.
  9692. </p></dd></dl>
  9693. <dl>
  9694. <dt id="index-file_002dinfo_003f">procedure: <strong>file-info?</strong> <em>object --&gt; boolean</em></dt>
  9695. <dt id="index-file_002dinfo_002dname">procedure: <strong>file-info-name</strong> <em>file-info --&gt; string</em></dt>
  9696. <dt id="index-file_002dinfo_002ddevice">procedure: <strong>file-info-device</strong> <em>file-info --&gt; integer</em></dt>
  9697. <dt id="index-file_002dinfo_002dinode">procedure: <strong>file-info-inode</strong> <em>file-info --&gt; integer</em></dt>
  9698. <dt id="index-file_002dinfo_002dlink_002dcount">procedure: <strong>file-info-link-count</strong> <em>file-info --&gt; integer</em></dt>
  9699. <dt id="index-file_002dinfo_002dsize">procedure: <strong>file-info-size</strong> <em>file-info --&gt; integer</em></dt>
  9700. <dt id="index-file_002dinfo_002downer">procedure: <strong>file-info-owner</strong> <em>file-info --&gt; user-id</em></dt>
  9701. <dt id="index-file_002dinfo_002dgroup">procedure: <strong>file-info-group</strong> <em>file-info --&gt; group-id</em></dt>
  9702. <dt id="index-file_002dinfo_002dmode">procedure: <strong>file-info-mode</strong> <em>file-info --&gt; file-mode</em></dt>
  9703. <dt id="index-file_002dinfo_002dlast_002daccess">procedure: <strong>file-info-last-access</strong> <em>file-info --&gt; time</em></dt>
  9704. <dt id="index-file_002dinfo_002dlast_002dmodification">procedure: <strong>file-info-last-modification</strong> <em>file-info --&gt; time</em></dt>
  9705. <dt id="index-file_002dinfo_002dlast_002dchange">procedure: <strong>file-info-last-change</strong> <em>file-info --&gt; time</em></dt>
  9706. <dd><p>Accessors for various file info record fields. The name is the string
  9707. passed to <code>get-file-info</code> or <code>get-file/link-info</code>, if the
  9708. file info record was created with either of those two, or the name of
  9709. the file that the file descriptor of the port queried was created on,
  9710. if the file info record was obtained with <code>get-port-info</code>.
  9711. </p></dd></dl>
  9712. <dl>
  9713. <dt id="index-file_002dinfo_002dtype">procedure: <strong>file-info-type</strong> <em>file-info --&gt; file-type</em></dt>
  9714. <dt id="index-file_002dtype">syntax: <strong>file-type</strong> <em>name --&gt; file-type</em></dt>
  9715. <dt id="index-file_002dtype_003f">procedure: <strong>file-type?</strong> <em>object --&gt; boolean</em></dt>
  9716. <dt id="index-file_002dtype_002dname">procedure: <strong>file-type-name</strong> <em>file-type --&gt; symbol</em></dt>
  9717. <dd><p><code>File-info-type</code> returns the type of the file as a <em>file type</em>
  9718. object. File types may be compared using <code>eq?</code>. <code>File-type</code>
  9719. evaluates to a file type of the given name. The disjoint type predicate
  9720. for file types is <code>file-type?</code>. <code>File-type-name</code> returns the
  9721. symbolic name that represents <var>file-type</var>.
  9722. </p>
  9723. <p>The valid file type names are:
  9724. </p>
  9725. <ul class="no-bullet">
  9726. <li><!-- /@w --> <code>regular</code>
  9727. </li><li><!-- /@w --> <code>directory</code>
  9728. </li><li><!-- /@w --> <code>character-device</code>
  9729. </li><li><!-- /@w --> <code>block-device</code>
  9730. </li><li><!-- /@w --> <code>fifo</code>
  9731. </li><li><!-- /@w --> <code>symbolic-link</code> (not required by POSIX)
  9732. </li><li><!-- /@w --> <code>socket</code> (not required by POSIX)
  9733. </li><li><!-- /@w --> <code>other</code>
  9734. </li></ul>
  9735. </dd></dl>
  9736. <span id="index-POSIX-file-permissions"></span>
  9737. <span id="index-file-permissions"></span>
  9738. <p><em>File modes</em> are boxed integers that represent POSIX file
  9739. protection masks.
  9740. </p>
  9741. <dl>
  9742. <dt id="index-file_002dmode">syntax: <strong>file-mode</strong> <em>permission-name &hellip; --&gt; file-mode</em></dt>
  9743. <dt id="index-file_002dmode_003f">procedure: <strong>file-mode?</strong> <em>object --&gt; boolean</em></dt>
  9744. <dd><p><code>File-mode</code> evaluates to a file mode object that contains all of
  9745. the specified permissions. <code>File-mode?</code> is the disjoint type
  9746. predicate for file mode descriptor objects. These are all of the names,
  9747. with their corresponding octal bit masks and meanings, allowed to be
  9748. passed to <code>file-mode</code>:
  9749. </p>
  9750. <table>
  9751. <tr><td>Permission name</td><td>Octal mask</td><td>Description</td></tr>
  9752. <tr><td><code>set-uid</code></td><td><code>#o4000</code></td><td>set user id when executing</td></tr>
  9753. <tr><td><code>set-gid</code></td><td><code>#o2000</code></td><td>set group id when executing</td></tr>
  9754. <tr><td><code>owner-read</code></td><td><code>#o0400</code></td><td>read by owner</td></tr>
  9755. <tr><td><code>owner-write</code></td><td><code>#o0200</code></td><td>write by owner</td></tr>
  9756. <tr><td><code>owner-exec</code></td><td><code>#o0100</code></td><td>execute (or search) by owner</td></tr>
  9757. <tr><td><code>group-read</code></td><td><code>#o0040</code></td><td>read by group</td></tr>
  9758. <tr><td><code>group-write</code></td><td><code>#o0020</code></td><td>write by group</td></tr>
  9759. <tr><td><code>group-exec</code></td><td><code>#o0010</code></td><td>execute (or search) by group</td></tr>
  9760. <tr><td><code>other-read</code></td><td><code>#o0004</code></td><td>read by others</td></tr>
  9761. <tr><td><code>other-write</code></td><td><code>#o0002</code></td><td>write by others</td></tr>
  9762. <tr><td><code>other-exec</code></td><td><code>#o0001</code></td><td>execute (or search) by others</td></tr>
  9763. </table>
  9764. <p>Also, several compound masks are supported for convenience:
  9765. </p>
  9766. <table>
  9767. <tr><td>Permission set name</td><td>Octal mask</td><td>Description</td></tr>
  9768. <tr><td><code>owner</code></td><td><code>#o0700</code></td><td>read, write, &amp; execute by owner</td></tr>
  9769. <tr><td><code>group</code></td><td><code>#o0070</code></td><td>read, write, &amp; execute by group</td></tr>
  9770. <tr><td><code>other</code></td><td><code>#o0007</code></td><td>read, write, &amp; execute by others</td></tr>
  9771. <tr><td><code>read</code></td><td><code>#o0444</code></td><td>read by anyone</td></tr>
  9772. <tr><td><code>write</code></td><td><code>#o0111</code></td><td>write by anyone</td></tr>
  9773. <tr><td><code>exec</code></td><td><code>#o0777</code></td><td>read, write, &amp; execute by anyone</td></tr>
  9774. </table>
  9775. </dd></dl>
  9776. <dl>
  9777. <dt id="index-file_002dmode_002b">procedure: <strong>file-mode+</strong> <em>file-mode &hellip; --&gt; file-mode</em></dt>
  9778. <dt id="index-file_002dmode_002d">procedure: <strong>file-mode-</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --&gt; file-mode</em></dt>
  9779. <dt id="index-file_002dmode_003d_003f">procedure: <strong>file-mode=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --&gt; boolean</em></dt>
  9780. <dt id="index-file_002dmode_003c_003d_003f">procedure: <strong>file-mode&lt;=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --&gt; boolean</em></dt>
  9781. <dt id="index-file_002dmode_003e_003d_003f">procedure: <strong>file-mode&gt;=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --&gt; boolean</em></dt>
  9782. <dd><p><code>File-mode+</code> returns a file mode that contains all of the
  9783. permissions specified in any of its arguments. <code>File-mode-</code>
  9784. returns a file mode that contains all of <var>file-mode<sub>a</sub></var>&rsquo;s
  9785. permissions not in <var>file-mode<sub>b</sub></var>. <code>File-mode=?</code> tests
  9786. whether two file modes are the same. <code>File-mode&lt;=?</code> returns true
  9787. if each successive file mode argument has the same or more permissions
  9788. as the previous one. <code>File-mode&gt;=?</code> returns true if each
  9789. successive file mode argument has the same or fewer permissions as the
  9790. previous one.
  9791. </p></dd></dl>
  9792. <dl>
  9793. <dt id="index-file_002dmode_002d_003einteger">procedure: <strong>file-mode-&gt;integer</strong> <em>file-mode --&gt; integer</em></dt>
  9794. <dt id="index-integer_002d_003efile_002dmode">procedure: <strong>integer-&gt;file-mode</strong> <em>integer --&gt; file-mode</em></dt>
  9795. <dd><p>These convert between file mode objects and Unix file mode masks as
  9796. integers. The integer representations may or may not be the masks used
  9797. by the underlying operating system.
  9798. </p></dd></dl>
  9799. <hr>
  9800. <span id="POSIX-time"></span><div class="header">
  9801. <p>
  9802. Next: <a href="#POSIX-I_002fO-utilities" accesskey="n" rel="next">POSIX I/O utilities</a>, Previous: <a href="#POSIX-file-system-access" accesskey="p" rel="prev">POSIX file system access</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9803. </div>
  9804. <span id="Time"></span><h3 class="section">8.7 Time</h3>
  9805. <p>A <em>time</em> record contains an integer that represents a time as the
  9806. number of seconds since the Unix epoch (00:00:00 GMT, January 1, 1970).
  9807. These procedures for operating on time records are in the structures
  9808. <code>posix-time</code> &amp; <code>posix</code>.
  9809. </p>
  9810. <dl>
  9811. <dt id="index-make_002dtime">procedure: <strong>make-time</strong> <em>seconds --&gt; time</em></dt>
  9812. <dt id="index-current_002dtime">procedure: <strong>current-time</strong> <em>--&gt; time</em></dt>
  9813. <dt id="index-time_003f">procedure: <strong>time?</strong> <em>object --&gt; boolean</em></dt>
  9814. <dt id="index-time_002dseconds">procedure: <strong>time-seconds</strong> <em>time --&gt; integer</em></dt>
  9815. <dd><p><code>Make-time</code> &amp; <code>current-time</code> construct time records;
  9816. <code>make-time</code> uses the number of seconds that is its argument, and
  9817. <code>current-time</code> uses the current number of seconds since the epoch.
  9818. <code>Time?</code> is the disjoint type predicate for time objects.
  9819. <code>Time-seconds</code> returns the number of seconds recorded by
  9820. <var>time</var>.
  9821. </p></dd></dl>
  9822. <dl>
  9823. <dt id="index-time_003d_003f">procedure: <strong>time=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --&gt; boolean</em></dt>
  9824. <dt id="index-time_003c_003f">procedure: <strong>time&lt;?</strong> <em>time<sub>a</sub> time<sub>b</sub> --&gt; boolean</em></dt>
  9825. <dt id="index-time_003c_003d_003f">procedure: <strong>time&lt;=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --&gt; boolean</em></dt>
  9826. <dt id="index-time_003e_003f">procedure: <strong>time&gt;?</strong> <em>time<sub>a</sub> time<sub>b</sub> --&gt; boolean</em></dt>
  9827. <dt id="index-time_003e_003d_003f">procedure: <strong>time&gt;=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --&gt; boolean</em></dt>
  9828. <dd><p>Various time comparators. <code>Time=?</code> returns true if its two
  9829. arguments represent the same number of seconds since the epoch.
  9830. <code>Time&lt;?</code>, <code>time&lt;=?</code>, <code>time&gt;?</code>, &amp; <code>time&gt;=</code> return
  9831. true if their arguments are monotonically increasing, monotonically
  9832. non-decreasing, monotonically decreasing, or monotonically
  9833. non-increasing, respectively.
  9834. </p></dd></dl>
  9835. <dl>
  9836. <dt id="index-time_002d_003estring">procedure: <strong>time-&gt;string</strong> <em>time --&gt; string</em></dt>
  9837. <dd><p>Returns a string representation of <var>time</var> in the format of
  9838. <code>&quot;<var>DDD</var> <var>MMM</var> <var>HH</var>:<var>MM</var>:<var>SS</var> <var>YYYY</var>&quot;</code>.
  9839. For example,
  9840. </p>
  9841. <div class="lisp">
  9842. <pre class="lisp">(time-&gt;string (make-time 1234567890))
  9843. &rArr; &quot;Fri Feb 13 18:31:30 2009&quot;</pre></div>
  9844. <p><strong>Note:</strong> The string has a newline suffix.
  9845. </p></dd></dl>
  9846. <hr>
  9847. <span id="POSIX-I_002fO-utilities"></span><div class="header">
  9848. <p>
  9849. Next: <a href="#POSIX-regular-expressions" accesskey="n" rel="next">POSIX regular expressions</a>, Previous: <a href="#POSIX-time" accesskey="p" rel="prev">POSIX time</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9850. </div>
  9851. <span id="I_002fO-utilities"></span><h3 class="section">8.8 I/O utilities</h3>
  9852. <span id="index-posix_002di_002fo-1"></span>
  9853. <p>These procedures for manipulating pipes and ports built on file
  9854. descriptors are provided by the structures <code>posix-i/o</code> &amp;
  9855. <code>posix</code>.
  9856. </p>
  9857. <span id="index-POSIX-pipe-I_002fO"></span>
  9858. <span id="index-pipe-I_002fO"></span>
  9859. <dl>
  9860. <dt id="index-open_002dpipe">procedure: <strong>open-pipe</strong> <em>--&gt; [input-port output-port]</em></dt>
  9861. <dd><p>Creates a pipe and returns the two ends of the pipe as an input port &amp;
  9862. an output port.
  9863. </p></dd></dl>
  9864. <span id="index-file-descriptor-ports"></span>
  9865. <span id="index-fd_002dports"></span>
  9866. <p>A <em>file descriptor port</em> (or <em>fd-port</em>) is a port or a
  9867. <a href="#Channels">channel</a> that reads from or writes to an OS file
  9868. descriptor. File descriptor ports are returned by the standard Scheme
  9869. procedures <code>open-input-file</code> &amp; <code>open-output-file</code> as well as
  9870. the procedures <code>open-file</code> &amp; <code>open-pipe</code> from this POSIX
  9871. interface.
  9872. </p>
  9873. <dl>
  9874. <dt id="index-fd_002dport_003f">procedure: <strong>fd-port?</strong> <em>port --&gt; boolean</em></dt>
  9875. <dt id="index-port_002d_003efd">procedure: <strong>port-&gt;fd</strong> <em>port --&gt; integer or <code>#f</code></em></dt>
  9876. <dd><p><code>Fd-port?</code> returns true if <var>port</var> is a port that reads from or
  9877. writes to a file descriptor, or false if not. <code>Port-&gt;fd</code> returns
  9878. the file descriptor that <var>port</var> reads from or writes to, if it is a
  9879. file descriptor port, or <code>#f</code> if it is not. It is an error to
  9880. pass a value that is not a port to either of these procedures.
  9881. </p>
  9882. <p><strong>Note:</strong> Channels may <em>not</em> be passed to these procedures.
  9883. To access a channel&rsquo;s file descriptor, use <code>channel-os-index</code>;
  9884. see <a href="#Channels">Channels</a> for more details.
  9885. </p></dd></dl>
  9886. <span id="index-file-descriptor-reassignment"></span>
  9887. <dl>
  9888. <dt id="index-remap_002dfile_002ddescriptors_0021">procedure: <strong>remap-file-descriptors!</strong> <em>fd-spec &hellip; --&gt; unspecified</em></dt>
  9889. <dd><p>Reassigns file descriptors to ports. Each <var>fd-spec</var> specifies what
  9890. port is to be mapped to what file descriptor: the first port gets file
  9891. descriptor <code>0</code>; the second, <code>1</code>; and so on. An <var>fd-spec</var>
  9892. is either a port that reads from or writes to a file descriptor or
  9893. <code>#f</code>; in the latter case, the corresponding file descriptor is not
  9894. used. Any open ports not listed are marked <em>close-on-exec</em>. The
  9895. same port may be moved to multiple new file descriptors.
  9896. </p>
  9897. <p>For example,
  9898. </p>
  9899. <div class="lisp">
  9900. <pre class="lisp">(remap-file-descriptors! (current-output-port)
  9901. #f
  9902. (current-input-port))</pre></div>
  9903. <p>moves the current output port to file descriptor <code>0</code> (<i>i.e.</i>
  9904. <code>stdin</code>) and the current input port to file descriptor <code>2</code>
  9905. (<i>i.e.</i> <code>stderr</code>). File descriptor <code>1</code> (<code>stdout</code>) is not
  9906. mapped to anything, and all other open ports (including anything that
  9907. had the file descriptor <code>1</code>) are marked <em>close-on-exec</em>.
  9908. </p></dd></dl>
  9909. <span id="index-fd_002dport-dup_0027ing"></span>
  9910. <dl>
  9911. <dt id="index-dup">procedure: <strong>dup</strong> <em>fd-port --&gt; fd-port</em></dt>
  9912. <dt id="index-dup_002dswitching_002dmode">procedure: <strong>dup-switching-mode</strong> <em>fd-port --&gt; fd-port</em></dt>
  9913. <dt id="index-dup2">procedure: <strong>dup2</strong> <em>fd-port fdes --&gt; fd-port</em></dt>
  9914. <dd><p>These change <var>fd-port</var>&rsquo;s file descriptor and return new ports that
  9915. have the ports&rsquo; old file descriptors. <code>Dup</code> uses the lowest
  9916. unused file descriptor; <code>dup2</code> uses the one provided.
  9917. <code>Dup-switching-mode</code> is the same as <code>dup</code> except that the
  9918. returned port is an input port if the argument was an output port and
  9919. vice versa. If any existing port uses the file descriptor passed to
  9920. <code>dup2</code>, that port is closed.
  9921. </p></dd></dl>
  9922. <dl>
  9923. <dt id="index-close_002dall_002dport">procedure: <strong>close-all-port</strong> <em>port-or-channel &hellip; --&gt; unspecified</em></dt>
  9924. <dd><p>Closes all ports or channels not listed as arguments.
  9925. </p></dd></dl>
  9926. <dl>
  9927. <dt id="index-close_002don_002dexec_003f">procedure: <strong>close-on-exec?</strong> <em>channel --&gt; boolean</em></dt>
  9928. <dt id="index-set_002dclose_002don_002dexec_003f_0021">procedure: <strong>set-close-on-exec?!</strong> <em>channel boolean --&gt; unspecified</em></dt>
  9929. <dd><p>These access the boolean flag that specifies whether <var>channel</var> will
  9930. be closed when a new program is <code>exec</code>&rsquo;d.
  9931. </p></dd></dl>
  9932. <span id="index-fcntl"></span>
  9933. <span id="index-POSIX-fcntl"></span>
  9934. <span id="index-fd_002dport-I_002fO-flags"></span>
  9935. <span id="index-I_002fO-flags"></span>
  9936. <dl>
  9937. <dt id="index-i_002fo_002dflags">procedure: <strong>i/o-flags</strong> <em>fd-port --&gt; file-options</em></dt>
  9938. <dt id="index-set_002di_002fo_002dflags_0021">procedure: <strong>set-i/o-flags!</strong> <em>fd-port file-options --&gt; unspecified</em></dt>
  9939. <dd><p>These access various <a href="#POSIX-file-system-access">file options</a>
  9940. for <var>fd-port</var>. The options that may be read are <code>append</code>,
  9941. <code>nonblocking</code>, <code>read-only</code>, <code>read-write</code>, and
  9942. <code>write-only</code>; only the <code>append</code> and <code>nonblocking</code>
  9943. options can be written.
  9944. </p></dd></dl>
  9945. <span id="index-terminal-ports"></span>
  9946. <span id="index-POSIX-terminal-ports"></span>
  9947. <dl>
  9948. <dt id="index-port_002dis_002da_002dterminal_003f">procedure: <strong>port-is-a-terminal?</strong> <em>port --&gt; boolean</em></dt>
  9949. <dt id="index-port_002dterminal_002dname">procedure: <strong>port-terminal-name</strong> <em>port --&gt; string or <code>#f</code></em></dt>
  9950. <dd><p><code>Port-is-a-terminal?</code> returns true of <var>port</var> is a port that
  9951. has an underlying file descriptor associated with a terminal. For such
  9952. ports, <code>port-terminal-name</code> returns the name of the terminal; for
  9953. all others, it returns <code>#f</code>.
  9954. </p>
  9955. <p><strong>Note:</strong> These procedures accept only ports, not channels.
  9956. </p></dd></dl>
  9957. <hr>
  9958. <span id="POSIX-regular-expressions"></span><div class="header">
  9959. <p>
  9960. Next: <a href="#POSIX-C-to-Scheme-correspondence" accesskey="n" rel="next">POSIX C to Scheme correspondence</a>, Previous: <a href="#POSIX-I_002fO-utilities" accesskey="p" rel="prev">POSIX I/O utilities</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  9961. </div>
  9962. <span id="Regular-expressions"></span><h3 class="section">8.9 Regular expressions</h3>
  9963. <span id="index-string-matching"></span>
  9964. <p>The procedures in this section provide access to POSIX regular
  9965. expression matching. The regular expression syntax and semantics are
  9966. far too complex to be described here.
  9967. </p>
  9968. <p><strong>Note:</strong> Because the C interface uses ASCII <code>NUL</code> bytes to
  9969. mark the ends of strings, patterns &amp; strings that contain <code>NUL</code>
  9970. characters will not work correctly.
  9971. </p>
  9972. <span id="Direct-POSIX-regular-expression-interface"></span><h4 class="subsection">8.9.1 Direct POSIX regular expression interface</h4>
  9973. <span id="index-posix_002dregexps-1"></span>
  9974. <p>The first interface to regular expressions is a thin layer over the
  9975. interface that POSIX provides. It is exported by the structures
  9976. <code>posix-regexps</code> &amp; <code>posix</code>.
  9977. </p>
  9978. <dl>
  9979. <dt id="index-make_002dregexp">procedure: <strong>make-regexp</strong> <em>string option &hellip; --&gt; regexp</em></dt>
  9980. <dt id="index-regexp_003f">procedure: <strong>regexp?</strong> <em>object --&gt; boolean</em></dt>
  9981. <dd><p><code>Make-regexp</code> creates a regular expression with the given string
  9982. pattern. The arguments after <var>string</var> specify various options for
  9983. the regular expression; see <code>regexp-option</code> below. The regular
  9984. expression is not compiled until it is matched against a string, so any
  9985. errors in the pattern string will not be reported until that point.
  9986. <code>Regexp?</code> is the disjoint type predicate for regular expression
  9987. objects.
  9988. </p></dd></dl>
  9989. <dl>
  9990. <dt id="index-regexp_002doption">syntax: <strong>regexp-option</strong> <em>name --&gt; regexp-option</em></dt>
  9991. <dd><p>Evaluates to a regular expression option, suitable to be passed to
  9992. <code>make-regexp</code>, with the given name. The possible option names
  9993. are:
  9994. </p>
  9995. <dl compact="compact">
  9996. <dt><code>extended</code></dt>
  9997. <dd><p>use the extended patterns
  9998. </p></dd>
  9999. <dt><code>ignore-case</code></dt>
  10000. <dd><p>ignore case differences when matching
  10001. </p></dd>
  10002. <dt><code>submatches</code></dt>
  10003. <dd><p>report submatches
  10004. </p></dd>
  10005. <dt><code>newline</code></dt>
  10006. <dd><p>treat newlines specially
  10007. </p></dd>
  10008. </dl>
  10009. </dd></dl>
  10010. <dl>
  10011. <dt id="index-regexp_002dmatch">procedure: <strong>regexp-match</strong> <em>regexp string start submatches? starts-line? ends-line? --&gt; boolean or list of matches</em></dt>
  10012. <dd><p><code>Regexp-match</code> matches <var>regexp</var> against the characters in
  10013. <var>string</var>, starting at position <var>start</var>. If the string does not
  10014. match the regular expression, <code>regexp-match</code> returns <code>#f</code>.
  10015. If the string does match, then a list of match records is returned if
  10016. <var>submatches?</var> is true or <code>#t</code> if <var>submatches?</var> is false.
  10017. The first match record gives the location of the substring that matched
  10018. <var>regexp</var>. If the pattern in <var>regexp</var> contained submatches,
  10019. then the submatches are returned in order, with match records in the
  10020. positions where submatches succeeded and <code>#f</code> in the positions
  10021. where submatches failed.
  10022. </p>
  10023. <p><var>Starts-line?</var> should be true if <var>string</var> starts at the
  10024. beginning of a line, and <var>ends-line?</var> should be true if it ends
  10025. one.
  10026. </p></dd></dl>
  10027. <dl>
  10028. <dt id="index-match_003f">procedure: <strong>match?</strong> <em>object --&gt; boolean</em></dt>
  10029. <dt id="index-match_002dstart">procedure: <strong>match-start</strong> <em>match --&gt; integer</em></dt>
  10030. <dt id="index-match_002dend">procedure: <strong>match-end</strong> <em>match --&gt; integer</em></dt>
  10031. <dt id="index-match_002dsubmatches">procedure: <strong>match-submatches</strong> <em>match --&gt; alist</em></dt>
  10032. <dd><p><code>Match?</code> is the disjoint type predicate for match records. Match
  10033. records contain three values: the beginning &amp; end of the substring that
  10034. matched the pattern and an association list of submatch keys and
  10035. corresponding match records for any named submatches that also matched.
  10036. <code>Match-start</code> returns the index of the first character in the
  10037. matching substring, and <code>match-end</code> gives the index of the
  10038. first character after the matching substring. <code>Match-submatches</code>
  10039. returns the alist of submatches.
  10040. </p></dd></dl>
  10041. <span id="High_002dlevel-regular-expression-construction"></span><h4 class="subsection">8.9.2 High-level regular expression construction</h4>
  10042. <span id="index-regexp"></span>
  10043. <p>This section describes a functional interface for building regular
  10044. expressions and matching them against strings, higher-level than the
  10045. direct POSIX interface. The matching is done using the POSIX regular
  10046. expression package. Regular expressions constructed by procedures
  10047. listed here are compatible with those in the previous section; that is,
  10048. they satisfy the predicate <code>regexp?</code> from the <code>posix-regexps</code>
  10049. structure. These names are exported by the structure <code>regexps</code>.
  10050. </p>
  10051. <span id="Character-sets"></span><h4 class="subsubsection">8.9.2.1 Character sets</h4>
  10052. <p>Character sets may be defined using a list of characters and strings,
  10053. using a range or ranges of characters, or by using set operations on
  10054. existing character sets.
  10055. </p>
  10056. <dl>
  10057. <dt id="index-set">procedure: <strong>set</strong> <em>char-or-string &hellip; --&gt; char-set-regexp</em></dt>
  10058. <dt id="index-range">procedure: <strong>range</strong> <em>low-char high-char --&gt; char-set-regexp</em></dt>
  10059. <dt id="index-ranges">procedure: <strong>ranges</strong> <em>low-char high-char &hellip; --&gt; char-set-regexp</em></dt>
  10060. <dt id="index-ascii_002drange">procedure: <strong>ascii-range</strong> <em>low-char high-char --&gt; char-set-regexp</em></dt>
  10061. <dt id="index-ascii_002dranges">procedure: <strong>ascii-ranges</strong> <em>low-char high-char &hellip; --&gt; char-set-regexp</em></dt>
  10062. <dd><p><code>Set</code> returns a character set that contains all of the character
  10063. arguments and all of the characters in all of the string arguments.
  10064. <code>Range</code> returns a character set that contains all characters
  10065. between <var>low-char</var> and <var>high-char</var>, inclusive. <code>Ranges</code>
  10066. returns a set that contains all of the characters in the given set of
  10067. ranges. <code>Range</code> &amp; <code>ranges</code> use the ordering imposed by
  10068. <code>char-&gt;integer</code>. <code>Ascii-range</code> &amp; <code>ascii-ranges</code> are
  10069. like <code>range</code> &amp; <code>ranges</code>, but they use the ASCII ordering.
  10070. <code>Ranges</code> &amp; <code>ascii-ranges</code> must be given an even number of
  10071. arguments. It is an error for a <var>high-char</var> to be less than the
  10072. preceding <var>low-char</var> in the appropriate ordering.
  10073. </p></dd></dl>
  10074. <dl>
  10075. <dt id="index-negate">procedure: <strong>negate</strong> <em>char-set --&gt; char-set-regexp</em></dt>
  10076. <dt id="index-union">procedure: <strong>union</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --&gt; char-set-regexp</em></dt>
  10077. <dt id="index-intersection">procedure: <strong>intersection</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --&gt; char-set-regexp</em></dt>
  10078. <dt id="index-subtract">procedure: <strong>subtract</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --&gt; char-set-regexp</em></dt>
  10079. <dd><p>Set operations on character sets. <code>Negate</code> returns a character
  10080. set of all characters that are not in <var>char-set</var>. <code>Union</code>
  10081. returns a character set that contains all of the characters in
  10082. <var>char-set<sub>a</sub></var> and all of the characters in
  10083. <var>char-set<sub>b</sub></var>. <code>Intersection</code> returns a character set of
  10084. all of the characters that are in both <var>char-set<sub>a</sub></var> and
  10085. <var>char-set<sub>b</sub></var>. <code>Subtract</code> returns a character set of all
  10086. the characters in <var>char-set<sub>a</sub></var> that are not also in
  10087. <var>char-set<sub>b</sub></var>.
  10088. </p></dd></dl>
  10089. <dl>
  10090. <dt id="index-lower_002dcase">character set: <strong>lower-case</strong> <em>= <code>(set &quot;abcdefghijklmnopqrstuvwxyz&quot;)</code></em></dt>
  10091. <dt id="index-lower_002dcase-1">character set: <strong>lower-case</strong> <em>= <code>(set &quot;abcdefghijklmnopqrstuvwxyz&quot;)</code></em></dt>
  10092. <dt id="index-upper_002dcase">character set: <strong>upper-case</strong> <em>= <code>(set &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)</code></em></dt>
  10093. <dt id="index-alphabetic">character set: <strong>alphabetic</strong> <em>= <code>(union lower-case upper-case)</code></em></dt>
  10094. <dt id="index-numeric">character set: <strong>numeric</strong> <em>= <code>(set &quot;0123456789&quot;)</code></em></dt>
  10095. <dt id="index-alphanumeric">character set: <strong>alphanumeric</strong> <em>= <code>(union alphabetic numeric)</code></em></dt>
  10096. <dt id="index-punctuation">character set: <strong>punctuation</strong> <em>= <code>(set &quot;!\&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?@[\\]^_`{|}~&quot;)</code></em></dt>
  10097. <dt id="index-graphic">character set: <strong>graphic</strong> <em>= <code>(union alphanumeric punctuation)</code></em></dt>
  10098. <dt id="index-printing-1">character set: <strong>printing</strong> <em>= <code>(union graphic (set #\space))</code></em></dt>
  10099. <dt id="index-control">character set: <strong>control</strong> <em>= <code>(negate printing)</code></em></dt>
  10100. <dt id="index-blank">character set: <strong>blank</strong> <em>= <code>(set #\space (ascii-&gt;char 9)) ; ASCII 9 = TAB</code></em></dt>
  10101. <dt id="index-whitespace">character set: <strong>whitespace</strong> <em>= <code>(union (set #\space) (ascii-range 9 13))</code></em></dt>
  10102. <dt id="index-hexdigit">character set: <strong>hexdigit</strong> <em>= <code>(set &quot;0123456789ABCDEF&quot;)</code></em></dt>
  10103. <dd><p>Predefined character sets.
  10104. </p></dd></dl>
  10105. <span id="Anchoring"></span><h4 class="subsubsection">8.9.2.2 Anchoring</h4>
  10106. <dl>
  10107. <dt id="index-string_002dstart">procedure: <strong>string-start</strong> <em>--&gt; regexp</em></dt>
  10108. <dt id="index-string_002dend">procedure: <strong>string-end</strong> <em>--&gt; regexp</em></dt>
  10109. <dd><p><code>String-start</code> returns a regular expression that matches the
  10110. beginning of the string being matched against; <code>string-end</code>
  10111. returns one that matches the end.
  10112. </p></dd></dl>
  10113. <span id="Composite-expressions"></span><h4 class="subsubsection">8.9.2.3 Composite expressions</h4>
  10114. <dl>
  10115. <dt id="index-sequence">procedure: <strong>sequence</strong> <em>regexp &hellip; --&gt; regexp</em></dt>
  10116. <dt id="index-one_002dof">procedure: <strong>one-of</strong> <em>regexp &hellip; --&gt; regexp</em></dt>
  10117. <dd><p><code>Sequence</code> returns a regular expression that matches
  10118. concatenation of all of its arguments; <code>one-of</code> returns a regular
  10119. expression that matches any one of its arguments.
  10120. </p></dd></dl>
  10121. <dl>
  10122. <dt id="index-text">procedure: <strong>text</strong> <em>string --&gt; regexp</em></dt>
  10123. <dd><p>Returns a regular expression that matches exactly the characters in
  10124. <var>string</var>, in order.
  10125. </p></dd></dl>
  10126. <dl>
  10127. <dt id="index-repeat">procedure: <strong>repeat</strong> <em>regexp --&gt; regexp</em></dt>
  10128. <dt id="index-repeat-1">procedure: <strong>repeat</strong> <em>count regexp --&gt; regexp</em></dt>
  10129. <dt id="index-repeat-2">procedure: <strong>repeat</strong> <em>min max regexp --&gt; regexp</em></dt>
  10130. <dd><p><code>Repeat</code> returns a regular expression that matches zero or more
  10131. occurrences of its <var>regexp</var> argument. With only one argument, the
  10132. result will match <var>regexp</var> any number of times. With two
  10133. arguments, <i>i.e.</i> one <var>count</var> argument, the returned regular
  10134. expression will match <var>regexp</var> exactly that number of times. The
  10135. final case will match from <var>min</var> to <var>max</var> repetitions,
  10136. inclusive. <var>Max</var> may be <code>#f</code>, in which case there is no
  10137. maximum number of matches. <var>Count</var> &amp; <var>min</var> must be exact,
  10138. non-negative integers; <var>max</var> should be either <code>#f</code> or an
  10139. exact, non-negative integer.
  10140. </p></dd></dl>
  10141. <span id="Case-sensitivity"></span><h4 class="subsubsection">8.9.2.4 Case sensitivity</h4>
  10142. <p>Regular expressions are normally case-sensitive, but case sensitivity
  10143. can be manipulated simply.
  10144. </p>
  10145. <dl>
  10146. <dt id="index-ignore_002dcase">procedure: <strong>ignore-case</strong> <em>regexp --&gt; regexp</em></dt>
  10147. <dt id="index-use_002dcase">procedure: <strong>use-case</strong> <em>regexp --&gt; regexp</em></dt>
  10148. <dd><p>The regular expression returned by <code>ignore-case</code> is identical to
  10149. its argument except that the case will be ignored when matching. The
  10150. value returned by <code>use-case</code> is protected from future applications
  10151. of <code>ignore-case</code>. The expressions returned by <code>use-case</code> and
  10152. <code>ignore-case</code> are unaffected by any enclosing uses of these
  10153. procedures.
  10154. </p>
  10155. <p>By way of example, the following matches <code>&quot;ab&quot;</code>, but not
  10156. <code>&quot;aB&quot;</code>, <code>&quot;Ab&quot;</code>, or <code>&quot;AB&quot;</code>:
  10157. </p>
  10158. <div class="lisp">
  10159. <pre class="lisp">(text &quot;ab&quot;)</pre></div>
  10160. <p>while
  10161. </p>
  10162. <div class="lisp">
  10163. <pre class="lisp">(ignore-case (text &quot;ab&quot;))</pre></div>
  10164. <p>matches all of those, and
  10165. </p>
  10166. <div class="lisp">
  10167. <pre class="lisp">(ignore-case (sequence (text &quot;a&quot;)
  10168. (use-case (text &quot;b&quot;))))</pre></div>
  10169. <p>matches <code>&quot;ab&quot;</code> or <code>&quot;Ab&quot;</code>, but not <code>&quot;aB&quot;</code> or <code>&quot;AB&quot;</code>.
  10170. </p></dd></dl>
  10171. <span id="Submatches-and-matching"></span><h4 class="subsubsection">8.9.2.5 Submatches and matching</h4>
  10172. <p>A subexpression within a larger expression can be marked as a submatch.
  10173. When an expression is matched against a string, the success or failure
  10174. of each submatch within that expression is reported, as well as the
  10175. location of the substring matched by each successful submatch.
  10176. </p>
  10177. <dl>
  10178. <dt id="index-submatch">procedure: <strong>submatch</strong> <em>key regexp --&gt; regexp</em></dt>
  10179. <dt id="index-no_002dsubmatches">procedure: <strong>no-submatches</strong> <em>regexp --&gt; regexp</em></dt>
  10180. <dd><p><code>Submatch</code> returns a regular expression that is equivalent to
  10181. <var>regexp</var> in every way except that the regular expression returned by
  10182. <code>submatch</code> will produce a submatch record in the output for the
  10183. part of the string matched by <var>regexp</var>. <code>No-submatches</code>
  10184. returns a regular expression that is equivalent to <var>regexp</var> in every
  10185. respect except that all submatches generated by <var>regexp</var> will be
  10186. ignored &amp; removed from the output.
  10187. </p></dd></dl>
  10188. <dl>
  10189. <dt id="index-any_002dmatch_003f">procedure: <strong>any-match?</strong> <em>regexp string --&gt; boolean</em></dt>
  10190. <dt id="index-exact_002dmatch_003f">procedure: <strong>exact-match?</strong> <em>regexp string --&gt; boolean</em></dt>
  10191. <dt id="index-match">procedure: <strong>match</strong> <em>regexp string --&gt; match or <code>#f</code></em></dt>
  10192. <dd><p><code>Any-match?</code> returns <code>#t</code> if <var>string</var> matches
  10193. <var>regexp</var> or contains a substring that does, or <code>#f</code> if
  10194. otherwise. <code>Exact-match?</code> returns <code>#t</code> if <var>string</var>
  10195. matches <var>regexp</var> exactly, or <code>#f</code> if it does not.
  10196. </p>
  10197. <p><code>Match</code> returns <code>#f</code> if <var>string</var> does not match
  10198. <var>regexp</var>, or a match record if it does, as described in the
  10199. previous section. Matching occurs according to POSIX. The match
  10200. returned is the one with the lowest starting index in <var>string</var>. If
  10201. there is more than one such match, the longest is returned. Within
  10202. that match, the longest possible submatches are returned.
  10203. </p>
  10204. <p>All three matching procedures cache a compiled version of <var>regexp</var>.
  10205. Subsequent calls with the same input regular expression will be more
  10206. efficient.
  10207. </p></dd></dl>
  10208. <p>Here are some examples of the high-level regular expression interface:
  10209. </p>
  10210. <div class="lisp">
  10211. <pre class="lisp">(define pattern (text &quot;abc&quot;))
  10212. (any-match? pattern &quot;abc&quot;) &rArr; #t
  10213. (any-match? pattern &quot;abx&quot;) &rArr; #f
  10214. (any-match? pattern &quot;xxabcxx&quot;) &rArr; #t
  10215. (exact-match? pattern &quot;abc&quot;) &rArr; #t
  10216. (exact-match? pattern &quot;abx&quot;) &rArr; #f
  10217. (exact-match? pattern &quot;xxabcxx&quot;) &rArr; #f
  10218. (let ((m (match (sequence (text &quot;ab&quot;)
  10219. (submatch 'foo (text &quot;cd&quot;))
  10220. (text &quot;ef&quot;)))
  10221. &quot;xxabcdefxx&quot;))
  10222. (list m (match-submatches m)))
  10223. &rArr; (#{Match 3 9} ((foo . #{Match 5 7})))
  10224. (match-submatches
  10225. (match (sequence (set &quot;a&quot;)
  10226. (one-of (submatch 'foo (text &quot;bc&quot;))
  10227. (submatch 'bar (text &quot;BC&quot;))))
  10228. &quot;xxxaBCd&quot;))
  10229. &rArr; ((bar . #{Match 4 6}))</pre></div>
  10230. <hr>
  10231. <span id="POSIX-C-to-Scheme-correspondence"></span><div class="header">
  10232. <p>
  10233. Previous: <a href="#POSIX-regular-expressions" accesskey="p" rel="prev">POSIX regular expressions</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10234. </div>
  10235. <span id="C-to-Scheme-correspondence"></span><h3 class="section">8.10 C to Scheme correspondence</h3>
  10236. <dl compact="compact">
  10237. <dt><code>access</code></dt>
  10238. <dd><p><code>accessible?</code>
  10239. </p></dd>
  10240. <dt><code>chdir</code></dt>
  10241. <dd><p><code>set-working-directory!</code>
  10242. </p></dd>
  10243. <dt><code>close</code></dt>
  10244. <dd><p><code>close-input-port, close-output-port, close-channel, close-socket</code>
  10245. </p></dd>
  10246. <dt><code>closedir</code></dt>
  10247. <dd><p><code>close-directory-stream</code>
  10248. </p></dd>
  10249. <dt><code>creat</code></dt>
  10250. <dd><p><code>open-file</code>
  10251. </p></dd>
  10252. <dt><code>ctime</code></dt>
  10253. <dd><p><code>time-&gt;string</code>
  10254. </p></dd>
  10255. <dt><code>dup</code></dt>
  10256. <dd><p><code>dup, dup-switching-mode</code>
  10257. </p></dd>
  10258. <dt><code>dup2</code></dt>
  10259. <dd><p><code>dup2</code>
  10260. </p></dd>
  10261. <dt><code>exec[l|v][e|p|eps]</code></dt>
  10262. <dd><p><code>exec, exec-with-environment, exec-file, exec-file-with-environment, exec-with-alias</code>
  10263. </p></dd>
  10264. <dt><code>_exit</code></dt>
  10265. <dd><p><code>exit</code>
  10266. </p></dd>
  10267. <dt><code>fcntl</code></dt>
  10268. <dd><p><code>i/o-flags, set-i/o-flags!, close-on-exec?, set-close-on-exec?!</code>
  10269. </p></dd>
  10270. <dt><code>fork</code></dt>
  10271. <dd><p><code>fork, fork-and-forget</code>
  10272. </p></dd>
  10273. <dt><code>fstat</code></dt>
  10274. <dd><p><code>get-port-info</code>
  10275. </p></dd>
  10276. <dt><code>getcwd</code></dt>
  10277. <dd><p><code>working-directory</code>
  10278. </p></dd>
  10279. <dt><code>getegid</code></dt>
  10280. <dd><p><code>get-effective-group-id</code>
  10281. </p></dd>
  10282. <dt><code>getenv</code></dt>
  10283. <dd><p><code>lookup-environment-variable, environment-alist</code>
  10284. </p></dd>
  10285. <dt><code>geteuid</code></dt>
  10286. <dd><p><code>get-effective-user-id</code>
  10287. </p></dd>
  10288. <dt><code>getgid</code></dt>
  10289. <dd><p><code>get-group-id</code>
  10290. </p></dd>
  10291. <dt><code>getgroups</code></dt>
  10292. <dd><p><code>get-login-name</code>
  10293. </p></dd>
  10294. <dt><code>getpid</code></dt>
  10295. <dd><p><code>get-process-id</code>
  10296. </p></dd>
  10297. <dt><code>getppid</code></dt>
  10298. <dd><p><code>get-parent-process-id</code>
  10299. </p></dd>
  10300. <dt><code>getuid</code></dt>
  10301. <dd><p><code>get-user-id</code>
  10302. </p></dd>
  10303. <dt><code>isatty</code></dt>
  10304. <dd><p><code>port-is-a-terminal?</code>
  10305. </p></dd>
  10306. <dt><code>link</code></dt>
  10307. <dd><p><code>link</code>
  10308. </p></dd>
  10309. <dt><code>lstat</code></dt>
  10310. <dd><p><code>get-file/link-info</code>
  10311. </p></dd>
  10312. <dt><code>mkdir</code></dt>
  10313. <dd><p><code>make-directory</code>
  10314. </p></dd>
  10315. <dt><code>mkfifo</code></dt>
  10316. <dd><p><code>make-fifo</code>
  10317. </p></dd>
  10318. <dt><code>open</code></dt>
  10319. <dd><p><code>open-file</code>
  10320. </p></dd>
  10321. <dt><code>opendir</code></dt>
  10322. <dd><p><code>open-directory-stream</code>
  10323. </p></dd>
  10324. <dt><code>pipe</code></dt>
  10325. <dd><p><code>open-pipe</code>
  10326. </p></dd>
  10327. <dt><code>read</code></dt>
  10328. <dd><p><code>read-char, read-block</code>
  10329. </p></dd>
  10330. <dt><code>readdir</code></dt>
  10331. <dd><p><code>read-directory-stream</code>
  10332. </p></dd>
  10333. <dt><code>rename</code></dt>
  10334. <dd><p><code>rename</code>
  10335. </p></dd>
  10336. <dt><code>rmdir</code></dt>
  10337. <dd><p><code>remove-directory</code>
  10338. </p></dd>
  10339. <dt><code>setgid</code></dt>
  10340. <dd><p><code>set-group-id!</code>
  10341. </p></dd>
  10342. <dt><code>setuid</code></dt>
  10343. <dd><p><code>set-user-id!</code>
  10344. </p></dd>
  10345. <dt><code>stat</code></dt>
  10346. <dd><p><code>get-file-info</code>
  10347. </p></dd>
  10348. <dt><code>time</code></dt>
  10349. <dd><p><code>current-time</code>
  10350. </p></dd>
  10351. <dt><code>ttyname</code></dt>
  10352. <dd><p><code>port-terminal-name</code>
  10353. </p></dd>
  10354. <dt><code>umask</code></dt>
  10355. <dd><p><code>set-file-creation-mask!</code>
  10356. </p></dd>
  10357. <dt><code>uname</code></dt>
  10358. <dd><p><code>os-name, os-node-name, os-release-name, os-version-name, machine-name</code>
  10359. </p></dd>
  10360. <dt><code>unlink</code></dt>
  10361. <dd><p><code>unlink</code>
  10362. </p></dd>
  10363. <dt><code>waitpid</code></dt>
  10364. <dd><p><code>wait-for-child-process</code>
  10365. </p></dd>
  10366. <dt><code>write</code></dt>
  10367. <dd><p><code>write-char, write-block</code>
  10368. </p></dd>
  10369. </dl>
  10370. <hr>
  10371. <span id="Pre_002dScheme"></span><div class="header">
  10372. <p>
  10373. Next: <a href="#References" accesskey="n" rel="next">References</a>, Previous: <a href="#POSIX-interface" accesskey="p" rel="prev">POSIX interface</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10374. </div>
  10375. <span id="Pre_002dScheme_003a-A-low_002dlevel-dialect-of-Scheme"></span><h2 class="chapter">9 Pre-Scheme: A low-level dialect of Scheme</h2>
  10376. <p>Pre-Scheme [Kelsey 97] is a low-level dialect of Scheme, designed for
  10377. systems programming with higher-level abstractions. For example, the
  10378. Scheme48 virtual machine is written in Pre-Scheme. Pre-Scheme is a
  10379. particularly interesting alternative to C for many systems programming
  10380. tasks, because not only does it operate at about the same level as C,
  10381. but it also may be run in a regular high-level Scheme development with
  10382. no changes to the source, without resorting to low-level stack munging
  10383. with tools such as gdb. Pre-Scheme also supports two <em>extremely</em>
  10384. important high-level abstractions of Scheme: macros and higher-order,
  10385. anonymous functions. Richard Kelsey&rsquo;s Pre-Scheme compiler, based on
  10386. his PhD research on transformational compilation [Kelsey 89], compiles
  10387. Pre-Scheme to efficient C, applying numerous intermediate source
  10388. transformations in the process.
  10389. </p>
  10390. <p>This chapter describes details of the differences between Scheme and
  10391. Pre-Scheme, listings of the default environment and other packages
  10392. available to Pre-Scheme, the operation of Richard Kelsey&rsquo;s Pre-Scheme
  10393. compiler, and how to run Pre-Scheme code as if it were Scheme in a
  10394. regular Scheme environment.
  10395. </p>
  10396. <table class="menu" border="0" cellspacing="0">
  10397. <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">&bull; <a href="#Differences-between-Pre_002dScheme-_0026-Scheme" accesskey="1">Differences between Pre-Scheme &amp; Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10398. </td></tr>
  10399. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-type-specifiers" accesskey="2">Pre-Scheme type specifiers</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10400. </td></tr>
  10401. <tr><td align="left" valign="top">&bull; <a href="#Standard-Pre_002dScheme-environment" accesskey="3">Standard Pre-Scheme environment</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10402. </td></tr>
  10403. <tr><td align="left" valign="top">&bull; <a href="#More-Pre_002dScheme-packages" accesskey="4">More Pre-Scheme packages</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10404. </td></tr>
  10405. <tr><td align="left" valign="top">&bull; <a href="#Invoking-the-Pre_002dScheme-compiler" accesskey="5">Invoking the Pre-Scheme compiler</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10406. </td></tr>
  10407. <tr><td align="left" valign="top">&bull; <a href="#Example-Pre_002dScheme-compiler-usage" accesskey="6">Example Pre-Scheme compiler usage</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10408. </td></tr>
  10409. <tr><td align="left" valign="top">&bull; <a href="#Running-Pre_002dScheme-as-Scheme" accesskey="7">Running Pre-Scheme as Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10410. </td></tr>
  10411. </table>
  10412. <hr>
  10413. <span id="Differences-between-Pre_002dScheme-_0026-Scheme"></span><div class="header">
  10414. <p>
  10415. Next: <a href="#Pre_002dScheme-type-specifiers" accesskey="n" rel="next">Pre-Scheme type specifiers</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10416. </div>
  10417. <span id="Differences-between-Pre_002dScheme-_0026-Scheme-1"></span><h3 class="section">9.1 Differences between Pre-Scheme &amp; Scheme</h3>
  10418. <p>Pre-Scheme is often considered either a dialect of Scheme or a subset
  10419. of Scheme. However, there are several very important fundamental
  10420. differences between the semantics of Pre-Scheme &amp; Scheme to detail.
  10421. </p>
  10422. <dl compact="compact">
  10423. <dd><span id="index-Pre_002dScheme-memory-management"></span>
  10424. <span id="index-Pre_002dScheme-garbage-collection"></span>
  10425. <span id="index-memory-management-in-Pre_002dScheme"></span>
  10426. <span id="index-garbage-collection-in-Pre_002dScheme"></span>
  10427. </dd>
  10428. <dt><strong>There is no garbage collector in Pre-Scheme.</strong></dt>
  10429. <dd><p>All memory management is manual, as in C, although there are two levels
  10430. to memory management, for higher- and lower-level purposes: pointers &amp;
  10431. addresses. Pointers represent higher-level data that are statically
  10432. checked for type coherency, such as vectors of a certain element type,
  10433. or strings. Addresses represent direct, low-level memory indices.
  10434. </p>
  10435. <span id="index-closures-in-Pre_002dScheme"></span>
  10436. <span id="index-Pre_002dScheme-closures"></span>
  10437. </dd>
  10438. <dt><strong>Pre-Scheme has no closures.</strong></dt>
  10439. <dd><p><code>Lambda</code> expressions that would require full closures at run-time
  10440. &mdash; <i>e.g.</i>, those whose values are stored in the heap &mdash; are not
  10441. permitted in Pre-Scheme. However, the Pre-Scheme compiler can hoist
  10442. many <code>lambda</code> expressions to the top level, removing the need of
  10443. closures for them. (Closures would be much less useful in the absence
  10444. of garbage collection, in any case.) If the Pre-Scheme compiler is
  10445. unable to move a <code>lambda</code> to a place where it requires no closure,
  10446. it signals an error to the user.
  10447. </p>
  10448. <span id="index-Pre_002dScheme-tail-call-optimization"></span>
  10449. <span id="index-tail-call-optimization-in-Pre_002dScheme"></span>
  10450. <span id="index-tail-recursion-in-Pre_002dScheme"></span>
  10451. </dd>
  10452. <dt><strong>Tail call optimization is not universal.</strong></dt>
  10453. <dd><p>The Pre-Scheme compiler optimizes tail calls where it is possible &mdash;
  10454. typically, just in local loops and top-level procedures that are not
  10455. exported from the package, but there are other heuristics &mdash;, but it
  10456. is not universal. Programmers may force tail call optimization with
  10457. Pre-Scheme&rsquo;s <code>goto</code> special form (see <a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a>), but, in situations where the compiler would not have
  10458. optimized the tail call, this can make the generated code have to jump
  10459. through many hoops to be a tail call &mdash; often necessitating code bloat,
  10460. because the code of the tail-called procedure is integrated into the
  10461. caller&rsquo;s driver loop &mdash;; and, where the compiler would have otherwise
  10462. optimized the tail call, <code>goto</code> has no effect anyway.
  10463. </p>
  10464. <span id="index-Pre_002dScheme-type-inference"></span>
  10465. <span id="index-static-types-in-Pre_002dScheme"></span>
  10466. </dd>
  10467. <dt><strong>Types are strictly verified with Hindley-Milner type inference.</strong></dt>
  10468. <dd><p>The types of Pre-Scheme programs are statically verified based on
  10469. Hindley-Milner type inference, with some modifications specific to
  10470. Pre-Scheme. Type information is <em>not</em> retained at run-time; any
  10471. tagging must be performed explicitly.
  10472. </p>
  10473. <span id="index-continuations-in-Pre_002dScheme"></span>
  10474. </dd>
  10475. <dt><strong>Pre-Scheme does not support first-class continuations.</strong></dt>
  10476. <dd><p>There is no <code>call-with-current-continuation</code> or other continuation
  10477. manipulation interface. It has been suggested that downward-only
  10478. continuations, based on C&rsquo;s <code>setjmp</code> &amp; <code>longjmp</code>, might be
  10479. implemented in the future, but this is not yet the case.<a id="DOCF27" href="#FOOT27"><sup>27</sup></a>
  10480. </p>
  10481. <span id="index-Pre_002dScheme-numbers"></span>
  10482. <span id="index-numbers-in-Pre_002dScheme"></span>
  10483. </dd>
  10484. <dt><strong>The full numeric tower of R5RS is not supported by Pre-Scheme.</strong></dt>
  10485. <dd><p>Pre-Scheme&rsquo;s only numeric types are fixnums and flonums, with precision
  10486. determined by the architecture on which the Pre-Scheme code runs.
  10487. Fixnums are translated to C as the <code>long</code> type; flonums are
  10488. translated as the <code>float</code> type.
  10489. </p>
  10490. <span id="index-top_002dlevel-evaluation-in-Pre_002dScheme"></span>
  10491. <span id="index-evaluation-of-top_002dlevel-code-in-Pre_002dScheme"></span>
  10492. <span id="index-Pre_002dScheme-top_002dlevel-evaluation"></span>
  10493. <span id="index-compile_002dtime-evaluation-in-Pre_002dScheme"></span>
  10494. </dd>
  10495. <dt><strong>Top-level Pre-Scheme code is evaluated at compile-time.</strong></dt>
  10496. <dd><p>Closures actually <em>are</em> available, as long as they may be
  10497. eliminated before run-time. Code evaluated at compile-time also does
  10498. not require satisfaction of strict static typing. Moreover, certain
  10499. procedures, such as <code>vector-length</code>, are available only at
  10500. compile-time.
  10501. </p></dd>
  10502. </dl>
  10503. <hr>
  10504. <span id="Pre_002dScheme-type-specifiers"></span><div class="header">
  10505. <p>
  10506. Next: <a href="#Standard-Pre_002dScheme-environment" accesskey="n" rel="next">Standard Pre-Scheme environment</a>, Previous: <a href="#Differences-between-Pre_002dScheme-_0026-Scheme" accesskey="p" rel="prev">Differences between Pre-Scheme &amp; Scheme</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10507. </div>
  10508. <span id="Type-specifiers"></span><h3 class="section">9.2 Type specifiers</h3>
  10509. <span id="index-Pre_002dScheme-type-inference-1"></span>
  10510. <span id="index-static-types-in-Pre_002dScheme-1"></span>
  10511. <p>Although Pre-Scheme&rsquo;s static type system is based mostly on
  10512. Hindley-Milner type inference, with as little explicit type information
  10513. as possible, there are still places where it is necessary to specify
  10514. types explicitly; for example, see <a href="#Pre_002dScheme-access-to-C-functions-and-macros">Pre-Scheme access to C functions and macros</a>. There are several different kinds of types with different
  10515. syntax:
  10516. </p>
  10517. <dl compact="compact">
  10518. <dt><code><var>type-name</var></code></dt>
  10519. <dd><p>Symbols denote either record type or base types. Record types are
  10520. defined with the <code>define-record-type</code> special form described
  10521. later; the following base types are defined:
  10522. </p>
  10523. <dl compact="compact">
  10524. <dt><code>integer</code></dt>
  10525. <dd><p>Fixed-size integers (fixnums). This type is translated into C as
  10526. <code>long</code>. The actual size depends on the size of C&rsquo;s <code>long</code>,
  10527. which on most architectures is 32 bits.
  10528. </p>
  10529. </dd>
  10530. <dt><code>float</code></dt>
  10531. <dd><p>Floating-point data. This type translates to C as <code>double</code>.
  10532. </p>
  10533. </dd>
  10534. <dt><code>null</code></dt>
  10535. <dd><p>Type which has no value. The <code>null</code> type translates to the C
  10536. <code>void</code> type.
  10537. </p>
  10538. </dd>
  10539. <dt><code>unit</code></dt>
  10540. <dd><p>Type which has one value. Actually, this, too, translates to C&rsquo;s
  10541. <code>void</code>, so that it has one value is not strictly true.
  10542. </p>
  10543. </dd>
  10544. <dt><code>boolean</code></dt>
  10545. <dd><p>Booleans translate to the C <code>char</code> type. <code>#t</code> is emitted as
  10546. <code>TRUE</code>, and <code>#f</code>, as <code>FALSE</code>; these are usually the same
  10547. as <code>1</code> &amp; <code>0</code>, respectively.
  10548. </p>
  10549. </dd>
  10550. <dt><code>input-port</code></dt>
  10551. <dt><code>output-port</code></dt>
  10552. <dd><p>I/O ports. On Unix, since Pre-Scheme uses <code>stdio</code>, these are
  10553. translated to <code>FILE *</code>s, <code>stdio</code> file streams.
  10554. </p>
  10555. </dd>
  10556. <dt><code>char</code></dt>
  10557. <dd><p>Characters. The size of characters is dependent on the underlying C
  10558. compiler&rsquo;s implementation of the <code>char</code> type.
  10559. </p>
  10560. </dd>
  10561. <dt><code>address</code></dt>
  10562. <dd><p>Simple addresses for use in <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Pre-Scheme&rsquo;s low-level memory manipulation primitives</a>;
  10563. see that section for more details.
  10564. </p></dd>
  10565. </dl>
  10566. </dd>
  10567. <dt><code>(=&gt; (<var>argument-type</var> &hellip;) <var>return-type</var> &hellip;)</code></dt>
  10568. <dd><p>The types of procedures, known as &lsquo;arrow&rsquo; types.
  10569. </p>
  10570. </dd>
  10571. <dt><code>(^ <var>type</var>)</code></dt>
  10572. <dd><p>The type of pointers that point to <var>type</var>. Note that these are
  10573. distinct from the address type. Pointer types are statically verified
  10574. to be coherent data, with no defined operations except for accessing
  10575. offsets in memory from the pointer &mdash; <i>i.e.</i> operations such as
  10576. <code>vector-ref</code> &mdash;; addresses simply index bytes, on which only
  10577. direct dereferencing, but also arbitrary address arithmetic, is
  10578. available. Pointers and addresses are <em>not</em> interchangeable, and
  10579. and there is no way to convert between them, as that would break the
  10580. type safety of Pre-Scheme pointers.
  10581. </p>
  10582. </dd>
  10583. <dt><code>(tuple <var>type</var> &hellip;)</code></dt>
  10584. <dd><p>Multiple value types, internally used for argument &amp; return types.
  10585. </p></dd>
  10586. </dl>
  10587. <hr>
  10588. <span id="Standard-Pre_002dScheme-environment"></span><div class="header">
  10589. <p>
  10590. Next: <a href="#More-Pre_002dScheme-packages" accesskey="n" rel="next">More Pre-Scheme packages</a>, Previous: <a href="#Pre_002dScheme-type-specifiers" accesskey="p" rel="prev">Pre-Scheme type specifiers</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10591. </div>
  10592. <span id="Standard-environment"></span><h3 class="section">9.3 Standard environment</h3>
  10593. <span id="index-prescheme-1"></span>
  10594. <p>Pre-Scheme programs usually open the <code>prescheme</code> structure. There
  10595. are several other structures built-in to Pre-Scheme as well, described
  10596. in the next section. This section describes the <code>prescheme</code>
  10597. structure.
  10598. </p>
  10599. <table class="menu" border="0" cellspacing="0">
  10600. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  10601. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Scheme-bindings-in-Pre_002dScheme" accesskey="1">Scheme bindings in Pre-Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Bindings from R5RS
  10602. </td></tr>
  10603. <tr><td align="left" valign="top">&bull; <a href="#Tail-call-optimization-in-Pre_002dScheme" accesskey="2">Tail call optimization in Pre-Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10604. </td></tr>
  10605. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-bitwise-manipulation" accesskey="3">Pre-Scheme bitwise manipulation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10606. </td></tr>
  10607. <tr><td align="left" valign="top">&bull; <a href="#Compound-Pre_002dScheme-data-manipulation" accesskey="4">Compound Pre-Scheme data manipulation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10608. </td></tr>
  10609. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-error-handling" accesskey="5">Pre-Scheme error handling</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10610. </td></tr>
  10611. <tr><td align="left" valign="top">&bull; <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="6">Input &amp; output in Pre-Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10612. </td></tr>
  10613. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-access-to-C-functions-and-macros" accesskey="7">Pre-Scheme access to C functions and macros</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10614. </td></tr>
  10615. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  10616. </pre></th></tr></table>
  10617. <hr>
  10618. <span id="Scheme-bindings-in-Pre_002dScheme"></span><div class="header">
  10619. <p>
  10620. Next: <a href="#Tail-call-optimization-in-Pre_002dScheme" accesskey="n" rel="next">Tail call optimization in Pre-Scheme</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10621. </div>
  10622. <span id="Scheme-bindings"></span><h4 class="subsection">9.3.1 Scheme bindings</h4>
  10623. <p>Bindings for all the names specified here from R5RS Scheme are
  10624. available in Pre-Scheme. The remainder of the sections after this one
  10625. detail Pre-Scheme specifics that are not a part of Scheme.
  10626. </p>
  10627. <dl>
  10628. <dt id="index-define">syntax: <strong>define</strong> <em>name value</em></dt>
  10629. <dt id="index-define-1">syntax: <strong>define</strong> <em>(name . argument-list) value</em></dt>
  10630. <dt id="index-if">syntax: <strong>if</strong> <em>condition consequent [alternate]</em></dt>
  10631. <dt id="index-let-1">syntax: <strong>let</strong> <em>((name expression) &hellip;) body</em></dt>
  10632. <dt id="index-let_002a">syntax: <strong>let*</strong> <em>((name expression) &hellip;) body</em></dt>
  10633. <dt id="index-and">syntax: <strong>and</strong> <em>conjunct &hellip;</em></dt>
  10634. <dt id="index-or">syntax: <strong>or</strong> <em>disjunct &hellip;</em></dt>
  10635. <dt id="index-cond">syntax: <strong>cond</strong> <em>cond-clause &hellip;</em></dt>
  10636. <dt id="index-do">syntax: <strong>do</strong> <em>((name init-exp [step-exp]) &hellip;) (test-exp [return-exp]) body</em></dt>
  10637. <dd><p>These special forms &amp; macros are all unchanged from their R5RS
  10638. specifications.
  10639. </p></dd></dl>
  10640. <dl>
  10641. <dt id="index-define_002dsyntax-2">syntax: <strong>define-syntax</strong> <em>name transformer-expression [aux-names]</em></dt>
  10642. <dt id="index-let_002dsyntax">syntax: <strong>let-syntax</strong> <em>((name transformer-expression) &hellip;) body</em></dt>
  10643. <dt id="index-letrec_002dsyntax">syntax: <strong>letrec-syntax</strong> <em>((name transformer-expression) &hellip;) body</em></dt>
  10644. <dd><p>Pre-Scheme&rsquo;s macro facility is exactly the same as Scheme48&rsquo;s.
  10645. <var>Transformer-expression</var> may be either a <code>syntax-rules</code> or an
  10646. explicit renaming transformer, just as in Scheme48; in the latter case,
  10647. it is evaluated either in a standard Scheme environment or however the
  10648. <code>for-syntax</code> clause specified of the package in whose code the
  10649. transformer appeared. For details on the extra <var>aux-names</var> operand
  10650. to <code>define-syntax</code>, see <a href="#Explicit-renaming-macros">Explicit renaming macros</a>.
  10651. </p></dd></dl>
  10652. <dl>
  10653. <dt id="index-not">procedure: <strong>not</strong> <em>boolean --&gt; boolean</em></dt>
  10654. <dt id="index-eq_003f">procedure: <strong>eq?</strong> <em>value<sub>a</sub> value<sub>b</sub> --&gt; boolean</em></dt>
  10655. <dt id="index-char_003d_003f">procedure: <strong>char=?</strong> <em>char<sub>a</sub> char<sub>b</sub> --&gt; boolean</em></dt>
  10656. <dt id="index-char_003c_003f">procedure: <strong>char&lt;?</strong> <em>char<sub>a</sub> char<sub>b</sub> --&gt; boolean</em></dt>
  10657. <dt id="index-values-1">procedure: <strong>values</strong> <em>value &hellip; --&gt; values</em></dt>
  10658. <dt id="index-call_002dwith_002dvalues">procedure: <strong>call-with-values</strong> <em>producer consumer --&gt; values</em></dt>
  10659. <dt id="index-current_002dinput_002dport-1">procedure: <strong>current-input-port</strong> <em>--&gt; input-port</em></dt>
  10660. <dt id="index-current_002doutput_002dport-1">procedure: <strong>current-output-port</strong> <em>--&gt; output-port</em></dt>
  10661. <dd><p>These procedures are all unchanged from their R5RS specifications.
  10662. </p></dd></dl>
  10663. <dl>
  10664. <dt id="index-_002b">procedure: <strong>+</strong> <em>addend &hellip; --&gt; integer</em></dt>
  10665. <dt id="index-_002d">procedure: <strong>-</strong> <em>integer --&gt; integer</em></dt>
  10666. <dt id="index-_002d-1">procedure: <strong>-</strong> <em>minuend subtrahend --&gt; integer</em></dt>
  10667. <dt id="index-_002a">procedure: <strong>*</strong> <em>multiplicand &hellip; --&gt; integer</em></dt>
  10668. <dt id="index-_003d">procedure: <strong>=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; boolean</em></dt>
  10669. <dt id="index-_003c">procedure: <strong>&lt;</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; boolean</em></dt>
  10670. <dt id="index-_003e">procedure: <strong>&gt;</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; boolean</em></dt>
  10671. <dt id="index-_003c_003d">procedure: <strong>&lt;=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; boolean</em></dt>
  10672. <dt id="index-_003e_003d">procedure: <strong>&gt;=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; boolean</em></dt>
  10673. <dt id="index-min">procedure: <strong>min</strong> <em>integer<sub>1</sub> integer<sub>2</sub> &hellip; --&gt; integer</em></dt>
  10674. <dt id="index-max">procedure: <strong>max</strong> <em>integer<sub>1</sub> integer<sub>2</sub> &hellip; --&gt; integer</em></dt>
  10675. <dt id="index-abs">procedure: <strong>abs</strong> <em>integer --&gt; integer</em></dt>
  10676. <dt id="index-quotient">procedure: <strong>quotient</strong> <em>divisor dividend --&gt; integer</em></dt>
  10677. <dt id="index-remainder">procedure: <strong>remainder</strong> <em>divisor dividend --&gt; integer</em></dt>
  10678. <dt id="index-expt">procedure: <strong>expt</strong> <em>base exponent --&gt; integer</em></dt>
  10679. <dd><p>These numerical operations are all unchanged from their R5RS
  10680. counterparts, except that they are applicable only to fixnums, not to
  10681. flonums, and they always return fixnums.
  10682. </p></dd></dl>
  10683. <hr>
  10684. <span id="Tail-call-optimization-in-Pre_002dScheme"></span><div class="header">
  10685. <p>
  10686. Next: <a href="#Pre_002dScheme-bitwise-manipulation" accesskey="n" rel="next">Pre-Scheme bitwise manipulation</a>, Previous: <a href="#Scheme-bindings-in-Pre_002dScheme" accesskey="p" rel="prev">Scheme bindings in Pre-Scheme</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10687. </div>
  10688. <span id="Tail-call-optimization"></span><h4 class="subsection">9.3.2 Tail call optimization</h4>
  10689. <span id="index-Pre_002dScheme-tail-call-optimization-1"></span>
  10690. <span id="index-tail-call-optimization-in-Pre_002dScheme-1"></span>
  10691. <span id="index-tail-recursion-in-Pre_002dScheme-1"></span>
  10692. <dl>
  10693. <dt id="index-goto">syntax: <strong>goto</strong> <em>procedure argument &hellip;</em></dt>
  10694. <dd><p>The Pre-Scheme compiler can be forced to optimize tail calls, even
  10695. those it would not have otherwise optimized, by use of the <code>goto</code>
  10696. special form, rather than simple procedure calls. In every respect
  10697. other than tail call optimization, this is equivalent to calling
  10698. <var>procedure</var> with the given arguments. Note, however, that uses of
  10699. <code>goto</code> may cause code to blow up if the Pre-Scheme compiler had
  10700. reason not to optimize the tail call were it not for the <code>goto</code>:
  10701. it may need to merge the tail-called procedure into the caller&rsquo;s code.
  10702. </p></dd></dl>
  10703. <hr>
  10704. <span id="Pre_002dScheme-bitwise-manipulation"></span><div class="header">
  10705. <p>
  10706. Next: <a href="#Compound-Pre_002dScheme-data-manipulation" accesskey="n" rel="next">Compound Pre-Scheme data manipulation</a>, Previous: <a href="#Tail-call-optimization-in-Pre_002dScheme" accesskey="p" rel="prev">Tail call optimization in Pre-Scheme</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10707. </div>
  10708. <span id="Bitwise-manipulation-2"></span><h4 class="subsection">9.3.3 Bitwise manipulation</h4>
  10709. <p>Pre-Scheme provides basic bitwise manipulation operators.
  10710. </p>
  10711. <dl>
  10712. <dt id="index-bitwise_002dand-1">procedure: <strong>bitwise-and</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; integer</em></dt>
  10713. <dt id="index-bitwise_002dior-1">procedure: <strong>bitwise-ior</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; integer</em></dt>
  10714. <dt id="index-bitwise_002dxor-1">procedure: <strong>bitwise-xor</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --&gt; integer</em></dt>
  10715. <dt id="index-bitwise_002dnot-1">procedure: <strong>bitwise-not</strong> <em>integer --&gt; integer</em></dt>
  10716. <dd><p>Bitwise boolean logical operations.
  10717. </p></dd></dl>
  10718. <dl>
  10719. <dt id="index-shift_002dleft">procedure: <strong>shift-left</strong> <em>integer count --&gt; integer</em></dt>
  10720. <dt id="index-arithmetic_002dshift_002dright">procedure: <strong>arithmetic-shift-right</strong> <em>integer count --&gt; integer</em></dt>
  10721. <dt id="index-logical_002dshift_002dright">procedure: <strong>logical-shift-right</strong> <em>integer count --&gt; integer</em></dt>
  10722. <dd><p>Three ways to shift bit strings: <code>shift-left</code> shifts <var>integer</var>
  10723. left by <var>count</var>, <code>arithmetic-shift-right</code> shifts <var>integer</var>
  10724. right by <var>count</var> arithmetically, and <code>logical-shift-right</code>
  10725. shifts <var>integer</var> right by <var>count</var> logically.
  10726. </p></dd></dl>
  10727. <hr>
  10728. <span id="Compound-Pre_002dScheme-data-manipulation"></span><div class="header">
  10729. <p>
  10730. Next: <a href="#Pre_002dScheme-error-handling" accesskey="n" rel="next">Pre-Scheme error handling</a>, Previous: <a href="#Pre_002dScheme-bitwise-manipulation" accesskey="p" rel="prev">Pre-Scheme bitwise manipulation</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10731. </div>
  10732. <span id="Compound-data-manipulation"></span><h4 class="subsection">9.3.4 Compound data manipulation</h4>
  10733. <span id="index-vectors-in-Pre_002dScheme"></span>
  10734. <span id="index-Pre_002dScheme-vectors"></span>
  10735. <span id="index-strings-in-Pre_002dScheme"></span>
  10736. <span id="index-Pre_002dScheme-strings"></span>
  10737. <span id="index-Pre_002dScheme-memory-management-1"></span>
  10738. <span id="index-memory-management-in-Pre_002dScheme-1"></span>
  10739. <p>Pre-Scheme has somewhat lower-level vector &amp; string facilities than
  10740. Scheme, with more orientation towards static typing. It also provides
  10741. a statically typed record facility, which translates to C structs,
  10742. though not described here, as it is not in the <code>prescheme</code>
  10743. structure; see <a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a>.
  10744. </p>
  10745. <dl>
  10746. <dt id="index-make_002dvector">procedure: <strong>make-vector</strong> <em>length init --&gt; vector</em></dt>
  10747. <dt id="index-vector_002dlength">procedure: <strong>vector-length</strong> <em>vector --&gt; integer</em></dt>
  10748. <dt id="index-vector_002dref">procedure: <strong>vector-ref</strong> <em>vector index --&gt; value</em></dt>
  10749. <dt id="index-vector_002dset_0021">procedure: <strong>vector-set!</strong> <em>vector index value --&gt; unit</em></dt>
  10750. <dd><p>Vectors in Pre-Scheme are almost the same as vectors in regular Scheme,
  10751. but with a few differences. <code>Make-vector</code> initializes what it
  10752. returns with null pointers (see below); it uses the <em>required</em>
  10753. (unlike Scheme) <var>init</var> argument only to determine the type of the
  10754. vector: vectors are statically typed; they can contain only values that
  10755. have the same static type as <var>init</var>. <code>Vector-length</code> is
  10756. available only at the top level, where calls to it can be evaluated at
  10757. compile-time; vectors do not at run-time store their lengths. Vectors
  10758. must also be explicitly deallocated.
  10759. </p>
  10760. <p><strong>Warning:</strong> As in C, there is <em>no</em> vector bounds checking at
  10761. run-time.
  10762. </p></dd></dl>
  10763. <dl>
  10764. <dt id="index-make_002dstring">procedure: <strong>make-string</strong> <em>length --&gt; string</em></dt>
  10765. <dt id="index-string_002dlength">procedure: <strong>string-length</strong> <em>string --&gt; integer</em></dt>
  10766. <dt id="index-string_002dref">procedure: <strong>string-ref</strong> <em>string index --&gt; char</em></dt>
  10767. <dt id="index-string_002dset_0021">procedure: <strong>string-set!</strong> <em>string index char --&gt; unit</em></dt>
  10768. <dd><p>Strings in Pre-Scheme are the nearly same as strings in R5RS Scheme.
  10769. The only three differences here are that <code>make-string</code> accepts
  10770. exactly one argument, strings must be explicitly deallocated, and
  10771. strings are <code>nul</code>-terminated: <code>string-length</code> operates by
  10772. scanning for the first ASCII <code>nul</code> character in a string.
  10773. </p>
  10774. <p><strong>Warning:</strong> As in C, there is <em>no</em> string bounds checking at
  10775. run-time.
  10776. </p></dd></dl>
  10777. <dl>
  10778. <dt id="index-deallocate">procedure: <strong>deallocate</strong> <em>pointer --&gt; unit</em></dt>
  10779. <dd><p>Deallocates the memory pointed to by <code>pointer</code>. This is necessary
  10780. at the end of a string, vector, or record&rsquo;s life, as Pre-Scheme data
  10781. are not automatically garbage-collected.
  10782. </p></dd></dl>
  10783. <dl>
  10784. <dt id="index-null_002dpointer">procedure: <strong>null-pointer</strong> <em>--&gt; null-pointer</em></dt>
  10785. <dt id="index-null_002dpointer_003f">procedure: <strong>null-pointer?</strong> <em>pointer --&gt; boolean</em></dt>
  10786. <dd><p><code>Null-pointer</code> returns the distinguished null pointer object. It
  10787. corresponds with <code>0</code> in a pointer context or <code>NULL</code> in C.
  10788. <code>Null-pointer?</code> returns true if <var>pointer</var> is a null pointer,
  10789. or false if not.
  10790. </p></dd></dl>
  10791. <hr>
  10792. <span id="Pre_002dScheme-error-handling"></span><div class="header">
  10793. <p>
  10794. Next: <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="n" rel="next">Input &amp; output in Pre-Scheme</a>, Previous: <a href="#Compound-Pre_002dScheme-data-manipulation" accesskey="p" rel="prev">Compound Pre-Scheme data manipulation</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10795. </div>
  10796. <span id="Error-handling"></span><h4 class="subsection">9.3.5 Error handling</h4>
  10797. <p>Pre-Scheme&rsquo;s method of error handling is similar to the most common one
  10798. in C: error codes. There is an enumeration <code>errors</code> of some error
  10799. codes commonly and portably encountered in Pre-Scheme.
  10800. </p>
  10801. <dl>
  10802. <dt id="index-errors-1">enumeration: <strong>errors</strong></dt>
  10803. <dd><div class="lisp">
  10804. <pre class="lisp">(define-enumeration errors
  10805. (no-errors
  10806. parse-error
  10807. file-not-found
  10808. out-of-memory
  10809. invalid-port))</pre></div>
  10810. <p>Each enumerand has the following meaning:
  10811. </p>
  10812. <dl compact="compact">
  10813. <dt><code>(enum errors no-errors)</code></dt>
  10814. <dd><p>Absence of error: success.
  10815. </p>
  10816. </dd>
  10817. <dt><code>(enum errors parse-error)</code></dt>
  10818. <dd><p>Any kind of parsing error. The Scheme48 VM uses this when someone
  10819. attempts to resume a malformed suspended heap image.
  10820. </p>
  10821. </dd>
  10822. <dt><code>(enum errors file-not-found)</code></dt>
  10823. <dd><p>Used when an operation that operates on a file given a string filename
  10824. found that the file for that filename was absent.
  10825. </p>
  10826. </dd>
  10827. <dt><code>(enum errors out-of-memory)</code></dt>
  10828. <dd><p>When there is no more memory to allocate.
  10829. </p>
  10830. </dd>
  10831. <dt><code>(enum errors invalid-port)</code></dt>
  10832. <dd><p>Unused.
  10833. </p></dd>
  10834. </dl>
  10835. </dd></dl>
  10836. <dl>
  10837. <dt id="index-error_002dstring">procedure: <strong>error-string</strong> <em>error-status --&gt; string</em></dt>
  10838. <dd><p>Returns a string describing the meaning of the <code>errors</code> enumerand
  10839. <var>error-status</var>.
  10840. </p></dd></dl>
  10841. <dl>
  10842. <dt id="index-error-2">procedure: <strong>error</strong> <em>message irritant &hellip;</em></dt>
  10843. <dd><p>Signals a fatal error with the given message &amp; related irritants and
  10844. halts the program. On Unix, the program&rsquo;s exit code is -1.
  10845. </p></dd></dl>
  10846. <hr>
  10847. <span id="Input-_0026-output-in-Pre_002dScheme"></span><div class="header">
  10848. <p>
  10849. Next: <a href="#Pre_002dScheme-access-to-C-functions-and-macros" accesskey="n" rel="next">Pre-Scheme access to C functions and macros</a>, Previous: <a href="#Pre_002dScheme-error-handling" accesskey="p" rel="prev">Pre-Scheme error handling</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10850. </div>
  10851. <span id="Input-_0026-output"></span><h4 class="subsection">9.3.6 Input &amp; output</h4>
  10852. <p>Pre-Scheme&rsquo;s I/O facilities are somewhat different from Scheme&rsquo;s, given
  10853. the low level and the static type strictness. There is no exception
  10854. mechanism in Pre-Scheme; everything is maintained by returning a status
  10855. token, as in C. Pre-Scheme&rsquo;s built-in I/O facilities are buffered.
  10856. <a id="DOCF28" href="#FOOT28"><sup>28</sup></a>
  10857. (see <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a>, for two other I/O
  10858. primitives, <code>read-block</code> &amp; <code>write-block</code>, for reading &amp;
  10859. writing blocks of direct memory.)
  10860. </p>
  10861. <dl>
  10862. <dt id="index-open_002dinput_002dfile-1">procedure: <strong>open-input-file</strong> <em>filename --&gt; [port status]</em></dt>
  10863. <dt id="index-open_002doutput_002dfile-1">procedure: <strong>open-output-file</strong> <em>filename --&gt; [port status]</em></dt>
  10864. <dt id="index-close_002dinput_002dport-1">procedure: <strong>close-input-port</strong> <em>input-port --&gt; status</em></dt>
  10865. <dt id="index-close_002doutput_002dport-1">procedure: <strong>close-output-port</strong> <em>output-port --&gt; status</em></dt>
  10866. <dd><p><code>Open-input-file</code> &amp; <code>open-output-file</code> open ports for the
  10867. given filenames. They each return two values: the newly open port and
  10868. an <code>errors</code> enumerand status. Users of these procedures should
  10869. always check the error status before proceeding to operate with the
  10870. port. <code>Close-input-port</code> &amp; <code>close-output-port</code> close their
  10871. port arguments and return the <code>errors</code> enumerand status of the
  10872. closing.
  10873. </p></dd></dl>
  10874. <dl>
  10875. <dt id="index-read_002dchar">procedure: <strong>read-char</strong> <em>input-port --&gt; [char eof? status]</em></dt>
  10876. <dt id="index-peek_002dchar">procedure: <strong>peek-char</strong> <em>input-port --&gt; [char eof? status]</em></dt>
  10877. <dt id="index-read_002dinteger">procedure: <strong>read-integer</strong> <em>input-port --&gt; [integer eof? status]</em></dt>
  10878. <dd><p><code>Read-char</code> reads &amp; consumes a single character from its
  10879. <var>input-port</var> argument. <code>Peek-char</code> reads, but does not
  10880. consume, a single character from <var>input-port</var>. <code>Read-integer</code>
  10881. parses an integer literal, including sign. All of these also return
  10882. two other values: whether or not the file is at the end and any
  10883. <code>errors</code> enumerand status. If any error occurred, the first two
  10884. values returned should be ignored. If <var>status</var> is <code>(enum
  10885. errors no-errors)</code>, users of these three procedures should then check
  10886. <var>eof?</var>; it is true if <var>input-port</var> was at the end of the file
  10887. with nothing more left to read and false otherwise. Finally, if both
  10888. <var>status</var> is <code>(enum errors no-errors)</code> and <var>eof?</var> is false,
  10889. the first value returned may be safely used.
  10890. </p></dd></dl>
  10891. <dl>
  10892. <dt id="index-write_002dchar">procedure: <strong>write-char</strong> <em>char output-port --&gt; status</em></dt>
  10893. <dt id="index-newline-1">procedure: <strong>newline</strong> <em>output-port --&gt; status</em></dt>
  10894. <dt id="index-write_002dstring-1">procedure: <strong>write-string</strong> <em>string output-port --&gt; status</em></dt>
  10895. <dt id="index-write_002dinteger">procedure: <strong>write-integer</strong> <em>integer output-port --&gt; status</em></dt>
  10896. <dd><p>These all write particular elements to their <var>output-port</var>
  10897. arguments. <code>Write-char</code> writes individual characters.
  10898. <code>Newline</code> writes newlines (line-feed, or ASCII codepoint 10, on
  10899. Unix). <code>Write-string</code> writes the contents of <var>string</var>.
  10900. <code>Write-integer</code> writes an ASCII representation of <var>integer</var> to
  10901. port, suitable to be read by <code>read-integer</code>. These all return an
  10902. <code>errors</code> enumerand status. If it is <code>no-errors</code>, the write
  10903. succeeded.
  10904. </p></dd></dl>
  10905. <dl>
  10906. <dt id="index-force_002doutput-2">procedure: <strong>force-output</strong> <em>output-port --&gt; status</em></dt>
  10907. <dd><p>Forces all buffered output in <var>output-port</var>. <var>Status</var> tells
  10908. whether or not the operation was successful.
  10909. </p></dd></dl>
  10910. <hr>
  10911. <span id="Pre_002dScheme-access-to-C-functions-and-macros"></span><div class="header">
  10912. <p>
  10913. Previous: <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="p" rel="prev">Input &amp; output in Pre-Scheme</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10914. </div>
  10915. <span id="Access-to-C-functions-and-macros"></span><h4 class="subsection">9.3.7 Access to C functions and macros</h4>
  10916. <dl>
  10917. <dt id="index-external">syntax: <strong>external</strong> <em>c-name ps-type --&gt; procedure</em></dt>
  10918. <dd><p>Special form for accessing C functions &amp; macros. Calls in Pre-Scheme to
  10919. the resulting procedure are compiled to calls in C to the function or
  10920. macro named by <var>c-name</var>, which should be a string. <var>PS-type</var> is
  10921. the <a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type</a> that the
  10922. procedure should have, which is necessary for type inference.
  10923. </p></dd></dl>
  10924. <hr>
  10925. <span id="More-Pre_002dScheme-packages"></span><div class="header">
  10926. <p>
  10927. Next: <a href="#Invoking-the-Pre_002dScheme-compiler" accesskey="n" rel="next">Invoking the Pre-Scheme compiler</a>, Previous: <a href="#Standard-Pre_002dScheme-environment" accesskey="p" rel="prev">Standard Pre-Scheme environment</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10928. </div>
  10929. <span id="More-Pre_002dScheme-packages-1"></span><h3 class="section">9.4 More Pre-Scheme packages</h3>
  10930. <p>Along with the <code>prescheme</code> structure, there are several other
  10931. structures built-in to Pre-Scheme.
  10932. </p>
  10933. <table class="menu" border="0" cellspacing="0">
  10934. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  10935. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-floating-point-operation" accesskey="1">Pre-Scheme floating point operation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10936. </td></tr>
  10937. <tr><td align="left" valign="top">&bull; <a href="#Pre_002dScheme-record-types" accesskey="2">Pre-Scheme record types</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10938. </td></tr>
  10939. <tr><td align="left" valign="top">&bull; <a href="#Multiple-return-values-in-Pre_002dScheme" accesskey="3">Multiple return values in Pre-Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10940. </td></tr>
  10941. <tr><td align="left" valign="top">&bull; <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation" accesskey="4">Low-level Pre-Scheme memory manipulation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  10942. </td></tr>
  10943. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  10944. </pre></th></tr></table>
  10945. <hr>
  10946. <span id="Pre_002dScheme-floating-point-operation"></span><div class="header">
  10947. <p>
  10948. Next: <a href="#Pre_002dScheme-record-types" accesskey="n" rel="next">Pre-Scheme record types</a>, Up: <a href="#More-Pre_002dScheme-packages" accesskey="u" rel="up">More Pre-Scheme packages</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10949. </div>
  10950. <span id="Floating-point-operation"></span><h4 class="subsection">9.4.1 Floating point operation</h4>
  10951. <span id="index-ps_002dflonums"></span>
  10952. <p>Since Pre-Scheme&rsquo;s strict static type system would not permit
  10953. overloading of the arithmetic operators for integers &amp; floats, it
  10954. provides a different set of operators for floats. These names are all
  10955. exported by the <code>ps-flonums</code> structure.
  10956. </p>
  10957. <dl>
  10958. <dt id="index-fl_002b">procedure: <strong>fl+</strong> <em>augend addend &hellip; --&gt; float</em></dt>
  10959. <dt id="index-fl_002d">procedure: <strong>fl-</strong> <em>float --&gt; float</em></dt>
  10960. <dt id="index-fl_002d-1">procedure: <strong>fl-</strong> <em>minuend subtrahend --&gt; float</em></dt>
  10961. <dt id="index-fl_002a">procedure: <strong>fl*</strong> <em>multiplier multiplicand &hellip; --&gt; float</em></dt>
  10962. <dt id="index-fl_002f">procedure: <strong>fl/</strong> <em>divisor dividend --&gt; float</em></dt>
  10963. <dt id="index-fl_003d">procedure: <strong>fl=</strong> <em>float<sub>a</sub> float<sub>b</sub> --&gt; boolean</em></dt>
  10964. <dt id="index-fl_003c">procedure: <strong>fl&lt;</strong> <em>float<sub>a</sub> float<sub>b</sub> --&gt; boolean</em></dt>
  10965. <dt id="index-fl_003e">procedure: <strong>fl&gt;</strong> <em>float<sub>a</sub> float<sub>b</sub> --&gt; boolean</em></dt>
  10966. <dt id="index-fl_003c_003d">procedure: <strong>fl&lt;=</strong> <em>float<sub>a</sub> float<sub>b</sub> --&gt; boolean</em></dt>
  10967. <dt id="index-fl_003e_003d">procedure: <strong>fl&gt;=</strong> <em>float<sub>a</sub> float<sub>b</sub> --&gt; boolean</em></dt>
  10968. <dd><p>All of these operations <code>fl<var>op</var></code> correspond as floating point
  10969. variations of their <var>op</var> integer equivalents.
  10970. </p></dd></dl>
  10971. <hr>
  10972. <span id="Pre_002dScheme-record-types"></span><div class="header">
  10973. <p>
  10974. Next: <a href="#Multiple-return-values-in-Pre_002dScheme" accesskey="n" rel="next">Multiple return values in Pre-Scheme</a>, Previous: <a href="#Pre_002dScheme-floating-point-operation" accesskey="p" rel="prev">Pre-Scheme floating point operation</a>, Up: <a href="#More-Pre_002dScheme-packages" accesskey="u" rel="up">More Pre-Scheme packages</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  10975. </div>
  10976. <span id="Record-types-1"></span><h4 class="subsection">9.4.2 Record types</h4>
  10977. <span id="index-ps_002drecord_002dtypes"></span>
  10978. <p>The <code>ps-record-types</code> structure defines the following special form
  10979. for introducing record types. Pre-Scheme record types are translated
  10980. to C as structs.
  10981. </p>
  10982. <dl>
  10983. <dt id="index-define_002drecord_002dtype-2">syntax: <strong>define-record-type</strong></dt>
  10984. <dd><div class="lisp">
  10985. <pre class="lisp">(define-record-type <var>type</var> <var>type-descriptor</var>
  10986. (<var>constructor</var> <var>argument-field-tag</var> &hellip;)
  10987. (<var>field-tag<sub>1</sub></var> <var>field-type-spec<sub>1</sub></var>
  10988. <var>field-accessor<sub>1</sub></var> [<var>field-modifier<sub>1</sub></var>])
  10989. (<var>field-tag<sub>2</sub></var> <var>field-type-spec<sub>2</sub></var>
  10990. <var>field-accessor<sub>2</sub></var> [<var>field-modifier<sub>2</sub></var>])
  10991. &hellip;
  10992. (<var>field-tag<sub>n</sub></var> <var>field-type-spec<sub>n</sub></var>
  10993. <var>field-accessor<sub>n</sub></var> [<var>field-modifier<sub>n</sub></var>])</pre></div>
  10994. <p>Defines a record type. <var>Type</var> is mangled to the C struct type name
  10995. (<var>type-descriptor-name</var> is unused unless running Pre-Scheme as
  10996. Scheme). <var>Constructor</var> is defined to construct a record of the new
  10997. type and initialize the fields <var>argument-type-field</var> &hellip; with
  10998. its arguments, respectively. If it cannot allocate a sufficient
  10999. quantity of memory, <var>constructor</var> returns a null pointer. The
  11000. initial values of fields that are not passed to the constructor are
  11001. undefined. For each field <var>field<sub>i</sub></var> specified,
  11002. </p>
  11003. <ul>
  11004. <li> <var>field<sub>i</sub></var> is specified to have the type
  11005. <var>field-type-spec<sub>i</sub></var>;
  11006. </li><li> <var>field-accessor<sub>i</sub></var> is defined to be a procedure of one
  11007. argument, a record of type <var>type-name</var>, that returns the value of
  11008. the field <var>field<sub>i</sub></var> of that record &mdash; its type is defined to
  11009. be <code>(=&gt; (<var>type-name</var>) <var>field-type-spec<sub>i</sub></var>)</code>; and
  11010. </li><li> if present, <var>field-modifier<sub>i</sub></var> is defined to be a
  11011. procedure of two arguments, a record of type <var>type-name</var> and a
  11012. value of type <var>field-type-spec</var>, that assigns the value of the
  11013. field <var>field<sub>i</sub></var> in its first argument to be the value of its
  11014. second argument; its type is <code>(=&gt; (<var>type-name</var>
  11015. <var>field-type-spec</var>) unit)</code>.
  11016. </li></ul>
  11017. <p>Records must be deallocated explicitly when their lifetime has expired
  11018. with <code>deallocate</code>.
  11019. </p></dd></dl>
  11020. <hr>
  11021. <span id="Multiple-return-values-in-Pre_002dScheme"></span><div class="header">
  11022. <p>
  11023. Next: <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation" accesskey="n" rel="next">Low-level Pre-Scheme memory manipulation</a>, Previous: <a href="#Pre_002dScheme-record-types" accesskey="p" rel="prev">Pre-Scheme record types</a>, Up: <a href="#More-Pre_002dScheme-packages" accesskey="u" rel="up">More Pre-Scheme packages</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11024. </div>
  11025. <span id="Multiple-return-values"></span><h4 class="subsection">9.4.3 Multiple return values</h4>
  11026. <span id="index-ps_002dreceive"></span>
  11027. <p>Pre-Scheme support multiple return values, like in Scheme. The only
  11028. difference is that one cannot operate on multiple return values as
  11029. lists, since Pre-Scheme does not have lists. Multiple return values
  11030. are implemented in C as returning in C the first value and passing
  11031. pointers to the remaining values, which the function returning multiple
  11032. values assigns. The <code>prescheme</code> structure exports the two
  11033. multiple return value primitives, <code>call-with-values</code> and
  11034. <code>values</code>, but the <code>ps-receive</code> structure exports this macro
  11035. for more conveniently binding multiple return values.
  11036. </p>
  11037. <dl>
  11038. <dt id="index-receive-3">syntax: <strong>receive</strong> <em>formals producer body</em></dt>
  11039. <dd><p>Binds the <code>lambda</code> parameter list <var>formals</var> to the multiple
  11040. values that <var>producer</var> returns, and evaluates <var>body</var> with the
  11041. new variables bound.
  11042. </p>
  11043. <div class="lisp">
  11044. <pre class="lisp">(receive <var>formals</var>
  11045. <var>producer</var>
  11046. <var>body</var>)
  11047. &equiv;
  11048. (call-with-values
  11049. (lambda () <var>producer</var>)
  11050. (lambda <var>formals</var>
  11051. <var>body</var>))</pre></div>
  11052. </dd></dl>
  11053. <hr>
  11054. <span id="Low_002dlevel-Pre_002dScheme-memory-manipulation"></span><div class="header">
  11055. <p>
  11056. Previous: <a href="#Multiple-return-values-in-Pre_002dScheme" accesskey="p" rel="prev">Multiple return values in Pre-Scheme</a>, Up: <a href="#More-Pre_002dScheme-packages" accesskey="u" rel="up">More Pre-Scheme packages</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11057. </div>
  11058. <span id="Low_002dlevel-memory-manipulation"></span><h4 class="subsection">9.4.4 Low-level memory manipulation</h4>
  11059. <span id="index-Pre_002dScheme-memory-management-2"></span>
  11060. <span id="index-memory-management-in-Pre_002dScheme-2"></span>
  11061. <span id="index-ps_002dmemory"></span>
  11062. <p>Pre-Scheme is a low-level language. It provides very low-level, direct
  11063. memory manipulation. &lsquo;Addresses&rsquo; index a flat store of sequences of
  11064. bytes. While Pre-Scheme &lsquo;pointers&rsquo; are statically checked for data
  11065. coherency, allow no arbitrary arithmetic, and in general are high-level
  11066. abstract data to some extent, addresses are much lower-level, have no
  11067. statically checked coherency &mdash; the values an address represents are
  11068. selected by what operation used to read or write from it &mdash;, permit
  11069. arbitrary address arithmetic, and are a much more concrete interface
  11070. into direct memory. The <code>ps-memory</code> structure exports these
  11071. direct memory manipulation primitives.
  11072. </p>
  11073. <dl>
  11074. <dt id="index-allocate_002dmemory">procedure: <strong>allocate-memory</strong> <em>size --&gt; address</em></dt>
  11075. <dt id="index-deallocate_002dmemory">procedure: <strong>deallocate-memory</strong> <em>address --&gt; unit</em></dt>
  11076. <dd><p><code>Allocate-memory</code> reserves a sequence of <var>size</var> bytes in the
  11077. store and returns an address to the first byte in the sequence.
  11078. <code>Deallocate-memory</code> releases the memory at <var>address</var>, which
  11079. should have been the initial address of a contiguous byte sequence, as
  11080. <code>allocate-memory</code> would return, not an offset address from such an
  11081. initial address.
  11082. </p></dd></dl>
  11083. <dl>
  11084. <dt id="index-unsigned_002dbyte_002dref">procedure: <strong>unsigned-byte-ref</strong> <em>address --&gt; unsigned-byte</em></dt>
  11085. <dt id="index-unsigned_002dbyte_002dset_0021">procedure: <strong>unsigned-byte-set!</strong> <em>address unsigned-byte --&gt; unit</em></dt>
  11086. <dt id="index-word_002dref">procedure: <strong>word-ref</strong> <em>address --&gt; word</em></dt>
  11087. <dt id="index-word_002dset_0021">procedure: <strong>word-set!</strong> <em>address word --&gt; unit</em></dt>
  11088. <dt id="index-flonum_002dref">procedure: <strong>flonum-ref</strong> <em>address --&gt; float</em></dt>
  11089. <dt id="index-flonum_002dset_0021">procedure: <strong>flonum-set!</strong> <em>address float --&gt; unit</em></dt>
  11090. <dd><p>Procedures for reading from &amp; storing to memory.
  11091. <code>Unsigned-byte-ref</code> &amp; <code>unsigned-byte-set!</code> access &amp; store the
  11092. first unsigned byte at <var>address</var>. <code>Word-ref</code> &amp;
  11093. <code>word-set!</code> access &amp; store the first word &mdash; Pre-Scheme integer
  11094. &mdash; beginning at <var>address</var>. <code>Flonum-ref</code> &amp; <code>flonum-set!</code>
  11095. access &amp; store 64-bit floats beginning at <var>address</var>..
  11096. </p>
  11097. <p><strong>Bug:</strong> <code>Flonum-ref</code> &amp; <code>flonum-set!</code> are unimplemented
  11098. in the Pre-Scheme-as-Scheme layer (see <a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a>).
  11099. </p></dd></dl>
  11100. <dl>
  11101. <dt id="index-address_003f">procedure: <strong>address?</strong> <em>value --&gt; boolean</em></dt>
  11102. <dd><p>Disjoint type predicate for addresses.
  11103. </p>
  11104. <p><strong>Note:</strong> <code>Address?</code> is available <em>only</em> at the top
  11105. level, where code is evaluated at compile-time. Do not use this in any
  11106. place where it may be called at run-time.
  11107. </p></dd></dl>
  11108. <dl>
  11109. <dt id="index-null_002daddress">constant: <strong>null-address</strong> <em>--&gt; address</em></dt>
  11110. <dd><p>The null address. This is somewhat similar to the null pointer, except
  11111. that it is an address.
  11112. </p>
  11113. <p><strong>Note:</strong> One acquires the null <em>pointer</em> by calling the
  11114. <em>procedure</em> <code>null-pointer</code>, whereas the constant value of the
  11115. <em>binding</em> named <code>null-address</code> is the null <em>address</em>.
  11116. </p></dd></dl>
  11117. <dl>
  11118. <dt id="index-null_002daddress_003f">procedure: <strong>null-address?</strong> <em>address --&gt; boolean</em></dt>
  11119. <dd><p><code>Null-address?</code> returns true if <var>address</var> is the null
  11120. address and false if not.
  11121. </p></dd></dl>
  11122. <dl>
  11123. <dt id="index-address_002b">procedure: <strong>address+</strong> <em>address increment --&gt; address</em></dt>
  11124. <dt id="index-address_002d">procedure: <strong>address-</strong> <em>address decrement --&gt; address</em></dt>
  11125. <dt id="index-address_002ddifference">procedure: <strong>address-difference</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; integer</em></dt>
  11126. <dd><p>Address arithmetic operators. <code>Address+</code> adds <var>increment</var> to
  11127. <var>address</var>; <code>address-</code> subtracts <var>decrement</var> from
  11128. <var>address</var>; and <code>address-difference</code> returns the integer
  11129. difference between <var>address<sub>a</sub></var> and <var>address<sub>b</sub></var>.
  11130. For any <var>address<sub>p</sub></var> &amp; <var>address<sub>q</sub></var>, <code>(address+
  11131. <var>address<sub>p</sub></var> (address-difference <var>address<sub>p</sub></var>
  11132. <var>address<sub>q</sub></var>))</code> is equal to <var>address<sub>q</sub></var>.
  11133. </p></dd></dl>
  11134. <dl>
  11135. <dt id="index-address_003d">procedure: <strong>address=</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; boolean</em></dt>
  11136. <dt id="index-address_003c">procedure: <strong>address&lt;</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; boolean</em></dt>
  11137. <dt id="index-address_003e">procedure: <strong>address&gt;</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; boolean</em></dt>
  11138. <dt id="index-address_003c_003d">procedure: <strong>address&lt;=</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; boolean</em></dt>
  11139. <dt id="index-address_003e_003d">procedure: <strong>address&gt;=</strong> <em>address<sub>a</sub> address<sub>b</sub> --&gt; boolean</em></dt>
  11140. <dd><p>Address comparators.
  11141. </p></dd></dl>
  11142. <dl>
  11143. <dt id="index-integer_002d_003eaddress">procedure: <strong>integer-&gt;address</strong> <em>integer --&gt; address</em></dt>
  11144. <dt id="index-address_002d_003einteger">procedure: <strong>address-&gt;integer</strong> <em>address --&gt; integer</em></dt>
  11145. <dd><p>Integers and addresses, although not the same type, may be converted to
  11146. and from each other; <code>integer-&gt;address</code> &amp; <code>address-&gt;integer</code>
  11147. perform this conversion. Note that Pre-Scheme <em>pointers</em> may not
  11148. be converted to addresses or integers, and the converse is also true.
  11149. </p></dd></dl>
  11150. <dl>
  11151. <dt id="index-copy_002dmemory_0021">procedure: <strong>copy-memory!</strong> <em>source-address target-address count --&gt; unit</em></dt>
  11152. <dd><p>Copies <var>count</var> bytes starting at <var>source-address</var> to
  11153. <var>target-address</var>. This is similar to C&rsquo;s <code>memcpy</code>.
  11154. </p></dd></dl>
  11155. <dl>
  11156. <dt id="index-memory_002dequal_003f">procedure: <strong>memory-equal?</strong> <em>address<sub>a</sub> address<sub>b</sub> count --&gt; boolean</em></dt>
  11157. <dd><p>Compares the two sequences of <var>count</var> bytes starting at addresses
  11158. <var>address<sub>a</sub></var> &amp; <var>address<sub>b</sub></var>. It returns true if every
  11159. byte is equal and false if not.
  11160. </p></dd></dl>
  11161. <dl>
  11162. <dt id="index-char_002dpointer_002d_003estring">procedure: <strong>char-pointer-&gt;string</strong> <em>address size --&gt; string</em></dt>
  11163. <dt id="index-char_002dpointer_002d_003enul_002dterminated_002dstring">procedure: <strong>char-pointer-&gt;nul-terminated-string</strong> <em>address --&gt; string</em></dt>
  11164. <dd><p><code>Char-pointer-&gt;string</code> returns a string with <var>size</var> bytes from
  11165. the contiguous sequence of bytes starting at <var>address</var>.
  11166. <code>Char-pointer-&gt;nul-terminated-string</code> does similarly, but it
  11167. returns a string whose contents include every byte starting at
  11168. <var>address</var> until, but not including, the first 0 byte, <i>i.e.</i> ASCII
  11169. nul character, following <var>address</var>.
  11170. </p></dd></dl>
  11171. <dl>
  11172. <dt id="index-read_002dblock-1">procedure: <strong>read-block</strong> <em>port address count --&gt; [count-read eof? status]</em></dt>
  11173. <dt id="index-write_002dblock-1">procedure: <strong>write-block</strong> <em>port address count --&gt; status</em></dt>
  11174. <dd><p><code>Read-block</code> attempts to read <var>count</var> bytes from <var>port</var>
  11175. into memory starting at <var>address</var>. <code>Write-block</code> attempts to
  11176. write <var>count</var> bytes to <var>port</var> from the contiguous sequence in
  11177. memory starting at <var>address</var>. <code>Read-block</code> returns three
  11178. values: the number of bytes read, whether or not the read went to the
  11179. end of the file, and the error status (see <a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a>). <code>Write-block</code> returns the error status.
  11180. </p></dd></dl>
  11181. <hr>
  11182. <span id="Invoking-the-Pre_002dScheme-compiler"></span><div class="header">
  11183. <p>
  11184. Next: <a href="#Example-Pre_002dScheme-compiler-usage" accesskey="n" rel="next">Example Pre-Scheme compiler usage</a>, Previous: <a href="#More-Pre_002dScheme-packages" accesskey="p" rel="prev">More Pre-Scheme packages</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11185. </div>
  11186. <span id="Invoking-the-Pre_002dScheme-compiler-1"></span><h3 class="section">9.5 Invoking the Pre-Scheme compiler</h3>
  11187. <p>Richard Kelsey&rsquo;s Pre-Scheme compiler is a whole-program compiler based
  11188. on techniques from his research in transformational compilation
  11189. [Kelsey 89]. It compiles the restricted dialect of Scheme to efficient
  11190. C, and provides facilities for programmer direction in several
  11191. optimizations.
  11192. </p>
  11193. <span id="Loading-the-compiler"></span><h4 class="subsection">9.5.1 Loading the compiler</h4>
  11194. <p>There is a script, a Scheme48 <a href="#Command-programs">command
  11195. program</a>, that comes with Scheme48 to load the Pre-Scheme compiler,
  11196. which is in the file <samp>ps-compiler/load-ps-compiler.scm</samp>. It must
  11197. be loaded from the <samp>ps-compiler/</samp> directory, from Scheme48&rsquo;s main
  11198. distribution, into the <code>exec</code> package, after having loaded
  11199. <samp>../scheme/prescheme/interface.scm</samp> &amp;
  11200. <samp>../scheme/prescheme/package-defs.scm</samp> into the <code>config</code>
  11201. package. The Pre-Scheme compiler takes some time to load, so it may be
  11202. easier to load it once and dump a heap image of the suspended command
  11203. processor after having loaded everything; see <a href="#Image_002dbuilding-commands">Image-building commands</a>.
  11204. </p>
  11205. <p>To load the Pre-Scheme compiler and dump an image to the file
  11206. <samp>ps-compiler.image</samp> that contains <code>prescheme-compiler</code> in the
  11207. user package, send this sequence of commands to the command processor
  11208. while in the <samp>ps-compiler/</samp> directory of Scheme48&rsquo;s distribution:
  11209. </p>
  11210. <div class="lisp">
  11211. <pre class="lisp">,config ,load ../scheme/prescheme/interface.scm
  11212. ,config ,load ../scheme/prescheme/package-defs.scm
  11213. ,exec ,load load-ps-compiler.scm
  11214. ,in prescheme-compiler prescheme-compiler
  11215. ,user (define prescheme-compiler ##)
  11216. ,dump ps-compiler.image &quot;(Pre-Scheme)&quot;</pre></div>
  11217. <span id="Calling-the-compiler"></span><h4 class="subsection">9.5.2 Calling the compiler</h4>
  11218. <span id="index-prescheme_002dcompiler-1"></span>
  11219. <p>After having loaded the Pre-Scheme compiler, the
  11220. <code>prescheme-compiler</code> structure is the front end to the compiler
  11221. that exports the <code>prescheme-compiler</code> procedure.
  11222. </p>
  11223. <dl>
  11224. <dt id="index-prescheme_002dcompiler">procedure: <strong>prescheme-compiler</strong> <em>structure-spec config-filenames init-name c-filename command &hellip;</em></dt>
  11225. <dd><p>Invokes the Pre-Scheme compiler. <var>Config-filenames</var> contain module
  11226. descriptions (see <a href="#Module-system">Module system</a>) for the components of the program.
  11227. <var>Structure-spec</var> may be a symbol or a list of symbols, naming the
  11228. important structure or structures. All structures that it relies/they
  11229. rely on are traced in the packages&rsquo; <code>open</code> clauses. Modules that
  11230. are not traced in the dependency graph with root vertices of the given
  11231. structure[s] are omitted from the output. <var>C-filename</var> is a string
  11232. naming the file to which the C code generated by the Pre-Scheme
  11233. compiler should be emitted. <var>Init-name</var> is the name for an
  11234. initialization routine, generated automatically by the Pre-Scheme
  11235. compiler to initialize some top-level variables. The <var>command</var>
  11236. arguments are used to control certain aspects of the compilation. The
  11237. following commands are defined:
  11238. </p>
  11239. <dl compact="compact">
  11240. <dt><code>(copy (<var>structure</var> <var>copyable-procedure</var>) &hellip;)</code></dt>
  11241. <dd><p>Specifies that each the body of each <var>copyable-procedure</var> from the
  11242. respective <var>structure</var> (from one of <var>config-filenames</var>) may be
  11243. integrated &amp; duplicated.
  11244. </p>
  11245. </dd>
  11246. <dt><code>(no-copy (<var>structure</var> <var>uncopyable-procedure</var>) &hellip;)</code></dt>
  11247. <dd><p>Specifies that the given procedures may not be integrated.
  11248. </p>
  11249. </dd>
  11250. <dt><code>(shadow ((<var>proc-structure</var> <var>procedure</var>) (<var>var-structure</var> <var>variable-to-shadow</var>) &hellip;) &hellip;)</code></dt>
  11251. <dd><p>Specifies that, in <var>procedure</var> from <var>proc-structure</var>, the
  11252. global variables <var>variable-to-shadow</var> from their respective
  11253. <var>var-structure</var>s should be shadowed with local variables, which
  11254. are more likely to be kept in registers for faster operation on them.
  11255. </p>
  11256. </dd>
  11257. <dt><code>(integrate (<var>client-procedure</var> <var>integrable-procedure</var>) &hellip;)</code></dt>
  11258. <dd><p>Forces <var>integrable-procedure</var> to be integrated in
  11259. <var>client-procedure</var>.
  11260. </p>
  11261. <p><strong>Note:</strong> The <code>integrate</code> command operates on the global
  11262. program, not on one particular module; each <var>client-procedure</var> and
  11263. <var>integrable-procedure</var> is chosen from all variables defined in the
  11264. entirety of the program, across all modules. It is advised that there
  11265. be only one of each.
  11266. </p>
  11267. </dd>
  11268. <dt><code>(header <var>header-line</var> &hellip;)</code></dt>
  11269. <dd><p>Each <var>header-line</var> is added to the top of the generated C file,
  11270. after a cpp inclusion of <code>&lt;stdio.h&gt;</code> and <code>&quot;prescheme.h&quot;</code>.
  11271. </p></dd>
  11272. </dl>
  11273. <p>The command arguments to <code>prescheme-compiler</code> are optional; they
  11274. are used only to optimize the compiled program at the programmer&rsquo;s
  11275. request.
  11276. </p></dd></dl>
  11277. <hr>
  11278. <span id="Example-Pre_002dScheme-compiler-usage"></span><div class="header">
  11279. <p>
  11280. Next: <a href="#Running-Pre_002dScheme-as-Scheme" accesskey="n" rel="next">Running Pre-Scheme as Scheme</a>, Previous: <a href="#Invoking-the-Pre_002dScheme-compiler" accesskey="p" rel="prev">Invoking the Pre-Scheme compiler</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11281. </div>
  11282. <span id="Example-Pre_002dScheme-compiler-usage-1"></span><h3 class="section">9.6 Example Pre-Scheme compiler usage</h3>
  11283. <p>The <samp>ps-compiler/compile-vm.scm</samp>,
  11284. <samp>ps-compiler/compile-gc.scm</samp>, and
  11285. <samp>ps-compiler/compile-vm-no-gc.scm</samp> files give examples of running
  11286. the Pre-Scheme compiler. They are Scheme48 <a href="#Command-programs">command programs</a>, to be loaded into the <code>exec</code> package after
  11287. having already loaded the Pre-Scheme compiler. <samp>compile-vm.scm</samp> &amp;
  11288. <samp>compile-vm-no-gc.scm</samp> generate a new <samp>scheme48vm.c</samp> in the
  11289. <samp>scheme/vm/</samp> directory &mdash; <samp>compile-vm.scm</samp> includes the
  11290. garbage collector, while <samp>compile-vm-no-gc.scm</samp> does not
  11291. <a id="DOCF29" href="#FOOT29"><sup>29</sup></a> &mdash;, and <samp>compile-gc.scm</samp>
  11292. generates a new <samp>scheme48heap.c</samp>, <samp>scheme48read-image.c</samp>, &amp;
  11293. <samp>scheme48write-image.c</samp> in the <samp>scheme/vm/</samp> directory.
  11294. </p>
  11295. <p>Here is a somewhat simpler example. It assumes a pre-built image with
  11296. the Pre-Scheme compiler loaded is in the <samp>ps-compiler.image</samp> file
  11297. in the current directory (see <a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a>,
  11298. where there is a description of how to dump an image with the
  11299. Pre-Scheme compiler loaded).
  11300. </p>
  11301. <div class="example">
  11302. <pre class="example">% ls
  11303. hello.scm packages.scm ps-compiler.image
  11304. % cat hello.scm
  11305. (define (main argc argv)
  11306. (if (= argc 2)
  11307. (let ((out (current-output-port)))
  11308. (write-string &quot;Hello, world, &quot; out)
  11309. (write-string (vector-ref argv 1) out)
  11310. (write-char #\! out)
  11311. (newline out)
  11312. 0)
  11313. (let ((out (current-error-port)))
  11314. (write-string &quot;Usage: &quot; out)
  11315. (write-string (vector-ref argv 0) out)
  11316. (write-string &quot; &lt;user&gt;&quot; out)
  11317. (newline out)
  11318. (write-string &quot; Greets the world &amp; &lt;user&gt;.&quot; out)
  11319. (newline out)
  11320. -1)))
  11321. % cat packages.scm
  11322. (define-structure hello (export main)
  11323. (open prescheme)
  11324. (files hello))
  11325. % scheme48 -i ps-compiler.image
  11326. heap size 3000000 is too small, using 4770088
  11327. Welcome to Scheme 48 1.3 (Pre-Scheme)
  11328. Copyright (c) 1993-2005 by Richard Kelsey and Jonathan Rees.
  11329. Please report bugs to scheme-48-bugs@s48.org.
  11330. Get more information at http://www.s48.org/.
  11331. Type ,? (comma question-mark) for help.
  11332. &gt; (prescheme-compiler 'hello '(&quot;packages.scm&quot;) 'hello-init &quot;hello.c&quot;)
  11333. packages.scm
  11334. hello.scmChecking types
  11335. main : ((integer **char) -&gt; integer)
  11336. In-lining single-use procedures
  11337. Call Graph:
  11338. &lt;procedure name&gt;
  11339. &lt;called non-tail-recursively&gt;
  11340. &lt;called tail-recursively&gt;
  11341. main (exported)
  11342. Merging forms
  11343. Translating
  11344. main
  11345. #{Unspecific}
  11346. &gt; ,exit
  11347. % cat hello.c
  11348. #include &lt;stdio.h&gt;
  11349. #include &quot;prescheme.h&quot;
  11350. long main(long, char**);
  11351. long main(long argc_0X, char **argv_1X)
  11352. {
  11353. FILE * out_3X;
  11354. FILE * out_2X;
  11355. { if ((1 == argc_0X)) {
  11356. out_2X = stdout;
  11357. ps_write_string(&quot;Hello, world, &quot;, out_2X);
  11358. ps_write_string((*(argv_1X + 1)), out_2X);
  11359. { long ignoreXX;
  11360. PS_WRITE_CHAR(33, out_2X, ignoreXX) }
  11361. { long ignoreXX;
  11362. PS_WRITE_CHAR(10, out_2X, ignoreXX) }
  11363. return 0;}
  11364. else {
  11365. out_3X = stderr;
  11366. ps_write_string(&quot;Usage: &quot;, out_3X);
  11367. ps_write_string((*(argv_1X + 0)), out_3X);
  11368. ps_write_string(&quot; &lt;user&gt;&quot;, out_3X);
  11369. { long ignoreXX;
  11370. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  11371. ps_write_string(&quot; Greets the world &amp; &lt;user&gt;.&quot;, out_3X);
  11372. { long ignoreXX;
  11373. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  11374. return -1;}}
  11375. }
  11376. % </pre></div>
  11377. <hr>
  11378. <span id="Running-Pre_002dScheme-as-Scheme"></span><div class="header">
  11379. <p>
  11380. Previous: <a href="#Example-Pre_002dScheme-compiler-usage" accesskey="p" rel="prev">Example Pre-Scheme compiler usage</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11381. </div>
  11382. <span id="Running-Pre_002dScheme-as-Scheme-1"></span><h3 class="section">9.7 Running Pre-Scheme as Scheme</h3>
  11383. <span id="index-prescheme-2"></span>
  11384. <span id="index-ps_002dmemory-1"></span>
  11385. <span id="index-ps_002dreceive-1"></span>
  11386. <span id="index-ps_002drecord_002dtypes-1"></span>
  11387. <span id="index-ps_002dflonums-1"></span>
  11388. <p>To facilitate the operation of Pre-Scheme systems within a high-level
  11389. Scheme development environment, Scheme48 simply defines the
  11390. <code>prescheme</code>, <code>ps-memory</code>, <code>ps-record-types</code>,
  11391. <code>ps-flonums</code>, and <code>ps-receive</code> structures in terms of Scheme;
  11392. Pre-Scheme structures can be loaded as regular Scheme structures
  11393. because of this. Those structures and the interfaces they implement
  11394. are defined in the files <samp>scheme/prescheme/interface.scm</samp> and
  11395. <samp>scheme/prescheme/package-defs.scm</samp> from the main Scheme48
  11396. distribution; simply load these files into the <a href="#Module-commands">config package</a> before loading any Pre-Scheme configuration
  11397. files.
  11398. </p>
  11399. <p>The Pre-Scheme emulation layer in Scheme has some shortcomings:
  11400. </p>
  11401. <ul>
  11402. <li> No more than sixteen megabytes can be allocated at once.
  11403. </li><li> More than thirty-two or sixty-four or so allocations result in
  11404. addresses overflowing bignums, which deallocations does not affect.
  11405. </li><li> Flonum memory access is unimplemented. (Flonum arithmetic works,
  11406. though.)
  11407. </li><li> The layer is very slow.
  11408. </li></ul>
  11409. <hr>
  11410. <span id="References"></span><div class="header">
  11411. <p>
  11412. Next: <a href="#Concept-index" accesskey="n" rel="next">Concept index</a>, Previous: <a href="#Pre_002dScheme" accesskey="p" rel="prev">Pre-Scheme</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11413. </div>
  11414. <span id="References-1"></span><h2 class="unnumbered">References</h2>
  11415. <dl compact="compact">
  11416. <dt>[Cejtin <i>et al.</i> 95]</dt>
  11417. <dd><p>Henry Cejtin, Suresh Jagannathan, and Richard Kelsey.
  11418. Higher-Order Distributed Objects.
  11419. In <cite>ACM Transactions on Programming Languages and Systems</cite>, vol.
  11420. 17, pp. 704&ndash;739, ACM Press, September 1995.
  11421. </p>
  11422. </dd>
  11423. <dt>[Clinger 91]</dt>
  11424. <dd><p>William D. Clinger.
  11425. Hygienic Macros through Explicit Renaming.
  11426. In <cite>Lisp Pointers</cite>, IV(4): 25-28, December 1991.
  11427. </p>
  11428. </dd>
  11429. <dt>[Donald 92]</dt>
  11430. <dd><p>Bruce Donald and Jonathan A. Rees.
  11431. Program Mobile Robots in Scheme!
  11432. In <cite>Proceedings of the 1992 IEEE International Conference on
  11433. Robotics and Automation</cite>, 2681-2688.
  11434. </p>
  11435. </dd>
  11436. <dt>[Friedman 00]</dt>
  11437. <dd><p>Daniel Friedman and Erik Hilsdale.
  11438. <cite>Writing Macros in Continuation-Passing Style</cite>.
  11439. Worksop on Scheme and Functional Programming, September 2000.
  11440. </p>
  11441. </dd>
  11442. <dt>[Kelsey 89]</dt>
  11443. <dd><p>Richard Kelsey.
  11444. <cite>Compilation by Program Transformation</cite>.
  11445. PhD thesis, Yale University, 1989.
  11446. </p>
  11447. </dd>
  11448. <dt>[Kelsey 97]</dt>
  11449. <dd><p>Richard Kelsey.
  11450. <cite>Pre-Scheme: A Scheme Dialect for Systems Programming</cite>.
  11451. June 1997.
  11452. </p>
  11453. </dd>
  11454. <dt>[Museme]</dt>
  11455. <dd><p>Franklyn Turbak and Dan Winship.
  11456. <cite>Museme: a multi-user simulation environment for Scheme</cite>.
  11457. <br><a href="http://www.bloodandcoffee.net/campbell/code/museme.tar.gz">http://www.bloodandcoffee.net/campbell/code/museme.tar.gz</a>
  11458. </p>
  11459. </dd>
  11460. <dt>[Rees 96]</dt>
  11461. <dd><p>Jonathan A. Rees.
  11462. <cite>A Security Kernel based on the Lambda-Calculus</cite>.
  11463. PhD thesis, AI Memo 1564, Massachusetts Institute of Technology,
  11464. Artificial Intelligence Laboratory, 1996.
  11465. </p>
  11466. </dd>
  11467. <dt>[Reppy 99]</dt>
  11468. <dd><p>John Reppy.
  11469. <cite>Concurrent Programming in ML</cite>.
  11470. Cambridge University Press, 1999.
  11471. </p>
  11472. </dd>
  11473. <dt>[Shivers 94]</dt>
  11474. <dd><p>Olin Shivers.
  11475. <cite>A Scheme Shell</cite>.
  11476. Tech Report 635, Massachusetts Institute of Technology, Laboratory for
  11477. Computer Science, 1994.
  11478. </p>
  11479. </dd>
  11480. <dt>[Shivers 96]</dt>
  11481. <dd><p>Olin Shivers.
  11482. <cite>A Universal Scripting Framework, or Lambda: the Ultimate &ldquo;Little
  11483. Language&rdquo;</cite>.
  11484. <cite>Concurrency and Parallelism, Programming, Networking, and
  11485. Security</cite>, pp. 254-265, 1996, Joxan Jaffar and Roland H. C. Yap (eds).
  11486. </p>
  11487. </dd>
  11488. <dt>[Shivers <i>et al.</i> 04]</dt>
  11489. <dd><p>Olin Shivers, Brian D. Carlstrom, Martin Gasbichler, and Michael
  11490. Sperber.
  11491. <cite>Scsh Reference Manual</cite>, for scsh release 0.6.6
  11492. <br><a href="http://www.scsh.net/docu/docu.html">http://www.scsh.net/docu/docu.html</a>
  11493. </p>
  11494. </dd>
  11495. <dt>[SRFI 1]</dt>
  11496. <dd><p>Olin Shivers.
  11497. <cite>SRFI 1: List Library</cite>
  11498. Scheme Requests for Implementation, 1999.
  11499. <br><a href="http://srfi.schemers.org/srfi-1/">http://srfi.schemers.org/srfi-1/</a>
  11500. </p>
  11501. </dd>
  11502. <dt>[SRFI 7]</dt>
  11503. <dd><p>Richard Kelsey.
  11504. <cite>SRFI 7: Feature-Based Program Configuration Language</cite>
  11505. Scheme Requests for Implementation, 1999.
  11506. <br><a href="http://srfi.schemers.org/srfi-7/">http://srfi.schemers.org/srfi-7/</a>
  11507. </p>
  11508. </dd>
  11509. <dt>[SRFI 9]</dt>
  11510. <dd><p>Richard Kelsey.
  11511. <cite>SRFI 9: Defining Record Types</cite>
  11512. Scheme Requests for Implementation, 1999.
  11513. <br><a href="http://srfi.schemers.org/srfi-9/">http://srfi.schemers.org/srfi-9/</a>
  11514. </p>
  11515. </dd>
  11516. <dt>[SRFI 22]</dt>
  11517. <dd><p>Martin Gasbichler and Michael Sperber
  11518. <cite>SRFI 22: Running Scheme Scripts on Unix</cite>
  11519. Scheme Requests for Implementation, 2002.
  11520. <br><a href="http://srfi.schemers.org/srfi-22/">http://srfi.schemers.org/srfi-22/</a>
  11521. </p>
  11522. </dd>
  11523. <dt>[SRFI 34]</dt>
  11524. <dd><p>Richard Kelsey and Michael Sperber.
  11525. <cite>SRFI 34: Exception Handling for Programs</cite>.
  11526. Scheme Requests for Implementation, 2002.
  11527. <br><a href="http://srfi.schemers.org/srfi-34/">http://srfi.schemers.org/srfi-34/</a>
  11528. </p>
  11529. </dd>
  11530. <dt>[SRFI 35]</dt>
  11531. <dd><p>Richard Kelsey and Michael Sperber.
  11532. <cite>SRFI 35: Conditions</cite>.
  11533. Scheme Requests for Implementation, 2002.
  11534. <br><a href="http://srfi.schemers.org/srfi-35/">http://srfi.schemers.org/srfi-35/</a>
  11535. </p>
  11536. </dd>
  11537. </dl>
  11538. <hr>
  11539. <span id="Concept-index"></span><div class="header">
  11540. <p>
  11541. Next: <a href="#Binding-index" accesskey="n" rel="next">Binding index</a>, Previous: <a href="#References" accesskey="p" rel="prev">References</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  11542. </div>
  11543. <span id="Concept-index-1"></span><h2 class="unnumbered">Concept index</h2>
  11544. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-index_cp_symbol-1"><b>=</b></a>
  11545. &nbsp;
  11546. <br>
  11547. <a class="summary-letter" href="#Concept-index_cp_letter-A"><b>A</b></a>
  11548. &nbsp;
  11549. <a class="summary-letter" href="#Concept-index_cp_letter-B"><b>B</b></a>
  11550. &nbsp;
  11551. <a class="summary-letter" href="#Concept-index_cp_letter-C"><b>C</b></a>
  11552. &nbsp;
  11553. <a class="summary-letter" href="#Concept-index_cp_letter-D"><b>D</b></a>
  11554. &nbsp;
  11555. <a class="summary-letter" href="#Concept-index_cp_letter-E"><b>E</b></a>
  11556. &nbsp;
  11557. <a class="summary-letter" href="#Concept-index_cp_letter-F"><b>F</b></a>
  11558. &nbsp;
  11559. <a class="summary-letter" href="#Concept-index_cp_letter-G"><b>G</b></a>
  11560. &nbsp;
  11561. <a class="summary-letter" href="#Concept-index_cp_letter-H"><b>H</b></a>
  11562. &nbsp;
  11563. <a class="summary-letter" href="#Concept-index_cp_letter-I"><b>I</b></a>
  11564. &nbsp;
  11565. <a class="summary-letter" href="#Concept-index_cp_letter-J"><b>J</b></a>
  11566. &nbsp;
  11567. <a class="summary-letter" href="#Concept-index_cp_letter-L"><b>L</b></a>
  11568. &nbsp;
  11569. <a class="summary-letter" href="#Concept-index_cp_letter-M"><b>M</b></a>
  11570. &nbsp;
  11571. <a class="summary-letter" href="#Concept-index_cp_letter-N"><b>N</b></a>
  11572. &nbsp;
  11573. <a class="summary-letter" href="#Concept-index_cp_letter-O"><b>O</b></a>
  11574. &nbsp;
  11575. <a class="summary-letter" href="#Concept-index_cp_letter-P"><b>P</b></a>
  11576. &nbsp;
  11577. <a class="summary-letter" href="#Concept-index_cp_letter-Q"><b>Q</b></a>
  11578. &nbsp;
  11579. <a class="summary-letter" href="#Concept-index_cp_letter-R"><b>R</b></a>
  11580. &nbsp;
  11581. <a class="summary-letter" href="#Concept-index_cp_letter-S"><b>S</b></a>
  11582. &nbsp;
  11583. <a class="summary-letter" href="#Concept-index_cp_letter-T"><b>T</b></a>
  11584. &nbsp;
  11585. <a class="summary-letter" href="#Concept-index_cp_letter-U"><b>U</b></a>
  11586. &nbsp;
  11587. <a class="summary-letter" href="#Concept-index_cp_letter-V"><b>V</b></a>
  11588. &nbsp;
  11589. <a class="summary-letter" href="#Concept-index_cp_letter-W"><b>W</b></a>
  11590. &nbsp;
  11591. <a class="summary-letter" href="#Concept-index_cp_letter-Y"><b>Y</b></a>
  11592. &nbsp;
  11593. </td></tr></table>
  11594. <table class="index-cp" border="0">
  11595. <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
  11596. <tr><td colspan="4"> <hr></td></tr>
  11597. <tr><th id="Concept-index_cp_symbol-1">=</th><td></td><td></td></tr>
  11598. <tr><td></td><td valign="top"><a href="#index-_003dscheme48_002f"><code>=scheme48/</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  11599. <tr><td colspan="4"> <hr></td></tr>
  11600. <tr><th id="Concept-index_cp_letter-A">A</th><td></td><td></td></tr>
  11601. <tr><td></td><td valign="top"><a href="#index-abstract-data-types">abstract data types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11602. <tr><td></td><td valign="top"><a href="#index-accessing-file-ports_0027-channels">accessing file ports&rsquo; channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  11603. <tr><td></td><td valign="top"><a href="#index-accessing-structures">accessing structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11604. <tr><td></td><td valign="top"><a href="#index-amb-operator"><code>amb</code> operator</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11605. <tr><td></td><td valign="top"><a href="#index-anonymous-structures">anonymous structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11606. <tr><td></td><td valign="top"><a href="#index-arrays">arrays</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  11607. <tr><td></td><td valign="top"><a href="#index-asynchronous-channels">asynchronous channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  11608. <tr><td></td><td valign="top"><a href="#index-asynchronous-thread-communication-channels">asynchronous thread communication channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  11609. <tr><td></td><td valign="top"><a href="#index-atomic-regions">atomic regions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11610. <tr><td></td><td valign="top"><a href="#index-auto_002dintegrate-optimizer"><code>auto-integrate</code> optimizer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11611. <tr><td colspan="4"> <hr></td></tr>
  11612. <tr><th id="Concept-index_cp_letter-B">B</th><td></td><td></td></tr>
  11613. <tr><td></td><td valign="top"><a href="#index-backtrace">backtrace</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11614. <tr><td></td><td valign="top"><a href="#index-backtracking">backtracking</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11615. <tr><td></td><td valign="top"><a href="#index-batch-mode">batch mode</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11616. <tr><td></td><td valign="top"><a href="#index-batch-mode-1">batch mode</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  11617. <tr><td></td><td valign="top"><a href="#index-binary-data-operation">binary data operation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  11618. <tr><td></td><td valign="top"><a href="#index-binary-search-trees">binary search trees</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  11619. <tr><td></td><td valign="top"><a href="#index-binding-multiple-values">binding multiple values</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11620. <tr><td></td><td valign="top"><a href="#index-bitwise-integer-operations">bitwise integer operations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  11621. <tr><td></td><td valign="top"><a href="#index-block-input-and-output">block input and output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11622. <tr><td></td><td valign="top"><a href="#index-blocking-I_002fO">blocking I/O</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11623. <tr><td></td><td valign="top"><a href="#index-buffered-input-and-output">buffered input and output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  11624. <tr><td></td><td valign="top"><a href="#index-buffered-output-forcing">buffered output forcing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11625. <tr><td></td><td valign="top"><a href="#index-buffered-output-forcing-1">buffered output forcing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11626. <tr><td></td><td valign="top"><a href="#index-byte-manipulation">byte manipulation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  11627. <tr><td colspan="4"> <hr></td></tr>
  11628. <tr><th id="Concept-index_cp_letter-C">C</th><td></td><td></td></tr>
  11629. <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-byte-vectors">C access to Scheme byte vectors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11630. <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-fixnums">C access to Scheme fixnums</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11631. <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-pairs">C access to Scheme pairs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11632. <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-strings">C access to Scheme strings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11633. <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-vectors">C access to Scheme vectors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11634. <tr><td></td><td valign="top"><a href="#index-C-and-Scheme-data-conversion">C and Scheme data conversion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11635. <tr><td></td><td valign="top"><a href="#index-C-dynamic-loading">C dynamic loading</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  11636. <tr><td></td><td valign="top"><a href="#index-C-macros-for-Scheme-constants">C macros for Scheme constants</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11637. <tr><td></td><td valign="top"><a href="#index-C-macros-on-Scheme-booleans">C macros on Scheme booleans</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11638. <tr><td></td><td valign="top"><a href="#index-C-naming-conventions">C naming conventions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
  11639. <tr><td></td><td valign="top"><a href="#index-C-predicates-for-Scheme-data">C predicates for Scheme data</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11640. <tr><td></td><td valign="top"><a href="#index-C-shared-objects">C shared objects</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  11641. <tr><td></td><td valign="top"><a href="#index-callbacks-from-C-and-continuations">callbacks from C and continuations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  11642. <tr><td></td><td valign="top"><a href="#index-callbacks-from-C-and-threads">callbacks from C and threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  11643. <tr><td></td><td valign="top"><a href="#index-channel-utilities_002c-higher_002dlevel">channel utilities, higher-level</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  11644. <tr><td></td><td valign="top"><a href="#index-channels">channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  11645. <tr><td></td><td valign="top"><a href="#index-channels-1">channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  11646. <tr><td></td><td valign="top"><a href="#index-channels-2">channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  11647. <tr><td></td><td valign="top"><a href="#index-character-sink-output-ports">character sink output ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11648. <tr><td></td><td valign="top"><a href="#index-character-source-input-ports">character source input ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11649. <tr><td></td><td valign="top"><a href="#index-closing-channels">closing channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  11650. <tr><td></td><td valign="top"><a href="#index-closure-flattening">closure flattening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11651. <tr><td></td><td valign="top"><a href="#index-closures-in-Pre_002dScheme">closures in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11652. <tr><td></td><td valign="top"><a href="#index-code-reloading">code reloading</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
  11653. <tr><td></td><td valign="top"><a href="#index-code-reloading-1">code reloading</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  11654. <tr><td></td><td valign="top"><a href="#index-command-levels">command levels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  11655. <tr><td></td><td valign="top"><a href="#index-command-levels-1">command levels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  11656. <tr><td></td><td valign="top"><a href="#index-command-processor-help">command processor help</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  11657. <tr><td></td><td valign="top"><a href="#index-command-processor-settings">command processor settings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  11658. <tr><td></td><td valign="top"><a href="#index-committing-proposals">committing proposals</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11659. <tr><td></td><td valign="top"><a href="#index-compile_002dtime-evaluation-in-Pre_002dScheme">compile-time evaluation in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11660. <tr><td></td><td valign="top"><a href="#index-compiler-optimization">compiler optimization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11661. <tr><td></td><td valign="top"><a href="#index-compound-interfaces">compound interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11662. <tr><td></td><td valign="top"><a href="#index-compound-interfaces-1">compound interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11663. <tr><td></td><td valign="top"><a href="#index-condition-handlers">condition handlers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11664. <tr><td></td><td valign="top"><a href="#index-condition-messages">condition messages</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11665. <tr><td></td><td valign="top"><a href="#index-condition-restarting">condition restarting</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11666. <tr><td></td><td valign="top"><a href="#index-condition-types">condition types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11667. <tr><td></td><td valign="top"><a href="#index-condition-types-1">condition types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11668. <tr><td></td><td valign="top"><a href="#index-conditions">conditions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11669. <tr><td></td><td valign="top"><a href="#index-conditions-1">conditions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11670. <tr><td></td><td valign="top"><a href="#index-config-package">config package</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  11671. <tr><td></td><td valign="top"><a href="#index-configuration-language">configuration language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11672. <tr><td></td><td valign="top"><a href="#index-configuration-language-1">configuration language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11673. <tr><td></td><td valign="top"><a href="#index-configuration-language-macros">configuration language macros</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11674. <tr><td></td><td valign="top"><a href="#index-configuring-the-command-processor">configuring the command processor</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  11675. <tr><td></td><td valign="top"><a href="#index-continuation-previews">continuation previews</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11676. <tr><td></td><td valign="top"><a href="#index-continuations-and-callbacks-from-C">continuations and callbacks from C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  11677. <tr><td></td><td valign="top"><a href="#index-continuations-in-Pre_002dScheme">continuations in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11678. <tr><td></td><td valign="top"><a href="#index-creating-directories">creating directories</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11679. <tr><td></td><td valign="top"><a href="#index-creating-POSIX-FIFOs">creating POSIX FIFOs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11680. <tr><td></td><td valign="top"><a href="#index-creating-POSIX-links">creating POSIX links</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11681. <tr><td></td><td valign="top"><a href="#index-customized-writer">customized writer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  11682. <tr><td></td><td valign="top"><a href="#index-customized-writer-1">customized writer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  11683. <tr><td colspan="4"> <hr></td></tr>
  11684. <tr><th id="Concept-index_cp_letter-D">D</th><td></td><td></td></tr>
  11685. <tr><td></td><td valign="top"><a href="#index-debug-data-storage-control">debug data storage control</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11686. <tr><td></td><td valign="top"><a href="#index-defining-record-types">defining record types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11687. <tr><td></td><td valign="top"><a href="#index-deleting-directories">deleting directories</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11688. <tr><td></td><td valign="top"><a href="#index-deleting-files">deleting files</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11689. <tr><td></td><td valign="top"><a href="#index-destructuring-S_002dexpressions">destructuring S-expressions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11690. <tr><td></td><td valign="top"><a href="#index-directory-creation">directory creation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11691. <tr><td></td><td valign="top"><a href="#index-directory-deletion">directory deletion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11692. <tr><td></td><td valign="top"><a href="#index-directory-listing">directory listing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11693. <tr><td></td><td valign="top"><a href="#index-directory-streams">directory streams</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11694. <tr><td></td><td valign="top"><a href="#index-disabling-command-levels">disabling command levels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  11695. <tr><td></td><td valign="top"><a href="#index-disabling-command-levels-1">disabling command levels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  11696. <tr><td></td><td valign="top"><a href="#index-disassembly">disassembly</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11697. <tr><td></td><td valign="top"><a href="#index-displaying-conditions">displaying conditions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11698. <tr><td></td><td valign="top"><a href="#index-displaying-heap-usage">displaying heap usage</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11699. <tr><td></td><td valign="top"><a href="#index-dumping-heap-images">dumping heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  11700. <tr><td></td><td valign="top"><a href="#index-dumping-heap-images-1">dumping heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11701. <tr><td></td><td valign="top"><a href="#index-dumping-Scheme-heap-images-with-C-data">dumping Scheme heap images with C data</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  11702. <tr><td></td><td valign="top"><a href="#index-dynamic-bindings">dynamic bindings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  11703. <tr><td colspan="4"> <hr></td></tr>
  11704. <tr><th id="Concept-index_cp_letter-E">E</th><td></td><td></td></tr>
  11705. <tr><td></td><td valign="top"><a href="#index-environment-flattening">environment flattening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11706. <tr><td></td><td valign="top"><a href="#index-environment-variables">environment variables</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11707. <tr><td></td><td valign="top"><a href="#index-error-messages">error messages</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11708. <tr><td></td><td valign="top"><a href="#index-errors">errors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11709. <tr><td></td><td valign="top"><a href="#index-evaluation-of-top_002dlevel-code-in-Pre_002dScheme">evaluation of top-level code in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11710. <tr><td></td><td valign="top"><a href="#index-event">event</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Concurrent-ML">Concurrent ML</a></td></tr>
  11711. <tr><td></td><td valign="top"><a href="#index-exceptions">exceptions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11712. <tr><td></td><td valign="top"><a href="#index-exec-language">exec language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
  11713. <tr><td></td><td valign="top"><a href="#index-exec-package">exec package</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
  11714. <tr><td></td><td valign="top"><a href="#index-executing-processes">executing processes</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11715. <tr><td></td><td valign="top"><a href="#index-execution-timing">execution timing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11716. <tr><td></td><td valign="top"><a href="#index-exiting-processes">exiting processes</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11717. <tr><td></td><td valign="top"><a href="#index-exiting-Scheme">exiting Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  11718. <tr><td></td><td valign="top"><a href="#index-expanding-macros">expanding macros</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11719. <tr><td></td><td valign="top"><a href="#index-exporting-bindings-from-C-to-Scheme">exporting bindings from C to Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11720. <tr><td></td><td valign="top"><a href="#index-exporting-bindings-from-Scheme-to-C">exporting bindings from Scheme to C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11721. <tr><td></td><td valign="top"><a href="#index-exporting-C-functions-to-Scheme">exporting C functions to Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11722. <tr><td colspan="4"> <hr></td></tr>
  11723. <tr><th id="Concept-index_cp_letter-F">F</th><td></td><td></td></tr>
  11724. <tr><td></td><td valign="top"><a href="#index-fcntl"><code>fcntl</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11725. <tr><td></td><td valign="top"><a href="#index-fd_002dport-dup_0027ing">fd-port dup&rsquo;ing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11726. <tr><td></td><td valign="top"><a href="#index-fd_002dport-I_002fO-flags">fd-port I/O flags</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11727. <tr><td></td><td valign="top"><a href="#index-fd_002dports">fd-ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11728. <tr><td></td><td valign="top"><a href="#index-FIFOs">FIFOs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  11729. <tr><td></td><td valign="top"><a href="#index-file-access-probing">file access probing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11730. <tr><td></td><td valign="top"><a href="#index-file-channels">file channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  11731. <tr><td></td><td valign="top"><a href="#index-file-deletion">file deletion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11732. <tr><td></td><td valign="top"><a href="#index-file-descriptor-ports">file descriptor ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11733. <tr><td></td><td valign="top"><a href="#index-file-descriptor-reassignment">file descriptor reassignment</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11734. <tr><td></td><td valign="top"><a href="#index-file-info">file info</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11735. <tr><td></td><td valign="top"><a href="#index-file-permissions">file permissions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11736. <tr><td></td><td valign="top"><a href="#index-filename-translations">filename translations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  11737. <tr><td></td><td valign="top"><a href="#index-flat-closures">flat closures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11738. <tr><td></td><td valign="top"><a href="#index-flat-environments">flat environments</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11739. <tr><td></td><td valign="top"><a href="#index-flat_002denvironments-optimizer"><code>flat-environments</code> optimizer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11740. <tr><td></td><td valign="top"><a href="#index-fluid-bindings">fluid bindings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  11741. <tr><td></td><td valign="top"><a href="#index-flushing-output-buffers">flushing output buffers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11742. <tr><td></td><td valign="top"><a href="#index-flushing-output-buffers-1">flushing output buffers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11743. <tr><td></td><td valign="top"><a href="#index-for_002dsyntax"><code>for-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11744. <tr><td></td><td valign="top"><a href="#index-for_002dsyntax-1"><code>for-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11745. <tr><td></td><td valign="top"><a href="#index-forcing-buffered-output">forcing buffered output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11746. <tr><td></td><td valign="top"><a href="#index-forcing-buffered-output-1">forcing buffered output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11747. <tr><td></td><td valign="top"><a href="#index-forcing-garbage-collection">forcing garbage collection</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11748. <tr><td></td><td valign="top"><a href="#index-forking">forking</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11749. <tr><td></td><td valign="top"><a href="#index-functors">functors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11750. <tr><td colspan="4"> <hr></td></tr>
  11751. <tr><th id="Concept-index_cp_letter-G">G</th><td></td><td></td></tr>
  11752. <tr><td></td><td valign="top"><a href="#index-garbage-collection-in-Pre_002dScheme">garbage collection in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11753. <tr><td></td><td valign="top"><a href="#index-garbage-collection_002c-forcing">garbage collection, forcing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11754. <tr><td></td><td valign="top"><a href="#index-GC-protection-in-C">GC protection in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  11755. <tr><td></td><td valign="top"><a href="#index-generic-functions">generic functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  11756. <tr><td></td><td valign="top"><a href="#index-generic-modules">generic modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11757. <tr><td></td><td valign="top"><a href="#index-generic-predicate-dispatch">generic predicate dispatch</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  11758. <tr><td></td><td valign="top"><a href="#index-graph-algorithms">graph algorithms</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11759. <tr><td></td><td valign="top"><a href="#index-group-ids">group ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11760. <tr><td></td><td valign="top"><a href="#index-group-ids-1">group ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  11761. <tr><td></td><td valign="top"><a href="#index-growing-vectors">growing vectors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  11762. <tr><td colspan="4"> <hr></td></tr>
  11763. <tr><th id="Concept-index_cp_letter-H">H</th><td></td><td></td></tr>
  11764. <tr><td></td><td valign="top"><a href="#index-heap-image-dumping">heap image dumping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  11765. <tr><td></td><td valign="top"><a href="#index-heap-image-dumping-1">heap image dumping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11766. <tr><td></td><td valign="top"><a href="#index-heap-image-resumption">heap image resumption</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11767. <tr><td></td><td valign="top"><a href="#index-heap-image-resumption-1">heap image resumption</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11768. <tr><td></td><td valign="top"><a href="#index-heap-image-writing">heap image writing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  11769. <tr><td></td><td valign="top"><a href="#index-heap-image-writing-1">heap image writing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11770. <tr><td></td><td valign="top"><a href="#index-heap-size">heap size</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11771. <tr><td></td><td valign="top"><a href="#index-heap-space-analysis">heap space analysis</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11772. <tr><td></td><td valign="top"><a href="#index-heap-traversal">heap traversal</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11773. <tr><td></td><td valign="top"><a href="#index-help">help</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  11774. <tr><td></td><td valign="top"><a href="#index-higher_002dlevel-channel-utilities">higher-level channel utilities</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  11775. <tr><td></td><td valign="top"><a href="#index-higher_002dorder-modules">higher-order modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11776. <tr><td></td><td valign="top"><a href="#index-hygiene-of-macros-in-modules">hygiene of macros in modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11777. <tr><td colspan="4"> <hr></td></tr>
  11778. <tr><th id="Concept-index_cp_letter-I">I</th><td></td><td></td></tr>
  11779. <tr><td></td><td valign="top"><a href="#index-I_002fO-flags">I/O flags</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11780. <tr><td></td><td valign="top"><a href="#index-image-dumping">image dumping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  11781. <tr><td></td><td valign="top"><a href="#index-image-dumping-1">image dumping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11782. <tr><td></td><td valign="top"><a href="#index-image-writing">image writing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  11783. <tr><td></td><td valign="top"><a href="#index-image-writing-1">image writing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11784. <tr><td></td><td valign="top"><a href="#index-immutability">immutability</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11785. <tr><td></td><td valign="top"><a href="#index-importing-bindings-into-C-from-Scheme">importing bindings into C from Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11786. <tr><td></td><td valign="top"><a href="#index-importing-bindings-into-Scheme-from-C">importing bindings into Scheme from C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11787. <tr><td></td><td valign="top"><a href="#index-importing-C-functions-to-Scheme">importing C functions to Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  11788. <tr><td></td><td valign="top"><a href="#index-importing-C-functions-to-Scheme-1">importing C functions to Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  11789. <tr><td></td><td valign="top"><a href="#index-in_002dline-procedures">in-line procedures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11790. <tr><td></td><td valign="top"><a href="#index-input-and-output-of-blocks">input and output of blocks</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11791. <tr><td></td><td valign="top"><a href="#index-input-ports-from-strings">input ports from strings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11792. <tr><td></td><td valign="top"><a href="#index-installing-condition-handlers">installing condition handlers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11793. <tr><td></td><td valign="top"><a href="#index-installing-proposals">installing proposals</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11794. <tr><td></td><td valign="top"><a href="#index-integrated-procedures">integrated procedures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11795. <tr><td></td><td valign="top"><a href="#index-interaction-between-continuations-and-C">interaction between continuations and C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  11796. <tr><td></td><td valign="top"><a href="#index-interface-abstraction">interface abstraction</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11797. <tr><td></td><td valign="top"><a href="#index-interface-definition-forms">interface definition forms</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11798. <tr><td></td><td valign="top"><a href="#index-interface-reuse">interface re&uuml;se</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11799. <tr><td></td><td valign="top"><a href="#index-interfaces">interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
  11800. <tr><td></td><td valign="top"><a href="#index-interfaces-1">interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11801. <tr><td colspan="4"> <hr></td></tr>
  11802. <tr><th id="Concept-index_cp_letter-J">J</th><td></td><td></td></tr>
  11803. <tr><td></td><td valign="top"><a href="#index-join-types">join types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  11804. <tr><td colspan="4"> <hr></td></tr>
  11805. <tr><th id="Concept-index_cp_letter-L">L</th><td></td><td></td></tr>
  11806. <tr><td></td><td valign="top"><a href="#index-limiting-output">limiting output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11807. <tr><td></td><td valign="top"><a href="#index-line_002d-_0026-column_002dtracking-ports">line- &amp; column-tracking ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11808. <tr><td></td><td valign="top"><a href="#index-listing-directories">listing directories</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11809. <tr><td></td><td valign="top"><a href="#index-locks-for-mutual-exclusion">locks for mutual exclusion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  11810. <tr><td></td><td valign="top"><a href="#index-logging-operations">logging operations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  11811. <tr><td></td><td valign="top"><a href="#index-logging-operations-1">logging operations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11812. <tr><td></td><td valign="top"><a href="#index-logs">logs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11813. <tr><td></td><td valign="top"><a href="#index-loopholes-in-the-type-system">loopholes in the type system</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
  11814. <tr><td></td><td valign="top"><a href="#index-low_002dlevel-access-to-records">low-level access to records</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11815. <tr><td></td><td valign="top"><a href="#index-low_002dlevel-macros">low-level macros</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
  11816. <tr><td colspan="4"> <hr></td></tr>
  11817. <tr><th id="Concept-index_cp_letter-M">M</th><td></td><td></td></tr>
  11818. <tr><td></td><td valign="top"><a href="#index-macro-expansion">macro expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11819. <tr><td></td><td valign="top"><a href="#index-macro-hygiene-in-modules">macro hygiene in modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11820. <tr><td></td><td valign="top"><a href="#index-macro-referential-transparency-in-modules">macro referential transparency in modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11821. <tr><td></td><td valign="top"><a href="#index-macros-in-the-module-configuration-language">macros in the module configuration language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11822. <tr><td></td><td valign="top"><a href="#index-macros_002c-low_002dlevel">macros, low-level</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
  11823. <tr><td></td><td valign="top"><a href="#index-macros_002c-unhygienic">macros, unhygienic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
  11824. <tr><td></td><td valign="top"><a href="#index-making-directories">making directories</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11825. <tr><td></td><td valign="top"><a href="#index-marshalling">marshalling</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11826. <tr><td></td><td valign="top"><a href="#index-meet-types">meet types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  11827. <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme">memory management in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11828. <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme-1">memory management in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  11829. <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme-2">memory management in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  11830. <tr><td></td><td valign="top"><a href="#index-memory-size">memory size</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11831. <tr><td></td><td valign="top"><a href="#index-message_002dpassing">message-passing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  11832. <tr><td></td><td valign="top"><a href="#index-message_002dpassing-1">message-passing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  11833. <tr><td></td><td valign="top"><a href="#index-modified-interfaces">modified interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11834. <tr><td></td><td valign="top"><a href="#index-modified-structures">modified structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11835. <tr><td></td><td valign="top"><a href="#index-module-language">module language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11836. <tr><td></td><td valign="top"><a href="#index-module-language-1">module language</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11837. <tr><td></td><td valign="top"><a href="#index-module-language-macros">module language macros</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11838. <tr><td></td><td valign="top"><a href="#index-modules">modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11839. <tr><td></td><td valign="top"><a href="#index-multimethod-dispatch">multimethod dispatch</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  11840. <tr><td></td><td valign="top"><a href="#index-multiple-value-binding">multiple value binding</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11841. <tr><td></td><td valign="top"><a href="#index-mutability">mutability</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11842. <tr><td></td><td valign="top"><a href="#index-mutex-locks">mutex locks</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  11843. <tr><td></td><td valign="top"><a href="#index-mutual-exclusion">mutual exclusion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  11844. <tr><td colspan="4"> <hr></td></tr>
  11845. <tr><th id="Concept-index_cp_letter-N">N</th><td></td><td></td></tr>
  11846. <tr><td></td><td valign="top"><a href="#index-namelists">namelists</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  11847. <tr><td></td><td valign="top"><a href="#index-networking">networking</a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  11848. <tr><td></td><td valign="top"><a href="#index-noise-output">noise output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11849. <tr><td></td><td valign="top"><a href="#index-noise-output-1">noise output</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11850. <tr><td></td><td valign="top"><a href="#index-nonblocking-I_002fO">nonblocking I/O</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11851. <tr><td></td><td valign="top"><a href="#index-nondeterminism">nondeterminism</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11852. <tr><td></td><td valign="top"><a href="#index-numbers-in-Pre_002dScheme">numbers in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11853. <tr><td colspan="4"> <hr></td></tr>
  11854. <tr><th id="Concept-index_cp_letter-O">O</th><td></td><td></td></tr>
  11855. <tr><td></td><td valign="top"><a href="#index-object-dumping">object dumping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11856. <tr><td></td><td valign="top"><a href="#index-object-reference-analysis">object reference analysis</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11857. <tr><td></td><td valign="top"><a href="#index-opaque-data-types">opaque data types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11858. <tr><td></td><td valign="top"><a href="#index-opening-structures">opening structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  11859. <tr><td></td><td valign="top"><a href="#index-opening-structures-1">opening structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11860. <tr><td></td><td valign="top"><a href="#index-opening-structures-2">opening structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11861. <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logging-operations">optimistic concurrency logging operations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  11862. <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logging-operations-1">optimistic concurrency logging operations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11863. <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logs">optimistic concurrency logs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11864. <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-proposals">optimistic concurrency proposals</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11865. <tr><td></td><td valign="top"><a href="#index-optimistically-concurrent-record-types">optimistically concurrent record types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11866. <tr><td></td><td valign="top"><a href="#index-optimizer">optimizer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11867. <tr><td></td><td valign="top"><a href="#index-output-port-buffer-forcing">output port buffer forcing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  11868. <tr><td></td><td valign="top"><a href="#index-output-port-buffer-forcing-1">output port buffer forcing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  11869. <tr><td></td><td valign="top"><a href="#index-output-ports-to-strings">output ports to strings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11870. <tr><td colspan="4"> <hr></td></tr>
  11871. <tr><th id="Concept-index_cp_letter-P">P</th><td></td><td></td></tr>
  11872. <tr><td></td><td valign="top"><a href="#index-package-clauses">package clauses</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11873. <tr><td></td><td valign="top"><a href="#index-packages">packages</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11874. <tr><td></td><td valign="top"><a href="#index-parameterized-modules">parameterized modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11875. <tr><td></td><td valign="top"><a href="#index-parametric-polymorphism">parametric polymorphism</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  11876. <tr><td></td><td valign="top"><a href="#index-phase-separation">phase separation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11877. <tr><td></td><td valign="top"><a href="#index-pipe-I_002fO">pipe I/O</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11878. <tr><td></td><td valign="top"><a href="#index-port-to-channel-conversion">port to channel conversion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  11879. <tr><td></td><td valign="top"><a href="#index-ports-that-track-line-_0026-column-numbers">ports that track line &amp; column numbers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11880. <tr><td></td><td valign="top"><a href="#index-ports-with-line-_0026-column-numbers">ports with line &amp; column numbers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11881. <tr><td></td><td valign="top"><a href="#index-POSIX-directory-access">POSIX directory access</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11882. <tr><td></td><td valign="top"><a href="#index-POSIX-environment-variables">POSIX environment variables</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11883. <tr><td></td><td valign="top"><a href="#index-POSIX-exec">POSIX <code>exec</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11884. <tr><td></td><td valign="top"><a href="#index-POSIX-fcntl">POSIX <code>fcntl</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11885. <tr><td></td><td valign="top"><a href="#index-POSIX-FIFOs">POSIX FIFOs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11886. <tr><td></td><td valign="top"><a href="#index-POSIX-file-creation-masks">POSIX file creation masks</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11887. <tr><td></td><td valign="top"><a href="#index-POSIX-file-opening">POSIX file opening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11888. <tr><td></td><td valign="top"><a href="#index-POSIX-file-permissions">POSIX file permissions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11889. <tr><td></td><td valign="top"><a href="#index-POSIX-fork">POSIX <code>fork</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11890. <tr><td></td><td valign="top"><a href="#index-POSIX-group-ids">POSIX group ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11891. <tr><td></td><td valign="top"><a href="#index-POSIX-group-info">POSIX group info</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  11892. <tr><td></td><td valign="top"><a href="#index-POSIX-links">POSIX links</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11893. <tr><td></td><td valign="top"><a href="#index-POSIX-pipe-I_002fO">POSIX pipe I/O</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11894. <tr><td></td><td valign="top"><a href="#index-POSIX-process-exiting">POSIX process exiting</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11895. <tr><td></td><td valign="top"><a href="#index-POSIX-process-ids">POSIX process ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11896. <tr><td></td><td valign="top"><a href="#index-POSIX-process-ids-1">POSIX process ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11897. <tr><td></td><td valign="top"><a href="#index-POSIX-process-termination">POSIX process termination</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11898. <tr><td></td><td valign="top"><a href="#index-POSIX-terminal-ports">POSIX terminal ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  11899. <tr><td></td><td valign="top"><a href="#index-POSIX-user-ids">POSIX user ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11900. <tr><td></td><td valign="top"><a href="#index-POSIX-user-info">POSIX user info</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  11901. <tr><td></td><td valign="top"><a href="#index-POSIX-working-directory">POSIX working directory</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11902. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-closures">Pre-Scheme closures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11903. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-garbage-collection">Pre-Scheme garbage collection</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11904. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management">Pre-Scheme memory management</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11905. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management-1">Pre-Scheme memory management</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  11906. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management-2">Pre-Scheme memory management</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  11907. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-numbers">Pre-Scheme numbers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11908. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-strings">Pre-Scheme strings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  11909. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-tail-call-optimization">Pre-Scheme tail call optimization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11910. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-tail-call-optimization-1">Pre-Scheme tail call optimization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
  11911. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-top_002dlevel-evaluation">Pre-Scheme top-level evaluation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11912. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-type-inference">Pre-Scheme type inference</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11913. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-type-inference-1">Pre-Scheme type inference</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type specifiers</a></td></tr>
  11914. <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-vectors">Pre-Scheme vectors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  11915. <tr><td></td><td valign="top"><a href="#index-pretty_002dprinting">pretty-printing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11916. <tr><td></td><td valign="top"><a href="#index-previewing-continuations">previewing continuations</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11917. <tr><td></td><td valign="top"><a href="#index-printing">printing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11918. <tr><td></td><td valign="top"><a href="#index-printing-conditions">printing conditions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11919. <tr><td></td><td valign="top"><a href="#index-procedure-integration">procedure integration</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11920. <tr><td></td><td valign="top"><a href="#index-procedures_002c-tracing">procedures, tracing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11921. <tr><td></td><td valign="top"><a href="#index-proceeding-from-errors">proceeding from errors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11922. <tr><td></td><td valign="top"><a href="#index-process-forking">process forking</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11923. <tr><td></td><td valign="top"><a href="#index-process-ids">process ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11924. <tr><td></td><td valign="top"><a href="#index-process-ids-1">process ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  11925. <tr><td></td><td valign="top"><a href="#index-process-termination">process termination</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  11926. <tr><td></td><td valign="top"><a href="#index-programmatic-record-types">programmatic record types</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11927. <tr><td></td><td valign="top"><a href="#index-proposals">proposals</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11928. <tr><td></td><td valign="top"><a href="#index-proposals-1">proposals</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11929. <tr><td></td><td valign="top"><a href="#index-proposals_002c-committing">proposals, committing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11930. <tr><td></td><td valign="top"><a href="#index-proposals_002c-installing">proposals, installing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  11931. <tr><td colspan="4"> <hr></td></tr>
  11932. <tr><th id="Concept-index_cp_letter-Q">Q</th><td></td><td></td></tr>
  11933. <tr><td></td><td valign="top"><a href="#index-quitting-Scheme">quitting Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  11934. <tr><td colspan="4"> <hr></td></tr>
  11935. <tr><th id="Concept-index_cp_letter-R">R</th><td></td><td></td></tr>
  11936. <tr><td></td><td valign="top"><a href="#index-real-time">real time</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11937. <tr><td></td><td valign="top"><a href="#index-record-resumers">record resumers</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  11938. <tr><td></td><td valign="top"><a href="#index-record-types_002c-defining">record types, defining</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11939. <tr><td></td><td valign="top"><a href="#index-record-types_002c-programmatic">record types, programmatic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11940. <tr><td></td><td valign="top"><a href="#index-records_002c-low_002dlevel-access-to">records, low-level access to</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  11941. <tr><td></td><td valign="top"><a href="#index-referential-transparency-of-macros-in-modules">referential transparency of macros in modules</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11942. <tr><td></td><td valign="top"><a href="#index-reflective-tower">reflective tower</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11943. <tr><td></td><td valign="top"><a href="#index-reloading-code">reloading code</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
  11944. <tr><td></td><td valign="top"><a href="#index-reloading-code-1">reloading code</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  11945. <tr><td></td><td valign="top"><a href="#index-removing-directories">removing directories</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11946. <tr><td></td><td valign="top"><a href="#index-removing-files">removing files</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11947. <tr><td></td><td valign="top"><a href="#index-renaming-files">renaming files</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  11948. <tr><td></td><td valign="top"><a href="#index-rendezvous">rendezvous</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Concurrent-ML">Concurrent ML</a></td></tr>
  11949. <tr><td></td><td valign="top"><a href="#index-resizable-vectors">resizable vectors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  11950. <tr><td></td><td valign="top"><a href="#index-restoring-C-data-after-resuming-images">restoring C data after resuming images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  11951. <tr><td></td><td valign="top"><a href="#index-resuming-heap-images">resuming heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11952. <tr><td></td><td valign="top"><a href="#index-resuming-heap-images-1">resuming heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  11953. <tr><td></td><td valign="top"><a href="#index-resuming-suspended-threads">resuming suspended threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  11954. <tr><td></td><td valign="top"><a href="#index-returning-from-errors">returning from errors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  11955. <tr><td></td><td valign="top"><a href="#index-run-time">run time</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11956. <tr><td colspan="4"> <hr></td></tr>
  11957. <tr><th id="Concept-index_cp_letter-S">S</th><td></td><td></td></tr>
  11958. <tr><td></td><td valign="top"><a href="#index-S_002dexpression-destructuring">S-expression destructuring</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11959. <tr><td></td><td valign="top"><a href="#index-Scheme-and-C-data-conversion">Scheme and C data conversion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11960. <tr><td></td><td valign="top"><a href="#index-Scheme-boolean-testing-in-C">Scheme boolean testing in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11961. <tr><td></td><td valign="top"><a href="#index-Scheme-byte-vector-operations-in-C">Scheme byte vector operations in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11962. <tr><td></td><td valign="top"><a href="#index-Scheme-callbacks-in-C">Scheme callbacks in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  11963. <tr><td></td><td valign="top"><a href="#index-Scheme-constants-in-C">Scheme constants in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11964. <tr><td></td><td valign="top"><a href="#index-Scheme-data-predicates-in-C">Scheme data predicates in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11965. <tr><td></td><td valign="top"><a href="#index-Scheme-fixnums-from-C">Scheme fixnums from C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11966. <tr><td></td><td valign="top"><a href="#index-Scheme-pair-operations-in-C">Scheme pair operations in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11967. <tr><td></td><td valign="top"><a href="#index-Scheme-string-operations-in-C">Scheme string operations in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11968. <tr><td></td><td valign="top"><a href="#index-Scheme-vector-operations-in-C">Scheme vector operations in C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11969. <tr><td></td><td valign="top"><a href="#index-scheme48_002eh"><samp>scheme48.h</samp></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  11970. <tr><td></td><td valign="top"><a href="#index-separate-compilation">separate compilation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  11971. <tr><td></td><td valign="top"><a href="#index-serialization">serialization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11972. <tr><td></td><td valign="top"><a href="#index-sharing-data-between-Scheme-and-C">sharing data between Scheme and C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  11973. <tr><td></td><td valign="top"><a href="#index-signal-queues">signal queues</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  11974. <tr><td></td><td valign="top"><a href="#index-signalling-conditions">signalling conditions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  11975. <tr><td></td><td valign="top"><a href="#index-simple-character-sink-output-ports">simple character sink output ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11976. <tr><td></td><td valign="top"><a href="#index-simple-character-source-input-ports">simple character source input ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11977. <tr><td></td><td valign="top"><a href="#index-simple-interfaces">simple interfaces</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11978. <tr><td></td><td valign="top"><a href="#index-sleeping-threads">sleeping threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  11979. <tr><td></td><td valign="top"><a href="#index-space-usage-analysis">space usage analysis</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11980. <tr><td></td><td valign="top"><a href="#index-spawning-threads">spawning threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  11981. <tr><td></td><td valign="top"><a href="#index-stack-size">stack size</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  11982. <tr><td></td><td valign="top"><a href="#index-static-type-analysis">static type analysis</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  11983. <tr><td></td><td valign="top"><a href="#index-static-types-in-Pre_002dScheme">static types in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  11984. <tr><td></td><td valign="top"><a href="#index-static-types-in-Pre_002dScheme-1">static types in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type specifiers</a></td></tr>
  11985. <tr><td></td><td valign="top"><a href="#index-storage-control-of-debug-data">storage control of debug data</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11986. <tr><td></td><td valign="top"><a href="#index-storage-leak-analysis">storage leak analysis</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  11987. <tr><td></td><td valign="top"><a href="#index-storing-C-data-in-the-Scheme-heap">storing C data in the Scheme heap</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  11988. <tr><td></td><td valign="top"><a href="#index-string-input-ports">string input ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11989. <tr><td></td><td valign="top"><a href="#index-string-matching">string matching</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  11990. <tr><td></td><td valign="top"><a href="#index-string-output-ports">string output ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11991. <tr><td></td><td valign="top"><a href="#index-string-ports">string ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  11992. <tr><td></td><td valign="top"><a href="#index-strings-in-Pre_002dScheme">strings in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  11993. <tr><td></td><td valign="top"><a href="#index-strongly_002dconnected-graph-components">strongly-connected graph components</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  11994. <tr><td></td><td valign="top"><a href="#index-structure-definition-forms">structure definition forms</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11995. <tr><td></td><td valign="top"><a href="#index-structures">structures</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11996. <tr><td></td><td valign="top"><a href="#index-structures_002c-accessing">structures, accessing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  11997. <tr><td></td><td valign="top"><a href="#index-structures_002c-opening">structures, opening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  11998. <tr><td></td><td valign="top"><a href="#index-structures_002c-opening-1">structures, opening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  11999. <tr><td></td><td valign="top"><a href="#index-structures_002c-opening-2">structures, opening</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12000. <tr><td></td><td valign="top"><a href="#index-suspending-threads">suspending threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12001. <tr><td></td><td valign="top"><a href="#index-synchronous-channels">synchronous channels</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12002. <tr><td></td><td valign="top"><a href="#index-syntactic-tower">syntactic tower</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  12003. <tr><td></td><td valign="top"><a href="#index-syntax-expansion">syntax expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12004. <tr><td colspan="4"> <hr></td></tr>
  12005. <tr><th id="Concept-index_cp_letter-T">T</th><td></td><td></td></tr>
  12006. <tr><td></td><td valign="top"><a href="#index-tail-call-optimization-in-Pre_002dScheme">tail call optimization in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  12007. <tr><td></td><td valign="top"><a href="#index-tail-call-optimization-in-Pre_002dScheme-1">tail call optimization in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
  12008. <tr><td></td><td valign="top"><a href="#index-tail-recursion-in-Pre_002dScheme">tail recursion in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  12009. <tr><td></td><td valign="top"><a href="#index-tail-recursion-in-Pre_002dScheme-1">tail recursion in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
  12010. <tr><td></td><td valign="top"><a href="#index-terminal-ports">terminal ports</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12011. <tr><td></td><td valign="top"><a href="#index-terminating-threads">terminating threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12012. <tr><td></td><td valign="top"><a href="#index-thread-cells">thread cells</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12013. <tr><td></td><td valign="top"><a href="#index-thread-communication-channels_002c-asynchronous">thread communication channels, asynchronous</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12014. <tr><td></td><td valign="top"><a href="#index-thread-descriptors">thread descriptors</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12015. <tr><td></td><td valign="top"><a href="#index-thread-queues">thread queues</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12016. <tr><td></td><td valign="top"><a href="#index-thread-sleeping">thread sleeping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12017. <tr><td></td><td valign="top"><a href="#index-thread-termination">thread termination</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12018. <tr><td></td><td valign="top"><a href="#index-thread-yielding">thread yielding</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12019. <tr><td></td><td valign="top"><a href="#index-threads-and-callbacks-from-C">threads and callbacks from C</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  12020. <tr><td></td><td valign="top"><a href="#index-threads_002c-spawning">threads, spawning</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12021. <tr><td></td><td valign="top"><a href="#index-time">time</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12022. <tr><td></td><td valign="top"><a href="#index-time-1">time</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12023. <tr><td></td><td valign="top"><a href="#index-timing-execution">timing execution</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12024. <tr><td></td><td valign="top"><a href="#index-top_002dlevel-evaluation-in-Pre_002dScheme">top-level evaluation in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme &amp; Scheme</a></td></tr>
  12025. <tr><td></td><td valign="top"><a href="#index-towers-of-evaluation-phases">towers of evaluation phases</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
  12026. <tr><td></td><td valign="top"><a href="#index-tracing">tracing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12027. <tr><td></td><td valign="top"><a href="#index-transaction-logs">transaction logs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12028. <tr><td></td><td valign="top"><a href="#index-type-dispatch">type dispatch</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  12029. <tr><td></td><td valign="top"><a href="#index-type-inference">type inference</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12030. <tr><td></td><td valign="top"><a href="#index-type-lattice">type lattice</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12031. <tr><td></td><td valign="top"><a href="#index-type-system-loopholes">type system loopholes</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
  12032. <tr><td colspan="4"> <hr></td></tr>
  12033. <tr><th id="Concept-index_cp_letter-U">U</th><td></td><td></td></tr>
  12034. <tr><td></td><td valign="top"><a href="#index-undefined-imported-bindings">undefined imported bindings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
  12035. <tr><td></td><td valign="top"><a href="#index-unhygienic-macros">unhygienic macros</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
  12036. <tr><td></td><td valign="top"><a href="#index-unspecific">unspecific</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12037. <tr><td></td><td valign="top"><a href="#index-unspecified">unspecified</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12038. <tr><td></td><td valign="top"><a href="#index-user-ids">user ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12039. <tr><td></td><td valign="top"><a href="#index-user-ids-1">user ids</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12040. <tr><td></td><td valign="top"><a href="#index-user-package">user package</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12041. <tr><td></td><td valign="top"><a href="#index-usual-resumer">usual resumer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  12042. <tr><td colspan="4"> <hr></td></tr>
  12043. <tr><th id="Concept-index_cp_letter-V">V</th><td></td><td></td></tr>
  12044. <tr><td></td><td valign="top"><a href="#index-vectors-in-Pre_002dScheme">vectors in Pre-Scheme</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12045. <tr><td colspan="4"> <hr></td></tr>
  12046. <tr><th id="Concept-index_cp_letter-W">W</th><td></td><td></td></tr>
  12047. <tr><td></td><td valign="top"><a href="#index-waiting-for-POSIX-processes">waiting for POSIX processes</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12048. <tr><td></td><td valign="top"><a href="#index-warnings">warnings</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12049. <tr><td></td><td valign="top"><a href="#index-working-directory">working directory</a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12050. <tr><td></td><td valign="top"><a href="#index-writer_002c-customized">writer, customized</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  12051. <tr><td></td><td valign="top"><a href="#index-writer_002c-customized-1">writer, customized</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  12052. <tr><td></td><td valign="top"><a href="#index-writing-heap-images">writing heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  12053. <tr><td></td><td valign="top"><a href="#index-writing-heap-images-1">writing heap images</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  12054. <tr><td colspan="4"> <hr></td></tr>
  12055. <tr><th id="Concept-index_cp_letter-Y">Y</th><td></td><td></td></tr>
  12056. <tr><td></td><td valign="top"><a href="#index-yielding-threads">yielding threads</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12057. <tr><td colspan="4"> <hr></td></tr>
  12058. </table>
  12059. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-index_cp_symbol-1"><b>=</b></a>
  12060. &nbsp;
  12061. <br>
  12062. <a class="summary-letter" href="#Concept-index_cp_letter-A"><b>A</b></a>
  12063. &nbsp;
  12064. <a class="summary-letter" href="#Concept-index_cp_letter-B"><b>B</b></a>
  12065. &nbsp;
  12066. <a class="summary-letter" href="#Concept-index_cp_letter-C"><b>C</b></a>
  12067. &nbsp;
  12068. <a class="summary-letter" href="#Concept-index_cp_letter-D"><b>D</b></a>
  12069. &nbsp;
  12070. <a class="summary-letter" href="#Concept-index_cp_letter-E"><b>E</b></a>
  12071. &nbsp;
  12072. <a class="summary-letter" href="#Concept-index_cp_letter-F"><b>F</b></a>
  12073. &nbsp;
  12074. <a class="summary-letter" href="#Concept-index_cp_letter-G"><b>G</b></a>
  12075. &nbsp;
  12076. <a class="summary-letter" href="#Concept-index_cp_letter-H"><b>H</b></a>
  12077. &nbsp;
  12078. <a class="summary-letter" href="#Concept-index_cp_letter-I"><b>I</b></a>
  12079. &nbsp;
  12080. <a class="summary-letter" href="#Concept-index_cp_letter-J"><b>J</b></a>
  12081. &nbsp;
  12082. <a class="summary-letter" href="#Concept-index_cp_letter-L"><b>L</b></a>
  12083. &nbsp;
  12084. <a class="summary-letter" href="#Concept-index_cp_letter-M"><b>M</b></a>
  12085. &nbsp;
  12086. <a class="summary-letter" href="#Concept-index_cp_letter-N"><b>N</b></a>
  12087. &nbsp;
  12088. <a class="summary-letter" href="#Concept-index_cp_letter-O"><b>O</b></a>
  12089. &nbsp;
  12090. <a class="summary-letter" href="#Concept-index_cp_letter-P"><b>P</b></a>
  12091. &nbsp;
  12092. <a class="summary-letter" href="#Concept-index_cp_letter-Q"><b>Q</b></a>
  12093. &nbsp;
  12094. <a class="summary-letter" href="#Concept-index_cp_letter-R"><b>R</b></a>
  12095. &nbsp;
  12096. <a class="summary-letter" href="#Concept-index_cp_letter-S"><b>S</b></a>
  12097. &nbsp;
  12098. <a class="summary-letter" href="#Concept-index_cp_letter-T"><b>T</b></a>
  12099. &nbsp;
  12100. <a class="summary-letter" href="#Concept-index_cp_letter-U"><b>U</b></a>
  12101. &nbsp;
  12102. <a class="summary-letter" href="#Concept-index_cp_letter-V"><b>V</b></a>
  12103. &nbsp;
  12104. <a class="summary-letter" href="#Concept-index_cp_letter-W"><b>W</b></a>
  12105. &nbsp;
  12106. <a class="summary-letter" href="#Concept-index_cp_letter-Y"><b>Y</b></a>
  12107. &nbsp;
  12108. </td></tr></table>
  12109. <hr>
  12110. <span id="Binding-index"></span><div class="header">
  12111. <p>
  12112. Next: <a href="#Structure-index" accesskey="n" rel="next">Structure index</a>, Previous: <a href="#Concept-index" accesskey="p" rel="prev">Concept index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  12113. </div>
  12114. <span id="Binding-index-1"></span><h2 class="unnumbered">Binding index</h2>
  12115. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Binding-index_bn_symbol-1"><b>&amp;</b></a>
  12116. &nbsp;
  12117. <a class="summary-letter" href="#Binding-index_bn_symbol-2"><b>*</b></a>
  12118. &nbsp;
  12119. <a class="summary-letter" href="#Binding-index_bn_symbol-3"><b>+</b></a>
  12120. &nbsp;
  12121. <a class="summary-letter" href="#Binding-index_bn_symbol-4"><b>,</b></a>
  12122. &nbsp;
  12123. <a class="summary-letter" href="#Binding-index_bn_symbol-5"><b>-</b></a>
  12124. &nbsp;
  12125. <a class="summary-letter" href="#Binding-index_bn_symbol-6"><b>:</b></a>
  12126. &nbsp;
  12127. <a class="summary-letter" href="#Binding-index_bn_symbol-7"><b>&lt;</b></a>
  12128. &nbsp;
  12129. <a class="summary-letter" href="#Binding-index_bn_symbol-8"><b>=</b></a>
  12130. &nbsp;
  12131. <a class="summary-letter" href="#Binding-index_bn_symbol-9"><b>&gt;</b></a>
  12132. &nbsp;
  12133. <br>
  12134. <a class="summary-letter" href="#Binding-index_bn_letter-A"><b>A</b></a>
  12135. &nbsp;
  12136. <a class="summary-letter" href="#Binding-index_bn_letter-B"><b>B</b></a>
  12137. &nbsp;
  12138. <a class="summary-letter" href="#Binding-index_bn_letter-C"><b>C</b></a>
  12139. &nbsp;
  12140. <a class="summary-letter" href="#Binding-index_bn_letter-D"><b>D</b></a>
  12141. &nbsp;
  12142. <a class="summary-letter" href="#Binding-index_bn_letter-E"><b>E</b></a>
  12143. &nbsp;
  12144. <a class="summary-letter" href="#Binding-index_bn_letter-F"><b>F</b></a>
  12145. &nbsp;
  12146. <a class="summary-letter" href="#Binding-index_bn_letter-G"><b>G</b></a>
  12147. &nbsp;
  12148. <a class="summary-letter" href="#Binding-index_bn_letter-H"><b>H</b></a>
  12149. &nbsp;
  12150. <a class="summary-letter" href="#Binding-index_bn_letter-I"><b>I</b></a>
  12151. &nbsp;
  12152. <a class="summary-letter" href="#Binding-index_bn_letter-J"><b>J</b></a>
  12153. &nbsp;
  12154. <a class="summary-letter" href="#Binding-index_bn_letter-L"><b>L</b></a>
  12155. &nbsp;
  12156. <a class="summary-letter" href="#Binding-index_bn_letter-M"><b>M</b></a>
  12157. &nbsp;
  12158. <a class="summary-letter" href="#Binding-index_bn_letter-N"><b>N</b></a>
  12159. &nbsp;
  12160. <a class="summary-letter" href="#Binding-index_bn_letter-O"><b>O</b></a>
  12161. &nbsp;
  12162. <a class="summary-letter" href="#Binding-index_bn_letter-P"><b>P</b></a>
  12163. &nbsp;
  12164. <a class="summary-letter" href="#Binding-index_bn_letter-Q"><b>Q</b></a>
  12165. &nbsp;
  12166. <a class="summary-letter" href="#Binding-index_bn_letter-R"><b>R</b></a>
  12167. &nbsp;
  12168. <a class="summary-letter" href="#Binding-index_bn_letter-S"><b>S</b></a>
  12169. &nbsp;
  12170. <a class="summary-letter" href="#Binding-index_bn_letter-T"><b>T</b></a>
  12171. &nbsp;
  12172. <a class="summary-letter" href="#Binding-index_bn_letter-U"><b>U</b></a>
  12173. &nbsp;
  12174. <a class="summary-letter" href="#Binding-index_bn_letter-V"><b>V</b></a>
  12175. &nbsp;
  12176. <a class="summary-letter" href="#Binding-index_bn_letter-W"><b>W</b></a>
  12177. &nbsp;
  12178. </td></tr></table>
  12179. <table class="index-bn" border="0">
  12180. <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
  12181. <tr><td colspan="4"> <hr></td></tr>
  12182. <tr><th id="Binding-index_bn_symbol-1">&amp;</th><td></td><td></td></tr>
  12183. <tr><td></td><td valign="top"><a href="#index-_0026disclose_002dcondition"><code>&amp;disclose-condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12184. <tr><td colspan="4"> <hr></td></tr>
  12185. <tr><th id="Binding-index_bn_symbol-2">*</th><td></td><td></td></tr>
  12186. <tr><td></td><td valign="top"><a href="#index-_002a"><code>*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12187. <tr><td></td><td valign="top"><a href="#index-_002aload_002dfile_002dtype_002a"><code>*load-file-type*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  12188. <tr><td></td><td valign="top"><a href="#index-_002ascheme_002dfile_002dtype_002a"><code>*scheme-file-type*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  12189. <tr><td colspan="4"> <hr></td></tr>
  12190. <tr><th id="Binding-index_bn_symbol-3">+</th><td></td><td></td></tr>
  12191. <tr><td></td><td valign="top"><a href="#index-_002b"><code>+</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12192. <tr><td colspan="4"> <hr></td></tr>
  12193. <tr><th id="Binding-index_bn_symbol-4">,</th><td></td><td></td></tr>
  12194. <tr><td></td><td valign="top"><a href="#index-_002c_003f"><code>,?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12195. <tr><td></td><td valign="top"><a href="#index-_002c_003f-1"><code>,?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12196. <tr><td></td><td valign="top"><a href="#index-_002cbound_003f"><code>,bound?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12197. <tr><td></td><td valign="top"><a href="#index-_002cbuild"><code>,build</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  12198. <tr><td></td><td valign="top"><a href="#index-_002ccollect"><code>,collect</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12199. <tr><td></td><td valign="top"><a href="#index-_002ccondition"><code>,condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12200. <tr><td></td><td valign="top"><a href="#index-_002ccondition-1"><code>,condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12201. <tr><td></td><td valign="top"><a href="#index-_002cconfig"><code>,config</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12202. <tr><td></td><td valign="top"><a href="#index-_002cconfig-1"><code>,config</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12203. <tr><td></td><td valign="top"><a href="#index-_002cconfig_002dpackage_002dis"><code>,config-package-is</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12204. <tr><td></td><td valign="top"><a href="#index-_002cdebug"><code>,debug</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12205. <tr><td></td><td valign="top"><a href="#index-_002cdis"><code>,dis</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12206. <tr><td></td><td valign="top"><a href="#index-_002cdis-1"><code>,dis</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12207. <tr><td></td><td valign="top"><a href="#index-_002cdump"><code>,dump</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  12208. <tr><td></td><td valign="top"><a href="#index-_002cdump-1"><code>,dump</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
  12209. <tr><td></td><td valign="top"><a href="#index-_002cend"><code>,end</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
  12210. <tr><td></td><td valign="top"><a href="#index-_002cexec"><code>,exec</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
  12211. <tr><td></td><td valign="top"><a href="#index-_002cexec-1"><code>,exec</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
  12212. <tr><td></td><td valign="top"><a href="#index-_002cexit"><code>,exit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12213. <tr><td></td><td valign="top"><a href="#index-_002cexit-1"><code>,exit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12214. <tr><td></td><td valign="top"><a href="#index-_002cexit_002dwhen_002ddone"><code>,exit-when-done</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12215. <tr><td></td><td valign="top"><a href="#index-_002cexit_002dwhen_002ddone-1"><code>,exit-when-done</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12216. <tr><td></td><td valign="top"><a href="#index-_002cexpand"><code>,expand</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12217. <tr><td></td><td valign="top"><a href="#index-_002cexpand-1"><code>,expand</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12218. <tr><td></td><td valign="top"><a href="#index-_002cflush"><code>,flush</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12219. <tr><td></td><td valign="top"><a href="#index-_002cflush-1"><code>,flush</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12220. <tr><td></td><td valign="top"><a href="#index-_002cfor_002dsyntax"><code>,for-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12221. <tr><td></td><td valign="top"><a href="#index-_002cfor_002dsyntax-1"><code>,for-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12222. <tr><td></td><td valign="top"><a href="#index-_002cforget"><code>,forget</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
  12223. <tr><td></td><td valign="top"><a href="#index-_002cfrom_002dfile"><code>,from-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
  12224. <tr><td></td><td valign="top"><a href="#index-_002cgo"><code>,go</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12225. <tr><td></td><td valign="top"><a href="#index-_002chelp"><code>,help</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12226. <tr><td></td><td valign="top"><a href="#index-_002chelp-1"><code>,help</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12227. <tr><td></td><td valign="top"><a href="#index-_002cin"><code>,in</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12228. <tr><td></td><td valign="top"><a href="#index-_002cin-1"><code>,in</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12229. <tr><td></td><td valign="top"><a href="#index-_002cinspect"><code>,inspect</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12230. <tr><td></td><td valign="top"><a href="#index-_002cinspect-1"><code>,inspect</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12231. <tr><td></td><td valign="top"><a href="#index-_002ckeep"><code>,keep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12232. <tr><td></td><td valign="top"><a href="#index-_002ckeep-1"><code>,keep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12233. <tr><td></td><td valign="top"><a href="#index-_002cload"><code>,load</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12234. <tr><td></td><td valign="top"><a href="#index-_002cload_002dpackage"><code>,load-package</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12235. <tr><td></td><td valign="top"><a href="#index-_002cload_002dsrfi_002d7_002dprogram"><code>,load-srfi-7-program</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
  12236. <tr><td></td><td valign="top"><a href="#index-_002cload_002dsrfi_002d7_002dscript"><code>,load-srfi-7-script</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
  12237. <tr><td></td><td valign="top"><a href="#index-_002cnew_002dpackage"><code>,new-package</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12238. <tr><td></td><td valign="top"><a href="#index-_002copen"><code>,open</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12239. <tr><td></td><td valign="top"><a href="#index-_002cpop"><code>,pop</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12240. <tr><td></td><td valign="top"><a href="#index-_002cpreview"><code>,preview</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12241. <tr><td></td><td valign="top"><a href="#index-_002cproceed"><code>,proceed</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12242. <tr><td></td><td valign="top"><a href="#index-_002cproceed-1"><code>,proceed</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12243. <tr><td></td><td valign="top"><a href="#index-_002cpush"><code>,push</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12244. <tr><td></td><td valign="top"><a href="#index-_002creload_002dpackage"><code>,reload-package</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12245. <tr><td></td><td valign="top"><a href="#index-_002creset"><code>,reset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12246. <tr><td></td><td valign="top"><a href="#index-_002creset-1"><code>,reset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12247. <tr><td></td><td valign="top"><a href="#index-_002cresume"><code>,resume</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12248. <tr><td></td><td valign="top"><a href="#index-_002cresume-1"><code>,resume</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12249. <tr><td></td><td valign="top"><a href="#index-_002crun"><code>,run</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12250. <tr><td></td><td valign="top"><a href="#index-_002cset"><code>,set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  12251. <tr><td></td><td valign="top"><a href="#index-_002cset-1"><code>,set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  12252. <tr><td></td><td valign="top"><a href="#index-_002cset-2"><code>,set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  12253. <tr><td></td><td valign="top"><a href="#index-_002cstructure"><code>,structure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12254. <tr><td></td><td valign="top"><a href="#index-_002cthreads"><code>,threads</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
  12255. <tr><td></td><td valign="top"><a href="#index-_002cthreads-1"><code>,threads</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12256. <tr><td></td><td valign="top"><a href="#index-_002ctime"><code>,time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12257. <tr><td></td><td valign="top"><a href="#index-_002ctrace"><code>,trace</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12258. <tr><td></td><td valign="top"><a href="#index-_002ctrace-1"><code>,trace</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12259. <tr><td></td><td valign="top"><a href="#index-_002ctranslate"><code>,translate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12260. <tr><td></td><td valign="top"><a href="#index-_002cundefine"><code>,undefine</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
  12261. <tr><td></td><td valign="top"><a href="#index-_002cunset"><code>,unset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
  12262. <tr><td></td><td valign="top"><a href="#index-_002cuntrace"><code>,untrace</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12263. <tr><td></td><td valign="top"><a href="#index-_002cuntrace-1"><code>,untrace</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12264. <tr><td></td><td valign="top"><a href="#index-_002cuser"><code>,user</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12265. <tr><td></td><td valign="top"><a href="#index-_002cuser-1"><code>,user</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12266. <tr><td></td><td valign="top"><a href="#index-_002cuser_002dpackage_002dis"><code>,user-package-is</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
  12267. <tr><td></td><td valign="top"><a href="#index-_002cwhere"><code>,where</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12268. <tr><td></td><td valign="top"><a href="#index-_002cwhere-1"><code>,where</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
  12269. <tr><td colspan="4"> <hr></td></tr>
  12270. <tr><th id="Binding-index_bn_symbol-5">-</th><td></td><td></td></tr>
  12271. <tr><td></td><td valign="top"><a href="#index-_002d"><code>-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12272. <tr><td></td><td valign="top"><a href="#index-_002d-1"><code>-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12273. <tr><td colspan="4"> <hr></td></tr>
  12274. <tr><th id="Binding-index_bn_symbol-6">:</th><td></td><td></td></tr>
  12275. <tr><td></td><td valign="top"><a href="#index-_003arecord_002dtype"><code>:record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12276. <tr><td colspan="4"> <hr></td></tr>
  12277. <tr><th id="Binding-index_bn_symbol-7">&lt;</th><td></td><td></td></tr>
  12278. <tr><td></td><td valign="top"><a href="#index-_003c"><code>&lt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12279. <tr><td></td><td valign="top"><a href="#index-_003c_003d"><code>&lt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12280. <tr><td colspan="4"> <hr></td></tr>
  12281. <tr><th id="Binding-index_bn_symbol-8">=</th><td></td><td></td></tr>
  12282. <tr><td></td><td valign="top"><a href="#index-_003d"><code>=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12283. <tr><td colspan="4"> <hr></td></tr>
  12284. <tr><th id="Binding-index_bn_symbol-9">&gt;</th><td></td><td></td></tr>
  12285. <tr><td></td><td valign="top"><a href="#index-_003e"><code>&gt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12286. <tr><td></td><td valign="top"><a href="#index-_003e_003d"><code>&gt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12287. <tr><td colspan="4"> <hr></td></tr>
  12288. <tr><th id="Binding-index_bn_letter-A">A</th><td></td><td></td></tr>
  12289. <tr><td></td><td valign="top"><a href="#index-abs"><code>abs</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12290. <tr><td></td><td valign="top"><a href="#index-access"><code>access</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12291. <tr><td></td><td valign="top"><a href="#index-access_002dmode"><code>access-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12292. <tr><td></td><td valign="top"><a href="#index-accessible_003f"><code>accessible?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12293. <tr><td></td><td valign="top"><a href="#index-add_002dfinalizer_0021"><code>add-finalizer!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12294. <tr><td></td><td valign="top"><a href="#index-add_002dsignal_002dqueue_002dsignal_0021"><code>add-signal-queue-signal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12295. <tr><td></td><td valign="top"><a href="#index-add_002dto_002dpopulation_0021"><code>add-to-population!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  12296. <tr><td></td><td valign="top"><a href="#index-address_002b"><code>address+</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12297. <tr><td></td><td valign="top"><a href="#index-address_002d"><code>address-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12298. <tr><td></td><td valign="top"><a href="#index-address_002d_003einteger"><code>address-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12299. <tr><td></td><td valign="top"><a href="#index-address_002ddifference"><code>address-difference</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12300. <tr><td></td><td valign="top"><a href="#index-address_003c"><code>address&lt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12301. <tr><td></td><td valign="top"><a href="#index-address_003c_003d"><code>address&lt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12302. <tr><td></td><td valign="top"><a href="#index-address_003d"><code>address=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12303. <tr><td></td><td valign="top"><a href="#index-address_003e"><code>address&gt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12304. <tr><td></td><td valign="top"><a href="#index-address_003e_003d"><code>address&gt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12305. <tr><td></td><td valign="top"><a href="#index-address_003f"><code>address?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12306. <tr><td></td><td valign="top"><a href="#index-after_002dtime_002drv"><code>after-time-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12307. <tr><td></td><td valign="top"><a href="#index-alias"><code>alias</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12308. <tr><td></td><td valign="top"><a href="#index-all_002dvalues"><code>all-values</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12309. <tr><td></td><td valign="top"><a href="#index-allocate_002dmemory"><code>allocate-memory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12310. <tr><td></td><td valign="top"><a href="#index-alphabetic"><code>alphabetic</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12311. <tr><td></td><td valign="top"><a href="#index-alphanumeric"><code>alphanumeric</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12312. <tr><td></td><td valign="top"><a href="#index-always_002drv"><code>always-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12313. <tr><td></td><td valign="top"><a href="#index-and"><code>and</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12314. <tr><td></td><td valign="top"><a href="#index-any"><code>any</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12315. <tr><td></td><td valign="top"><a href="#index-any-1"><code>any</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12316. <tr><td></td><td valign="top"><a href="#index-any_002dmatch_003f"><code>any-match?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12317. <tr><td></td><td valign="top"><a href="#index-any_003f"><code>any?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12318. <tr><td></td><td valign="top"><a href="#index-arithmetic_002dshift"><code>arithmetic-shift</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12319. <tr><td></td><td valign="top"><a href="#index-arithmetic_002dshift_002dright"><code>arithmetic-shift-right</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12320. <tr><td></td><td valign="top"><a href="#index-array"><code>array</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12321. <tr><td></td><td valign="top"><a href="#index-array_002d_003evector"><code>array-&gt;vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12322. <tr><td></td><td valign="top"><a href="#index-array_002dref"><code>array-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12323. <tr><td></td><td valign="top"><a href="#index-array_002dset_0021"><code>array-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12324. <tr><td></td><td valign="top"><a href="#index-array_002dshape"><code>array-shape</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12325. <tr><td></td><td valign="top"><a href="#index-array_003f"><code>array?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12326. <tr><td></td><td valign="top"><a href="#index-ascii_002d_003echar"><code>ascii-&gt;char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
  12327. <tr><td></td><td valign="top"><a href="#index-ascii_002dlimit"><code>ascii-limit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
  12328. <tr><td></td><td valign="top"><a href="#index-ascii_002drange"><code>ascii-range</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12329. <tr><td></td><td valign="top"><a href="#index-ascii_002dranges"><code>ascii-ranges</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12330. <tr><td></td><td valign="top"><a href="#index-ascii_002dwhitespaces"><code>ascii-whitespaces</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
  12331. <tr><td></td><td valign="top"><a href="#index-async_002dchannel_003f"><code>async-channel?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12332. <tr><td></td><td valign="top"><a href="#index-at_002dreal_002dtime_002drv"><code>at-real-time-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12333. <tr><td></td><td valign="top"><a href="#index-atom_003f"><code>atom?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12334. <tr><td></td><td valign="top"><a href="#index-atomically"><code>atomically</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12335. <tr><td></td><td valign="top"><a href="#index-atomically_0021"><code>atomically!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12336. <tr><td></td><td valign="top"><a href="#index-attempt_002dcopy_002dbytes_0021"><code>attempt-copy-bytes!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12337. <tr><td colspan="4"> <hr></td></tr>
  12338. <tr><th id="Binding-index_bn_letter-B">B</th><td></td><td></td></tr>
  12339. <tr><td></td><td valign="top"><a href="#index-begin"><code>begin</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12340. <tr><td></td><td valign="top"><a href="#index-begin-1"><code>begin</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12341. <tr><td></td><td valign="top"><a href="#index-bit_002dcount"><code>bit-count</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12342. <tr><td></td><td valign="top"><a href="#index-bitwise_002dand"><code>bitwise-and</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12343. <tr><td></td><td valign="top"><a href="#index-bitwise_002dand-1"><code>bitwise-and</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12344. <tr><td></td><td valign="top"><a href="#index-bitwise_002dior"><code>bitwise-ior</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12345. <tr><td></td><td valign="top"><a href="#index-bitwise_002dior-1"><code>bitwise-ior</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12346. <tr><td></td><td valign="top"><a href="#index-bitwise_002dnot"><code>bitwise-not</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12347. <tr><td></td><td valign="top"><a href="#index-bitwise_002dnot-1"><code>bitwise-not</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12348. <tr><td></td><td valign="top"><a href="#index-bitwise_002dxor"><code>bitwise-xor</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12349. <tr><td></td><td valign="top"><a href="#index-bitwise_002dxor-1"><code>bitwise-xor</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12350. <tr><td></td><td valign="top"><a href="#index-blank"><code>blank</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12351. <tr><td></td><td valign="top"><a href="#index-breakpoint"><code>breakpoint</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12352. <tr><td></td><td valign="top"><a href="#index-byte_002dvector"><code>byte-vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12353. <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dlength"><code>byte-vector-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12354. <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dref"><code>byte-vector-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12355. <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dset_0021"><code>byte-vector-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12356. <tr><td></td><td valign="top"><a href="#index-byte_002dvector_003f"><code>byte-vector?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12357. <tr><td colspan="4"> <hr></td></tr>
  12358. <tr><th id="Binding-index_bn_letter-C">C</th><td></td><td></td></tr>
  12359. <tr><td></td><td valign="top"><a href="#index-call_002datomically"><code>call-atomically</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12360. <tr><td></td><td valign="top"><a href="#index-call_002datomically_0021"><code>call-atomically!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12361. <tr><td></td><td valign="top"><a href="#index-call_002densuring_002datomicity"><code>call-ensuring-atomicity</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12362. <tr><td></td><td valign="top"><a href="#index-call_002densuring_002datomicity_0021"><code>call-ensuring-atomicity!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12363. <tr><td></td><td valign="top"><a href="#index-call_002derror"><code>call-error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12364. <tr><td></td><td valign="top"><a href="#index-call_002derror_003f"><code>call-error?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12365. <tr><td></td><td valign="top"><a href="#index-call_002dexternal"><code>call-external</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12366. <tr><td></td><td valign="top"><a href="#index-call_002dexternal_002dvalue"><code>call-external-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12367. <tr><td></td><td valign="top"><a href="#index-call_002dimported_002dbinding"><code>call-imported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12368. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002dinput_002dport"><code>call-with-current-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12369. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002dnoise_002dport"><code>call-with-current-noise-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12370. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002doutput_002dport"><code>call-with-current-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12371. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dinput_002dfile"><code>call-with-input-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12372. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002doutput_002dfile"><code>call-with-output-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12373. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dstring_002doutput_002dport"><code>call-with-string-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12374. <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dvalues"><code>call-with-values</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12375. <tr><td></td><td valign="top"><a href="#index-cell_002dref"><code>cell-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Cells">Cells</a></td></tr>
  12376. <tr><td></td><td valign="top"><a href="#index-cell_002dset_0021"><code>cell-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Cells">Cells</a></td></tr>
  12377. <tr><td></td><td valign="top"><a href="#index-cell_003f"><code>cell?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Cells">Cells</a></td></tr>
  12378. <tr><td></td><td valign="top"><a href="#index-channel_002dabort"><code>channel-abort</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12379. <tr><td></td><td valign="top"><a href="#index-channel_002did"><code>channel-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12380. <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dclose"><code>channel-maybe-commit-and-close</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12381. <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dread"><code>channel-maybe-commit-and-read</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12382. <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dwrite"><code>channel-maybe-commit-and-write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12383. <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dread"><code>channel-maybe-read</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12384. <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dwrite"><code>channel-maybe-write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12385. <tr><td></td><td valign="top"><a href="#index-channel_002dos_002dindex"><code>channel-os-index</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12386. <tr><td></td><td valign="top"><a href="#index-channel_002dready_003f"><code>channel-ready?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12387. <tr><td></td><td valign="top"><a href="#index-channel_002dstatus"><code>channel-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12388. <tr><td></td><td valign="top"><a href="#index-channel_002dstatus_002doption"><code>channel-status-option</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12389. <tr><td></td><td valign="top"><a href="#index-channel_002dwrite"><code>channel-write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12390. <tr><td></td><td valign="top"><a href="#index-channel_003f"><code>channel?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12391. <tr><td></td><td valign="top"><a href="#index-channel_003f-1"><code>channel?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12392. <tr><td></td><td valign="top"><a href="#index-char_002d_003eascii"><code>char-&gt;ascii</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
  12393. <tr><td></td><td valign="top"><a href="#index-char_002dpointer_002d_003enul_002dterminated_002dstring"><code>char-pointer-&gt;nul-terminated-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12394. <tr><td></td><td valign="top"><a href="#index-char_002dpointer_002d_003estring"><code>char-pointer-&gt;string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12395. <tr><td></td><td valign="top"><a href="#index-char_002dready_003f"><code>char-ready?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12396. <tr><td></td><td valign="top"><a href="#index-char_002dsink_002d_003eoutput_002dport"><code>char-sink-&gt;output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12397. <tr><td></td><td valign="top"><a href="#index-char_002dsource_002d_003einput_002dport"><code>char-source-&gt;input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12398. <tr><td></td><td valign="top"><a href="#index-char_003c_003f"><code>char&lt;?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12399. <tr><td></td><td valign="top"><a href="#index-char_003d_003f"><code>char=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12400. <tr><td></td><td valign="top"><a href="#index-check_002dbuffer_002dtimestamp_0021"><code>check-buffer-timestamp!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12401. <tr><td></td><td valign="top"><a href="#index-choose"><code>choose</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12402. <tr><td></td><td valign="top"><a href="#index-close_002dall_002dport"><code>close-all-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12403. <tr><td></td><td valign="top"><a href="#index-close_002dchannel"><code>close-channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12404. <tr><td></td><td valign="top"><a href="#index-close_002ddirectory_002dstream"><code>close-directory-stream</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12405. <tr><td></td><td valign="top"><a href="#index-close_002dinput_002dport"><code>close-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12406. <tr><td></td><td valign="top"><a href="#index-close_002dinput_002dport-1"><code>close-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12407. <tr><td></td><td valign="top"><a href="#index-close_002don_002dexec_003f"><code>close-on-exec?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12408. <tr><td></td><td valign="top"><a href="#index-close_002doutput_002dport"><code>close-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12409. <tr><td></td><td valign="top"><a href="#index-close_002doutput_002dport-1"><code>close-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12410. <tr><td></td><td valign="top"><a href="#index-close_002dsocket"><code>close-socket</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  12411. <tr><td></td><td valign="top"><a href="#index-code_002dquote"><code>code-quote</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12412. <tr><td></td><td valign="top"><a href="#index-components"><code>components</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12413. <tr><td></td><td valign="top"><a href="#index-compound_002dinterface"><code>compound-interface</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12414. <tr><td></td><td valign="top"><a href="#index-concatenate_002dsymbol"><code>concatenate-symbol</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12415. <tr><td></td><td valign="top"><a href="#index-cond"><code>cond</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12416. <tr><td></td><td valign="top"><a href="#index-condition_002dpredicate"><code>condition-predicate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12417. <tr><td></td><td valign="top"><a href="#index-condition_002dstuff"><code>condition-stuff</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12418. <tr><td></td><td valign="top"><a href="#index-condition_002dtype"><code>condition-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12419. <tr><td></td><td valign="top"><a href="#index-condvar_002dhas_002dvalue_003f"><code>condvar-has-value?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12420. <tr><td></td><td valign="top"><a href="#index-condvar_002dvalue"><code>condvar-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12421. <tr><td></td><td valign="top"><a href="#index-condvar_003f"><code>condvar?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12422. <tr><td></td><td valign="top"><a href="#index-control"><code>control</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12423. <tr><td></td><td valign="top"><a href="#index-copy_002darray"><code>copy-array</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12424. <tr><td></td><td valign="top"><a href="#index-copy_002dmemory_0021"><code>copy-memory!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12425. <tr><td></td><td valign="top"><a href="#index-count_0025"><code>count%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  12426. <tr><td></td><td valign="top"><a href="#index-count_002a"><code>count*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  12427. <tr><td></td><td valign="top"><a href="#index-current_002dcolumn"><code>current-column</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12428. <tr><td></td><td valign="top"><a href="#index-current_002derror_002dport"><code>current-error-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12429. <tr><td></td><td valign="top"><a href="#index-current_002dinput_002dport"><code>current-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12430. <tr><td></td><td valign="top"><a href="#index-current_002dinput_002dport-1"><code>current-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12431. <tr><td></td><td valign="top"><a href="#index-current_002dnoise_002dport"><code>current-noise-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12432. <tr><td></td><td valign="top"><a href="#index-current_002dnoise_002dport-1"><code>current-noise-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12433. <tr><td></td><td valign="top"><a href="#index-current_002doutput_002dport"><code>current-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12434. <tr><td></td><td valign="top"><a href="#index-current_002doutput_002dport-1"><code>current-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12435. <tr><td></td><td valign="top"><a href="#index-current_002dproposal"><code>current-proposal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12436. <tr><td></td><td valign="top"><a href="#index-current_002drow"><code>current-row</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12437. <tr><td></td><td valign="top"><a href="#index-current_002dthread"><code>current-thread</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12438. <tr><td></td><td valign="top"><a href="#index-current_002dtime"><code>current-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  12439. <tr><td colspan="4"> <hr></td></tr>
  12440. <tr><th id="Binding-index_bn_letter-D">D</th><td></td><td></td></tr>
  12441. <tr><td></td><td valign="top"><a href="#index-d"><code>d</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12442. <tr><td></td><td valign="top"><a href="#index-deallocate"><code>deallocate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12443. <tr><td></td><td valign="top"><a href="#index-deallocate_002dmemory"><code>deallocate-memory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12444. <tr><td></td><td valign="top"><a href="#index-debug_002dmessage"><code>debug-message</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12445. <tr><td></td><td valign="top"><a href="#index-def"><code>def</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12446. <tr><td></td><td valign="top"><a href="#index-default_002dbuffer_002dsize"><code>default-buffer-size</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12447. <tr><td></td><td valign="top"><a href="#index-default_002dhash_002dfunction"><code>default-hash-function</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12448. <tr><td></td><td valign="top"><a href="#index-define"><code>define</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12449. <tr><td></td><td valign="top"><a href="#index-define-1"><code>define</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12450. <tr><td></td><td valign="top"><a href="#index-define_002dcondition_002dtype"><code>define-condition-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12451. <tr><td></td><td valign="top"><a href="#index-define_002denum_002dset_002dtype"><code>define-enum-set-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12452. <tr><td></td><td valign="top"><a href="#index-define_002denumerated_002dtype"><code>define-enumerated-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12453. <tr><td></td><td valign="top"><a href="#index-define_002denumeration"><code>define-enumeration</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12454. <tr><td></td><td valign="top"><a href="#index-define_002dexported_002dbinding"><code>define-exported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  12455. <tr><td></td><td valign="top"><a href="#index-define_002dexported_002dbinding-1"><code>define-exported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12456. <tr><td></td><td valign="top"><a href="#index-define_002dfinite_002dtype"><code>define-finite-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12457. <tr><td></td><td valign="top"><a href="#index-define_002dgeneric"><code>define-generic</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  12458. <tr><td></td><td valign="top"><a href="#index-define_002dimported_002dbinding"><code>define-imported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  12459. <tr><td></td><td valign="top"><a href="#index-define_002dindentation"><code>define-indentation</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12460. <tr><td></td><td valign="top"><a href="#index-define_002dinterface"><code>define-interface</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12461. <tr><td></td><td valign="top"><a href="#index-define_002dmethod"><code>define-method</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  12462. <tr><td></td><td valign="top"><a href="#index-define_002dmodule"><code>define-module</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12463. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002ddiscloser"><code>define-record-discloser</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12464. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dresumer"><code>define-record-resumer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12465. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dresumer-1"><code>define-record-resumer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12466. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype"><code>define-record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12467. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype-1"><code>define-record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12468. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype-2"><code>define-record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a></td></tr>
  12469. <tr><td></td><td valign="top"><a href="#index-define_002dsharp_002dmacro"><code>define-sharp-macro</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Reader">Reader</a></td></tr>
  12470. <tr><td></td><td valign="top"><a href="#index-define_002dsimple_002dtype"><code>define-simple-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  12471. <tr><td></td><td valign="top"><a href="#index-define_002dstructure"><code>define-structure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12472. <tr><td></td><td valign="top"><a href="#index-define_002dstructures"><code>define-structures</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12473. <tr><td></td><td valign="top"><a href="#index-define_002dsynchronized_002drecord_002dtype"><code>define-synchronized-record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12474. <tr><td></td><td valign="top"><a href="#index-define_002dsyntax"><code>define-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12475. <tr><td></td><td valign="top"><a href="#index-define_002dsyntax-1"><code>define-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
  12476. <tr><td></td><td valign="top"><a href="#index-define_002dsyntax-2"><code>define-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12477. <tr><td></td><td valign="top"><a href="#index-delete"><code>delete</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12478. <tr><td></td><td valign="top"><a href="#index-delete_002dfrom_002dqueue_0021"><code>delete-from-queue!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12479. <tr><td></td><td valign="top"><a href="#index-delq"><code>delq</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12480. <tr><td></td><td valign="top"><a href="#index-delq_0021"><code>delq!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12481. <tr><td></td><td valign="top"><a href="#index-dequeue_0021"><code>dequeue!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12482. <tr><td></td><td valign="top"><a href="#index-dequeue_002dsignal_0021"><code>dequeue-signal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12483. <tr><td></td><td valign="top"><a href="#index-destructure"><code>destructure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12484. <tr><td></td><td valign="top"><a href="#index-directory_002dstream_003f"><code>directory-stream?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12485. <tr><td></td><td valign="top"><a href="#index-disclose_002dport"><code>disclose-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12486. <tr><td></td><td valign="top"><a href="#index-disclose_002drecord"><code>disclose-record</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12487. <tr><td></td><td valign="top"><a href="#index-display"><code>display</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  12488. <tr><td></td><td valign="top"><a href="#index-display_002dcondition"><code>display-condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12489. <tr><td></td><td valign="top"><a href="#index-display_002dtype_002dname"><code>display-type-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  12490. <tr><td></td><td valign="top"><a href="#index-do"><code>do</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12491. <tr><td></td><td valign="top"><a href="#index-dump"><code>dump</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12492. <tr><td></td><td valign="top"><a href="#index-dup"><code>dup</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12493. <tr><td></td><td valign="top"><a href="#index-dup_002dswitching_002dmode"><code>dup-switching-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12494. <tr><td></td><td valign="top"><a href="#index-dup2"><code>dup2</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12495. <tr><td></td><td valign="top"><a href="#index-dynamic_002dload"><code>dynamic-load</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12496. <tr><td colspan="4"> <hr></td></tr>
  12497. <tr><th id="Binding-index_bn_letter-E">E</th><td></td><td></td></tr>
  12498. <tr><td></td><td valign="top"><a href="#index-either"><code>either</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12499. <tr><td></td><td valign="top"><a href="#index-empty_002dpipe_0021"><code>empty-pipe!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12500. <tr><td></td><td valign="top"><a href="#index-empty_002dpipe_003f"><code>empty-pipe?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12501. <tr><td></td><td valign="top"><a href="#index-empty_002dqueue_0021"><code>empty-queue!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12502. <tr><td></td><td valign="top"><a href="#index-enqueue_0021"><code>enqueue!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12503. <tr><td></td><td valign="top"><a href="#index-ensure_002datomicity"><code>ensure-atomicity</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12504. <tr><td></td><td valign="top"><a href="#index-ensure_002datomicity_0021"><code>ensure-atomicity!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12505. <tr><td></td><td valign="top"><a href="#index-enum"><code>enum</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12506. <tr><td></td><td valign="top"><a href="#index-enum_002dcase"><code>enum-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12507. <tr><td></td><td valign="top"><a href="#index-enum_002dset_002d_003elist"><code>enum-set-&gt;list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12508. <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dintersection"><code>enum-set-intersection</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12509. <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dmember_003f"><code>enum-set-member?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12510. <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dnegation"><code>enum-set-negation</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12511. <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dunion"><code>enum-set-union</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12512. <tr><td></td><td valign="top"><a href="#index-enum_002dset_003d_003f"><code>enum-set=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  12513. <tr><td></td><td valign="top"><a href="#index-enumerand_002d_003ename"><code>enumerand-&gt;name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12514. <tr><td></td><td valign="top"><a href="#index-environment_002dalist"><code>environment-alist</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12515. <tr><td></td><td valign="top"><a href="#index-eof_002dobject"><code>eof-object</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12516. <tr><td></td><td valign="top"><a href="#index-eq_003f"><code>eq?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12517. <tr><td></td><td valign="top"><a href="#index-error"><code>error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12518. <tr><td></td><td valign="top"><a href="#index-error-1"><code>error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12519. <tr><td></td><td valign="top"><a href="#index-error-2"><code>error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
  12520. <tr><td></td><td valign="top"><a href="#index-error_002dstring"><code>error-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
  12521. <tr><td></td><td valign="top"><a href="#index-error_003f"><code>error?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12522. <tr><td></td><td valign="top"><a href="#index-errors-1"><code>errors</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
  12523. <tr><td></td><td valign="top"><a href="#index-every"><code>every</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12524. <tr><td></td><td valign="top"><a href="#index-every_003f"><code>every?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12525. <tr><td></td><td valign="top"><a href="#index-exact_002dmatch_003f"><code>exact-match?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12526. <tr><td></td><td valign="top"><a href="#index-exception_002darguments"><code>exception-arguments</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12527. <tr><td></td><td valign="top"><a href="#index-exception_002dopcode"><code>exception-opcode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12528. <tr><td></td><td valign="top"><a href="#index-exception_002dreason"><code>exception-reason</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12529. <tr><td></td><td valign="top"><a href="#index-exception_003f"><code>exception?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12530. <tr><td></td><td valign="top"><a href="#index-exec"><code>exec</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12531. <tr><td></td><td valign="top"><a href="#index-exec_002dfile"><code>exec-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12532. <tr><td></td><td valign="top"><a href="#index-exec_002dfile_002dwith_002denvironment"><code>exec-file-with-environment</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12533. <tr><td></td><td valign="top"><a href="#index-exec_002dwith_002dalias"><code>exec-with-alias</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12534. <tr><td></td><td valign="top"><a href="#index-exec_002dwith_002denvironment"><code>exec-with-environment</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12535. <tr><td></td><td valign="top"><a href="#index-exit"><code>exit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12536. <tr><td></td><td valign="top"><a href="#index-export"><code>export</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12537. <tr><td></td><td valign="top"><a href="#index-expose"><code>expose</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12538. <tr><td></td><td valign="top"><a href="#index-expt"><code>expt</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12539. <tr><td></td><td valign="top"><a href="#index-external"><code>external</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-access-to-C-functions-and-macros">Pre-Scheme access to C functions and macros</a></td></tr>
  12540. <tr><td></td><td valign="top"><a href="#index-external_002dname"><code>external-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12541. <tr><td></td><td valign="top"><a href="#index-external_002dvalue"><code>external-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12542. <tr><td></td><td valign="top"><a href="#index-external_003f"><code>external?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12543. <tr><td colspan="4"> <hr></td></tr>
  12544. <tr><th id="Binding-index_bn_letter-F">F</th><td></td><td></td></tr>
  12545. <tr><td></td><td valign="top"><a href="#index-fail"><code>fail</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12546. <tr><td></td><td valign="top"><a href="#index-fd_002dport_003f"><code>fd-port?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12547. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002ddevice"><code>file-info-device</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12548. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dgroup"><code>file-info-group</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12549. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dinode"><code>file-info-inode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12550. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002daccess"><code>file-info-last-access</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12551. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002dchange"><code>file-info-last-change</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12552. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002dmodification"><code>file-info-last-modification</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12553. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlink_002dcount"><code>file-info-link-count</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12554. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dmode"><code>file-info-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12555. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dname"><code>file-info-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12556. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002downer"><code>file-info-owner</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12557. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dsize"><code>file-info-size</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12558. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dtype"><code>file-info-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12559. <tr><td></td><td valign="top"><a href="#index-file_002dinfo_003f"><code>file-info?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12560. <tr><td></td><td valign="top"><a href="#index-file_002dmode"><code>file-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12561. <tr><td></td><td valign="top"><a href="#index-file_002dmode_002b"><code>file-mode+</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12562. <tr><td></td><td valign="top"><a href="#index-file_002dmode_002d"><code>file-mode-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12563. <tr><td></td><td valign="top"><a href="#index-file_002dmode_002d_003einteger"><code>file-mode-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12564. <tr><td></td><td valign="top"><a href="#index-file_002dmode_003c_003d_003f"><code>file-mode&lt;=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12565. <tr><td></td><td valign="top"><a href="#index-file_002dmode_003d_003f"><code>file-mode=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12566. <tr><td></td><td valign="top"><a href="#index-file_002dmode_003e_003d_003f"><code>file-mode&gt;=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12567. <tr><td></td><td valign="top"><a href="#index-file_002dmode_003f"><code>file-mode?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12568. <tr><td></td><td valign="top"><a href="#index-file_002dname_002ddirectory"><code>file-name-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  12569. <tr><td></td><td valign="top"><a href="#index-file_002dname_002dnondirectory"><code>file-name-nondirectory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  12570. <tr><td></td><td valign="top"><a href="#index-file_002doptions"><code>file-options</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12571. <tr><td></td><td valign="top"><a href="#index-file_002doptions_002don_003f"><code>file-options-on?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12572. <tr><td></td><td valign="top"><a href="#index-file_002dtype"><code>file-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12573. <tr><td></td><td valign="top"><a href="#index-file_002dtype_002dname"><code>file-type-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12574. <tr><td></td><td valign="top"><a href="#index-file_002dtype_003f"><code>file-type?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12575. <tr><td></td><td valign="top"><a href="#index-files"><code>files</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12576. <tr><td></td><td valign="top"><a href="#index-filter"><code>filter</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12577. <tr><td></td><td valign="top"><a href="#index-filter-1"><code>filter</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12578. <tr><td></td><td valign="top"><a href="#index-filter_0021"><code>filter!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12579. <tr><td></td><td valign="top"><a href="#index-filter_002dmap"><code>filter-map</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12580. <tr><td></td><td valign="top"><a href="#index-find_002dundefined_002dimported_002dbindings"><code>find-undefined-imported-bindings</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  12581. <tr><td></td><td valign="top"><a href="#index-first"><code>first</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12582. <tr><td></td><td valign="top"><a href="#index-fl_002a"><code>fl*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12583. <tr><td></td><td valign="top"><a href="#index-fl_002b"><code>fl+</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12584. <tr><td></td><td valign="top"><a href="#index-fl_002d"><code>fl-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12585. <tr><td></td><td valign="top"><a href="#index-fl_002d-1"><code>fl-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12586. <tr><td></td><td valign="top"><a href="#index-fl_002f"><code>fl/</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12587. <tr><td></td><td valign="top"><a href="#index-fl_003c"><code>fl&lt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12588. <tr><td></td><td valign="top"><a href="#index-fl_003c_003d"><code>fl&lt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12589. <tr><td></td><td valign="top"><a href="#index-fl_003d"><code>fl=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12590. <tr><td></td><td valign="top"><a href="#index-fl_003e"><code>fl&gt;</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12591. <tr><td></td><td valign="top"><a href="#index-fl_003e_003d"><code>fl&gt;=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  12592. <tr><td></td><td valign="top"><a href="#index-flonum_002dref"><code>flonum-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12593. <tr><td></td><td valign="top"><a href="#index-flonum_002dset_0021"><code>flonum-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12594. <tr><td></td><td valign="top"><a href="#index-fluid"><code>fluid</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12595. <tr><td></td><td valign="top"><a href="#index-fluid_002dcell_002dref"><code>fluid-cell-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12596. <tr><td></td><td valign="top"><a href="#index-fluid_002dcell_002dset_0021"><code>fluid-cell-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12597. <tr><td></td><td valign="top"><a href="#index-fold"><code>fold</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12598. <tr><td></td><td valign="top"><a href="#index-fold_002d_003e2"><code>fold-&gt;2</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12599. <tr><td></td><td valign="top"><a href="#index-fold_002d_003e3"><code>fold-&gt;3</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12600. <tr><td></td><td valign="top"><a href="#index-for_002dsyntax-2"><code>for-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12601. <tr><td></td><td valign="top"><a href="#index-force_002dchannel_002doutput_002dports_0021"><code>force-channel-output-ports!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12602. <tr><td></td><td valign="top"><a href="#index-force_002doutput"><code>force-output</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12603. <tr><td></td><td valign="top"><a href="#index-force_002doutput-1"><code>force-output</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12604. <tr><td></td><td valign="top"><a href="#index-force_002doutput-2"><code>force-output</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12605. <tr><td></td><td valign="top"><a href="#index-force_002doutput_002dif_002dopen"><code>force-output-if-open</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12606. <tr><td></td><td valign="top"><a href="#index-fork"><code>fork</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12607. <tr><td></td><td valign="top"><a href="#index-fork_002dand_002dforget"><code>fork-and-forget</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12608. <tr><td></td><td valign="top"><a href="#index-format"><code>format</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Common_002dLisp_002dstyle-formatting">Common-Lisp-style formatting</a></td></tr>
  12609. <tr><td></td><td valign="top"><a href="#index-fresh_002dline"><code>fresh-line</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12610. <tr><td colspan="4"> <hr></td></tr>
  12611. <tr><th id="Binding-index_bn_letter-G">G</th><td></td><td></td></tr>
  12612. <tr><td></td><td valign="top"><a href="#index-get_002deffective_002dgroup_002did"><code>get-effective-group-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12613. <tr><td></td><td valign="top"><a href="#index-get_002deffective_002duser_002did"><code>get-effective-user-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12614. <tr><td></td><td valign="top"><a href="#index-get_002dexternal"><code>get-external</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12615. <tr><td></td><td valign="top"><a href="#index-get_002dfile_002dinfo"><code>get-file-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12616. <tr><td></td><td valign="top"><a href="#index-get_002dfile_002flink_002dinfo"><code>get-file/link-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12617. <tr><td></td><td valign="top"><a href="#index-get_002dgroup_002did"><code>get-group-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12618. <tr><td></td><td valign="top"><a href="#index-get_002dgroups"><code>get-groups</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12619. <tr><td></td><td valign="top"><a href="#index-get_002dhost_002dname"><code>get-host-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  12620. <tr><td></td><td valign="top"><a href="#index-get_002dlogin_002dname"><code>get-login-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12621. <tr><td></td><td valign="top"><a href="#index-get_002dparent_002dprocess_002did"><code>get-parent-process-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12622. <tr><td></td><td valign="top"><a href="#index-get_002dport_002dinfo"><code>get-port-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12623. <tr><td></td><td valign="top"><a href="#index-get_002dprocess_002did"><code>get-process-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12624. <tr><td></td><td valign="top"><a href="#index-get_002duser_002did"><code>get-user-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12625. <tr><td></td><td valign="top"><a href="#index-gobble_002dline"><code>gobble-line</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Reader">Reader</a></td></tr>
  12626. <tr><td></td><td valign="top"><a href="#index-goto"><code>goto</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
  12627. <tr><td></td><td valign="top"><a href="#index-graphic"><code>graphic</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12628. <tr><td></td><td valign="top"><a href="#index-group_002did_002d_003egroup_002dinfo"><code>group-id-&gt;group-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12629. <tr><td></td><td valign="top"><a href="#index-group_002did_002d_003einteger"><code>group-id-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12630. <tr><td></td><td valign="top"><a href="#index-group_002did_003d_003f"><code>group-id=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12631. <tr><td></td><td valign="top"><a href="#index-group_002did_003f"><code>group-id?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12632. <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002did"><code>group-info-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12633. <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002dmembers"><code>group-info-members</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12634. <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002dname"><code>group-info-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12635. <tr><td></td><td valign="top"><a href="#index-group_002dinfo_003f"><code>group-info?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12636. <tr><td></td><td valign="top"><a href="#index-guard"><code>guard</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12637. <tr><td colspan="4"> <hr></td></tr>
  12638. <tr><th id="Binding-index_bn_letter-H">H</th><td></td><td></td></tr>
  12639. <tr><td></td><td valign="top"><a href="#index-hexdigit"><code>hexdigit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12640. <tr><td></td><td valign="top"><a href="#index-hide"><code>hide</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12641. <tr><td></td><td valign="top"><a href="#index-host_002dname"><code>host-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  12642. <tr><td colspan="4"> <hr></td></tr>
  12643. <tr><th id="Binding-index_bn_letter-I">I</th><td></td><td></td></tr>
  12644. <tr><td></td><td valign="top"><a href="#index-i_002fo_002dflags"><code>i/o-flags</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12645. <tr><td></td><td valign="top"><a href="#index-identity"><code>identity</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12646. <tr><td></td><td valign="top"><a href="#index-if"><code>if</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12647. <tr><td></td><td valign="top"><a href="#index-ignore_002dcase"><code>ignore-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12648. <tr><td></td><td valign="top"><a href="#index-ignore_002derrors"><code>ignore-errors</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12649. <tr><td></td><td valign="top"><a href="#index-immutable_003f"><code>immutable?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12650. <tr><td></td><td valign="top"><a href="#index-import_002ddefinition"><code>import-definition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12651. <tr><td></td><td valign="top"><a href="#index-import_002ddynamic_002dexternals"><code>import-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12652. <tr><td></td><td valign="top"><a href="#index-import_002dlambda_002ddefinition"><code>import-lambda-definition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12653. <tr><td></td><td valign="top"><a href="#index-input_0025"><code>input%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  12654. <tr><td></td><td valign="top"><a href="#index-input_002a"><code>input*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  12655. <tr><td></td><td valign="top"><a href="#index-input_002dchannel_002bcloser_002d_003eport"><code>input-channel+closer-&gt;port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12656. <tr><td></td><td valign="top"><a href="#index-input_002dchannel_002d_003eport"><code>input-channel-&gt;port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12657. <tr><td></td><td valign="top"><a href="#index-input_002dport_002doption"><code>input-port-option</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12658. <tr><td></td><td valign="top"><a href="#index-input_002dport_003f"><code>input-port?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12659. <tr><td></td><td valign="top"><a href="#index-insert"><code>insert</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12660. <tr><td></td><td valign="top"><a href="#index-integer_002d_003eaddress"><code>integer-&gt;address</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12661. <tr><td></td><td valign="top"><a href="#index-integer_002d_003efile_002dmode"><code>integer-&gt;file-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12662. <tr><td></td><td valign="top"><a href="#index-integer_002d_003egroup_002did"><code>integer-&gt;group-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12663. <tr><td></td><td valign="top"><a href="#index-integer_002d_003emask"><code>integer-&gt;mask</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12664. <tr><td></td><td valign="top"><a href="#index-integer_002d_003eprocess_002did"><code>integer-&gt;process-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12665. <tr><td></td><td valign="top"><a href="#index-integer_002d_003esignal"><code>integer-&gt;signal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12666. <tr><td></td><td valign="top"><a href="#index-integer_002d_003euser_002did"><code>integer-&gt;user-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12667. <tr><td></td><td valign="top"><a href="#index-integrate"><code>integrate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12668. <tr><td></td><td valign="top"><a href="#index-interrupt_003f"><code>interrupt?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12669. <tr><td></td><td valign="top"><a href="#index-intersection"><code>intersection</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12670. <tr><td></td><td valign="top"><a href="#index-invalidate_002dcurrent_002dproposal_0021"><code>invalidate-current-proposal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12671. <tr><td></td><td valign="top"><a href="#index-iterate"><code>iterate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Main-looping-macros">Main looping macros</a></td></tr>
  12672. <tr><td colspan="4"> <hr></td></tr>
  12673. <tr><th id="Binding-index_bn_letter-J">J</th><td></td><td></td></tr>
  12674. <tr><td></td><td valign="top"><a href="#index-jar_002dput_0021"><code>jar-put!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12675. <tr><td></td><td valign="top"><a href="#index-jar_002dtake"><code>jar-take</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12676. <tr><td></td><td valign="top"><a href="#index-jar_002dtake_002drv"><code>jar-take-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12677. <tr><td></td><td valign="top"><a href="#index-jar_003f"><code>jar?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12678. <tr><td></td><td valign="top"><a href="#index-join"><code>join</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12679. <tr><td colspan="4"> <hr></td></tr>
  12680. <tr><th id="Binding-index_bn_letter-L">L</th><td></td><td></td></tr>
  12681. <tr><td></td><td valign="top"><a href="#index-last"><code>last</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12682. <tr><td></td><td valign="top"><a href="#index-let"><code>let</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12683. <tr><td></td><td valign="top"><a href="#index-let-1"><code>let</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12684. <tr><td></td><td valign="top"><a href="#index-let_002a"><code>let*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12685. <tr><td></td><td valign="top"><a href="#index-let_002dfluid"><code>let-fluid</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12686. <tr><td></td><td valign="top"><a href="#index-let_002dfluids"><code>let-fluids</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12687. <tr><td></td><td valign="top"><a href="#index-let_002dsyntax"><code>let-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12688. <tr><td></td><td valign="top"><a href="#index-letrec_002dsyntax"><code>letrec-syntax</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12689. <tr><td></td><td valign="top"><a href="#index-limit_002doutput"><code>limit-output</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12690. <tr><td></td><td valign="top"><a href="#index-limited_002dwrite"><code>limited-write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12691. <tr><td></td><td valign="top"><a href="#index-link"><code>link</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12692. <tr><td></td><td valign="top"><a href="#index-list_0025"><code>list%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  12693. <tr><td></td><td valign="top"><a href="#index-list_002a"><code>list*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  12694. <tr><td></td><td valign="top"><a href="#index-list_002d_003emask"><code>list-&gt;mask</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12695. <tr><td></td><td valign="top"><a href="#index-list_002d_003equeue"><code>list-&gt;queue</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12696. <tr><td></td><td valign="top"><a href="#index-list_002ddirectory"><code>list-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12697. <tr><td></td><td valign="top"><a href="#index-list_002dinterface"><code>list-interface</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
  12698. <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals"><code>load-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12699. <tr><td></td><td valign="top"><a href="#index-lock_003f"><code>lock?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  12700. <tr><td></td><td valign="top"><a href="#index-logical_002dshift_002dright"><code>logical-shift-right</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  12701. <tr><td></td><td valign="top"><a href="#index-lookup_002dall_002dexternals"><code>lookup-all-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12702. <tr><td></td><td valign="top"><a href="#index-lookup_002denvironment_002dvariable"><code>lookup-environment-variable</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  12703. <tr><td></td><td valign="top"><a href="#index-lookup_002dexported_002dbinding"><code>lookup-exported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  12704. <tr><td></td><td valign="top"><a href="#index-lookup_002dexternal"><code>lookup-external</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12705. <tr><td></td><td valign="top"><a href="#index-lookup_002dimported_002dbinding"><code>lookup-imported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  12706. <tr><td></td><td valign="top"><a href="#index-lookup_002dimported_002dbinding-1"><code>lookup-imported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  12707. <tr><td></td><td valign="top"><a href="#index-lookup_002dudp_002daddress"><code>lookup-udp-address</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  12708. <tr><td></td><td valign="top"><a href="#index-loophole"><code>loophole</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
  12709. <tr><td></td><td valign="top"><a href="#index-lower_002dcase"><code>lower-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12710. <tr><td></td><td valign="top"><a href="#index-lower_002dcase-1"><code>lower-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12711. <tr><td colspan="4"> <hr></td></tr>
  12712. <tr><th id="Binding-index_bn_letter-M">M</th><td></td><td></td></tr>
  12713. <tr><td></td><td valign="top"><a href="#index-m"><code>m</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12714. <tr><td></td><td valign="top"><a href="#index-machine_002dname"><code>machine-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  12715. <tr><td></td><td valign="top"><a href="#index-make_002darray"><code>make-array</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12716. <tr><td></td><td valign="top"><a href="#index-make_002dasync_002dchannel"><code>make-async-channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12717. <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002dinput_002dport"><code>make-buffered-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12718. <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002dinput_002dport_002dhandler"><code>make-buffered-input-port-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12719. <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002doutput_002dport"><code>make-buffered-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12720. <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002doutput_002dport_002dhandler"><code>make-buffered-output-port-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12721. <tr><td></td><td valign="top"><a href="#index-make_002dbyte_002dvector"><code>make-byte-vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  12722. <tr><td></td><td valign="top"><a href="#index-make_002dcell"><code>make-cell</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Cells">Cells</a></td></tr>
  12723. <tr><td></td><td valign="top"><a href="#index-make_002dchannel"><code>make-channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12724. <tr><td></td><td valign="top"><a href="#index-make_002dcondition"><code>make-condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12725. <tr><td></td><td valign="top"><a href="#index-make_002dcondvar"><code>make-condvar</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12726. <tr><td></td><td valign="top"><a href="#index-make_002ddirectory"><code>make-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12727. <tr><td></td><td valign="top"><a href="#index-make_002dexception"><code>make-exception</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12728. <tr><td></td><td valign="top"><a href="#index-make_002dfifo"><code>make-fifo</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12729. <tr><td></td><td valign="top"><a href="#index-make_002dfluid"><code>make-fluid</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  12730. <tr><td></td><td valign="top"><a href="#index-make_002dimmutable_0021"><code>make-immutable!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  12731. <tr><td></td><td valign="top"><a href="#index-make_002dinput_002dport_002dclosed_0021"><code>make-input-port-closed!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12732. <tr><td></td><td valign="top"><a href="#index-make_002dinteger_002dtable"><code>make-integer-table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12733. <tr><td></td><td valign="top"><a href="#index-make_002djar"><code>make-jar</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12734. <tr><td></td><td valign="top"><a href="#index-make_002dlock"><code>make-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  12735. <tr><td></td><td valign="top"><a href="#index-make_002dmask_002dtype"><code>make-mask-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12736. <tr><td></td><td valign="top"><a href="#index-make_002dnull_002doutput_002dport"><code>make-null-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12737. <tr><td></td><td valign="top"><a href="#index-make_002doutput_002dport_002dclosed_0021"><code>make-output-port-closed!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12738. <tr><td></td><td valign="top"><a href="#index-make_002dpipe"><code>make-pipe</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12739. <tr><td></td><td valign="top"><a href="#index-make_002dplaceholder"><code>make-placeholder</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12740. <tr><td></td><td valign="top"><a href="#index-make_002dplaceholder-1"><code>make-placeholder</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12741. <tr><td></td><td valign="top"><a href="#index-make_002dpopulation"><code>make-population</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  12742. <tr><td></td><td valign="top"><a href="#index-make_002dport"><code>make-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12743. <tr><td></td><td valign="top"><a href="#index-make_002dport_002dhandler"><code>make-port-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-handlers">Port handlers</a></td></tr>
  12744. <tr><td></td><td valign="top"><a href="#index-make_002dproposal"><code>make-proposal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12745. <tr><td></td><td valign="top"><a href="#index-make_002dqueue"><code>make-queue</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12746. <tr><td></td><td valign="top"><a href="#index-make_002drecord"><code>make-record</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12747. <tr><td></td><td valign="top"><a href="#index-make_002drecord_002dtype"><code>make-record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12748. <tr><td></td><td valign="top"><a href="#index-make_002dregexp"><code>make-regexp</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12749. <tr><td></td><td valign="top"><a href="#index-make_002dsearch_002dtree"><code>make-search-tree</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12750. <tr><td></td><td valign="top"><a href="#index-make_002dshared_002darray"><code>make-shared-array</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12751. <tr><td></td><td valign="top"><a href="#index-make_002dsignal_002dqueue"><code>make-signal-queue</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12752. <tr><td></td><td valign="top"><a href="#index-make_002dsparse_002dvector"><code>make-sparse-vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12753. <tr><td></td><td valign="top"><a href="#index-make_002dstring"><code>make-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12754. <tr><td></td><td valign="top"><a href="#index-make_002dstring_002dinput_002dport"><code>make-string-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12755. <tr><td></td><td valign="top"><a href="#index-make_002dstring_002doutput_002dport"><code>make-string-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12756. <tr><td></td><td valign="top"><a href="#index-make_002dstring_002dtable"><code>make-string-table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12757. <tr><td></td><td valign="top"><a href="#index-make_002dsymbol_002dtable"><code>make-symbol-table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12758. <tr><td></td><td valign="top"><a href="#index-make_002dtable"><code>make-table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12759. <tr><td></td><td valign="top"><a href="#index-make_002dtable_002dimmutable_0021"><code>make-table-immutable!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12760. <tr><td></td><td valign="top"><a href="#index-make_002dtable_002dmaker"><code>make-table-maker</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  12761. <tr><td></td><td valign="top"><a href="#index-make_002dtime"><code>make-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  12762. <tr><td></td><td valign="top"><a href="#index-make_002dtracking_002dinput_002dport"><code>make-tracking-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12763. <tr><td></td><td valign="top"><a href="#index-make_002dtracking_002doutput_002dport"><code>make-tracking-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  12764. <tr><td></td><td valign="top"><a href="#index-make_002dunbuffered_002dinput_002dport"><code>make-unbuffered-input-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12765. <tr><td></td><td valign="top"><a href="#index-make_002dunbuffered_002doutput_002dport"><code>make-unbuffered-output-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12766. <tr><td></td><td valign="top"><a href="#index-make_002dvector"><code>make-vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12767. <tr><td></td><td valign="top"><a href="#index-make_002dweak_002dpointer"><code>make-weak-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  12768. <tr><td></td><td valign="top"><a href="#index-mask_002d_003einteger"><code>mask-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12769. <tr><td></td><td valign="top"><a href="#index-mask_002d_003elist"><code>mask-&gt;list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12770. <tr><td></td><td valign="top"><a href="#index-mask_002dclear"><code>mask-clear</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12771. <tr><td></td><td valign="top"><a href="#index-mask_002dhas_002dtype_003f"><code>mask-has-type?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12772. <tr><td></td><td valign="top"><a href="#index-mask_002dintersection"><code>mask-intersection</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12773. <tr><td></td><td valign="top"><a href="#index-mask_002dmember_003f"><code>mask-member?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12774. <tr><td></td><td valign="top"><a href="#index-mask_002dnegate"><code>mask-negate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12775. <tr><td></td><td valign="top"><a href="#index-mask_002dset"><code>mask-set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12776. <tr><td></td><td valign="top"><a href="#index-mask_002dsubtract"><code>mask-subtract</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12777. <tr><td></td><td valign="top"><a href="#index-mask_002dtype"><code>mask-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12778. <tr><td></td><td valign="top"><a href="#index-mask_002dtype_003f"><code>mask-type?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12779. <tr><td></td><td valign="top"><a href="#index-mask_002dunion"><code>mask-union</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12780. <tr><td></td><td valign="top"><a href="#index-mask_003f"><code>mask?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  12781. <tr><td></td><td valign="top"><a href="#index-match"><code>match</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12782. <tr><td></td><td valign="top"><a href="#index-match_002dend"><code>match-end</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12783. <tr><td></td><td valign="top"><a href="#index-match_002dstart"><code>match-start</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12784. <tr><td></td><td valign="top"><a href="#index-match_002dsubmatches"><code>match-submatches</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12785. <tr><td></td><td valign="top"><a href="#index-match_003f"><code>match?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12786. <tr><td></td><td valign="top"><a href="#index-max"><code>max</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12787. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit"><code>maybe-commit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12788. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dblock"><code>maybe-commit-and-block</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12789. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dblock_002don_002dqueue"><code>maybe-commit-and-block-on-queue</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12790. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dmake_002dready"><code>maybe-commit-and-make-ready</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12791. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dset_002dcondvar_0021"><code>maybe-commit-and-set-condvar!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12792. <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dwait_002dfor_002dcondvar"><code>maybe-commit-and-wait-for-condvar</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12793. <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_0021"><code>maybe-dequeue!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12794. <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_002dsignal_0021"><code>maybe-dequeue-signal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12795. <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_002dthread_0021"><code>maybe-dequeue-thread!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  12796. <tr><td></td><td valign="top"><a href="#index-maybe_002dobtain_002dlock"><code>maybe-obtain-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  12797. <tr><td></td><td valign="top"><a href="#index-meet"><code>meet</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12798. <tr><td></td><td valign="top"><a href="#index-memory_002dequal_003f"><code>memory-equal?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12799. <tr><td></td><td valign="top"><a href="#index-memq_003f"><code>memq?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12800. <tr><td></td><td valign="top"><a href="#index-menu"><code>menu</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12801. <tr><td></td><td valign="top"><a href="#index-min"><code>min</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12802. <tr><td></td><td valign="top"><a href="#index-modify"><code>modify</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12803. <tr><td></td><td valign="top"><a href="#index-mvlet"><code>mvlet</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12804. <tr><td></td><td valign="top"><a href="#index-mvlet_002a"><code>mvlet*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12805. <tr><td colspan="4"> <hr></td></tr>
  12806. <tr><th id="Binding-index_bn_letter-N">N</th><td></td><td></td></tr>
  12807. <tr><td></td><td valign="top"><a href="#index-n_003d"><code>n=</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12808. <tr><td></td><td valign="top"><a href="#index-name_002d_003eenumerand"><code>name-&gt;enumerand</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  12809. <tr><td></td><td valign="top"><a href="#index-name_002d_003egroup_002dinfo"><code>name-&gt;group-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12810. <tr><td></td><td valign="top"><a href="#index-name_002d_003esignal"><code>name-&gt;signal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  12811. <tr><td></td><td valign="top"><a href="#index-name_002d_003euser_002dinfo"><code>name-&gt;user-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  12812. <tr><td></td><td valign="top"><a href="#index-namestring"><code>namestring</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  12813. <tr><td></td><td valign="top"><a href="#index-negate"><code>negate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12814. <tr><td></td><td valign="top"><a href="#index-neq_003f"><code>neq?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12815. <tr><td></td><td valign="top"><a href="#index-never_002drv"><code>never-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  12816. <tr><td></td><td valign="top"><a href="#index-newline"><code>newline</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12817. <tr><td></td><td valign="top"><a href="#index-newline-1"><code>newline</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12818. <tr><td></td><td valign="top"><a href="#index-no_002dop"><code>no-op</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12819. <tr><td></td><td valign="top"><a href="#index-no_002dsubmatches"><code>no-submatches</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12820. <tr><td></td><td valign="top"><a href="#index-not"><code>not</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12821. <tr><td></td><td valign="top"><a href="#index-note"><code>note</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12822. <tr><td></td><td valign="top"><a href="#index-note_002dbuffer_002dreuse_0021"><code>note-buffer-reuse!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  12823. <tr><td></td><td valign="top"><a href="#index-note_003f"><code>note?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12824. <tr><td></td><td valign="top"><a href="#index-null_002daddress"><code>null-address</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12825. <tr><td></td><td valign="top"><a href="#index-null_002daddress_003f"><code>null-address?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12826. <tr><td></td><td valign="top"><a href="#index-null_002dlist_003f"><code>null-list?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12827. <tr><td></td><td valign="top"><a href="#index-null_002dpointer"><code>null-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12828. <tr><td></td><td valign="top"><a href="#index-null_002dpointer_003f"><code>null-pointer?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  12829. <tr><td></td><td valign="top"><a href="#index-numeric"><code>numeric</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12830. <tr><td colspan="4"> <hr></td></tr>
  12831. <tr><th id="Binding-index_bn_letter-O">O</th><td></td><td></td></tr>
  12832. <tr><td></td><td valign="top"><a href="#index-obtain_002dlock"><code>obtain-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  12833. <tr><td></td><td valign="top"><a href="#index-on_002dqueue_003f"><code>on-queue?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12834. <tr><td></td><td valign="top"><a href="#index-one_002dof"><code>one-of</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12835. <tr><td></td><td valign="top"><a href="#index-one_002dvalue"><code>one-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12836. <tr><td></td><td valign="top"><a href="#index-open"><code>open</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12837. <tr><td></td><td valign="top"><a href="#index-open_002dchannel"><code>open-channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12838. <tr><td></td><td valign="top"><a href="#index-open_002dchannels_002dlist"><code>open-channels-list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  12839. <tr><td></td><td valign="top"><a href="#index-open_002ddirectory_002dstream"><code>open-directory-stream</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12840. <tr><td></td><td valign="top"><a href="#index-open_002dfile"><code>open-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12841. <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dfile"><code>open-input-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12842. <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dfile-1"><code>open-input-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12843. <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dport_002dstatus"><code>open-input-port-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12844. <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dport_003f"><code>open-input-port?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12845. <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dfile"><code>open-output-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12846. <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dfile-1"><code>open-output-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12847. <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dport_002dstatus"><code>open-output-port-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12848. <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dport_003f"><code>open-output-port?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12849. <tr><td></td><td valign="top"><a href="#index-open_002dpipe"><code>open-pipe</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12850. <tr><td></td><td valign="top"><a href="#index-open_002dsocket"><code>open-socket</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  12851. <tr><td></td><td valign="top"><a href="#index-open_002dudp_002dsocket"><code>open-udp-socket</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  12852. <tr><td></td><td valign="top"><a href="#index-optimize"><code>optimize</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12853. <tr><td></td><td valign="top"><a href="#index-or"><code>or</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12854. <tr><td></td><td valign="top"><a href="#index-os_002dnode_002dname"><code>os-node-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  12855. <tr><td></td><td valign="top"><a href="#index-os_002drelease_002dname"><code>os-release-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  12856. <tr><td></td><td valign="top"><a href="#index-os_002dversion_002dname"><code>os-version-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  12857. <tr><td></td><td valign="top"><a href="#index-output_002dchannel_002bcloser_002d_003eport"><code>output-channel+closer-&gt;port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12858. <tr><td></td><td valign="top"><a href="#index-output_002dchannel_002d_003eport"><code>output-channel-&gt;port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12859. <tr><td></td><td valign="top"><a href="#index-output_002dport_002doption"><code>output-port-option</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12860. <tr><td></td><td valign="top"><a href="#index-output_002dport_002dready_003f"><code>output-port-ready?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12861. <tr><td></td><td valign="top"><a href="#index-output_002dport_003f"><code>output-port?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12862. <tr><td colspan="4"> <hr></td></tr>
  12863. <tr><th id="Binding-index_bn_letter-P">P</th><td></td><td></td></tr>
  12864. <tr><td></td><td valign="top"><a href="#index-p"><code>p</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12865. <tr><td></td><td valign="top"><a href="#index-partition_002dlist"><code>partition-list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12866. <tr><td></td><td valign="top"><a href="#index-partition_002dlist_0021"><code>partition-list!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12867. <tr><td></td><td valign="top"><a href="#index-peek_002dchar"><code>peek-char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12868. <tr><td></td><td valign="top"><a href="#index-periodically_002dflushed_002dports"><code>periodically-flushed-ports</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12869. <tr><td></td><td valign="top"><a href="#index-periodically_002dforce_002doutput_0021"><code>periodically-force-output!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12870. <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dread_0021"><code>pipe-maybe-read!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12871. <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dread_003f_0021"><code>pipe-maybe-read?!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12872. <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dwrite_0021"><code>pipe-maybe-write!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12873. <tr><td></td><td valign="top"><a href="#index-pipe_002dpush_0021"><code>pipe-push!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12874. <tr><td></td><td valign="top"><a href="#index-pipe_002dread_0021"><code>pipe-read!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12875. <tr><td></td><td valign="top"><a href="#index-pipe_002dwrite_0021"><code>pipe-write!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12876. <tr><td></td><td valign="top"><a href="#index-pipe_003f"><code>pipe?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12877. <tr><td></td><td valign="top"><a href="#index-placeholder_002dset_0021"><code>placeholder-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12878. <tr><td></td><td valign="top"><a href="#index-placeholder_002dset_0021-1"><code>placeholder-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12879. <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue"><code>placeholder-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12880. <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue-1"><code>placeholder-value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12881. <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue_002drv"><code>placeholder-value-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12882. <tr><td></td><td valign="top"><a href="#index-placeholder_003f"><code>placeholder?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  12883. <tr><td></td><td valign="top"><a href="#index-placeholder_003f-1"><code>placeholder?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  12884. <tr><td></td><td valign="top"><a href="#index-pop_002dsearch_002dtree_002dmax_0021"><code>pop-search-tree-max!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12885. <tr><td></td><td valign="top"><a href="#index-pop_002dsearch_002dtree_002dmin_0021"><code>pop-search-tree-min!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  12886. <tr><td></td><td valign="top"><a href="#index-population_002d_003elist"><code>population-&gt;list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  12887. <tr><td></td><td valign="top"><a href="#index-port_002d_003echannel"><code>port-&gt;channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  12888. <tr><td></td><td valign="top"><a href="#index-port_002d_003efd"><code>port-&gt;fd</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12889. <tr><td></td><td valign="top"><a href="#index-port_002dbuffer"><code>port-buffer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12890. <tr><td></td><td valign="top"><a href="#index-port_002ddata"><code>port-data</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12891. <tr><td></td><td valign="top"><a href="#index-port_002dhandler"><code>port-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12892. <tr><td></td><td valign="top"><a href="#index-port_002dindex"><code>port-index</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12893. <tr><td></td><td valign="top"><a href="#index-port_002dis_002da_002dterminal_003f"><code>port-is-a-terminal?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12894. <tr><td></td><td valign="top"><a href="#index-port_002dlimit"><code>port-limit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12895. <tr><td></td><td valign="top"><a href="#index-port_002dlock"><code>port-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12896. <tr><td></td><td valign="top"><a href="#index-port_002dpending_002deof_003f"><code>port-pending-eof?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12897. <tr><td></td><td valign="top"><a href="#index-port_002dstatus"><code>port-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12898. <tr><td></td><td valign="top"><a href="#index-port_002dstatus_002doptions"><code>port-status-options</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  12899. <tr><td></td><td valign="top"><a href="#index-port_002dterminal_002dname"><code>port-terminal-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12900. <tr><td></td><td valign="top"><a href="#index-position"><code>position</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12901. <tr><td></td><td valign="top"><a href="#index-posq"><code>posq</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12902. <tr><td></td><td valign="top"><a href="#index-posv"><code>posv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12903. <tr><td></td><td valign="top"><a href="#index-prefix"><code>prefix</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12904. <tr><td></td><td valign="top"><a href="#index-prescheme_002dcompiler"><code>prescheme-compiler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a></td></tr>
  12905. <tr><td></td><td valign="top"><a href="#index-pretty_002dprint"><code>pretty-print</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12906. <tr><td></td><td valign="top"><a href="#index-printing-1"><code>printing</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12907. <tr><td></td><td valign="top"><a href="#index-proc"><code>proc</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12908. <tr><td></td><td valign="top"><a href="#index-proc-1"><code>proc</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12909. <tr><td></td><td valign="top"><a href="#index-procedure"><code>procedure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12910. <tr><td></td><td valign="top"><a href="#index-procedure-1"><code>procedure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  12911. <tr><td></td><td valign="top"><a href="#index-process_002did_002d_003einteger"><code>process-id-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12912. <tr><td></td><td valign="top"><a href="#index-process_002did_002dexit_002dstatus"><code>process-id-exit-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12913. <tr><td></td><td valign="top"><a href="#index-process_002did_002dterminating_002dsignal"><code>process-id-terminating-signal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12914. <tr><td></td><td valign="top"><a href="#index-process_002did_003d_003f"><code>process-id=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12915. <tr><td></td><td valign="top"><a href="#index-process_002did_003f"><code>process-id?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  12916. <tr><td></td><td valign="top"><a href="#index-provisional_002dbyte_002dvector_002dref"><code>provisional-byte-vector-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12917. <tr><td></td><td valign="top"><a href="#index-provisional_002dbyte_002dvector_002dset_0021"><code>provisional-byte-vector-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12918. <tr><td></td><td valign="top"><a href="#index-provisional_002dcar"><code>provisional-car</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12919. <tr><td></td><td valign="top"><a href="#index-provisional_002dcdr"><code>provisional-cdr</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12920. <tr><td></td><td valign="top"><a href="#index-provisional_002dcell_002dref"><code>provisional-cell-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12921. <tr><td></td><td valign="top"><a href="#index-provisional_002dcell_002dset_0021"><code>provisional-cell-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12922. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002ddata"><code>provisional-port-data</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12923. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dhandler"><code>provisional-port-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12924. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dindex"><code>provisional-port-index</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12925. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dlimit"><code>provisional-port-limit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12926. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dlock"><code>provisional-port-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12927. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dpending_002deof_003f"><code>provisional-port-pending-eof?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12928. <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dstatus"><code>provisional-port-status</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12929. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dcar_0021"><code>provisional-set-car!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12930. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dcdr_0021"><code>provisional-set-cdr!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12931. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002ddata_0021"><code>provisional-set-port-data!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12932. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dindex_0021"><code>provisional-set-port-index!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12933. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dlimit_0021"><code>provisional-set-port-limit!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12934. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dlock_0021"><code>provisional-set-port-lock!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12935. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dpending_002deof_003f_0021"><code>provisional-set-port-pending-eof?!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12936. <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dstatus_0021"><code>provisional-set-port-status!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  12937. <tr><td></td><td valign="top"><a href="#index-provisional_002dstring_002dref"><code>provisional-string-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12938. <tr><td></td><td valign="top"><a href="#index-provisional_002dstring_002dset_0021"><code>provisional-string-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12939. <tr><td></td><td valign="top"><a href="#index-provisional_002dvector_002dref"><code>provisional-vector-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12940. <tr><td></td><td valign="top"><a href="#index-provisional_002dvector_002dset_0021"><code>provisional-vector-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12941. <tr><td></td><td valign="top"><a href="#index-punctuation"><code>punctuation</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12942. <tr><td colspan="4"> <hr></td></tr>
  12943. <tr><th id="Binding-index_bn_letter-Q">Q</th><td></td><td></td></tr>
  12944. <tr><td></td><td valign="top"><a href="#index-q"><code>q</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  12945. <tr><td></td><td valign="top"><a href="#index-queue_002d_003elist"><code>queue-&gt;list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12946. <tr><td></td><td valign="top"><a href="#index-queue_002dempty_003f"><code>queue-empty?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12947. <tr><td></td><td valign="top"><a href="#index-queue_002dhead"><code>queue-head</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12948. <tr><td></td><td valign="top"><a href="#index-queue_002dlength"><code>queue-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12949. <tr><td></td><td valign="top"><a href="#index-queue_003f"><code>queue?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  12950. <tr><td></td><td valign="top"><a href="#index-quotient"><code>quotient</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12951. <tr><td colspan="4"> <hr></td></tr>
  12952. <tr><th id="Binding-index_bn_letter-R">R</th><td></td><td></td></tr>
  12953. <tr><td></td><td valign="top"><a href="#index-range"><code>range</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12954. <tr><td></td><td valign="top"><a href="#index-ranges"><code>ranges</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12955. <tr><td></td><td valign="top"><a href="#index-read"><code>read</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Reader">Reader</a></td></tr>
  12956. <tr><td></td><td valign="top"><a href="#index-read_002dblock"><code>read-block</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  12957. <tr><td></td><td valign="top"><a href="#index-read_002dblock-1"><code>read-block</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  12958. <tr><td></td><td valign="top"><a href="#index-read_002dchar"><code>read-char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12959. <tr><td></td><td valign="top"><a href="#index-read_002ddirectory_002dstream"><code>read-directory-stream</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12960. <tr><td></td><td valign="top"><a href="#index-read_002derror_003f"><code>read-error?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  12961. <tr><td></td><td valign="top"><a href="#index-read_002dinteger"><code>read-integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  12962. <tr><td></td><td valign="top"><a href="#index-reading_002derror"><code>reading-error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Reader">Reader</a></td></tr>
  12963. <tr><td></td><td valign="top"><a href="#index-real_002dtime"><code>real-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12964. <tr><td></td><td valign="top"><a href="#index-receive"><code>receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  12965. <tr><td></td><td valign="top"><a href="#index-receive-1"><code>receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12966. <tr><td></td><td valign="top"><a href="#index-receive-2"><code>receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12967. <tr><td></td><td valign="top"><a href="#index-receive-3"><code>receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Multiple-return-values-in-Pre_002dScheme">Multiple return values in Pre-Scheme</a></td></tr>
  12968. <tr><td></td><td valign="top"><a href="#index-receive_002dasync"><code>receive-async</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12969. <tr><td></td><td valign="top"><a href="#index-receive_002dasync_002drv"><code>receive-async-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12970. <tr><td></td><td valign="top"><a href="#index-receive_002drv"><code>receive-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  12971. <tr><td></td><td valign="top"><a href="#index-record"><code>record</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12972. <tr><td></td><td valign="top"><a href="#index-record_002daccessor"><code>record-accessor</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12973. <tr><td></td><td valign="top"><a href="#index-record_002dconstructor"><code>record-constructor</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12974. <tr><td></td><td valign="top"><a href="#index-record_002dlength"><code>record-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12975. <tr><td></td><td valign="top"><a href="#index-record_002dmodifier"><code>record-modifier</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12976. <tr><td></td><td valign="top"><a href="#index-record_002dpredicate"><code>record-predicate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12977. <tr><td></td><td valign="top"><a href="#index-record_002dref"><code>record-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12978. <tr><td></td><td valign="top"><a href="#index-record_002dset_0021"><code>record-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12979. <tr><td></td><td valign="top"><a href="#index-record_002dspace"><code>record-space</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  12980. <tr><td></td><td valign="top"><a href="#index-record_002dtype"><code>record-type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12981. <tr><td></td><td valign="top"><a href="#index-record_002dtype_002dfield_002dnames"><code>record-type-field-names</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12982. <tr><td></td><td valign="top"><a href="#index-record_002dtype_002dname"><code>record-type-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12983. <tr><td></td><td valign="top"><a href="#index-record_002dtype_003f"><code>record-type?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12984. <tr><td></td><td valign="top"><a href="#index-record_003f"><code>record?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  12985. <tr><td></td><td valign="top"><a href="#index-recurring_002dwrite"><code>recurring-write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  12986. <tr><td></td><td valign="top"><a href="#index-reduce"><code>reduce</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  12987. <tr><td></td><td valign="top"><a href="#index-reduce-1"><code>reduce</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Main-looping-macros">Main looping macros</a></td></tr>
  12988. <tr><td></td><td valign="top"><a href="#index-regexp_002dmatch"><code>regexp-match</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12989. <tr><td></td><td valign="top"><a href="#index-regexp_002doption"><code>regexp-option</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12990. <tr><td></td><td valign="top"><a href="#index-regexp_003f"><code>regexp?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  12991. <tr><td></td><td valign="top"><a href="#index-release_002dlock"><code>release-lock</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  12992. <tr><td></td><td valign="top"><a href="#index-relinquish_002dtimeslice"><code>relinquish-timeslice</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  12993. <tr><td></td><td valign="top"><a href="#index-reload_002ddynamic_002dexternals"><code>reload-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  12994. <tr><td></td><td valign="top"><a href="#index-remainder"><code>remainder</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  12995. <tr><td></td><td valign="top"><a href="#index-remap_002dfile_002ddescriptors_0021"><code>remap-file-descriptors!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  12996. <tr><td></td><td valign="top"><a href="#index-remove_002dcurrent_002dproposal_0021"><code>remove-current-proposal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  12997. <tr><td></td><td valign="top"><a href="#index-remove_002ddirectory"><code>remove-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  12998. <tr><td></td><td valign="top"><a href="#index-remove_002dduplicates"><code>remove-duplicates</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  12999. <tr><td></td><td valign="top"><a href="#index-remove_002dsignal_002dqueue_002dsignal_0021"><code>remove-signal-queue-signal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13000. <tr><td></td><td valign="top"><a href="#index-rename"><code>rename</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13001. <tr><td></td><td valign="top"><a href="#index-rename-1"><code>rename</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13002. <tr><td></td><td valign="top"><a href="#index-repeat"><code>repeat</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13003. <tr><td></td><td valign="top"><a href="#index-repeat-1"><code>repeat</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13004. <tr><td></td><td valign="top"><a href="#index-repeat-2"><code>repeat</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13005. <tr><td></td><td valign="top"><a href="#index-report_002derrors_002das_002dwarnings"><code>report-errors-as-warnings</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13006. <tr><td></td><td valign="top"><a href="#index-restore"><code>restore</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13007. <tr><td></td><td valign="top"><a href="#index-reverse_0021"><code>reverse!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13008. <tr><td></td><td valign="top"><a href="#index-reverse_002dlist_002d_003estring"><code>reverse-list-&gt;string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13009. <tr><td></td><td valign="top"><a href="#index-run_002dscheme"><code>run-scheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-integration">Emacs integration</a></td></tr>
  13010. <tr><td></td><td valign="top"><a href="#index-run_002dtime"><code>run-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13011. <tr><td colspan="4"> <hr></td></tr>
  13012. <tr><th id="Binding-index_bn_letter-S">S</th><td></td><td></td></tr>
  13013. <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fLENGTH"><code>S48_BYTE_VECTOR_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13014. <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fP"><code>S48_BYTE_VECTOR_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13015. <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fREF"><code>S48_BYTE_VECTOR_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13016. <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fSET"><code>S48_BYTE_VECTOR_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13017. <tr><td></td><td valign="top"><a href="#index-s48_005fcall_005fscheme"><code>s48_call_scheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
  13018. <tr><td></td><td valign="top"><a href="#index-S48_005fCAR"><code>S48_CAR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13019. <tr><td></td><td valign="top"><a href="#index-S48_005fCDR"><code>S48_CDR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13020. <tr><td></td><td valign="top"><a href="#index-S48_005fCHAR_005fP"><code>S48_CHAR_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13021. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fBOOLEAN"><code>S48_CHECK_BOOLEAN</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13022. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fBYTE_005fVECTOR"><code>S48_CHECK_BYTE_VECTOR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13023. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fCHANNEL"><code>S48_CHECK_CHANNEL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13024. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fINTEGER"><code>S48_CHECK_INTEGER</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13025. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fPAIR"><code>S48_CHECK_PAIR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13026. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fRECORD"><code>S48_CHECK_RECORD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13027. <tr><td></td><td valign="top"><a href="#index-s48_005fcheck_005frecord_005ftype"><code>s48_check_record_type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13028. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSHARED_005fBINDING"><code>S48_CHECK_SHARED_BINDING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13029. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSTRING"><code>S48_CHECK_STRING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13030. <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSYMBOL"><code>S48_CHECK_SYMBOL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13031. <tr><td></td><td valign="top"><a href="#index-s48_005fcons"><code>s48_cons</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13032. <tr><td></td><td valign="top"><a href="#index-S48_005fDECLARE_005fGC_005fPROTECT"><code>S48_DECLARE_GC_PROTECT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13033. <tr><td></td><td valign="top"><a href="#index-s48_005fdefine_005fexported_005fbinding"><code>s48_define_exported_binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13034. <tr><td></td><td valign="top"><a href="#index-S48_005fENTER_005fBOOLEAN"><code>S48_ENTER_BOOLEAN</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13035. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fbyte_005fvector"><code>s48_enter_byte_vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13036. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fchar"><code>s48_enter_char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13037. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fdouble"><code>s48_enter_double</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13038. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005ffixnum"><code>s48_enter_fixnum</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13039. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005finteger"><code>s48_enter_integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13040. <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fstring"><code>s48_enter_string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13041. <tr><td></td><td valign="top"><a href="#index-S48_005fEOF"><code>S48_EOF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13042. <tr><td></td><td valign="top"><a href="#index-S48_005fEQ_005fP"><code>S48_EQ_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13043. <tr><td></td><td valign="top"><a href="#index-S48_005fEXPORT_005fFUNCTION"><code>S48_EXPORT_FUNCTION</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13044. <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fBOOLEAN"><code>S48_EXTRACT_BOOLEAN</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13045. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fbyte_005fvector"><code>s48_extract_byte_vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13046. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fchar"><code>s48_extract_char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13047. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fdouble"><code>s48_extract_double</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13048. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005ffixnum"><code>s48_extract_fixnum</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13049. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005finteger"><code>s48_extract_integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13050. <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fstring"><code>s48_extract_string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13051. <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fVALUE"><code>S48_EXTRACT_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13052. <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fVALUE_005fPOINTER"><code>S48_EXTRACT_VALUE_POINTER</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13053. <tr><td></td><td valign="top"><a href="#index-S48_005fFALSE"><code>S48_FALSE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13054. <tr><td></td><td valign="top"><a href="#index-S48_005fFALSE_005fP"><code>S48_FALSE_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13055. <tr><td></td><td valign="top"><a href="#index-S48_005fFIXNUM_005fP"><code>S48_FIXNUM_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13056. <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fPROTECT_005fGLOBAL"><code>S48_GC_PROTECT_GLOBAL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13057. <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fPROTECT_005fn"><code>S48_GC_PROTECT_<var>n</var></code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13058. <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fUNPROTECT"><code>S48_GC_UNPROTECT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13059. <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fUNPROTECT_005fGLOBAL"><code>S48_GC_UNPROTECT_GLOBAL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13060. <tr><td></td><td valign="top"><a href="#index-s48_005fget_005fimported_005fbinding"><code>s48_get_imported_binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13061. <tr><td></td><td valign="top"><a href="#index-s48_005flength"><code>s48_length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13062. <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fbyte_005fvector"><code>s48_make_byte_vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13063. <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005frecord"><code>s48_make_record</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13064. <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fstring"><code>s48_make_string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13065. <tr><td></td><td valign="top"><a href="#index-S48_005fMAKE_005fVALUE"><code>S48_MAKE_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13066. <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fvector"><code>s48_make_vector</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13067. <tr><td></td><td valign="top"><a href="#index-S48_005fMAX_005fFIXNUM_005fVALUE"><code>S48_MAX_FIXNUM_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13068. <tr><td></td><td valign="top"><a href="#index-S48_005fMIN_005fFIXNUM_005fVALUE"><code>S48_MIN_FIXNUM_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13069. <tr><td></td><td valign="top"><a href="#index-S48_005fNULL"><code>S48_NULL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13070. <tr><td></td><td valign="top"><a href="#index-s48_005fon_005fload"><code>s48_on_load</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  13071. <tr><td></td><td valign="top"><a href="#index-s48_005fon_005freload"><code>s48_on_reload</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  13072. <tr><td></td><td valign="top"><a href="#index-S48_005fPAIR_005fP"><code>S48_PAIR_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13073. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fargument_005fnumber_005ferror"><code>s48_raise_argument_number_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13074. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fargument_005ftype_005ferror"><code>s48_raise_argument_type_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13075. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fclosed_005fchannel_005ferror"><code>s48_raise_closed_channel_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13076. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fos_005ferror"><code>s48_raise_os_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13077. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fout_005fof_005fmemory_005ferror"><code>s48_raise_out_of_memory_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13078. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005frange_005ferror"><code>s48_raise_range_error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13079. <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fscheme_005fexception"><code>s48_raise_scheme_exception</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
  13080. <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fP"><code>S48_RECORD_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13081. <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fREF"><code>S48_RECORD_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13082. <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fSET"><code>S48_RECORD_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13083. <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fTYPE"><code>S48_RECORD_TYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
  13084. <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fCAR"><code>S48_SET_CAR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13085. <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fCDR"><code>S48_SET_CDR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13086. <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fVALUE"><code>S48_SET_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
  13087. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fCHECK"><code>S48_SHARED_BINDING_CHECK</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13088. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fIS_005fIMPORTP"><code>S48_SHARED_BINDING_IS_IMPORTP</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13089. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fNAME"><code>S48_SHARED_BINDING_NAME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13090. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fP"><code>S48_SHARED_BINDING_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13091. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fREF"><code>S48_SHARED_BINDING_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13092. <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fSET"><code>S48_SHARED_BINDING_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13093. <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fLENGTH"><code>S48_STRING_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13094. <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fP"><code>S48_STRING_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13095. <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fREF"><code>S48_STRING_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13096. <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fSET"><code>S48_STRING_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13097. <tr><td></td><td valign="top"><a href="#index-S48_005fSYMBOL_005fP"><code>S48_SYMBOL_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13098. <tr><td></td><td valign="top"><a href="#index-S48_005fSYMBOL_005fTO_005fSTRING"><code>S48_SYMBOL_TO_STRING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13099. <tr><td></td><td valign="top"><a href="#index-S48_005fTRUE"><code>S48_TRUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13100. <tr><td></td><td valign="top"><a href="#index-S48_005fTRUE_005fP"><code>S48_TRUE_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13101. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fLENGTH"><code>S48_UNSAFE_BYTE_VECTOR_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13102. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fREF"><code>S48_UNSAFE_BYTE_VECTOR_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13103. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fSET"><code>S48_UNSAFE_BYTE_VECTOR_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13104. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fCAR"><code>S48_UNSAFE_CAR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13105. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fCDR"><code>S48_UNSAFE_CDR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13106. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fENTER_005fFIXNUM"><code>S48_UNSAFE_ENTER_FIXNUM</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13107. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fCHAR"><code>S48_UNSAFE_EXTRACT_CHAR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13108. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fDOUBLE"><code>S48_UNSAFE_EXTRACT_DOUBLE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13109. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fFIXNUM"><code>S48_UNSAFE_EXTRACT_FIXNUM</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13110. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fINTEGER"><code>S48_UNSAFE_EXTRACT_INTEGER</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13111. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fSTRING"><code>S48_UNSAFE_EXTRACT_STRING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13112. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fVALUE"><code>S48_UNSAFE_EXTRACT_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13113. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fVALUE_005fPOINTER"><code>S48_UNSAFE_EXTRACT_VALUE_POINTER</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13114. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fCAR"><code>S48_UNSAFE_SET_CAR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13115. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fCDR"><code>S48_UNSAFE_SET_CDR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13116. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fVALUE"><code>S48_UNSAFE_SET_VALUE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13117. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fIS_005fIMPORTP"><code>S48_UNSAFE_SHARED_BINDING_IS_IMPORTP</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13118. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fNAME"><code>S48_UNSAFE_SHARED_BINDING_NAME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13119. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fREF"><code>S48_UNSAFE_SHARED_BINDING_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13120. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fSET"><code>S48_UNSAFE_SHARED_BINDING_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13121. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fLENGTH"><code>S48_UNSAFE_STRING_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13122. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fREF"><code>S48_UNSAFE_STRING_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13123. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fSET"><code>S48_UNSAFE_STRING_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13124. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSYMBOL_005fTO_005fSTRING"><code>S48_UNSAFE_SYMBOL_TO_STRING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13125. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fLENGTH"><code>S48_UNSAFE_VECTOR_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13126. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fREF"><code>S48_UNSAFE_VECTOR_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13127. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fSET"><code>S48_UNSAFE_VECTOR_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
  13128. <tr><td></td><td valign="top"><a href="#index-S48_005fUNSPECIFIC"><code>S48_UNSPECIFIC</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13129. <tr><td></td><td valign="top"><a href="#index-s48_005fvalue"><code>s48_value</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13130. <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fLENGTH"><code>S48_VECTOR_LENGTH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13131. <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fP"><code>S48_VECTOR_P</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13132. <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fREF"><code>S48_VECTOR_REF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13133. <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fSET"><code>S48_VECTOR_SET</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
  13134. <tr><td></td><td valign="top"><a href="#index-scheme_002dprogram_002dname"><code>scheme-program-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-integration">Emacs integration</a></td></tr>
  13135. <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmax"><code>search-tree-max</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13136. <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmin"><code>search-tree-min</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13137. <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmodify_0021"><code>search-tree-modify!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13138. <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dref"><code>search-tree-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13139. <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dset_0021"><code>search-tree-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13140. <tr><td></td><td valign="top"><a href="#index-search_002dtree_003f"><code>search-tree?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13141. <tr><td></td><td valign="top"><a href="#index-select"><code>select</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13142. <tr><td></td><td valign="top"><a href="#index-send"><code>send</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  13143. <tr><td></td><td valign="top"><a href="#index-send_002dasync"><code>send-async</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  13144. <tr><td></td><td valign="top"><a href="#index-send_002drv"><code>send-rv</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  13145. <tr><td></td><td valign="top"><a href="#index-sequence"><code>sequence</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13146. <tr><td></td><td valign="top"><a href="#index-set"><code>set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13147. <tr><td></td><td valign="top"><a href="#index-set_002dclose_002don_002dexec_003f_0021"><code>set-close-on-exec?!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  13148. <tr><td></td><td valign="top"><a href="#index-set_002dcondvar_002dhas_002dvalue_003f_0021"><code>set-condvar-has-value?!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  13149. <tr><td></td><td valign="top"><a href="#index-set_002dcondvar_002dvalue_0021"><code>set-condvar-value!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  13150. <tr><td></td><td valign="top"><a href="#index-set_002dcurrent_002dproposal_0021"><code>set-current-proposal!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  13151. <tr><td></td><td valign="top"><a href="#index-set_002dfile_002dcreation_002dmask_0021"><code>set-file-creation-mask!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13152. <tr><td></td><td valign="top"><a href="#index-set_002dfluid_0021"><code>set-fluid!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  13153. <tr><td></td><td valign="top"><a href="#index-set_002dgroup_002did_0021"><code>set-group-id!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  13154. <tr><td></td><td valign="top"><a href="#index-set_002di_002fo_002dflags_0021"><code>set-i/o-flags!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  13155. <tr><td></td><td valign="top"><a href="#index-set_002dleaf_002dpredicate_0021"><code>set-leaf-predicate!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13156. <tr><td></td><td valign="top"><a href="#index-set_002dport_002ddata_0021"><code>set-port-data!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13157. <tr><td></td><td valign="top"><a href="#index-set_002dport_002dindex_0021"><code>set-port-index!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13158. <tr><td></td><td valign="top"><a href="#index-set_002dport_002dlimit_0021"><code>set-port-limit!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13159. <tr><td></td><td valign="top"><a href="#index-set_002dport_002dlock_0021"><code>set-port-lock!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13160. <tr><td></td><td valign="top"><a href="#index-set_002dport_002dpending_002deof_003f_0021"><code>set-port-pending-eof?!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13161. <tr><td></td><td valign="top"><a href="#index-set_002dport_002dstatus_0021"><code>set-port-status!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13162. <tr><td></td><td valign="top"><a href="#index-set_002dtranslation_0021"><code>set-translation!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  13163. <tr><td></td><td valign="top"><a href="#index-set_002duser_002did_0021"><code>set-user-id!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  13164. <tr><td></td><td valign="top"><a href="#index-set_002dworking_002ddirectory_0021"><code>set-working-directory!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13165. <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dis_002dimport_003f"><code>shared-binding-is-import?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13166. <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dref"><code>shared-binding-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13167. <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dref-1"><code>shared-binding-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  13168. <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dset_0021"><code>shared-binding-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13169. <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_003f"><code>shared-binding?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13170. <tr><td></td><td valign="top"><a href="#index-shift_002dleft"><code>shift-left</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
  13171. <tr><td></td><td valign="top"><a href="#index-signal"><code>signal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13172. <tr><td></td><td valign="top"><a href="#index-signal-1"><code>signal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13173. <tr><td></td><td valign="top"><a href="#index-signal_002dcondition"><code>signal-condition</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13174. <tr><td></td><td valign="top"><a href="#index-signal_002dname"><code>signal-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13175. <tr><td></td><td valign="top"><a href="#index-signal_002dos_002dnumber"><code>signal-os-number</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13176. <tr><td></td><td valign="top"><a href="#index-signal_002dprocess"><code>signal-process</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13177. <tr><td></td><td valign="top"><a href="#index-signal_002dqueue_002dmonitored_002dsignals"><code>signal-queue-monitored-signals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13178. <tr><td></td><td valign="top"><a href="#index-signal_002dqueue_003f"><code>signal-queue?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13179. <tr><td></td><td valign="top"><a href="#index-signal_003d_003f"><code>signal=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13180. <tr><td></td><td valign="top"><a href="#index-signal_003f"><code>signal?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13181. <tr><td></td><td valign="top"><a href="#index-silently"><code>silently</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13182. <tr><td></td><td valign="top"><a href="#index-singleton"><code>singleton</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  13183. <tr><td></td><td valign="top"><a href="#index-sleep"><code>sleep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13184. <tr><td></td><td valign="top"><a href="#index-socket_002daccept"><code>socket-accept</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13185. <tr><td></td><td valign="top"><a href="#index-socket_002dclient"><code>socket-client</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13186. <tr><td></td><td valign="top"><a href="#index-socket_002dport_002dnumber"><code>socket-port-number</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13187. <tr><td></td><td valign="top"><a href="#index-some_002dvalues"><code>some-values</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  13188. <tr><td></td><td valign="top"><a href="#index-space"><code>space</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13189. <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002d_003elist"><code>sparse-vector-&gt;list</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13190. <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002dref"><code>sparse-vector-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13191. <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002dset_0021"><code>sparse-vector-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13192. <tr><td></td><td valign="top"><a href="#index-spawn"><code>spawn</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13193. <tr><td></td><td valign="top"><a href="#index-stream_0025"><code>stream%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  13194. <tr><td></td><td valign="top"><a href="#index-stream_002a"><code>stream*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  13195. <tr><td></td><td valign="top"><a href="#index-string_0025"><code>string%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  13196. <tr><td></td><td valign="top"><a href="#index-string_002a"><code>string*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  13197. <tr><td></td><td valign="top"><a href="#index-string_002d_003eimmutable_002dstring"><code>string-&gt;immutable-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13198. <tr><td></td><td valign="top"><a href="#index-string_002dend"><code>string-end</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13199. <tr><td></td><td valign="top"><a href="#index-string_002dhash"><code>string-hash</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13200. <tr><td></td><td valign="top"><a href="#index-string_002dhash-1"><code>string-hash</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13201. <tr><td></td><td valign="top"><a href="#index-string_002dlength"><code>string-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13202. <tr><td></td><td valign="top"><a href="#index-string_002doutput_002dport_002doutput"><code>string-output-port-output</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  13203. <tr><td></td><td valign="top"><a href="#index-string_002dref"><code>string-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13204. <tr><td></td><td valign="top"><a href="#index-string_002dset_0021"><code>string-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13205. <tr><td></td><td valign="top"><a href="#index-string_002dstart"><code>string-start</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13206. <tr><td></td><td valign="top"><a href="#index-strongly_002dconnected_002dcomponents"><code>strongly-connected-components</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13207. <tr><td></td><td valign="top"><a href="#index-structure"><code>structure</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13208. <tr><td></td><td valign="top"><a href="#index-structure_002dref"><code>structure-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13209. <tr><td></td><td valign="top"><a href="#index-structures-1"><code>structures</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13210. <tr><td></td><td valign="top"><a href="#index-sublist"><code>sublist</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  13211. <tr><td></td><td valign="top"><a href="#index-submatch"><code>submatch</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13212. <tr><td></td><td valign="top"><a href="#index-subset"><code>subset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13213. <tr><td></td><td valign="top"><a href="#index-subtract"><code>subtract</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13214. <tr><td></td><td valign="top"><a href="#index-sync"><code>sync</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13215. <tr><td></td><td valign="top"><a href="#index-syntax_002derror"><code>syntax-error</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13216. <tr><td></td><td valign="top"><a href="#index-syntax_002derror_003f"><code>syntax-error?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13217. <tr><td colspan="4"> <hr></td></tr>
  13218. <tr><th id="Binding-index_bn_letter-T">T</th><td></td><td></td></tr>
  13219. <tr><td></td><td valign="top"><a href="#index-table_002dref"><code>table-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13220. <tr><td></td><td valign="top"><a href="#index-table_002dset_0021"><code>table-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13221. <tr><td></td><td valign="top"><a href="#index-table_002dwalk"><code>table-walk</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13222. <tr><td></td><td valign="top"><a href="#index-table_003f"><code>table?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13223. <tr><td></td><td valign="top"><a href="#index-template"><code>template</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  13224. <tr><td></td><td valign="top"><a href="#index-terminate_002dcurrent_002dthread"><code>terminate-current-thread</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13225. <tr><td></td><td valign="top"><a href="#index-text"><code>text</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13226. <tr><td></td><td valign="top"><a href="#index-thread_002dname"><code>thread-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13227. <tr><td></td><td valign="top"><a href="#index-thread_002dqueue_002dempty_003f"><code>thread-queue-empty?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  13228. <tr><td></td><td valign="top"><a href="#index-thread_002duid"><code>thread-uid</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13229. <tr><td></td><td valign="top"><a href="#index-thread_003f"><code>thread?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13230. <tr><td></td><td valign="top"><a href="#index-time_002d_003estring"><code>time-&gt;string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13231. <tr><td></td><td valign="top"><a href="#index-time_002dseconds"><code>time-seconds</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13232. <tr><td></td><td valign="top"><a href="#index-time_003c_003d_003f"><code>time&lt;=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13233. <tr><td></td><td valign="top"><a href="#index-time_003c_003f"><code>time&lt;?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13234. <tr><td></td><td valign="top"><a href="#index-time_003d_003f"><code>time=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13235. <tr><td></td><td valign="top"><a href="#index-time_003e_003d_003f"><code>time&gt;=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13236. <tr><td></td><td valign="top"><a href="#index-time_003e_003f"><code>time&gt;?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13237. <tr><td></td><td valign="top"><a href="#index-time_003f"><code>time?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
  13238. <tr><td></td><td valign="top"><a href="#index-trail"><code>trail</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13239. <tr><td></td><td valign="top"><a href="#index-translate"><code>translate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  13240. <tr><td></td><td valign="top"><a href="#index-translations"><code>translations</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  13241. <tr><td></td><td valign="top"><a href="#index-traverse_002dbreadth_002dfirst"><code>traverse-breadth-first</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13242. <tr><td></td><td valign="top"><a href="#index-traverse_002ddepth_002dfirst"><code>traverse-depth-first</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13243. <tr><td colspan="4"> <hr></td></tr>
  13244. <tr><th id="Binding-index_bn_letter-U">U</th><td></td><td></td></tr>
  13245. <tr><td></td><td valign="top"><a href="#index-u"><code>u</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
  13246. <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002daddress"><code>udp-address-address</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13247. <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002dhostname"><code>udp-address-hostname</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13248. <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002dport"><code>udp-address-port</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13249. <tr><td></td><td valign="top"><a href="#index-udp_002daddress_003f"><code>udp-address?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13250. <tr><td></td><td valign="top"><a href="#index-udp_002dreceive"><code>udp-receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13251. <tr><td></td><td valign="top"><a href="#index-udp_002dsend"><code>udp-send</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13252. <tr><td></td><td valign="top"><a href="#index-undefine_002dexported_002dbinding"><code>undefine-exported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13253. <tr><td></td><td valign="top"><a href="#index-undefine_002dimported_002dbinding"><code>undefine-imported-binding</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13254. <tr><td></td><td valign="top"><a href="#index-union"><code>union</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13255. <tr><td></td><td valign="top"><a href="#index-unlink"><code>unlink</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13256. <tr><td></td><td valign="top"><a href="#index-unload_002ddynamic_002dexternals"><code>unload-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  13257. <tr><td></td><td valign="top"><a href="#index-unsigned_002dbyte_002dref"><code>unsigned-byte-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13258. <tr><td></td><td valign="top"><a href="#index-unsigned_002dbyte_002dset_0021"><code>unsigned-byte-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13259. <tr><td></td><td valign="top"><a href="#index-unspecific-1"><code>unspecific</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  13260. <tr><td></td><td valign="top"><a href="#index-upper_002dcase"><code>upper-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13261. <tr><td></td><td valign="top"><a href="#index-use_002dcase"><code>use-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13262. <tr><td></td><td valign="top"><a href="#index-user_002did_002d_003einteger"><code>user-id-&gt;integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13263. <tr><td></td><td valign="top"><a href="#index-user_002did_002d_003euser_002dinfo"><code>user-id-&gt;user-info</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13264. <tr><td></td><td valign="top"><a href="#index-user_002did_003d_003f"><code>user-id=?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13265. <tr><td></td><td valign="top"><a href="#index-user_002did_003f"><code>user-id?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13266. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dgroup"><code>user-info-group</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13267. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dhome_002ddirectory"><code>user-info-home-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13268. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002did"><code>user-info-id</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13269. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dname"><code>user-info-name</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13270. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dshell"><code>user-info-shell</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13271. <tr><td></td><td valign="top"><a href="#index-user_002dinfo_003f"><code>user-info?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13272. <tr><td></td><td valign="top"><a href="#index-usual_002dleaf_002dpredicate"><code>usual-leaf-predicate</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13273. <tr><td></td><td valign="top"><a href="#index-usual_002dresumer"><code>usual-resumer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  13274. <tr><td colspan="4"> <hr></td></tr>
  13275. <tr><th id="Binding-index_bn_letter-V">V</th><td></td><td></td></tr>
  13276. <tr><td></td><td valign="top"><a href="#index-values"><code>values</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13277. <tr><td></td><td valign="top"><a href="#index-values-1"><code>values</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
  13278. <tr><td></td><td valign="top"><a href="#index-variable"><code>variable</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
  13279. <tr><td></td><td valign="top"><a href="#index-vector_0025"><code>vector%</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
  13280. <tr><td></td><td valign="top"><a href="#index-vector_002a"><code>vector*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
  13281. <tr><td></td><td valign="top"><a href="#index-vector_002dlength"><code>vector-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13282. <tr><td></td><td valign="top"><a href="#index-vector_002dref"><code>vector-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13283. <tr><td></td><td valign="top"><a href="#index-vector_002dset_0021"><code>vector-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
  13284. <tr><td></td><td valign="top"><a href="#index-vector_002dspace"><code>vector-space</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13285. <tr><td colspan="4"> <hr></td></tr>
  13286. <tr><th id="Binding-index_bn_letter-W">W</th><td></td><td></td></tr>
  13287. <tr><td></td><td valign="top"><a href="#index-wait_002dfor_002dchannel"><code>wait-for-channel</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  13288. <tr><td></td><td valign="top"><a href="#index-wait_002dfor_002dchild_002dprocess"><code>wait-for-child-process</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  13289. <tr><td></td><td valign="top"><a href="#index-walk_002dpopulation"><code>walk-population</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  13290. <tr><td></td><td valign="top"><a href="#index-walk_002dsearch_002dtree"><code>walk-search-tree</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13291. <tr><td></td><td valign="top"><a href="#index-warn"><code>warn</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13292. <tr><td></td><td valign="top"><a href="#index-warning_003f"><code>warning?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13293. <tr><td></td><td valign="top"><a href="#index-weak_002dpointer_002dref"><code>weak-pointer-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  13294. <tr><td></td><td valign="top"><a href="#index-weak_002dpointer_003f"><code>weak-pointer?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  13295. <tr><td></td><td valign="top"><a href="#index-whitespace"><code>whitespace</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13296. <tr><td></td><td valign="top"><a href="#index-with_002dcurrent_002dports"><code>with-current-ports</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13297. <tr><td></td><td valign="top"><a href="#index-with_002dhandler"><code>with-handler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13298. <tr><td></td><td valign="top"><a href="#index-with_002dinput_002dfrom_002dfile"><code>with-input-from-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  13299. <tr><td></td><td valign="top"><a href="#index-with_002dnack"><code>with-nack</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13300. <tr><td></td><td valign="top"><a href="#index-with_002dnew_002dproposal"><code>with-new-proposal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  13301. <tr><td></td><td valign="top"><a href="#index-with_002dnondeterminism"><code>with-nondeterminism</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13302. <tr><td></td><td valign="top"><a href="#index-with_002doutput_002dto_002dfile"><code>with-output-to-file</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  13303. <tr><td></td><td valign="top"><a href="#index-with_002dprefix"><code>with-prefix</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13304. <tr><td></td><td valign="top"><a href="#index-word_002dref"><code>word-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13305. <tr><td></td><td valign="top"><a href="#index-word_002dset_0021"><code>word-set!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13306. <tr><td></td><td valign="top"><a href="#index-working_002ddirectory"><code>working-directory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13307. <tr><td></td><td valign="top"><a href="#index-wrap"><code>wrap</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13308. <tr><td></td><td valign="top"><a href="#index-write"><code>write</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  13309. <tr><td></td><td valign="top"><a href="#index-write_002dblock"><code>write-block</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13310. <tr><td></td><td valign="top"><a href="#index-write_002dblock-1"><code>write-block</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13311. <tr><td></td><td valign="top"><a href="#index-write_002dchar"><code>write-char</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  13312. <tr><td></td><td valign="top"><a href="#index-write_002dimage"><code>write-image</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  13313. <tr><td></td><td valign="top"><a href="#index-write_002dinteger"><code>write-integer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  13314. <tr><td></td><td valign="top"><a href="#index-write_002dstring"><code>write-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13315. <tr><td></td><td valign="top"><a href="#index-write_002dstring-1"><code>write-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input &amp; output in Pre-Scheme</a></td></tr>
  13316. <tr><td colspan="4"> <hr></td></tr>
  13317. </table>
  13318. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Binding-index_bn_symbol-1"><b>&amp;</b></a>
  13319. &nbsp;
  13320. <a class="summary-letter" href="#Binding-index_bn_symbol-2"><b>*</b></a>
  13321. &nbsp;
  13322. <a class="summary-letter" href="#Binding-index_bn_symbol-3"><b>+</b></a>
  13323. &nbsp;
  13324. <a class="summary-letter" href="#Binding-index_bn_symbol-4"><b>,</b></a>
  13325. &nbsp;
  13326. <a class="summary-letter" href="#Binding-index_bn_symbol-5"><b>-</b></a>
  13327. &nbsp;
  13328. <a class="summary-letter" href="#Binding-index_bn_symbol-6"><b>:</b></a>
  13329. &nbsp;
  13330. <a class="summary-letter" href="#Binding-index_bn_symbol-7"><b>&lt;</b></a>
  13331. &nbsp;
  13332. <a class="summary-letter" href="#Binding-index_bn_symbol-8"><b>=</b></a>
  13333. &nbsp;
  13334. <a class="summary-letter" href="#Binding-index_bn_symbol-9"><b>&gt;</b></a>
  13335. &nbsp;
  13336. <br>
  13337. <a class="summary-letter" href="#Binding-index_bn_letter-A"><b>A</b></a>
  13338. &nbsp;
  13339. <a class="summary-letter" href="#Binding-index_bn_letter-B"><b>B</b></a>
  13340. &nbsp;
  13341. <a class="summary-letter" href="#Binding-index_bn_letter-C"><b>C</b></a>
  13342. &nbsp;
  13343. <a class="summary-letter" href="#Binding-index_bn_letter-D"><b>D</b></a>
  13344. &nbsp;
  13345. <a class="summary-letter" href="#Binding-index_bn_letter-E"><b>E</b></a>
  13346. &nbsp;
  13347. <a class="summary-letter" href="#Binding-index_bn_letter-F"><b>F</b></a>
  13348. &nbsp;
  13349. <a class="summary-letter" href="#Binding-index_bn_letter-G"><b>G</b></a>
  13350. &nbsp;
  13351. <a class="summary-letter" href="#Binding-index_bn_letter-H"><b>H</b></a>
  13352. &nbsp;
  13353. <a class="summary-letter" href="#Binding-index_bn_letter-I"><b>I</b></a>
  13354. &nbsp;
  13355. <a class="summary-letter" href="#Binding-index_bn_letter-J"><b>J</b></a>
  13356. &nbsp;
  13357. <a class="summary-letter" href="#Binding-index_bn_letter-L"><b>L</b></a>
  13358. &nbsp;
  13359. <a class="summary-letter" href="#Binding-index_bn_letter-M"><b>M</b></a>
  13360. &nbsp;
  13361. <a class="summary-letter" href="#Binding-index_bn_letter-N"><b>N</b></a>
  13362. &nbsp;
  13363. <a class="summary-letter" href="#Binding-index_bn_letter-O"><b>O</b></a>
  13364. &nbsp;
  13365. <a class="summary-letter" href="#Binding-index_bn_letter-P"><b>P</b></a>
  13366. &nbsp;
  13367. <a class="summary-letter" href="#Binding-index_bn_letter-Q"><b>Q</b></a>
  13368. &nbsp;
  13369. <a class="summary-letter" href="#Binding-index_bn_letter-R"><b>R</b></a>
  13370. &nbsp;
  13371. <a class="summary-letter" href="#Binding-index_bn_letter-S"><b>S</b></a>
  13372. &nbsp;
  13373. <a class="summary-letter" href="#Binding-index_bn_letter-T"><b>T</b></a>
  13374. &nbsp;
  13375. <a class="summary-letter" href="#Binding-index_bn_letter-U"><b>U</b></a>
  13376. &nbsp;
  13377. <a class="summary-letter" href="#Binding-index_bn_letter-V"><b>V</b></a>
  13378. &nbsp;
  13379. <a class="summary-letter" href="#Binding-index_bn_letter-W"><b>W</b></a>
  13380. &nbsp;
  13381. </td></tr></table>
  13382. <hr>
  13383. <span id="Structure-index"></span><div class="header">
  13384. <p>
  13385. Previous: <a href="#Binding-index" accesskey="p" rel="prev">Binding index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
  13386. </div>
  13387. <span id="Structure-index-1"></span><h2 class="unnumbered">Structure index</h2>
  13388. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Structure-index_st_letter-A"><b>A</b></a>
  13389. &nbsp;
  13390. <a class="summary-letter" href="#Structure-index_st_letter-B"><b>B</b></a>
  13391. &nbsp;
  13392. <a class="summary-letter" href="#Structure-index_st_letter-C"><b>C</b></a>
  13393. &nbsp;
  13394. <a class="summary-letter" href="#Structure-index_st_letter-D"><b>D</b></a>
  13395. &nbsp;
  13396. <a class="summary-letter" href="#Structure-index_st_letter-E"><b>E</b></a>
  13397. &nbsp;
  13398. <a class="summary-letter" href="#Structure-index_st_letter-F"><b>F</b></a>
  13399. &nbsp;
  13400. <a class="summary-letter" href="#Structure-index_st_letter-H"><b>H</b></a>
  13401. &nbsp;
  13402. <a class="summary-letter" href="#Structure-index_st_letter-I"><b>I</b></a>
  13403. &nbsp;
  13404. <a class="summary-letter" href="#Structure-index_st_letter-L"><b>L</b></a>
  13405. &nbsp;
  13406. <a class="summary-letter" href="#Structure-index_st_letter-M"><b>M</b></a>
  13407. &nbsp;
  13408. <a class="summary-letter" href="#Structure-index_st_letter-N"><b>N</b></a>
  13409. &nbsp;
  13410. <a class="summary-letter" href="#Structure-index_st_letter-P"><b>P</b></a>
  13411. &nbsp;
  13412. <a class="summary-letter" href="#Structure-index_st_letter-Q"><b>Q</b></a>
  13413. &nbsp;
  13414. <a class="summary-letter" href="#Structure-index_st_letter-R"><b>R</b></a>
  13415. &nbsp;
  13416. <a class="summary-letter" href="#Structure-index_st_letter-S"><b>S</b></a>
  13417. &nbsp;
  13418. <a class="summary-letter" href="#Structure-index_st_letter-T"><b>T</b></a>
  13419. &nbsp;
  13420. <a class="summary-letter" href="#Structure-index_st_letter-U"><b>U</b></a>
  13421. &nbsp;
  13422. <a class="summary-letter" href="#Structure-index_st_letter-W"><b>W</b></a>
  13423. &nbsp;
  13424. </td></tr></table>
  13425. <table class="index-st" border="0">
  13426. <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
  13427. <tr><td colspan="4"> <hr></td></tr>
  13428. <tr><th id="Structure-index_st_letter-A">A</th><td></td><td></td></tr>
  13429. <tr><td></td><td valign="top"><a href="#index-architecture"><code>architecture</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  13430. <tr><td></td><td valign="top"><a href="#index-arrays-1"><code>arrays</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13431. <tr><td></td><td valign="top"><a href="#index-ascii"><code>ascii</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
  13432. <tr><td colspan="4"> <hr></td></tr>
  13433. <tr><th id="Structure-index_st_letter-B">B</th><td></td><td></td></tr>
  13434. <tr><td></td><td valign="top"><a href="#index-big_002dutil"><code>big-util</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13435. <tr><td></td><td valign="top"><a href="#index-bitwise"><code>bitwise</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  13436. <tr><td></td><td valign="top"><a href="#index-byte_002dvectors"><code>byte-vectors</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
  13437. <tr><td colspan="4"> <hr></td></tr>
  13438. <tr><th id="Structure-index_st_letter-C">C</th><td></td><td></td></tr>
  13439. <tr><td></td><td valign="top"><a href="#index-cells"><code>cells</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Cells">Cells</a></td></tr>
  13440. <tr><td></td><td valign="top"><a href="#index-channel_002di_002fo"><code>channel-i/o</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  13441. <tr><td></td><td valign="top"><a href="#index-channel_002dports"><code>channel-ports</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
  13442. <tr><td></td><td valign="top"><a href="#index-channels-3"><code>channels</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Channels">Channels</a></td></tr>
  13443. <tr><td></td><td valign="top"><a href="#index-code_002dquote-1"><code>code-quote</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13444. <tr><td></td><td valign="top"><a href="#index-conditions-2"><code>conditions</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13445. <tr><td></td><td valign="top"><a href="#index-condvars"><code>condvars</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  13446. <tr><td colspan="4"> <hr></td></tr>
  13447. <tr><th id="Structure-index_st_letter-D">D</th><td></td><td></td></tr>
  13448. <tr><td></td><td valign="top"><a href="#index-debug_002dmessages"><code>debug-messages</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13449. <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtypes"><code>define-record-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13450. <tr><td></td><td valign="top"><a href="#index-define_002dsync_002drecord_002dtypes"><code>define-sync-record-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  13451. <tr><td></td><td valign="top"><a href="#index-defrecord"><code>defrecord</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13452. <tr><td></td><td valign="top"><a href="#index-destructuring"><code>destructuring</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13453. <tr><td></td><td valign="top"><a href="#index-dump_002frestore"><code>dump/restore</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13454. <tr><td></td><td valign="top"><a href="#index-dynamic_002dexternals"><code>dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
  13455. <tr><td></td><td valign="top"><a href="#index-dynamic_002dexternals-1"><code>dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  13456. <tr><td colspan="4"> <hr></td></tr>
  13457. <tr><th id="Structure-index_st_letter-E">E</th><td></td><td></td></tr>
  13458. <tr><td></td><td valign="top"><a href="#index-enum_002dcase-1"><code>enum-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  13459. <tr><td></td><td valign="top"><a href="#index-enum_002dsets"><code>enum-sets</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  13460. <tr><td></td><td valign="top"><a href="#index-enumerated"><code>enumerated</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
  13461. <tr><td></td><td valign="top"><a href="#index-exceptions-1"><code>exceptions</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13462. <tr><td></td><td valign="top"><a href="#index-extended_002dports"><code>extended-ports</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
  13463. <tr><td></td><td valign="top"><a href="#index-external_002dcalls"><code>external-calls</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
  13464. <tr><td></td><td valign="top"><a href="#index-external_002dcalls-1"><code>external-calls</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
  13465. <tr><td colspan="4"> <hr></td></tr>
  13466. <tr><th id="Structure-index_st_letter-F">F</th><td></td><td></td></tr>
  13467. <tr><td></td><td valign="top"><a href="#index-features"><code>features</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13468. <tr><td></td><td valign="top"><a href="#index-filenames"><code>filenames</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
  13469. <tr><td></td><td valign="top"><a href="#index-finite_002dtypes"><code>finite-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
  13470. <tr><td></td><td valign="top"><a href="#index-fluids"><code>fluids</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
  13471. <tr><td></td><td valign="top"><a href="#index-formats"><code>formats</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Common_002dLisp_002dstyle-formatting">Common-Lisp-style formatting</a></td></tr>
  13472. <tr><td colspan="4"> <hr></td></tr>
  13473. <tr><th id="Structure-index_st_letter-H">H</th><td></td><td></td></tr>
  13474. <tr><td></td><td valign="top"><a href="#index-handle"><code>handle</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13475. <tr><td colspan="4"> <hr></td></tr>
  13476. <tr><th id="Structure-index_st_letter-I">I</th><td></td><td></td></tr>
  13477. <tr><td></td><td valign="top"><a href="#index-i_002fo"><code>i/o</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13478. <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal"><code>i/o-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Ports">Ports</a></td></tr>
  13479. <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-1"><code>i/o-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-handlers">Port handlers</a></td></tr>
  13480. <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-2"><code>i/o-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports &amp; handlers</a></td></tr>
  13481. <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-3"><code>i/o-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
  13482. <tr><td colspan="4"> <hr></td></tr>
  13483. <tr><th id="Structure-index_st_letter-L">L</th><td></td><td></td></tr>
  13484. <tr><td></td><td valign="top"><a href="#index-list_002dinterfaces"><code>list-interfaces</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
  13485. <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals-1"><code>load-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
  13486. <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals-2"><code>load-dynamic-externals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
  13487. <tr><td></td><td valign="top"><a href="#index-locks"><code>locks</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
  13488. <tr><td></td><td valign="top"><a href="#index-loopholes"><code>loopholes</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
  13489. <tr><td colspan="4"> <hr></td></tr>
  13490. <tr><th id="Structure-index_st_letter-M">M</th><td></td><td></td></tr>
  13491. <tr><td></td><td valign="top"><a href="#index-mask_002dtypes"><code>mask-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  13492. <tr><td></td><td valign="top"><a href="#index-masks"><code>masks</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
  13493. <tr><td></td><td valign="top"><a href="#index-meta_002dmethods"><code>meta-methods</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  13494. <tr><td></td><td valign="top"><a href="#index-methods"><code>methods</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
  13495. <tr><td></td><td valign="top"><a href="#index-methods-1"><code>methods</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  13496. <tr><td></td><td valign="top"><a href="#index-mvlet-1"><code>mvlet</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13497. <tr><td colspan="4"> <hr></td></tr>
  13498. <tr><th id="Structure-index_st_letter-N">N</th><td></td><td></td></tr>
  13499. <tr><td></td><td valign="top"><a href="#index-nondeterminism-1"><code>nondeterminism</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13500. <tr><td colspan="4"> <hr></td></tr>
  13501. <tr><th id="Structure-index_st_letter-P">P</th><td></td><td></td></tr>
  13502. <tr><td></td><td valign="top"><a href="#index-placeholders"><code>placeholders</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
  13503. <tr><td></td><td valign="top"><a href="#index-ports"><code>ports</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
  13504. <tr><td></td><td valign="top"><a href="#index-posix"><code>posix</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13505. <tr><td></td><td valign="top"><a href="#index-posix_002dfiles"><code>posix-files</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13506. <tr><td></td><td valign="top"><a href="#index-posix_002dfiles-1"><code>posix-files</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
  13507. <tr><td></td><td valign="top"><a href="#index-posix_002di_002fo"><code>posix-i/o</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13508. <tr><td></td><td valign="top"><a href="#index-posix_002di_002fo-1"><code>posix-i/o</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
  13509. <tr><td></td><td valign="top"><a href="#index-posix_002dplatform_002dnames"><code>posix-platform-names</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
  13510. <tr><td></td><td valign="top"><a href="#index-posix_002dprocess_002ddata"><code>posix-process-data</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13511. <tr><td></td><td valign="top"><a href="#index-posix_002dprocess_002ddata-1"><code>posix-process-data</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
  13512. <tr><td></td><td valign="top"><a href="#index-posix_002dprocesses"><code>posix-processes</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13513. <tr><td></td><td valign="top"><a href="#index-posix_002dprocesses-1"><code>posix-processes</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
  13514. <tr><td></td><td valign="top"><a href="#index-posix_002dregexps"><code>posix-regexps</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13515. <tr><td></td><td valign="top"><a href="#index-posix_002dregexps-1"><code>posix-regexps</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13516. <tr><td></td><td valign="top"><a href="#index-posix_002dsignals"><code>posix-signals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
  13517. <tr><td></td><td valign="top"><a href="#index-posix_002dtime"><code>posix-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13518. <tr><td></td><td valign="top"><a href="#index-posix_002dusers"><code>posix-users</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
  13519. <tr><td></td><td valign="top"><a href="#index-posix_002dusers-1"><code>posix-users</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
  13520. <tr><td></td><td valign="top"><a href="#index-pp"><code>pp</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13521. <tr><td></td><td valign="top"><a href="#index-prescheme"><code>prescheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  13522. <tr><td></td><td valign="top"><a href="#index-prescheme-1"><code>prescheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Standard-Pre_002dScheme-environment">Standard Pre-Scheme environment</a></td></tr>
  13523. <tr><td></td><td valign="top"><a href="#index-prescheme-2"><code>prescheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
  13524. <tr><td></td><td valign="top"><a href="#index-prescheme_002dcompiler-1"><code>prescheme-compiler</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a></td></tr>
  13525. <tr><td></td><td valign="top"><a href="#index-proposals-2"><code>proposals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
  13526. <tr><td></td><td valign="top"><a href="#index-ps_002dflonums"><code>ps-flonums</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
  13527. <tr><td></td><td valign="top"><a href="#index-ps_002dflonums-1"><code>ps-flonums</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
  13528. <tr><td></td><td valign="top"><a href="#index-ps_002dmemory"><code>ps-memory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
  13529. <tr><td></td><td valign="top"><a href="#index-ps_002dmemory-1"><code>ps-memory</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
  13530. <tr><td></td><td valign="top"><a href="#index-ps_002dreceive"><code>ps-receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Multiple-return-values-in-Pre_002dScheme">Multiple return values in Pre-Scheme</a></td></tr>
  13531. <tr><td></td><td valign="top"><a href="#index-ps_002dreceive-1"><code>ps-receive</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
  13532. <tr><td></td><td valign="top"><a href="#index-ps_002drecord_002dtypes"><code>ps-record-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a></td></tr>
  13533. <tr><td></td><td valign="top"><a href="#index-ps_002drecord_002dtypes-1"><code>ps-record-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
  13534. <tr><td colspan="4"> <hr></td></tr>
  13535. <tr><th id="Structure-index_st_letter-Q">Q</th><td></td><td></td></tr>
  13536. <tr><td></td><td valign="top"><a href="#index-queues"><code>queues</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Queues">Queues</a></td></tr>
  13537. <tr><td colspan="4"> <hr></td></tr>
  13538. <tr><th id="Structure-index_st_letter-R">R</th><td></td><td></td></tr>
  13539. <tr><td></td><td valign="top"><a href="#index-reading"><code>reading</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Reader">Reader</a></td></tr>
  13540. <tr><td></td><td valign="top"><a href="#index-receiving"><code>receiving</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13541. <tr><td></td><td valign="top"><a href="#index-record_002dtypes"><code>record-types</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13542. <tr><td></td><td valign="top"><a href="#index-records"><code>records</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13543. <tr><td></td><td valign="top"><a href="#index-records_002dinternal"><code>records-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13544. <tr><td></td><td valign="top"><a href="#index-reduce-2"><code>reduce</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Macros-for-writing-loops">Macros for writing loops</a></td></tr>
  13545. <tr><td></td><td valign="top"><a href="#index-regexp"><code>regexp</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
  13546. <tr><td></td><td valign="top"><a href="#index-rendezvous-1"><code>rendezvous</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13547. <tr><td></td><td valign="top"><a href="#index-rendezvous_002dasync_002dchannels"><code>rendezvous-async-channels</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  13548. <tr><td></td><td valign="top"><a href="#index-rendezvous_002dchannels"><code>rendezvous-channels</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
  13549. <tr><td></td><td valign="top"><a href="#index-rendezvous_002djars"><code>rendezvous-jars</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  13550. <tr><td></td><td valign="top"><a href="#index-rendezvous_002dplaceholders"><code>rendezvous-placeholders</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
  13551. <tr><td></td><td valign="top"><a href="#index-rendezvous_002dtime"><code>rendezvous-time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
  13552. <tr><td colspan="4"> <hr></td></tr>
  13553. <tr><th id="Structure-index_st_letter-S">S</th><td></td><td></td></tr>
  13554. <tr><td></td><td valign="top"><a href="#index-scheme"><code>scheme</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
  13555. <tr><td></td><td valign="top"><a href="#index-search_002dtrees"><code>search-trees</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13556. <tr><td></td><td valign="top"><a href="#index-shared_002dbindings"><code>shared-bindings</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
  13557. <tr><td></td><td valign="top"><a href="#index-shared_002dbindings-1"><code>shared-bindings</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
  13558. <tr><td></td><td valign="top"><a href="#index-silly"><code>silly</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
  13559. <tr><td></td><td valign="top"><a href="#index-simple_002dconditions"><code>simple-conditions</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13560. <tr><td></td><td valign="top"><a href="#index-simple_002dsignals"><code>simple-signals</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
  13561. <tr><td></td><td valign="top"><a href="#index-sockets"><code>sockets</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13562. <tr><td></td><td valign="top"><a href="#index-sockets-1"><code>sockets</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13563. <tr><td></td><td valign="top"><a href="#index-sparse_002dvectors"><code>sparse-vectors</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
  13564. <tr><td></td><td valign="top"><a href="#index-spatial"><code>spatial</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13565. <tr><td></td><td valign="top"><a href="#index-srfi_002d7"><code>srfi-7</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
  13566. <tr><td></td><td valign="top"><a href="#index-srfi_002d9"><code>srfi-9</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Records">Records</a></td></tr>
  13567. <tr><td></td><td valign="top"><a href="#index-strong"><code>strong</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13568. <tr><td></td><td valign="top"><a href="#index-structure_002drefs"><code>structure-refs</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
  13569. <tr><td colspan="4"> <hr></td></tr>
  13570. <tr><th id="Structure-index_st_letter-T">T</th><td></td><td></td></tr>
  13571. <tr><td></td><td valign="top"><a href="#index-tables"><code>tables</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
  13572. <tr><td></td><td valign="top"><a href="#index-threads"><code>threads</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
  13573. <tr><td></td><td valign="top"><a href="#index-threads_002dinternal"><code>threads-internal</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
  13574. <tr><td></td><td valign="top"><a href="#index-time-2"><code>time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
  13575. <tr><td></td><td valign="top"><a href="#index-traverse"><code>traverse</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
  13576. <tr><td colspan="4"> <hr></td></tr>
  13577. <tr><th id="Structure-index_st_letter-U">U</th><td></td><td></td></tr>
  13578. <tr><td></td><td valign="top"><a href="#index-udp_002dsockets"><code>udp-sockets</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13579. <tr><td></td><td valign="top"><a href="#index-udp_002dsockets-1"><code>udp-sockets</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP &amp; UDP sockets</a></td></tr>
  13580. <tr><td></td><td valign="top"><a href="#index-usual_002dresumer-1"><code>usual-resumer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  13581. <tr><td></td><td valign="top"><a href="#index-util"><code>util</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
  13582. <tr><td colspan="4"> <hr></td></tr>
  13583. <tr><th id="Structure-index_st_letter-W">W</th><td></td><td></td></tr>
  13584. <tr><td></td><td valign="top"><a href="#index-weak"><code>weak</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
  13585. <tr><td></td><td valign="top"><a href="#index-write_002dimages"><code>write-images</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
  13586. <tr><td></td><td valign="top"><a href="#index-writing"><code>writing</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Writer">Writer</a></td></tr>
  13587. <tr><td colspan="4"> <hr></td></tr>
  13588. </table>
  13589. <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Structure-index_st_letter-A"><b>A</b></a>
  13590. &nbsp;
  13591. <a class="summary-letter" href="#Structure-index_st_letter-B"><b>B</b></a>
  13592. &nbsp;
  13593. <a class="summary-letter" href="#Structure-index_st_letter-C"><b>C</b></a>
  13594. &nbsp;
  13595. <a class="summary-letter" href="#Structure-index_st_letter-D"><b>D</b></a>
  13596. &nbsp;
  13597. <a class="summary-letter" href="#Structure-index_st_letter-E"><b>E</b></a>
  13598. &nbsp;
  13599. <a class="summary-letter" href="#Structure-index_st_letter-F"><b>F</b></a>
  13600. &nbsp;
  13601. <a class="summary-letter" href="#Structure-index_st_letter-H"><b>H</b></a>
  13602. &nbsp;
  13603. <a class="summary-letter" href="#Structure-index_st_letter-I"><b>I</b></a>
  13604. &nbsp;
  13605. <a class="summary-letter" href="#Structure-index_st_letter-L"><b>L</b></a>
  13606. &nbsp;
  13607. <a class="summary-letter" href="#Structure-index_st_letter-M"><b>M</b></a>
  13608. &nbsp;
  13609. <a class="summary-letter" href="#Structure-index_st_letter-N"><b>N</b></a>
  13610. &nbsp;
  13611. <a class="summary-letter" href="#Structure-index_st_letter-P"><b>P</b></a>
  13612. &nbsp;
  13613. <a class="summary-letter" href="#Structure-index_st_letter-Q"><b>Q</b></a>
  13614. &nbsp;
  13615. <a class="summary-letter" href="#Structure-index_st_letter-R"><b>R</b></a>
  13616. &nbsp;
  13617. <a class="summary-letter" href="#Structure-index_st_letter-S"><b>S</b></a>
  13618. &nbsp;
  13619. <a class="summary-letter" href="#Structure-index_st_letter-T"><b>T</b></a>
  13620. &nbsp;
  13621. <a class="summary-letter" href="#Structure-index_st_letter-U"><b>U</b></a>
  13622. &nbsp;
  13623. <a class="summary-letter" href="#Structure-index_st_letter-W"><b>W</b></a>
  13624. &nbsp;
  13625. </td></tr></table>
  13626. <div class="footnote">
  13627. <hr>
  13628. <h4 class="footnotes-heading">Footnotes</h4>
  13629. <h5><a id="FOOT1" href="#DOCF1">(1)</a></h3>
  13630. <p>The
  13631. Scheme48 team is also working on a new, generational garbage collector,
  13632. but it is not in the standard distribution of Scheme48 yet.</p>
  13633. <h5><a id="FOOT2" href="#DOCF2">(2)</a></h3>
  13634. <p><samp>scheme48.el</samp> is based on the older
  13635. <samp>cmuscheme48.el</samp>, which is bundled with Scheme48 in the
  13636. <samp>emacs/</samp> directory. Since <samp>cmuscheme48.el</samp> is older and less
  13637. developed, it is not documented here.</p>
  13638. <h5><a id="FOOT3" href="#DOCF3">(3)</a></h3>
  13639. <p>Darcs is a revision control
  13640. system; see
  13641. </p>
  13642. <div class="display">
  13643. <pre class="display"><a href="http://www.darcs.net/">http://www.darcs.net/</a></pre></div>
  13644. <p>for more details.</p>
  13645. <h5><a id="FOOT4" href="#DOCF4">(4)</a></h3>
  13646. <p>A description of the byte code is forthcoming, although
  13647. it does not have much priority to this manual&rsquo;s author. For now, users
  13648. can read the rudimentary descriptions of the Scheme48 virtual machine&rsquo;s
  13649. byte code instruction set in <samp>vm/interp/arch.scm</samp> of Scheme48&rsquo;s
  13650. Scheme source.</p>
  13651. <h5><a id="FOOT5" href="#DOCF5">(5)</a></h3>
  13652. <p>This is in contrast to, for example, Common Lisp&rsquo;s
  13653. package system, which controls the mapping from strings to names.</p>
  13654. <h5><a id="FOOT6" href="#DOCF6">(6)</a></h3>
  13655. <p>The current implementation,
  13656. however, does not detect this. Instead it uses the left-most structure
  13657. in the list of a package&rsquo;s <code>open</code> clause; see the next section for
  13658. details on this.</p>
  13659. <h5><a id="FOOT7" href="#DOCF7">(7)</a></h3>
  13660. <p>While such facilities are
  13661. not built-in to Scheme48, there is a package to do this, which will
  13662. probably be integrated at some point soon into Scheme48.</p>
  13663. <h5><a id="FOOT8" href="#DOCF8">(8)</a></h3>
  13664. <p>This would be more
  13665. accurately named &lsquo;syntactic tower,&rsquo; as it has nothing to do with
  13666. reflection.</p>
  13667. <h5><a id="FOOT9" href="#DOCF9">(9)</a></h3>
  13668. <p>This is actually only
  13669. in the default config package of the default development environment.
  13670. The full mechanism is very general.</p>
  13671. <h5><a id="FOOT10" href="#DOCF10">(10)</a></h3>
  13672. <p>The author of this manual is not at fault for
  13673. this nomenclature.</p>
  13674. <h5><a id="FOOT11" href="#DOCF11">(11)</a></h3>
  13675. <p>On Unix,
  13676. this is <code>stderr</code>, the standard I/O error output file.</p>
  13677. <h5><a id="FOOT12" href="#DOCF12">(12)</a></h3>
  13678. <p>Continuations here are in the
  13679. sense of VM stack frames, not escape procedures as obtained using
  13680. <code>call-with-current-continuation</code>.</p>
  13681. <h5><a id="FOOT13" href="#DOCF13">(13)</a></h3>
  13682. <p>The facilities Scheme48 provides
  13683. are very rudimentary, and they are not intended to act as a coherent
  13684. and comprehensive pathname or logical name facility such as that of
  13685. Common Lisp. However, they served the basic needs of Scheme48&rsquo;s build
  13686. process when they were originally created.</p>
  13687. <h5><a id="FOOT14" href="#DOCF14">(14)</a></h3>
  13688. <p>However, the current standard distribution
  13689. of Scheme48 is specific to Unix: the current code implements only Unix
  13690. filename facilities.</p>
  13691. <h5><a id="FOOT15" href="#DOCF15">(15)</a></h3>
  13692. <p>For the
  13693. sake of avoiding any potential copyright issues, the paper is not
  13694. duplicated here, and instead the author of this manual has written the
  13695. entirety of this section.</p>
  13696. <h5><a id="FOOT16" href="#DOCF16">(16)</a></h3>
  13697. <p>However, the current compiler in Scheme48
  13698. does not require this, though the static linker does.</p>
  13699. <h5><a id="FOOT17" href="#DOCF17">(17)</a></h3>
  13700. <p>Note, however,
  13701. that Scheme48&rsquo;s condition system is likely to be superseded in the near
  13702. future by [SRFI 34, SRFI 35].</p>
  13703. <h5><a id="FOOT18" href="#DOCF18">(18)</a></h3>
  13704. <p>There is an internal interface, a
  13705. sort of meta-object protocol, to the method dispatch system, but it is
  13706. not yet documented.</p>
  13707. <h5><a id="FOOT19" href="#DOCF19">(19)</a></h3>
  13708. <p>For example, the author of this manual, merely out of
  13709. curiosity, compared the sizes of two images: one that used the usual
  13710. resumer and printed each of its command-line arguments, and one that
  13711. performed <em>no</em> run-time system initialization &mdash; which eliminated
  13712. the run-time system in the image, because it was untraceable from the
  13713. resumer &mdash; and wrote directly to the standard output channel. The
  13714. difference was a factor of about twenty. However, also note that the
  13715. difference is constant; the run-time system happened to account for
  13716. nineteen twentieths of the larger image.</p>
  13717. <h5><a id="FOOT20" href="#DOCF20">(20)</a></h3>
  13718. <p>In the original CML, these were called
  13719. <em>events</em>, but that term was deemed too overloaded and confusing
  13720. when Scheme48&rsquo;s library was developed.</p>
  13721. <h5><a id="FOOT21" href="#DOCF21">(21)</a></h3>
  13722. <p>Known as <em>mailboxes</em> in Reppy&rsquo;s original CML.</p>
  13723. <h5><a id="FOOT22" href="#DOCF22">(22)</a></h3>
  13724. <p>However, asynchronous channels are
  13725. implemented by a thread that manages two synchronous channels (one for
  13726. sends &amp; one for receives), so this may block briefly if the thread is
  13727. busy receiving other send or receive requests.</p>
  13728. <h5><a id="FOOT23" href="#DOCF23">(23)</a></h3>
  13729. <p>Called <em>I-variables</em> in Reppy&rsquo;s CML,
  13730. and <em>I-structures</em> in ID-90.</p>
  13731. <h5><a id="FOOT24" href="#DOCF24">(24)</a></h3>
  13732. <p>Termed <em>M-variables</em> in Reppy&rsquo;s CML.</p>
  13733. <h5><a id="FOOT25" href="#DOCF25">(25)</a></h3>
  13734. <p>In the current implementation on
  13735. Unix, this moment happens to be the first call to <code>real-time</code>; on
  13736. Win32, this is the start of the Scheme process.</p>
  13737. <h5><a id="FOOT26" href="#DOCF26">(26)</a></h3>
  13738. <p>This is clearly
  13739. a problem; we are working on a solution.</p>
  13740. <h5><a id="FOOT27" href="#DOCF27">(27)</a></h3>
  13741. <p>It
  13742. may be possible to use Pre-Scheme&rsquo;s C FFI to manually use <code>setjmp</code>
  13743. &amp; <code>longjmp</code>, but the author of this manual cannot attest to this
  13744. working.</p>
  13745. <h5><a id="FOOT28" href="#DOCF28">(28)</a></h3>
  13746. <p>Scheme48&rsquo;s VM does not use Pre-Scheme&rsquo;s built-in I/O
  13747. facilities to implement <a href="#Channels">channels</a> &mdash; it builds its
  13748. own lower-level facilities that are still OS-independent, but, because
  13749. they&rsquo;re written individually for different OSs, they integrate better
  13750. as low-level I/O channels with the OS. On Unix, the Scheme48 VM uses
  13751. file descriptors; Pre-Scheme&rsquo;s built-in I/O uses <code>stdio</code>.
  13752. Scheme48&rsquo;s VM uses Pre-Scheme&rsquo;s built-in I/O only to read heap images.</p>
  13753. <h5><a id="FOOT29" href="#DOCF29">(29)</a></h3>
  13754. <p>The actual distribution of Scheme48 separates the garbage
  13755. collector and the main virtual machine.</p>
  13756. </div>
  13757. <hr>
  13758. </body>
  13759. </html>