12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- This manual is for Scheme48 version 1.3.
- Copyright (C) 2004, 2005, 2006 Taylor Campbell.
- All rights reserved.
- This manual includes material derived from works bearing the following
- notice:
- Copyright (C) 1993-2005 Richard Kelsey, Jonathan Rees, and
- Mike Sperber.
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- The name of the authors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
- THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- -->
- <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>The Nearly Complete Scheme48 1.3 Reference Manual</title>
- <meta name="description" content="The Nearly Complete Scheme48 1.3 Reference Manual">
- <meta name="keywords" content="The Nearly Complete Scheme48 1.3 Reference Manual">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="#Top" rel="start" title="Top">
- <link href="#Concept-index" rel="index" title="Concept index">
- <link href="#SEC_Contents" rel="contents" title="Table of Contents">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
- </head>
- <body lang="en">
- <h1 class="settitle" align="center">The Nearly Complete Scheme48 1.3 Reference Manual</h1>
- <span id="SEC_Contents"></span>
- <h2 class="contents-heading">Table of Contents</h2>
- <div class="contents">
- <ul class="no-bullet">
- <li><a id="toc-Introduction" href="#Introduction-_0026-acknowledgements">1 Introduction</a>
- <ul class="no-bullet">
- <li><a id="toc-This-manual" href="#This-manual">1.1 This manual</a></li>
- <li><a id="toc-Acknowledgements" href="#Acknowledgements">1.2 Acknowledgements</a></li>
- </ul></li>
- <li><a id="toc-User-environment-1" href="#User-environment">2 User environment</a>
- <ul class="no-bullet">
- <li><a id="toc-Running-Scheme48-1" href="#Running-Scheme48">2.1 Running Scheme48</a>
- <ul class="no-bullet">
- <li><a id="toc-Command-processor-introduction" href="#Command-processor-introduction">2.1.1 Command processor introduction</a></li>
- </ul></li>
- <li><a id="toc-Emacs-integration-1" href="#Emacs-integration">2.2 Emacs integration</a></li>
- <li><a id="toc-Using-the-module-system-1" href="#Using-the-module-system">2.3 Using the module system</a>
- <ul class="no-bullet">
- <li><a id="toc-Configuration-mutation" href="#Configuration-mutation">2.3.1 Configuration mutation</a></li>
- <li><a id="toc-Listing-interfaces" href="#Listing-interfaces">2.3.2 Listing interfaces</a></li>
- </ul></li>
- <li><a id="toc-Command-processor-1" href="#Command-processor">2.4 Command processor</a>
- <ul class="no-bullet">
- <li><a id="toc-Basic-commands-1" href="#Basic-commands">2.4.1 Basic commands</a></li>
- <li><a id="toc-Switches" href="#Command-processor-switches">2.4.2 Switches</a></li>
- <li><a id="toc-Emacs-integration-commands-1" href="#Emacs-integration-commands">2.4.3 Emacs integration commands</a></li>
- <li><a id="toc-Focus-value-1" href="#Focus-value">2.4.4 Focus value</a></li>
- <li><a id="toc-Command-levels-1" href="#Command-levels">2.4.5 Command levels</a></li>
- <li><a id="toc-Module-commands-1" href="#Module-commands">2.4.6 Module commands</a></li>
- <li><a id="toc-SRFI-7-1" href="#SRFI-7">2.4.7 SRFI 7</a></li>
- <li><a id="toc-Debugging-commands-1" href="#Debugging-commands">2.4.8 Debugging commands</a></li>
- <li><a id="toc-Inspector-1" href="#Inspector">2.4.9 Inspector</a></li>
- <li><a id="toc-Command-programs-1" href="#Command-programs">2.4.10 Command programs</a></li>
- <li><a id="toc-Image_002dbuilding-commands-1" href="#Image_002dbuilding-commands">2.4.11 Image-building commands</a></li>
- <li><a id="toc-Resource-statistics-and-control-1" href="#Resource-statistics-and-control">2.4.12 Resource statistics and control</a></li>
- </ul></li>
- </ul></li>
- <li><a id="toc-Module-system-1" href="#Module-system">3 Module system</a>
- <ul class="no-bullet">
- <li><a id="toc-Module-system-architecture-1" href="#Module-system-architecture">3.1 Module system architecture</a></li>
- <li><a id="toc-Module-configuration-language-1" href="#Module-configuration-language">3.2 Module configuration language</a></li>
- <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>
- <li><a id="toc-Static-type-system-1" href="#Static-type-system">3.4 Static type system</a>
- <ul class="no-bullet">
- <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>
- </ul></li>
- </ul></li>
- <li><a id="toc-System-facilities-1" href="#System-facilities">4 System facilities</a>
- <ul class="no-bullet">
- <li><a id="toc-System-features-1" href="#System-features">4.1 System features</a>
- <ul class="no-bullet">
- <li><a id="toc-Miscellaneous-features-1" href="#Miscellaneous-features">4.1.1 Miscellaneous features</a></li>
- <li><a id="toc-Various-utilities-1" href="#Various-utilities">4.1.2 Various utilities</a></li>
- <li><a id="toc-Filenames-1" href="#Filenames">4.1.3 Filenames</a>
- <ul class="no-bullet">
- <li><a id="toc-Filename-translations" href="#Filename-translations">4.1.3.1 Filename translations</a></li>
- </ul></li>
- <li><a id="toc-Fluid_002fdynamic-bindings-1" href="#Fluid_002fdynamic-bindings">4.1.4 Fluid/dynamic bindings</a></li>
- <li><a id="toc-ASCII-character-encoding-1" href="#ASCII-character-encoding">4.1.5 ASCII character encoding</a></li>
- <li><a id="toc-Integer-enumerations-1" href="#Integer-enumerations">4.1.6 Integer enumerations</a></li>
- <li><a id="toc-Cells-1" href="#Cells">4.1.7 Cells</a></li>
- <li><a id="toc-Queues-1" href="#Queues">4.1.8 Queues</a></li>
- <li><a id="toc-Hash-tables-1" href="#Hash-tables">4.1.9 Hash tables</a></li>
- <li><a id="toc-Weak-references-1" href="#Weak-references">4.1.10 Weak references</a>
- <ul class="no-bullet">
- <li><a id="toc-Weak-pointers" href="#Weak-pointers">4.1.10.1 Weak pointers</a></li>
- <li><a id="toc-Populations-_0028weak-sets_0029" href="#Populations-_0028weak-sets_0029">4.1.10.2 Populations (weak sets)</a></li>
- </ul></li>
- <li><a id="toc-Type-annotations-1" href="#Type-annotations">4.1.11 Type annotations</a></li>
- <li><a id="toc-Explicit-renaming-macros-1" href="#Explicit-renaming-macros">4.1.12 Explicit renaming macros</a></li>
- </ul></li>
- <li><a id="toc-Condition-system-1" href="#Condition-system">4.2 Condition system</a>
- <ul class="no-bullet">
- <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>
- <li><a id="toc-Displaying-conditions" href="#Displaying-conditions">4.2.2 Displaying conditions</a></li>
- </ul></li>
- <li><a id="toc-Bitwise-manipulation-1" href="#Bitwise-manipulation">4.3 Bitwise manipulation</a>
- <ul class="no-bullet">
- <li><a id="toc-Bitwise-integer-operations" href="#Bitwise-integer-operations">4.3.1 Bitwise integer operations</a></li>
- <li><a id="toc-Byte-vectors" href="#Byte-vectors">4.3.2 Byte vectors</a></li>
- </ul></li>
- <li><a id="toc-Generic-dispatch-system-1" href="#Generic-dispatch-system">4.4 Generic dispatch system</a></li>
- <li><a id="toc-I_002fO-system-1" href="#I_002fO-system">4.5 I/O system</a>
- <ul class="no-bullet">
- <li><a id="toc-Ports-1" href="#Ports">4.5.1 Ports</a>
- <ul class="no-bullet">
- <li><a id="toc-Port-operations" href="#Port-operations">4.5.1.1 Port operations</a></li>
- <li><a id="toc-Current-ports" href="#Current-ports">4.5.1.2 Current ports</a></li>
- </ul></li>
- <li><a id="toc-Programmatic-ports-1" href="#Programmatic-ports">4.5.2 Programmatic ports</a>
- <ul class="no-bullet">
- <li><a id="toc-Port-data-type-1" href="#Port-data-type">4.5.2.1 Port data type</a></li>
- <li><a id="toc-Port-handlers-1" href="#Port-handlers">4.5.2.2 Port handlers</a></li>
- <li><a id="toc-Buffered-ports-_0026-handlers-1" href="#Buffered-ports-_0026-handlers">4.5.2.3 Buffered ports & handlers</a></li>
- </ul></li>
- <li><a id="toc-Miscellaneous-I_002fO-internals-1" href="#Miscellaneous-I_002fO-internals">4.5.3 Miscellaneous I/O internals</a></li>
- <li><a id="toc-Channels-1" href="#Channels">4.5.4 Channels</a>
- <ul class="no-bullet">
- <li><a id="toc-Low_002dlevel-channel-operations" href="#Low_002dlevel-channel-operations">4.5.4.1 Low-level channel operations</a></li>
- <li><a id="toc-Higher_002dlevel-channel-operations" href="#Higher_002dlevel-channel-operations">4.5.4.2 Higher-level channel operations</a></li>
- </ul></li>
- <li><a id="toc-Channel-ports-1" href="#Channel-ports">4.5.5 Channel ports</a></li>
- </ul></li>
- <li><a id="toc-Reader-_0026-writer-1" href="#Reader-_0026-writer">4.6 Reader & writer</a>
- <ul class="no-bullet">
- <li><a id="toc-Reader-1" href="#Reader">4.6.1 Reader</a></li>
- <li><a id="toc-Writer-1" href="#Writer">4.6.2 Writer</a>
- <ul class="no-bullet">
- <li><a id="toc-Object-disclosure" href="#Object-disclosure">4.6.2.1 Object disclosure</a></li>
- </ul></li>
- </ul></li>
- <li><a id="toc-Records-1" href="#Records">4.7 Records</a>
- <ul class="no-bullet">
- <li><a id="toc-Jonathan-Rees_0027s-define_002drecord_002dtype-macro" href="#Jonathan-Rees_0027s-define_002drecord_002dtype-macro">4.7.1 Jonathan Rees’s <code>define-record-type</code> macro</a></li>
- <li><a id="toc-Richard-Kelsey_0027s-define_002drecord_002dtype-macro" href="#Richard-Kelsey_0027s-define_002drecord_002dtype-macro">4.7.2 Richard Kelsey’s <code>define-record-type</code> macro</a></li>
- <li><a id="toc-Record-types" href="#Record-types">4.7.3 Record types</a></li>
- <li><a id="toc-Low_002dlevel-record-manipulation" href="#Low_002dlevel-record-manipulation">4.7.4 Low-level record manipulation</a></li>
- </ul></li>
- <li><a id="toc-Suspending-and-resuming-heap-images-1" href="#Suspending-and-resuming-heap-images">4.8 Suspending and resuming heap images</a>
- <ul class="no-bullet">
- <li><a id="toc-System-initialization" href="#System-initialization">4.8.1 System initialization</a></li>
- <li><a id="toc-Manual-system-initialization" href="#Manual-system-initialization">4.8.2 Manual system initialization</a></li>
- </ul></li>
- </ul></li>
- <li><a id="toc-Multithreading-1" href="#Multithreading">5 Multithreading</a>
- <ul class="no-bullet">
- <li><a id="toc-Basic-thread-operations-1" href="#Basic-thread-operations">5.1 Basic thread operations</a></li>
- <li><a id="toc-Optimistic-concurrency-1" href="#Optimistic-concurrency">5.2 Optimistic concurrency</a>
- <ul class="no-bullet">
- <li><a id="toc-High_002dlevel-optimistic-concurrency" href="#High_002dlevel-optimistic-concurrency">5.2.1 High-level optimistic concurrency</a></li>
- <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>
- <li><a id="toc-Synchronized-records" href="#Synchronized-records">5.2.3 Synchronized records</a></li>
- <li><a id="toc-Optimistic-concurrency-example" href="#Optimistic-concurrency-example">5.2.4 Optimistic concurrency example</a></li>
- <li><a id="toc-Low_002dlevel-optimistic-concurrency" href="#Low_002dlevel-optimistic-concurrency">5.2.5 Low-level optimistic concurrency</a></li>
- </ul></li>
- <li><a id="toc-Higher_002dlevel-synchronization-1" href="#Higher_002dlevel-synchronization">5.3 Higher-level synchronization</a>
- <ul class="no-bullet">
- <li><a id="toc-Condition-variables" href="#Condition-variables">5.3.1 Condition variables</a></li>
- <li><a id="toc-Placeholders" href="#Placeholders">5.3.2 Placeholders</a></li>
- <li><a id="toc-Value-pipes" href="#Value-pipes">5.3.3 Value pipes</a></li>
- </ul></li>
- <li><a id="toc-Concurrent-ML-1" href="#Concurrent-ML">5.4 Concurrent ML</a>
- <ul class="no-bullet">
- <li><a id="toc-Rendezvous-concepts-1" href="#Rendezvous-concepts">5.4.1 Rendezvous concepts</a></li>
- <li><a id="toc-Delayed-rendezvous" href="#Delayed-rendezvous">5.4.2 Delayed rendezvous</a>
- <ul class="no-bullet">
- <li><a id="toc-Negative-acknowledgements" href="#Negative-acknowledgements">5.4.2.1 Negative acknowledgements</a></li>
- </ul></li>
- <li><a id="toc-Rendezvous-combinators" href="#Rendezvous-base-combinators">5.4.3 Rendezvous combinators</a>
- <ul class="no-bullet">
- <li><a id="toc-Timing-rendezvous" href="#Timing-rendezvous">5.4.3.1 Timing rendezvous</a></li>
- </ul></li>
- <li><a id="toc-Rendezvous-communication-channels-1" href="#Rendezvous-communication-channels">5.4.4 Rendezvous communication channels</a>
- <ul class="no-bullet">
- <li><a id="toc-Synchronous-channels" href="#Synchronous-channels">5.4.4.1 Synchronous channels</a></li>
- <li><a id="toc-Asynchronous-channels" href="#Asynchronous-channels">5.4.4.2 Asynchronous channels</a></li>
- </ul></li>
- <li><a id="toc-Rendezvous_002dsynchronized-cells-1" href="#Rendezvous_002dsynchronized-cells">5.4.5 Rendezvous-synchronized cells</a>
- <ul class="no-bullet">
- <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>
- <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>
- </ul></li>
- <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>
- </ul></li>
- <li><a id="toc-Pessimistic-concurrency-1" href="#Pessimistic-concurrency">5.5 Pessimistic concurrency</a></li>
- <li><a id="toc-Custom-thread-synchronization-1" href="#Custom-thread-synchronization">5.6 Custom thread synchronization</a></li>
- </ul></li>
- <li><a id="toc-Libraries-1" href="#Libraries">6 Libraries</a>
- <ul class="no-bullet">
- <li><a id="toc-Boxed-bitwise_002dinteger-masks-1" href="#Boxed-bitwise_002dinteger-masks">6.1 Boxed bitwise-integer masks</a>
- <ul class="no-bullet">
- <li><a id="toc-Mask-types" href="#Mask-types">6.1.1 Mask types</a></li>
- <li><a id="toc-Masks" href="#Masks">6.1.2 Masks</a></li>
- </ul></li>
- <li><a id="toc-Enumerated_002ffinite-types-and-sets-1" href="#Enumerated_002ffinite-types-and-sets">6.2 Enumerated/finite types and sets</a>
- <ul class="no-bullet">
- <li><a id="toc-Enumerated_002ffinite-types" href="#Enumerated_002ffinite-types">6.2.1 Enumerated/finite types</a></li>
- <li><a id="toc-Sets-over-enumerated-types" href="#Sets-over-enumerated-types">6.2.2 Sets over enumerated types</a></li>
- </ul></li>
- <li><a id="toc-Macros-for-writing-loops-1" href="#Macros-for-writing-loops">6.3 Macros for writing loops</a>
- <ul class="no-bullet">
- <li><a id="toc-Main-looping-macros-1" href="#Main-looping-macros">6.3.1 Main looping macros</a></li>
- <li><a id="toc-Sequence-types-1" href="#Sequence-types">6.3.2 Sequence types</a></li>
- <li><a id="toc-Synchronous-sequences-1" href="#Synchronous-sequences">6.3.3 Synchronous sequences</a></li>
- <li><a id="toc-Examples-1" href="#Examples">6.3.4 Examples</a></li>
- <li><a id="toc-Defining-sequence-types-1" href="#Defining-sequence-types">6.3.5 Defining sequence types</a></li>
- <li><a id="toc-Loop-macro-expansion-1" href="#Loop-macro-expansion">6.3.6 Loop macro expansion</a></li>
- </ul></li>
- <li><a id="toc-Library-data-structures-1" href="#Library-data-structures">6.4 Library data structures</a>
- <ul class="no-bullet">
- <li><a id="toc-Multi_002ddimensional-arrays" href="#Multi_002ddimensional-arrays">6.4.1 Multi-dimensional arrays</a></li>
- <li><a id="toc-Red_002fblack-search-trees" href="#Red_002fblack-search-trees">6.4.2 Red/black search trees</a></li>
- <li><a id="toc-Sparse-vectors" href="#Sparse-vectors">6.4.3 Sparse vectors</a></li>
- </ul></li>
- <li><a id="toc-I_002fO-extensions-1" href="#I_002fO-extensions">6.5 I/O extensions</a></li>
- <li><a id="toc-TCP-_0026-UDP-sockets-1" href="#TCP-_0026-UDP-sockets">6.6 TCP & UDP sockets</a>
- <ul class="no-bullet">
- <li><a id="toc-TCP-sockets" href="#TCP-sockets">6.6.1 TCP sockets</a></li>
- <li><a id="toc-UDP-sockets" href="#UDP-sockets">6.6.2 UDP sockets</a></li>
- </ul></li>
- <li><a id="toc-Common_002dLisp_002dstyle-formatting-1" href="#Common_002dLisp_002dstyle-formatting">6.7 Common-Lisp-style formatting</a></li>
- <li><a id="toc-Library-utilities-1" href="#Library-utilities">6.8 Library utilities</a>
- <ul class="no-bullet">
- <li><a id="toc-Destructuring" href="#Destructuring">6.8.1 Destructuring</a></li>
- <li><a id="toc-Pretty_002dprinting" href="#Pretty_002dprinting">6.8.2 Pretty-printing</a></li>
- <li><a id="toc-Strongly-connected-graph-components" href="#Strongly-connected-graph-components">6.8.3 Strongly connected graph components</a></li>
- <li><a id="toc-Nondeterminism" href="#Nondeterminism">6.8.4 Nondeterminism</a></li>
- <li><a id="toc-Miscellaneous-utilities" href="#Miscellaneous-utilities">6.8.5 Miscellaneous utilities</a></li>
- <li><a id="toc-Multiple-value-binding" href="#Multiple-value-binding">6.8.6 Multiple value binding</a></li>
- <li><a id="toc-Object-dumper" href="#Object-dumper">6.8.7 Object dumper</a></li>
- <li><a id="toc-Simple-time-access" href="#Simple-time-access">6.8.8 Simple time access</a></li>
- </ul></li>
- </ul></li>
- <li><a id="toc-C-interface-1" href="#C-interface">7 C interface</a>
- <ul class="no-bullet">
- <li><a id="toc-Overview-of-the-C-interface" href="#Overview-of-the-C-interface">7.1 Overview of the C interface</a>
- <ul class="no-bullet">
- <li><a id="toc-Scheme-structures" href="#Scheme-structures">7.1.1 Scheme structures</a></li>
- <li><a id="toc-C-naming-conventions" href="#C-naming-conventions">7.1.2 C naming conventions</a></li>
- <li><a id="toc-Garbage-collection" href="#Garbage-collection">7.1.3 Garbage collection</a></li>
- </ul></li>
- <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>
- <ul class="no-bullet">
- <li><a id="toc-Scheme-shared-binding-interface" href="#Scheme-shared-binding-interface">7.2.1 Scheme shared binding interface</a></li>
- <li><a id="toc-C-shared-binding-interface" href="#C-shared-binding-interface">7.2.2 C shared binding interface</a></li>
- </ul></li>
- <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>
- <li><a id="toc-Dynamic-loading-of-C-modules-1" href="#Dynamic-loading-of-C-modules">7.4 Dynamic loading of C modules</a>
- <ul class="no-bullet">
- <li><a id="toc-Old-dynamic-loading-interface" href="#Old-dynamic-loading-interface">7.4.1 Old dynamic loading interface</a></li>
- </ul></li>
- <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>
- <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>
- <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>
- <ul class="no-bullet">
- <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>
- <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>
- </ul></li>
- <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>
- <li><a id="toc-Raising-exceptions-from-C-1" href="#Raising-exceptions-from-C">7.9 Raising exceptions from C</a></li>
- <li><a id="toc-Unsafe-C-macros-1" href="#Unsafe-C-macros">7.10 Unsafe C macros</a></li>
- </ul></li>
- <li><a id="toc-POSIX-interface-1" href="#POSIX-interface">8 POSIX interface</a>
- <ul class="no-bullet">
- <li><a id="toc-Processes" href="#POSIX-processes">8.1 Processes</a></li>
- <li><a id="toc-Signals" href="#POSIX-signals">8.2 Signals</a>
- <ul class="no-bullet">
- <li><a id="toc-Sending-_0026-receiving-signals" href="#Sending-_0026-receiving-signals">8.2.1 Sending & receiving signals</a></li>
- </ul></li>
- <li><a id="toc-Process-environment" href="#POSIX-process-environment">8.3 Process environment</a></li>
- <li><a id="toc-Users-and-groups" href="#POSIX-users-and-groups">8.4 Users and groups</a></li>
- <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>
- <li><a id="toc-File-system-access" href="#POSIX-file-system-access">8.6 File system access</a></li>
- <li><a id="toc-Time" href="#POSIX-time">8.7 Time</a></li>
- <li><a id="toc-I_002fO-utilities" href="#POSIX-I_002fO-utilities">8.8 I/O utilities</a></li>
- <li><a id="toc-Regular-expressions" href="#POSIX-regular-expressions">8.9 Regular expressions</a>
- <ul class="no-bullet">
- <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>
- <li><a id="toc-High_002dlevel-regular-expression-construction" href="#High_002dlevel-regular-expression-construction">8.9.2 High-level regular expression construction</a>
- <ul class="no-bullet">
- <li><a id="toc-Character-sets" href="#Character-sets">8.9.2.1 Character sets</a></li>
- <li><a id="toc-Anchoring" href="#Anchoring">8.9.2.2 Anchoring</a></li>
- <li><a id="toc-Composite-expressions" href="#Composite-expressions">8.9.2.3 Composite expressions</a></li>
- <li><a id="toc-Case-sensitivity" href="#Case-sensitivity">8.9.2.4 Case sensitivity</a></li>
- <li><a id="toc-Submatches-and-matching" href="#Submatches-and-matching">8.9.2.5 Submatches and matching</a></li>
- </ul></li>
- </ul></li>
- <li><a id="toc-C-to-Scheme-correspondence" href="#POSIX-C-to-Scheme-correspondence">8.10 C to Scheme correspondence</a></li>
- </ul></li>
- <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>
- <ul class="no-bullet">
- <li><a id="toc-Differences-between-Pre_002dScheme-_0026-Scheme-1" href="#Differences-between-Pre_002dScheme-_0026-Scheme">9.1 Differences between Pre-Scheme & Scheme</a></li>
- <li><a id="toc-Type-specifiers" href="#Pre_002dScheme-type-specifiers">9.2 Type specifiers</a></li>
- <li><a id="toc-Standard-environment" href="#Standard-Pre_002dScheme-environment">9.3 Standard environment</a>
- <ul class="no-bullet">
- <li><a id="toc-Scheme-bindings" href="#Scheme-bindings-in-Pre_002dScheme">9.3.1 Scheme bindings</a></li>
- <li><a id="toc-Tail-call-optimization" href="#Tail-call-optimization-in-Pre_002dScheme">9.3.2 Tail call optimization</a></li>
- <li><a id="toc-Bitwise-manipulation-2" href="#Pre_002dScheme-bitwise-manipulation">9.3.3 Bitwise manipulation</a></li>
- <li><a id="toc-Compound-data-manipulation" href="#Compound-Pre_002dScheme-data-manipulation">9.3.4 Compound data manipulation</a></li>
- <li><a id="toc-Error-handling" href="#Pre_002dScheme-error-handling">9.3.5 Error handling</a></li>
- <li><a id="toc-Input-_0026-output" href="#Input-_0026-output-in-Pre_002dScheme">9.3.6 Input & output</a></li>
- <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>
- </ul></li>
- <li><a id="toc-More-Pre_002dScheme-packages-1" href="#More-Pre_002dScheme-packages">9.4 More Pre-Scheme packages</a>
- <ul class="no-bullet">
- <li><a id="toc-Floating-point-operation" href="#Pre_002dScheme-floating-point-operation">9.4.1 Floating point operation</a></li>
- <li><a id="toc-Record-types-1" href="#Pre_002dScheme-record-types">9.4.2 Record types</a></li>
- <li><a id="toc-Multiple-return-values" href="#Multiple-return-values-in-Pre_002dScheme">9.4.3 Multiple return values</a></li>
- <li><a id="toc-Low_002dlevel-memory-manipulation" href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">9.4.4 Low-level memory manipulation</a></li>
- </ul></li>
- <li><a id="toc-Invoking-the-Pre_002dScheme-compiler-1" href="#Invoking-the-Pre_002dScheme-compiler">9.5 Invoking the Pre-Scheme compiler</a>
- <ul class="no-bullet">
- <li><a id="toc-Loading-the-compiler" href="#Loading-the-compiler">9.5.1 Loading the compiler</a></li>
- <li><a id="toc-Calling-the-compiler" href="#Calling-the-compiler">9.5.2 Calling the compiler</a></li>
- </ul></li>
- <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>
- <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>
- </ul></li>
- <li><a id="toc-References-1" href="#References">References</a></li>
- <li><a id="toc-Concept-index-1" href="#Concept-index" rel="index">Concept index</a></li>
- <li><a id="toc-Binding-index-1" href="#Binding-index" rel="index">Binding index</a></li>
- <li><a id="toc-Structure-index-1" href="#Structure-index" rel="index">Structure index</a></li>
- </ul>
- </div>
- <span id="Top"></span><div class="header">
- <p>
- Next: <a href="#Introduction-_0026-acknowledgements" accesskey="n" rel="next">Introduction & acknowledgements</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="The-Nearly-Complete-Scheme48-Reference-Manual"></span><h1 class="top">The Nearly Complete Scheme48 Reference Manual</h1>
- <p>This manual is for Scheme48 version 1.3.
- </p>
- <p>Copyright © 2004, 2005, 2006 Taylor Campbell.
- All rights reserved.
- </p>
- <p>This manual includes material derived from works bearing the following
- notice:
- </p>
- <p>Copyright © 1993–2005 Richard Kelsey, Jonathan Rees, and
- Mike Sperber.
- All rights reserved.
- </p>
- <blockquote>
- <p>Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- </p>
- <ul>
- <li> Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- </li><li> Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- </li><li> The name of the authors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
- </li></ul>
- </blockquote>
- <p>THIS SOFTWARE IS PROVIDED BY THE AUTHORS “AS IS” AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><td align="left" valign="top">• <a href="#Introduction-_0026-acknowledgements" accesskey="1">Introduction & acknowledgements</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#User-environment" accesskey="2">User environment</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Module-system" accesskey="3">Module system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#System-facilities" accesskey="4">System facilities</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Multithreading" accesskey="5">Multithreading</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Libraries" accesskey="6">Libraries</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#C-interface" accesskey="7">C interface</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-interface" accesskey="8">POSIX interface</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme" accesskey="9">Pre-Scheme</a></td><td> </td><td align="left" valign="top">A low-level dialect of Scheme
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#References">References</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Concept-index" rel="index">Concept index</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Binding-index" rel="index">Binding index</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Structure-index" rel="index">Structure index</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Introduction-_0026-acknowledgements"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Introduction"></span><h2 class="chapter">1 Introduction</h2>
- <p>Scheme48 is an implementation of Scheme based on a byte-code virtual
- machine with design goals of simplicity and cleanliness. To briefly
- enumerate some interesting aspects of it, Scheme48 features:
- </p><ul>
- <li> an advanced module system based on Jonathan Rees’s W7 security kernel
- with well-integrated interaction between macros and modules;
- </li><li> a virtual machine written in a dialect of Scheme itself, Pre-Scheme,
- for which a compiler is written with Scheme48;
- </li><li> a sophisticated, user-level, preëmptive multithreading system with
- numerous high-level concurrency abstractions;
- </li><li> a composable, lock-free shared-memory thread synchronization mechanism
- known as <em>optimistic concurrency</em>; and
- </li><li> an advanced user environment that is well-integrated with the module
- and thread systems to facilitate very rapid development of software
- systems scaling from small to large and single-threaded to
- multi-threaded.
- </li></ul>
- <p>It was originally written by Jonathan Rees and Richard Kelsey in 1986
- in response to the fact that so many Lisp implementations had started
- out simple and grown to be complex monsters of projects. It has been
- used in a number of research areas, including:
- </p><ul>
- <li> mobile robots at Cornell [Donald 92];
- </li><li> a multi-user collaboration system, sometimes known as a ‘MUD’
- (‘multi-user dungeon’) or ‘MUSE’ (‘multi-user simulation environment’),
- as well as general research in capability-based security [Museme; Rees
- 96]; and
- </li><li> advanced distributed computing with higher-order mobile agents at NEC’s
- Princeton research lab [Cejtin <i>et al.</i> 95].
- </li></ul>
- <p>The system is tied together in a modular fashion by a configuration
- language that permits quite easy mixing and matching of components, so
- much so that Scheme48 can be used essentially as its own OS, as it was
- in Cornell’s mobile robots program, or just as easily within another,
- as the standard distribution is. The standard distribution is quite
- portable and needs only a 32-bit byte-addressed POSIX system.
- </p>
- <p>The name ‘Scheme48’ commemorates the time it took Jonathan Rees and
- Richard Kelsey to originally write Scheme48 on August 6th & 7th, 1986:
- forty-eight hours. (It has been joked that the system has expanded to
- such a size now that it requires forty-eight hours to <em>read</em> the
- source.)
- </p>
- <span id="This-manual"></span><h3 class="section">1.1 This manual</h3>
- <p>This manual begins in the form of an introduction to the usage of
- Scheme48, suitable for those new to the system, after which it is
- primarily a reference material, organized by subject. Included in the
- manual is also a complete reference manual for Pre-Scheme, a low-level
- dialect of Scheme for systems programming and in which the Scheme48
- virtual machine is written; see <a href="#Pre_002dScheme">Pre-Scheme</a>.
- </p>
- <p>This manual is, except for some sections pilfered and noted as such
- from the official but incomplete Scheme48 reference manual, solely the
- work of Taylor Campbell, on whom all responsibility for the content of
- the manual lies. The authors of Scheme48 do not endorse this manual.
- </p>
- <span id="Acknowledgements"></span><h3 class="section">1.2 Acknowledgements</h3>
- <p>Thanks to Jonathan Rees and Richard Kelsey for having decided so many
- years ago to make a simple Scheme implementation with a clean design in
- the first place, and for having worked on it so hard for so many years
- (almost twenty!); to Martin Gasbichler and Mike Sperber, for having
- picked up Scheme48 in the past couple years when Richard and Jonathan
- were unable to work actively on it; to Jeremy Fincher for having asked
- numerous questions about Scheme48 as he gathered knowledge from which
- he intended to build an implementation of his own Lisp dialect, thereby
- inducing me to decide to write the manual in the first place; to Jorgen
- Schäfer, for having also asked so many questions, proofread various
- drafts, and made innumerable suggestions to the manual.
- </p><hr>
- <span id="User-environment"></span><div class="header">
- <p>
- Next: <a href="#Module-system" accesskey="n" rel="next">Module system</a>, Previous: <a href="#Introduction-_0026-acknowledgements" accesskey="p" rel="prev">Introduction & acknowledgements</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="User-environment-1"></span><h2 class="chapter">2 User environment</h2>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Running-Scheme48" accesskey="1">Running Scheme48</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Emacs-integration" accesskey="2">Emacs integration</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Using-the-module-system" accesskey="3">Using the module system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Command-processor" accesskey="4">Command processor</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="Running-Scheme48"></span><div class="header">
- <p>
- Next: <a href="#Emacs-integration" accesskey="n" rel="next">Emacs integration</a>, Up: <a href="#User-environment" accesskey="u" rel="up">User environment</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Running-Scheme48-1"></span><h3 class="section">2.1 Running Scheme48</h3>
- <span id="index-heap-image-resumption"></span>
- <span id="index-resuming-heap-images"></span>
- <p>Scheme48 is run by invoking its virtual machine on a dumped heap image
- to resume a saved system state. The common case of invoking the
- default image, <samp>scheme48.image</samp>, which contains the usual command
- processor, run-time system, <i>&c.</i>, is what the <code>scheme48</code>
- script that is installed does. The actual virtual machine executable
- itself, <code>scheme48vm</code>, is typically not installed into an
- executable directory such as <samp>/usr/local/bin/</samp> on Unix, but in
- the Scheme48 library directory, which is, by default on Unix
- installations of Scheme48, <samp>/usr/local/lib/</samp>. However, both
- <code>scheme48</code> and <code>scheme48vm</code> share the following
- command-line options; the only difference is that <code>scheme48</code>
- has a default <samp>-i</samp> argument.
- </p>
- <dl compact="compact">
- <dt><samp>-h <var>heap-size</var></samp></dt>
- <dd><span id="index-heap-size"></span>
- <span id="index-memory-size"></span>
- <p>The size of Scheme48’s heap, in cells. By default, the heap size is 3
- megacells, or 12 megabytes, permitting 6 megabytes per semispace —
- Scheme48 uses a simple stop & copy garbage collector.<a id="DOCF1" href="#FOOT1"><sup>1</sup></a> Since
- the current garbage collector cannot resize the heap dynamically if it
- becomes consistently too full, users on machines with much RAM may be
- more comfortable with liberally increasing this option.
- </p>
- </dd>
- <dt><samp>-s <var>stack-size</var></samp></dt>
- <dd><span id="index-stack-size"></span>
- <p>The stack size, in cells. The default stack size is 10000 bytes, or
- 2500 cells. Note that this is only the size of the stack cache
- segment of memory for fast stack frame storage. When this overflows,
- there is no error; instead, Scheme48 simply copies the contents of the
- stack cache into the heap, until the frames it copied into the heap
- are needed later, at which point they are copied back into the stack
- cache. The <samp>-s</samp> option therefore affects only performance, not
- the probability of fatal stack overflow errors.
- </p>
- </dd>
- <dt><samp>-i <var>image-filename</var></samp></dt>
- <dd><p>The filename of the suspended heap image to resume. When running the
- <code>scheme48</code> executable, the default is the regular Scheme48
- image; when running the virtual machine directly, this option must be
- passed explicitly. For information on creating custom heap images,
- 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>.
- </p>
- </dd>
- <dt><samp>-a <var>argument</var> …</samp></dt>
- <dd><p>Command-line arguments to pass to the heap image’s resumer, rather than
- being parsed by the virtual machine. In the usual Scheme48 command
- processor image, these arguments are put in a list of strings that will
- be the initial <a href="#Focus-value">focus value</a>.
- </p>
- </dd>
- <dt><samp>-u</samp></dt>
- <dd><span id="index-undefined-imported-bindings"></span>
- <p>Muffles warnings on startup about undefined imported foreign bindings.
- </p></dd>
- </dl>
- <span id="index-batch-mode"></span>
- <p>The usual Scheme48 image may accept an argument of <code>batch</code>, using
- the <samp>-a</samp> switch to the virtual machine. This enters Scheme48
- in batch mode, which displays no welcoming banner, prints no prompt
- for inputs, and exits when an EOF is read. This may be used to run
- scripts from the command-line, often in the <a href="#Command-programs">exec language</a>, by sending text to Scheme48 through Unix
- pipes or shell heredocs. For example, this Unix shell command will
- load the command program in the file <samp>foo.scm</samp> into the exec
- language environment and exit Scheme48 when the program returns:
- </p>
- <div class="example">
- <pre class="example">echo ,exec ,load foo.scm | scheme48 -a batch</pre></div>
- <p>This Unix shell command will load <samp>packages.scm</samp> into the module
- language environment, open the <code>tests</code> structure into the user
- environment, and call the procedure <code>run-tests</code> with zero
- arguments:
- </p>
- <div class="example">
- <pre class="example">scheme48 -a batch <<END
- ,config ,load packages.scm
- ,open tests
- (run-tests)
- END</pre></div>
- <p>Scheme48 also supports [SRFI 22] and [SRFI 7] by providing R5RS and
- [SRFI 7] script interpreters in the location where Scheme48 binaries
- are kept as <code>scheme-r5rs</code> and <code>scheme-srfi-7</code>. See the
- [SRFI 22] and [SRFI 7] documents for more details. Scheme48’s command
- processor also has commands for loading [SRFI 7] programs, with or
- without a [SRFI 22] script header; see <a href="#SRFI-7">SRFI 7</a>.
- </p>
- <span id="Command-processor-introduction"></span><h4 class="subsection">2.1.1 Command processor introduction</h4>
- <p>The Scheme48 command processor is started up on resumption of the usual
- Scheme48 image. This is by default what the <code>scheme48</code> script
- installed by Scheme48 does. It will first print out a banner that
- contains some general information about the system, which will typically
- look something like this:
- </p>
- <div class="example">
- <pre class="example">Welcome to Scheme 48 1.3 (made by root on Sun Jul 10 10:57:03 EDT 2005)
- Copyright (c) 1993-2005 by Richard Kelsey and Jonathan Rees.
- Please report bugs to scheme-48-bugs@s48.org.
- Get more information at http://www.s48.org/.
- Type ,? (comma question-mark) for help.</pre></div>
- <p>After the banner, it will initiate a REPL (read-eval-print loop). At
- first, there should be a simple ‘<samp>></samp>’ prompt. The command processor
- interprets Scheme code as well as <em>commands</em>. Commands operate the
- system at a level above or outside Scheme. They begin with a comma, and
- they continue until the end of the line, unless they expect a Scheme
- expression argument, which may continue as many lines as desired. Here
- is an example of a command invocation:
- </p>
- <div class="example">
- <pre class="example">> ,set load-noisily on</pre></div>
- <p>This will set the <a href="#Command-processor-switches"><code>load-noisily</code> switch</a> on.
- </p>
- <p><strong>Note:</strong> If a command accepts a Scheme expression argument that
- is followed by more arguments, all of the arguments after the Scheme
- expression must be put on the same line as the last line of the Scheme
- expression.
- </p>
- <p>Certain operations, such as breakpoints and errors, result in a
- recursive command processor to be invoked. This is known as
- <em>pushing a command level</em>. See <a href="#Command-levels">Command levels</a>. Also, the
- command processor supports an <em>object inspector</em>, an interactive
- program for inspecting the components of objects, including continuation
- or stack frame objects; the debugger is little more than the inspector,
- working on continuations. See <a href="#Inspector">Inspector</a>.
- </p>
- <p>Evaluation of code takes place in the <em>interaction environment</em>.
- (This is what R5RS’s <code>interaction-environment</code> returns.)
- Initially, this is the <em>user environment</em>, which by default is a
- normal R5RS Scheme environment. There are commands that set the
- interaction environment and evaluate code in other environments, too;
- see <a href="#Module-commands">Module commands</a>.
- </p>
- <p>The command processor’s prompt has a variety of forms. As above, it
- starts out with as a simple ‘<samp>></samp>’. Several factors can affect the
- prompt. The complete form of the prompt is as follows:
- </p>
- <ul>
- <li> It begins with an optional <a href="#Command-levels">command level</a>
- number: at the top level, there is no command level number; as command
- levels are pushed, the number is incremented, starting at 1.
- </li><li> Optionally, the name of the interaction environment follows the
- command level number: if the interaction environment is the user
- environment, there is no name printed here; named environments are
- printed with their names; unnamed environments (usually created using
- the <code>,new-package</code> command; see <a href="#Module-commands">Module commands</a>) are
- printed with their numeric identifiers. If a command level number
- preceded an environment name, a space is printed between them.
- </li><li> If the command processor is in the regular REPL mode, it ends with a
- ‘<samp>></samp>’ and a space before the user input area; if it is in
- <a href="#Inspector">inspector mode</a>, it ends with a ‘<samp>:</samp>’ and a
- space before the user input area.
- </li></ul>
- <p>For example, this prompt denotes that the user is in inspector mode at
- command level 3 and that the interaction environment is an environment
- named <code>frobozz</code>:
- </p>
- <div class="example">
- <pre class="example">3 frobozz: </pre></div>
- <p>This prompt shows that the user is in the regular REPL mode at the top
- level, but in the <a href="#Module-commands">environment for module
- descriptions</a>:
- </p>
- <div class="example">
- <pre class="example">config> </pre></div>
- <p>For a complete listing of all the commands in the command processor,
- see <a href="#Command-processor">Command processor</a>.
- </p>
- <hr>
- <span id="Emacs-integration"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Emacs-integration-1"></span><h3 class="section">2.2 Emacs integration</h3>
- <p>Emacs is the canonical development environment for Scheme48. The
- <samp>scheme.el</samp> and <samp>cmuscheme.el</samp> packages provide support for
- editing Scheme code and running inferior Scheme processes,
- respectively. Also, the <samp>scheme48.el</samp> package provides more
- support for integrating directly with
- Scheme48.<a id="DOCF2" href="#FOOT2"><sup>2</sup></a> <samp>scheme.el</samp> and
- <samp>cmuscheme.el</samp> come with GNU Emacs; <samp>scheme48.el</samp> is
- available separately from
- </p>
- <div class="display">
- <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>
- <p>To load <samp>scheme48.el</samp> if it is in the directory <var>emacs-dir</var>,
- add these lines to your <samp>.emacs</samp>:
- </p>
- <div class="lisp">
- <pre class="lisp">(add-to-list 'load-path "<var>emacs-dir</var>/")
- (autoload 'scheme48-mode "scheme48"
- "Major mode for improved Scheme48 integration."
- t)
- (add-hook 'hack-local-variables-hook
- (lambda ()
- (if (and (boundp 'scheme48-package)
- scheme48-package)
- (progn (scheme48-mode)
- (hack-local-variables-prop-line)))))</pre></div>
- <p>The <code>add-hook</code> call sets Emacs up so that any file with a
- <code>scheme48-package</code> local variable specified in the file’s
- <code>-*-</code> line or <code>Local Variables</code> section will be entered in
- Scheme48 mode. Files should use the <code>scheme48-package</code> variable
- to enable Scheme48 mode; they should not specify Scheme48 mode
- explicitly, since this would fail in Emacs instances without
- <samp>scheme48.el</samp>. That is, put this at the tops of files:
- </p>
- <div class="lisp">
- <pre class="lisp">;;; -*- Mode: Scheme; scheme48-package: ... -*-</pre></div>
- <p>Avoid this at the tops of files:
- </p>
- <div class="lisp">
- <pre class="lisp">;;; -*- Mode: Scheme48 -*- </pre></div>
- <p>There is also SLIME48, the Superior Lisp Interaction Mode for Emacs
- with Scheme48. It provides a considerably higher level of integration
- the other Emacs packages do, although it is less mature. It is at
- </p>
- <div class="display">
- <pre class="display"><a href="http://mumble.net/~campbell/scheme/slime48.tar.gz">http://mumble.net/~campbell/scheme/slime48.tar.gz</a>;</pre></div>
- <p>there is also a Darcs repository<a id="DOCF3" href="#FOOT3"><sup>3</sup></a> at
- </p>
- <div class="display">
- <pre class="display"><a href="http://mumble.net/~campbell/darcs/slime48/">http://mumble.net/~campbell/darcs/slime48/</a>.</pre></div>
- <p>Finally, <samp>paredit.el</samp> implements pseudo-structural editing
- facilities for S-expressions: it automatically balances parentheses and
- provides a number of high-level operations on S-expressions.
- <samp>Paredit.el</samp> is available on the web at
- </p>
- <div class="display">
- <pre class="display"><a href="http://mumble.net/~campbell/emacs/paredit.el">http://mumble.net/~campbell/emacs/paredit.el</a>.</pre></div>
- <p><samp>cmuscheme.el</samp> defines these:
- </p>
- <dl>
- <dt id="index-run_002dscheme">Emacs command: <strong>run-scheme</strong> <em>[scheme-prog]</em></dt>
- <dd><p>Starts an inferior Scheme process or switches to a running one. With
- no argument, this uses the value of <code>scheme-program-name</code> to run
- the inferior Scheme system; with a prefix argument <var>scheme-prog</var>,
- this invokes <var>scheme-prog</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-scheme_002dprogram_002dname">Emacs variable: <strong>scheme-program-name</strong></dt>
- <dd><p>The Scheme program to invoke for inferior Scheme processes.
- </p></dd></dl>
- <p>Under <code>scheme48-mode</code> with <samp>scheme.el</samp>, <samp>cmuscheme.el</samp>,
- and <samp>scheme48.el</samp>, these keys are defined:
- </p>
- <dl compact="compact">
- <dt><kbd>C-M-f</kbd> — <code>forward-sexp</code></dt>
- <dt><kbd>C-M-b</kbd> — <code>backward-sexp</code></dt>
- <dt><kbd>C-M-k</kbd> — <code>kill-sexp</code></dt>
- <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>) — <code>backward-kill-sexp</code></dt>
- <dt><kbd>C-M-q</kbd> — <code>indent-sexp</code></dt>
- <dt><kbd>C-M-@</kbd> — <code>mark-sexp</code></dt>
- <dt><kbd>C-M-<span class="key">SPC</span></kbd> — <code>mark-sexp</code></dt>
- <dd><p>S-expression manipulation commands. <kbd>C-M-f</kbd> moves forward by one
- S-expression; <kbd>C-M-b</kbd> moves backward by one. <kbd>C-M-k</kbd> kills the
- S-expression following the point; <kbd><span class="key">ESC</span> C-<span class="key">DEL</span></kbd> kills the
- S-expression preceding the point. <kbd>C-M-q</kbd> indents the S-expression
- following the point. <kbd>C-M-@</kbd> & <kbd>C-M-<span class="key">SPC</span></kbd>, equivalent to
- one another, mark the S-expression following the point.
- </p>
- </dd>
- <dt><kbd>C-c z</kbd> — <code>switch-to-scheme</code></dt>
- <dd><p>Switches to the inferior Scheme process buffer.
- </p>
- </dd>
- <dt><kbd>C-c C-l</kbd> — <code>scheme48-load-file</code></dt>
- <dd><p>Loads the file corresponding with the current buffer into Scheme48. If
- that file was not previously loaded into Scheme48 with <kbd>C-c C-l</kbd>,
- Scheme48 records the current interaction environment in place as it
- loads the file; if the file was previously recorded, it is loaded into
- the recorded environment. See <a href="#Emacs-integration-commands">Emacs integration commands</a>.
- </p>
- </dd>
- <dt><kbd>C-c C-r</kbd> — <code>scheme48-send-region</code></dt>
- <dt><kbd>C-c M-r</kbd> — <code>scheme48-send-region-and-go</code></dt>
- <dd><p><kbd>C-c C-r</kbd> sends the currently selected region to the current
- inferior Scheme process. The file of the current buffer is recorded as
- in the <kbd>C-c C-l</kbd> command, and code is evaluated in the recorded
- package. <kbd>C-c M-r</kbd> does similarly, but subsequently also switches
- to the inferior Scheme process buffer.
- </p>
- </dd>
- <dt><kbd>C-M-x</kbd> — <code>scheme48-send-definition</code></dt>
- <dt><kbd>C-c C-e</kbd> — <code>scheme48-send-definition</code></dt>
- <dt><kbd>C-c M-e</kbd> — <code>scheme48-send-definition-and-go</code></dt>
- <dd><p><kbd>C-M-x</kbd> (GNU convention) and <kbd>C-c C-e</kbd> send the top-level
- definition that the current point is within to the current inferior
- Scheme process. <kbd>C-c M-e</kbd> does similarly, but subsequently also
- switches to the inferior Scheme process buffer. <kbd>C-c C-e</kbd> and
- <kbd>C-c M-e</kbd> also respect Scheme48’s file/environment mapping.
- </p>
- </dd>
- <dt><kbd>C-x C-e</kbd> — <code>scheme48-send-last-sexp</code></dt>
- <dd><p>Sends the S-expression preceding the point to the inferior Scheme
- process. This also respects Scheme48’s file/environment mapping.
- </p></dd>
- </dl>
- <hr>
- <span id="Using-the-module-system"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Using-the-module-system-1"></span><h3 class="section">2.3 Using the module system</h3>
- <p>Scheme48 is deeply integrated with an advanced module system. For
- complete detail of its module system, see <a href="#Module-system">Module system</a>. Briefly,
- however:
- </p>
- <ul>
- <li> <em>Packages</em> are top-level environments suitable for
- evaluating expressions and definitions, either interactively, from
- files loaded on-the-fly, or as the bodies of modules. They can also
- access bindings exported by structures by <em>opening</em> the
- structures.
- </li><li> <em>Structures</em> are libraries, or implementations of
- interfaces, exporting sets of bindings that packages can access.
- Underlying structures are usually packages, in which the user can, in
- some cases, interactively evaluate code during development.
- </li></ul>
- <p>Scheme48’s usual development system, the command processor, provides a
- number of commands for working with the module system. For complete
- details, see <a href="#Module-commands">Module commands</a>. Chief among these commands are
- <code>,open</code> and <code>,in</code>. ‘<samp>,open <var>struct</var> …</samp>’
- makes all of the bindings from each of <var>struct</var> … available
- in the interaction environment. Many of the sections in this manual
- describe one or more structures with the name they are given. For
- example, in order to use, or open, the multi-dimensional array library
- in the current interaction environment, one would enter
- </p>
- <div class="lisp">
- <pre class="lisp">,open arrays</pre></div>
- <p>to the command processor. ‘<samp>,in <var>struct</var></samp>’ sets the
- interaction environment to be the package underlying <var>struct</var>.
- For instance, if, during development, the user decides that the
- package of the existing structure <code>foo</code> should open the structure
- <code>bar</code>, he might type
- </p>
- <div class="lisp">
- <pre class="lisp">,in foo
- ,open bar</pre></div>
- <p>The initial interaction environment is known as the <em>user
- package</em>; the interaction environment may be reverted to the user
- package with the <code>,user</code> command.
- </p>
- <p>Module descriptions, or code in the <a href="#Module-configuration-language">module configuration language</a> should be loaded into the
- special environment for that language with the <code>,config</code> command
- (see <a href="#Module-commands">Module commands</a>). <i>E.g.</i>, if <samp>packages.scm</samp> contains a
- set of module descriptions that the user wishes to load, among which
- is the definition of a structure <code>frobozz</code> which he wishes to
- open, he will typically send the following to the command processor
- prompt:
- </p>
- <div class="lisp">
- <pre class="lisp">,config ,load packages.scm
- ,open frobozz</pre></div>
- <p><strong>Note:</strong> These are commands for the interactive command
- processor, <em>not</em> special directives to store in files to work
- with the module system. The module language is disjoint from Scheme;
- for complete detail on it, see <a href="#Module-system">Module system</a>.
- </p>
- <span id="Configuration-mutation"></span><h4 class="subsection">2.3.1 Configuration mutation</h4>
- <p><i>(This section was derived from work copyrighted ©
- 1993–2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
- </p>
- <span id="index-code-reloading"></span>
- <span id="index-reloading-code"></span>
- <p>During program development, it is often desirable to make changes to
- packages and interfaces. In static languages, it is usually necessary
- to re-compile and re-link a program in order for such changes to be
- reflected in a running system. Even in interactive Common Lisp
- systems, a change to a package’s exports often requires reloading
- clients that have already mentioned names whose bindings change. In
- those systems, once <code>read</code> resolves a use of a name to a symbol,
- that resolution is fixed, so a change in the way that a name resolves
- to a symbol can be reflected only by re-<code>read</code>ing all such
- references.
- </p>
- <p>The Scheme48 development environment supports rapid turnaround in
- modular program development by allowing mutations to a program’s
- configuration and giving a clear semantics to such mutation. The rule
- is that variable bindings in a running program are always resolved
- according to the current structure and interface bindings, even when
- these bindings change as a result of edits to the configuration. For
- example, consider the following:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-interface foo-interface (export a c))
- (define-structure foo foo-interface
- (open scheme)
- (begin (define a 1)
- (define (b x) (+ a x))
- (define (c y) (* (b a) y))))
- (define-structure bar (export d)
- (open scheme foo)
- (begin (define (d w) (+ (b w) a))))</pre></div>
- <p>This program has a bug. The variable named <code>b</code>, which is free in
- the definition of <code>d</code>, has no binding in <code>bar</code>’s package.
- Suppose that <code>b</code> was intended to be exported by <code>foo</code>, but
- was mistakenly omitted. It is not necessary to re-process <code>bar</code> or
- any of <code>foo</code>’s other clients at this point. One need only change
- <code>foo-interface</code> and inform the development system of that change
- (using, say, an appropriate Emacs command), and <code>foo</code>’s binding of
- <code>b</code> will be found when the procedure <code>d</code> is called and its
- reference to <code>b</code> actually evaluated.
- </p>
- <p>Similarly, it is possible to replace a structure; clients of the old
- structure will be modified so that they see bindings from the new one.
- Shadowing is also supported in the same way. Suppose that a client
- package <var>C</var> opens a structure <code>mumble</code> that exports a name
- <code>x</code>, and <code>mumble</code>’s implementation obtains the binding of
- <code>x</code> from some other structure <code>frotz</code>. <var>C</var> will see the
- binding from <code>frotz</code>. If one then alters <code>mumble</code> so that it
- shadows <code>bar</code>’s binding of <code>x</code> with a definition of its own,
- procedures in <var>C</var> that refer to <code>x</code> will subsequently
- automatically see <code>mumble</code>’s definition instead of the one from
- <code>frotz</code> that they saw earlier.
- </p>
- <p>This semantics might appear to require a large amount of computation on
- every variable reference: the specified behaviour appears to require
- scanning the package’s list of opened structures and examining their
- interfaces — on every variable reference evaluated, not just at
- compile-time. However, the development environment uses caching with
- cache invalidation to make variable references fast, and most of the
- code is invoked only when the virtual machine traps due to a reference
- to an undefined variable.
- </p>
- <span id="Listing-interfaces"></span><h4 class="subsection">2.3.2 Listing interfaces</h4>
- <span id="index-interfaces"></span>
- <span id="index-list_002dinterfaces"></span>
- <p>The <code>list-interfaces</code> structure provides a utility for examining
- interfaces. It is usually opened into the config package with
- <code>,config ,open list-interfaces</code> in order to have access to the
- structures & interfaces easily.
- </p>
- <dl>
- <dt id="index-list_002dinterface">procedure: <strong>list-interface</strong> <em>struct-or-interface --> unspecified</em></dt>
- <dd><p>Lists all of the bindings exported by <var>struct-or-interface</var> along
- with their <a href="#Static-type-system">static types</a>. For example,
- </p>
- <div class="lisp">
- <pre class="lisp">> ,config ,open list-interfaces
- > ,config (list-interface condvars)
- condvar-has-value? (proc (:condvar) :value)
- condvar-value (proc (:condvar) :value)
- condvar? (proc (:value) :boolean)
- make-condvar (proc (&rest :value) :condvar)
- maybe-commit-and-set-condvar! (proc (:condvar :value) :boolean)
- maybe-commit-and-wait-for-condvar (proc (:condvar) :boolean)
- set-condvar-has-value?! (proc (:condvar :value) :unspecific)
- set-condvar-value! (proc (:condvar :value) :unspecific)</pre></div>
- </dd></dl>
- <hr>
- <span id="Command-processor"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Command-processor-1"></span><h3 class="section">2.4 Command processor</h3>
- <p>The Scheme48 command processor is the main development environment. It
- incorporates a read-eval-print loop as well as an interactive inspector
- and debugger. It is well-integrated with the module system for rapid
- dynamic development, which is made even more convenient with the Emacs
- interface, <samp>scheme48.el</samp>; see <a href="#Emacs-integration">Emacs integration</a>.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Basic-commands" accesskey="1">Basic commands</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Command-processor-switches" accesskey="2">Command processor switches</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Emacs-integration-commands" accesskey="3">Emacs integration commands</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Focus-value" accesskey="4">Focus value</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Command-levels" accesskey="5">Command levels</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Module-commands" accesskey="6">Module commands</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#SRFI-7" accesskey="7">SRFI 7</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Debugging-commands" accesskey="8">Debugging commands</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Inspector" accesskey="9">Inspector</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Command-programs">Command programs</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Image_002dbuilding-commands">Image-building commands</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Resource-statistics-and-control">Resource statistics and control</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Basic-commands"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Basic-commands-1"></span><h4 class="subsection">2.4.1 Basic commands</h4>
- <p>There are several generally useful commands built-in, along with many
- others described in subsequent sections:
- </p>
- <span id="index-help"></span>
- <span id="index-command-processor-help"></span>
- <dl>
- <dt id="index-_002chelp">command: <strong>,help</strong></dt>
- <dt id="index-_002chelp-1">command: <strong>,help</strong> <em>command</em></dt>
- <dt id="index-_002c_003f">command: <strong>,?</strong></dt>
- <dt id="index-_002c_003f-1">command: <strong>,?</strong> <em>command</em></dt>
- <dd><p>Requests help on commands. <code>,?</code> is an alias for
- <code>,help</code>. Plain ‘<samp>,help</samp>’ lists a synopsis of all commands
- available, as well as all <a href="#Command-processor-switches">switches</a>. ‘<samp>,help <var>command</var></samp>’ requests help on the particular
- command <var>command</var>.
- </p></dd></dl>
- <span id="index-exiting-Scheme"></span>
- <span id="index-quitting-Scheme"></span>
- <dl>
- <dt id="index-_002cexit">command: <strong>,exit</strong></dt>
- <dt id="index-_002cexit-1">command: <strong>,exit</strong> <em>status</em></dt>
- <dt id="index-_002cexit_002dwhen_002ddone">command: <strong>,exit-when-done</strong></dt>
- <dt id="index-_002cexit_002dwhen_002ddone-1">command: <strong>,exit-when-done</strong> <em>status</em></dt>
- <dd><p>Exits the command processor. ‘<samp>,exit</samp>’ immediately exits with an
- exit status of 0. ‘<samp>,exit <var>status</var></samp>’ exits with the status that
- evaluating the expression <var>status</var> in the interaction environment
- produces. <code>,exit-when-done</code> is like <code>,exit</code>, but it
- waits until all threads complete before exiting.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cgo">command: <strong>,go</strong> <em>expression</em></dt>
- <dd><p><code>,go</code> is like <code>,exit</code>, except that it requires an
- argument, and it evaluates <var>expression</var> in the interaction
- environment in a <em>tail context</em> with respect to the command
- processor. This means that the command processor may no longer be
- reachable by the garbage collector, and may be collected as garbage
- during the evaluation of <var>expression</var>. For example, the full
- Scheme48 command processor is bootstrapped from a minimal one that
- supports the <code>,go</code> command. The full command processor is
- initiated in an argument to the command, but the minimal one is no
- longer reachable, so it may be collected as garbage, leaving only the
- full one.
- </p></dd></dl>
- <dl>
- <dt id="index-_002crun">command: <strong>,run</strong> <em>expression</em></dt>
- <dd><p>Evaluates <var>expression</var> in the interaction environment. Alone, this
- command is not very useful, but it is required in situations such as
- the <a href="#Inspector">inspector</a> and <a href="#Command-programs">command programs</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cundefine">command: <strong>,undefine</strong> <em>name</em></dt>
- <dd><p>Removes the binding for <var>name</var> in the interaction environment.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cload">command: <strong>,load</strong> <em>filename …</em></dt>
- <dd><p>Loads the contents each <var>filename</var> as Scheme source code into the
- interaction environment. Each <var>filename</var> is translated first
- (see <a href="#Filenames">Filenames</a>). The given filenames may be surrounded or not by
- double-quotes; however, if a filename contains spaces, it must be
- surrounded by double-quotes. The differences between the
- <code>,load</code> command and Scheme’s <code>load</code> procedure are that
- <code>,load</code> does not require its arguments to be quoted, allows
- arbitrarily many arguments while the <code>load</code> procedure accepts only
- one filename (and an optional environment), and works even in
- environments in which <code>load</code> is not bound.
- </p></dd></dl>
- <dl>
- <dt id="index-_002ctranslate">command: <strong>,translate</strong> <em>from to</em></dt>
- <dd><p>A convenience for registering a filename translation without needing to
- open the <code>filenames</code> structure. For more details on filename
- translations, see <a href="#Filenames">Filenames</a>; this command corresponds with the
- <code>filename</code> structure’s <code>set-translation!</code> procedure. As
- with <code>,load</code>, each of the filenames <var>from</var> and <var>to</var> may
- be surrounded or not by double-quotes, unless there is a space in the
- filenames, in which case it must be surrounded by double-quotes.
- </p>
- <p>Note that in the exec language (see <a href="#Command-programs">Command programs</a>),
- <code>translate</code> is the same as the <code>filenames</code> structure’s
- <code>set-translation!</code> procedure, <em>not</em> the procedure named
- <code>translate</code> from the <code>filenames</code> structure.
- </p></dd></dl>
- <hr>
- <span id="Command-processor-switches"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Switches"></span><h4 class="subsection">2.4.2 Switches</h4>
- <span id="index-command-processor-settings"></span>
- <span id="index-configuring-the-command-processor"></span>
- <p>The Scheme48 command processor keeps track of a set of <em>switches</em>,
- user-settable configurations.
- </p>
- <dl>
- <dt id="index-_002cset">command: <strong>,set</strong> <em>switch</em></dt>
- <dt id="index-_002cset-1">command: <strong>,set</strong> <em>switch {on|off|?}</em></dt>
- <dt id="index-_002cunset">command: <strong>,unset</strong> <em>switch</em></dt>
- <dt id="index-_002cset-2">command: <strong>,set</strong> <em>?</em></dt>
- <dd><p>‘<samp>,set <var>switch</var></samp>’ & ‘<samp>,set <var>switch</var> on</samp>’ set the switch
- <var>switch</var> on. ‘<samp>,unset <var>switch</var></samp>’ & ‘<samp>,set <var>switch</var>
- off</samp>’ turn <var>switch</var> off. ‘<samp>,set <var>switch</var> ?</samp>’ gives a brief
- description of <var>switch</var>’s current status. ‘<samp>,set ?</samp>’ gives
- information about all the available switches and their current state.
- </p></dd></dl>
- <p>The following switches are defined. Each switch is listed with its
- name and its default status.
- </p>
- <dl compact="compact">
- <dt><code>ask-before-loading</code> <em>(off)</em></dt>
- <dd><p>If this is on, Scheme48 will prompt the user before loading modules’
- code. If it is off, it will quietly just load it.
- </p>
- <span id="index-batch-mode-1"></span>
- </dd>
- <dt><code>batch</code> <em>(off)</em></dt>
- <dd><p>Batch mode is intended for automated uses of the command processor.
- With batch mode on, errors cause the command processor to exit, and the
- prompt is not printed.
- </p>
- </dd>
- <dt><code>break-on-warnings</code> <em>(off)</em></dt>
- <dd><p>If the <code>break-on-warnings</code> switch is on, <a href="#Condition-system">warnings</a> signalled that reach the command processor’s handler
- will cause a <a href="#Command-levels">command level</a> to be pushed,
- similarly to breakpoints and errors.
- </p>
- </dd>
- <dt><code>inline-values</code> <em>(off)</em></dt>
- <dd><p><code>Inline-values</code> tells whether or not certain procedures may be
- integrated in-line.
- </p>
- <span id="index-command-levels"></span>
- <span id="index-disabling-command-levels"></span>
- </dd>
- <dt><code>levels</code> <em>(on)</em></dt>
- <dd><p>Errors will push a new <a href="#Command-levels">command level</a> if this
- switch is on, or they will just reset back to the top level if
- <code>levels</code> is off.
- </p>
- </dd>
- <dt><code>load-noisily</code> <em>(off)</em></dt>
- <dd><p>Loading source files will cause messages to be printed if
- <code>load-noisily</code> is on; otherwise they will be suppressed.
- </p></dd>
- </dl>
- <hr>
- <span id="Emacs-integration-commands"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Emacs-integration-commands-1"></span><h4 class="subsection">2.4.3 Emacs integration commands</h4>
- <p>There are several commands that exist mostly for <a href="#Emacs-integration">Emacs integration</a>; although they may be used elsewhere,
- they are not very useful or convenient without <samp>scheme48.el</samp>.
- </p>
- <dl>
- <dt id="index-_002cfrom_002dfile">command: <strong>,from-file</strong> <em>filename</em></dt>
- <dt id="index-_002cend">command: <strong>,end</strong></dt>
- <dd><p>‘<samp>,from-file <var>filename</var></samp>’ proclaims that the code following the
- command, until an <code>,end</code> command, comes from <var>filename</var> —
- for example, this may be due to an appropriate Emacs command, such as
- <kbd>C-c C-l</kbd> in <samp>scheme48.el</samp> —; if this is the first time the
- command processor has seen code from <var>filename</var>, it is registered
- to correspond with the interaction environment wherein the
- <code>,from-file</code> command was used. If it is not the first time,
- the code is evaluated within the package that was registered for
- <var>filename</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cforget">command: <strong>,forget</strong> <em>filename</em></dt>
- <dd><p>Clears the command processor’s memory of the package to which
- <var>filename</var> corresponds.
- </p></dd></dl>
- <hr>
- <span id="Focus-value"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Focus-value-1"></span><h4 class="subsection">2.4.4 Focus value</h4>
- <p>The Scheme48 command processor maintains a current <em>focus value</em>.
- This is typically the value that the last expression evaluated to, or a
- list of values if it returned multiple values. If it evaluated to
- either zero values or Scheme48’s ‘unspecific’ token (see <a href="#System-features">System features</a>), the focus value is unchanged. At the initial startup of
- Scheme48, the focus value is set to the arguments passed to Scheme48’s
- virtual machine after the <samp>-a</samp> argument on the command-line
- (see <a href="#Running-Scheme48">Running Scheme48</a>). The focus value is accessed through the
- <code>##</code> syntax; the reader substitutes a special quotation (special
- so that the compiler will not generate warnings about a regular
- <code>quote</code> expression containing a weird value) for occurrences of
- <code>##</code>. Several commands, such as <code>,inspect</code> and
- <code>,dis</code>, either accept an argument or use the current focus
- value. Also, in the <a href="#Inspector">inspector</a>, the focus object
- is the object that is currently being inspected.
- </p>
- <div class="example">
- <pre class="example">> (cons 1 2)
- '(1 . 2)
- > ##
- '(1 . 2)
- > (begin (display "Hello, world!") (newline))
- Hello, world!
- > ##
- '(1 . 2)
- > (cdr ##)
- 2
- > (define x 5)
- ; no values returned
- > (+ ## x)
- 7
- > (values 1 2 3)
- ; 3 values returned
- 1
- 2
- 3
- > ##
- '(1 2 3)</pre></div>
- <hr>
- <span id="Command-levels"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Command-levels-1"></span><h4 class="subsection">2.4.5 Command levels</h4>
- <span id="index-command-levels-1"></span>
- <p>The Scheme48 command processor maintains a stack of <em>command
- levels</em>, or recursive invocations of the command processor. Each
- command level retains information about the point from the previous
- command level at which it was pushed: the threads that were running —
- which the command processor suspends —, including the thread of that
- command level itself; the continuation of what pushed the level; and,
- if applicable, the <a href="#Condition-system">condition</a> that caused
- the command level to be pushed. Each command level has its own thread
- scheduler, which controls all threads running at that level, including
- those threads’ children.
- </p>
- <span id="index-disabling-command-levels-1"></span>
- <p>Some beginning users may find command levels confusing, particularly
- those who are new to Scheme or who are familiar with the more
- simplistic interaction methods of other Scheme systems. These users
- may disable the command level system with the <a href="#Command-processor-switches"><code>levels</code> switch</a> by writing the command
- ‘<samp>,set levels off</samp>’.
- </p>
- <dl>
- <dt id="index-_002cpush">command: <strong>,push</strong></dt>
- <dt id="index-_002cpop">command: <strong>,pop</strong></dt>
- <dt id="index-_002cresume">command: <strong>,resume</strong></dt>
- <dt id="index-_002cresume-1">command: <strong>,resume</strong> <em>level</em></dt>
- <dt id="index-_002creset">command: <strong>,reset</strong></dt>
- <dt id="index-_002creset-1">command: <strong>,reset</strong> <em>level</em></dt>
- <dd><p>‘<samp>,push</samp>’ pushes a new command level. ‘<samp>,pop</samp>’ pops the current
- command level. <kbd>C-d</kbd>/<kbd>^D</kbd>, or EOF, has the same effect as the
- <code>,pop</code> command. Popping the top command level inquires the
- user whether to exit or to return to the top level. ‘<samp>,resume
- <var>level</var></samp>’ pops all command levels down to <var>level</var> and resumes
- all threads that were running at <var>level</var> when it was suspended to
- push another command level. ‘<samp>,reset <var>level</var></samp>’ resets the
- command processor to <var>level</var>, terminating all threads at that
- level but the command reader thread. <code>,resume</code> &
- <code>,reset</code> with no argument use the top command level.
- </p></dd></dl>
- <dl>
- <dt id="index-_002ccondition">command: <strong>,condition</strong></dt>
- <dt id="index-_002cthreads">command: <strong>,threads</strong></dt>
- <dd><p>‘<samp>,condition</samp>’ sets the focus value to the condition that caused the
- command level to be pushed, or prints ‘no condition’ if there was no
- relevant condition. ‘<samp>,threads</samp>’ invokes the inspector on the list
- of threads of the previous command level, or on nothing if the current
- command level is the top one.
- </p></dd></dl>
- <div class="example">
- <pre class="example">> ,push
- 1> ,push
- 2> ,pop
- 1> ,reset
- Top level
- > ,open threads formats
- > ,push
- 1> ,push
- 2> (spawn (lambda ()
- (let loop ()
- (sleep 10000) ; Sleep for ten seconds.
- (format #t "~&foo~%")
- (loop)))
- 'my-thread)
- 2>
- foo
- ,push
- 3> ,threads
- ; 2 values returned
- [0] '#{Thread 4 my-thread}
- [1] '#{Thread 3 command-loop}
- 3: q
- '(#{Thread 4 my-thread} #{Thread 3 command-loop})
- 3> ,resume 1
- foo
- 2>
- foo
- ,push
- 3> ,reset 1
- Back to 1> ,pop
- > </pre></div>
- <hr>
- <span id="Module-commands"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Module-commands-1"></span><h4 class="subsection">2.4.6 Module commands</h4>
- <p>Scheme48’s command processor is well-integrated with its
- <a href="#Module-system">module system</a>. It has several dedicated
- environments, including the user package and the config package, and
- can be used to evaluate code within most packages in the Scheme48 image
- during program development. The config package includes bindings for
- Scheme48’s configuration language; structure & interface definitions
- may be evaluated in it. The command processor also has provisions
- to support rapid development and module reloading by automatically
- updating references to redefined variables in compiled code without
- having to reload all of that code.
- </p>
- <span id="index-opening-structures"></span>
- <span id="index-structures_002c-opening"></span>
- <dl>
- <dt id="index-_002copen">command: <strong>,open</strong> <em>struct …</em></dt>
- <dd><p>Opens each <var>struct</var> into the interaction environment, making all
- of its exported bindings available. This may have the consequence of
- loading code to implement those bindings. If there was code evaluated
- in the interaction environment that referred to a previously undefined
- variable for whose name a binding was exported by one of these
- structures, a message is printed to the effect that that binding is
- now available, and the code that referred to that undefined variable
- will be modified to subsequently refer to the newly available binding.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cload_002dpackage">command: <strong>,load-package</strong> <em>struct</em></dt>
- <dd><span id="index-reloading-code-1"></span>
- <span id="index-code-reloading-1"></span>
- </dd><dt id="index-_002creload_002dpackage">command: <strong>,reload-package</strong> <em>struct</em></dt>
- <dd><p><code>,load-package</code> and <code>,reload-package</code> both load the
- code associated with the package underlying <var>struct</var>, after
- ensuring that all of the other structures opened by that package are
- loaded as well. <code>,load-package</code> loads the code only if has
- not already been loaded; <code>,reload-package</code> unconditionally
- loads it.
- </p></dd></dl>
- <span id="index-user-package"></span>
- <span id="index-config-package"></span>
- <dl>
- <dt id="index-_002cuser">command: <strong>,user</strong></dt>
- <dt id="index-_002cuser-1">command: <strong>,user</strong> <em>command-or-exp</em></dt>
- <dt id="index-_002cconfig">command: <strong>,config</strong></dt>
- <dt id="index-_002cconfig-1">command: <strong>,config</strong> <em>command-or-exp</em></dt>
- <dt id="index-_002cfor_002dsyntax">command: <strong>,for-syntax</strong></dt>
- <dt id="index-_002cfor_002dsyntax-1">command: <strong>,for-syntax</strong> <em>command-or-exp</em></dt>
- <dt id="index-_002cnew_002dpackage">command: <strong>,new-package</strong></dt>
- <dt id="index-_002cin">command: <strong>,in</strong> <em>structure</em></dt>
- <dt id="index-_002cin-1">command: <strong>,in</strong> <em>structure command-or-exp</em></dt>
- <dd><p>These all operate on the interaction environment. ‘<samp>,user</samp>’ sets it
- to the user package, which is the default at initial startup.
- ‘<samp>,user <var>command-or-exp</var></samp>’ temporarily sets the interaction
- environment to the user package, processes <var>command-or-exp</var>, and
- reverts the interaction environment to what it was before
- <code>,user</code> was invoked. The <code>,config</code> &
- <code>,for-syntax</code> commands are similar, except that they operate on
- the config package and the package used for the user package’s macros
- (see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>). ‘<samp>,new-package</samp>’ creates
- a temporary, unnamed package with a vanilla R5RS environment and sets
- the interaction environment to it. That new package is not accessible
- in any way except to the user of the command processor, and it is
- destroyed after the user switches to another environment (unless the
- user uses the <code>,structure</code> command; see below). ‘<samp>,in
- <var>structure</var></samp>’ sets the interaction environment to be
- <var>structure</var>’s package; <var>structure</var> is a name whose value is
- extracted from the config package. ‘<samp>,in <var>structure</var>
- <var>command-or-exp</var></samp>’ sets the interaction environment to
- <var>structure</var> temporarily to process <var>command-or-exp</var> and then
- reverts it to what it was before the use of <code>,in</code>. Note that,
- within a structure, the bindings available are exactly those bindings
- that would be available within the structure’s static code, <i>i.e.</i> code
- in the structure’s <code>begin</code> package clauses or code in files
- referred to by <code>files</code> package clauses.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cuser_002dpackage_002dis">command: <strong>,user-package-is</strong> <em>struct</em></dt>
- <dt id="index-_002cconfig_002dpackage_002dis">command: <strong>,config-package-is</strong> <em>struct</em></dt>
- <dd><p><code>,user-package-is</code> & <code>,config-package-is</code> set the user
- & config packages, respectively, to be <var>struct</var>’s package.
- <var>Struct</var> is a name whose value is accessed from the current config
- package.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cstructure">command: <strong>,structure</strong> <em>name interface</em></dt>
- <dd><p>This defines a structure named <var>name</var> in the config package that is
- a view of <var>interface</var> on the current interaction environment.
- </p></dd></dl>
- <hr>
- <span id="SRFI-7"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="SRFI-7-1"></span><h4 class="subsection">2.4.7 SRFI 7</h4>
- <span id="index-srfi_002d7"></span>
- <p>Scheme48 supports [SRFI 7] after loading the <code>srfi-7</code> structure by
- providing two commands for loading [SRFI 7] programs:
- </p>
- <dl>
- <dt id="index-_002cload_002dsrfi_002d7_002dprogram">command: <strong>,load-srfi-7-program</strong> <em>name filename</em></dt>
- <dt id="index-_002cload_002dsrfi_002d7_002dscript">command: <strong>,load-srfi-7-script</strong> <em>name filename</em></dt>
- <dd><p>These load [SRFI 7] a program into a newly constructed structure, named
- <var>name</var>, which opens whatever other structures are needed by
- features specified in the program. <code>,load-srfi-7-program</code>
- loads a simple [SRFI 7] program; <code>,load-srfi-7-script</code> skips
- the first line, intended for [SRFI 22] Unix scripts.
- </p></dd></dl>
- <hr>
- <span id="Debugging-commands"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Debugging-commands-1"></span><h4 class="subsection">2.4.8 Debugging commands</h4>
- <p>There are a number of commands useful for debugging, along with a
- continuation inspector, all of which composes a convenient debugger.
- </p>
- <dl>
- <dt id="index-_002cbound_003f">command: <strong>,bound?</strong> <em>name</em></dt>
- <dt id="index-_002cwhere">command: <strong>,where</strong></dt>
- <dt id="index-_002cwhere-1">command: <strong>,where</strong> <em>procedure</em></dt>
- <dd><p><code>,bound?</code> prints out binding information about <var>name</var>, if
- it is bound in the interaction environment, or ‘Not bound’ if
- <var>name</var> is unbound. <code>,where</code> prints out information about
- what file and package its procedure argument was created in. If
- <var>procedure</var> is not passed, <code>,where</code> uses the focus value.
- If <code>,where</code>’s argument is not a procedure, it informs the user
- of this fact. If <code>,where</code> cannot find the location of its
- argument’s creation, it prints ‘Source file not recorded.’
- </p></dd></dl>
- <span id="index-macro-expansion"></span>
- <span id="index-expanding-macros"></span>
- <span id="index-syntax-expansion"></span>
- <span id="index-disassembly"></span>
- <dl>
- <dt id="index-_002cexpand">command: <strong>,expand</strong></dt>
- <dt id="index-_002cexpand-1">command: <strong>,expand</strong> <em>exp</em></dt>
- <dt id="index-_002cdis">command: <strong>,dis</strong></dt>
- <dt id="index-_002cdis-1">command: <strong>,dis</strong> <em>proc</em></dt>
- <dd><p><code>,expand</code> prints out a macro-expansion of <var>exp</var>, or the
- focus value if <var>exp</var> is not provided. The expression to be
- expanded should be an ordinary S-expression. The expansion may contain
- ‘generated names’ and ‘qualified names.’ These merely contain lexical
- context information that allow one to differentiate between identifiers
- with the same name. Generated names look like <code>#{Generated
- <var>name</var> <var>unique-numeric-id</var>}</code>. Qualified names appear to be
- vectors; they look like <code>#(>> <var>introducer-macro</var> <var>name</var>
- <var>unique-numeric-id</var>)</code>, where <var>introducer-macro</var> is the macro
- that introduced the name.
- </p>
- <p><code>,dis</code> prints out a disassembly of its procedure, continuation,
- or template argument. If <var>proc</var> is passed, it is evaluated in the
- interaction environment; if not, <code>,dis</code> disassembles the focus
- value. The disassembly is of Scheme48’s virtual machine’s byte
- code.<a id="DOCF4" href="#FOOT4"><sup>4</sup></a>
- </p></dd></dl>
- <dl>
- <dt id="index-_002ccondition-1">command: <strong>,condition</strong></dt>
- <dt id="index-_002cthreads-1">command: <strong>,threads</strong></dt>
- <dd><p>For the descriptions of these commands, see <a href="#Command-levels">Command levels</a>. These
- are mentioned here because they are relevant in the context of
- debugging.
- </p></dd></dl>
- <span id="index-tracing"></span>
- <span id="index-procedures_002c-tracing"></span>
- <dl>
- <dt id="index-_002ctrace">command: <strong>,trace</strong></dt>
- <dt id="index-_002ctrace-1">command: <strong>,trace</strong> <em>name …</em></dt>
- <dt id="index-_002cuntrace">command: <strong>,untrace</strong></dt>
- <dt id="index-_002cuntrace-1">command: <strong>,untrace</strong> <em>name …</em></dt>
- <dd><p>Traced procedures will print out information about when they are
- entered and when they exit. ‘<samp>,trace</samp>’ lists all of the traced
- procedures’ bindings. ‘<samp>,trace <var>name</var> …</samp>’ sets each
- <var>name</var> in the interaction environment, which should be bound to a
- procedure, to be a traced procedure over the original procedure.
- ‘<samp>,untrace</samp>’ resets all traced procedures to their original,
- untraced procedures. ‘<samp>,untrace <var>name</var> …</samp>’ untraces each
- individual traced procedure of <var>name</var> … in the interaction
- environment.
- </p></dd></dl>
- <span id="index-backtrace"></span>
- <span id="index-continuation-previews"></span>
- <span id="index-previewing-continuations"></span>
- <dl>
- <dt id="index-_002cpreview">command: <strong>,preview</strong></dt>
- <dd><p>Prints a trace of the previous command level’s suspended continuation.
- This is analogous with stack traces in many debuggers.
- </p></dd></dl>
- <dl>
- <dt id="index-_002cdebug">command: <strong>,debug</strong></dt>
- <dd><p>Invokes the debugger: runs the inspector on the previous command
- level’s saved continuation. For more details, see <a href="#Inspector">Inspector</a>.
- </p></dd></dl>
- <span id="index-proceeding-from-errors"></span>
- <span id="index-returning-from-errors"></span>
- <span id="index-condition-restarting"></span>
- <dl>
- <dt id="index-_002cproceed">command: <strong>,proceed</strong></dt>
- <dt id="index-_002cproceed-1">command: <strong>,proceed</strong> <em>exp</em></dt>
- <dd><p>Returns to the continuation of the condition signalling of the previous
- command level. Only certain kinds of conditions will push a new
- command level, however — breakpoints, errors, and interrupts, and,
- if the <code>break-on-warnings</code> switch is on, warnings —; also,
- certain kinds of errors that do push new command levels do not permit
- being proceeded from. In particular, only with a few VM primitives may
- the <code>,proceed</code> command be used. If <var>exp</var> is passed, it is
- evaluated in the interaction environment to produce the values to
- return; if it is not passed, zero values are returned.
- </p></dd></dl>
- <hr>
- <span id="Inspector"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Inspector-1"></span><h4 class="subsection">2.4.9 Inspector</h4>
- <p>Scheme48 provides a simple interactive object inspector. The command
- processor’s prompt’s end changes from ‘<samp>></samp>’ to ‘<samp>:</samp>’ when in
- inspection mode. The inspector is the basis of the debugger, which is,
- for the most part, merely an inspector of continuations. In the
- debugger, the prompt is ‘<samp>debug:</samp>’. In the inspector, objects are
- printed followed by menus of their components. Entries in the menu are
- printed with the index, which optionally includes a symbolic name, and
- the value of the component. For example, a pair whose car is the
- symbol <code>a</code> and whose cdr is the symbol <code>b</code> would be printed
- by the inspector like this:
- </p>
- <div class="example">
- <pre class="example">'(a . b)
- [0: car] 'a
- [1: cdr] 'b</pre></div>
- <p>The inspector maintains a stack of the focus objects it previously
- inspected. Selecting a new focus object pushes the current one onto
- the stack; the <code>u</code> command pops the stack.
- </p>
- <dl>
- <dt id="index-_002cinspect">command: <strong>,inspect</strong></dt>
- <dt id="index-_002cinspect-1">command: <strong>,inspect</strong> <em>exp</em></dt>
- <dd><p>Invokes the inspector. If <var>exp</var> is present, it is evaluated in the
- user package and its result is inspected (or a list of results, if it
- returned multiple values, is inspected). If <var>exp</var> is absent, the
- current focus value is inspected.
- </p></dd></dl>
- <p>The inspector operates with its own set of commands, separate from the
- regular interaction commands, although regular commands may be invoked
- from the inspector as normal. Inspector commands are entered with or
- without a preceding comma at the inspector prompt. Multiple inspector
- commands may be entered on one line; an input may also consist of an
- expression to be evaluated. If an expression is evaluated, its value
- is selected as the focus object. Note, however, that, since inspector
- commands are symbols, variables cannot be evaluated just by entering
- their names; one must use either the <code>,run</code> command or wrap the
- variables in a <code>begin</code>.
- </p>
- <p>These inspector commands are defined:
- </p>
- <dl>
- <dt id="index-menu">inspector command: <strong>menu</strong></dt>
- <dt id="index-m">inspector command: <strong>m</strong></dt>
- <dd><p><code>Menu</code> prints a menu for the focus object. <code>M</code> moves
- forward in the current menu if there are more than sixteen items to be
- displayed.
- </p></dd></dl>
- <dl>
- <dt id="index-u">inspector command: <strong>u</strong></dt>
- <dd><p>Pops the stack of focus objects, discarding the current one and setting
- the focus object to the current top of the stack.
- </p></dd></dl>
- <dl>
- <dt id="index-q">inspector command: <strong>q</strong></dt>
- <dd><p>Quits the inspector, going back into the read-eval-print loop.
- </p></dd></dl>
- <dl>
- <dt id="index-template">inspector command: <strong>template</strong></dt>
- <dd><p>Attempts to coerce the focus object into a template. If successful,
- this selects it as the new focus object; if not, this prints an error
- to that effect. Templates are the static components of closures and
- continuations: they contain the code for the procedure, the top-level
- references made by the procedure, literal constants used in the code,
- and any inferior templates of closures that may be constructed by the
- code.
- </p></dd></dl>
- <dl>
- <dt id="index-d">inspector command: <strong>d</strong></dt>
- <dd><p>Goes down to the parent of the continuation being inspected. This
- command is valid only in the debugger mode, <i>i.e.</i> when the focus object
- is a continuation.
- </p></dd></dl>
- <hr>
- <span id="Command-programs"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Command-programs-1"></span><h4 class="subsection">2.4.10 Command programs</h4>
- <span id="index-exec-language"></span>
- <span id="index-exec-package"></span>
- <p>The Scheme48 command processor can be controlled programmatically by
- <em>command programs</em>, programs written in the <em>exec language</em>.
- This language is essentially a mirror of the commands but in a syntax
- using S-expressions. The language also includes all of Scheme. The
- exec language is defined as part of the <em>exec package</em>.
- </p>
- <dl>
- <dt id="index-_002cexec">command: <strong>,exec</strong></dt>
- <dt id="index-_002cexec-1">command: <strong>,exec</strong> <em>command</em></dt>
- <dd><p>Sets the interaction environment to be the exec package. If an
- argument is passed, it is set temporarily, only to run the given
- command.
- </p></dd></dl>
- <p>Commands in the exec language are invoked as procedures in Scheme.
- Arguments should be passed as follows:
- </p>
- <ul>
- <li> Identifiers, such as those of structure names in the config package,
- should be passed as literal symbols. For instance, the command
- ‘<samp>,in frobbotz</samp>’ would become in the exec language <code>(in
- 'frobbotz)</code>.
- </li><li> Filenames should be passed as strings; <i>e.g.</i>, ‘<samp>,dump frob.image</samp>’
- becomes <code>(dump "frob.image")</code>.
- </li><li> Commands should be represented in list values with the car being the
- command name and the cdr being the arguments. Note that when applying
- a command an argument that is a command invocation is often quoted to
- produce a list, but the list should not include any quotation; for
- instance, ‘<samp>,in mumble ,undefine frobnicate</samp>’ would become <code>(in
- 'mumble '(undefine frobnicate))</code>, even though simply ‘<samp>,undefine
- frobnicate</samp>’ would become <code>(undefine 'frobnicate)</code>.
- <p>The reason for this is that the command invocation in the exec language
- is different from a list that represents a command invocation passed as
- an argument to another command; since commands in the exec language are
- ordinary procedures, the arguments must be quoted, but the quoted
- arguments are not themselves evaluated: they are applied as commands.
- </p>
- <p>An argument to a command that expects a command invocation can also be
- a procedure, which would simply be called with zero arguments. For
- instance, <code>(config (lambda () (display (interaction-environment))
- (newline)))</code> will call the given procedure with the interaction
- environment set to the config package.
- </p>
- </li><li> Expressions must be passed using the <code>run</code> command. For
- example, the equivalent of ‘<samp>,user (+ 1 2)</samp>’ in the exec language
- would be <code>(user '(run (+ 1 2)))</code>.
- </li></ul>
- <p>Command programs can be loaded by running the <code>,load</code> command
- in the exec package. Scripts to load application bundles are usually
- written in the exec language and loaded into the exec package. For
- example, this command program, when loaded into the exec package, will
- load <samp>foo.scm</samp> into the config package, ensure that the package
- <code>frobbotzim</code> is loaded, and open the <code>quuxim</code> structure in
- the user package:
- </p>
- <div class="lisp">
- <pre class="lisp">(config '(load "foo.scm"))
- (load-package 'frobbotzim)
- (user '(open quuxim))</pre></div>
- <hr>
- <span id="Image_002dbuilding-commands"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Image_002dbuilding-commands-1"></span><h4 class="subsection">2.4.11 Image-building commands</h4>
- <span id="index-dumping-heap-images"></span>
- <span id="index-heap-image-dumping"></span>
- <span id="index-image-dumping"></span>
- <span id="index-writing-heap-images"></span>
- <span id="index-heap-image-writing"></span>
- <span id="index-image-writing"></span>
- <p>Since Scheme48’s operation revolves about an image-based model, these
- commands provide a way to save heap images on the file system, which
- may be resumed by invoking the Scheme48 virtual machine on them as in
- <a href="#Running-Scheme48">Running Scheme48</a>.
- </p>
- <dl>
- <dt id="index-_002cbuild">command: <strong>,build</strong> <em>resumer filename</em></dt>
- <dt id="index-_002cdump">command: <strong>,dump</strong> <em>filename</em></dt>
- <dt id="index-_002cdump-1">command: <strong>,dump</strong> <em>filename message</em></dt>
- <dd><p><code>,build</code> evaluates <var>resumer</var>, whose value should be a unary
- procedure, and builds a heap image in <var>filename</var> that, when resumed
- by the virtual machine, will pass the resumer all of the command-line
- arguments after the <samp>-a</samp> argument to the virtual machine. The
- run-time system will have been initialized as with <a href="#Suspending-and-resuming-heap-images">usual resumers</a>, and a basic condition handler
- will have been installed by the time that the resumer is called. On
- Unix, <var>resumer</var> must return an integer exit status for the process.
- <code>,dump</code> dumps the Scheme48 command processor, including all of
- the current settings, to <var>filename</var>. If <var>message</var> is passed,
- it should be a string delimited by double-quotes, and it will be
- printed as part of the welcome banner on startup; its default value, if
- it is not present, is <code>"(suspended image)"</code>.
- </p></dd></dl>
- <hr>
- <span id="Resource-statistics-and-control"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Resource-statistics-and-control-1"></span><h4 class="subsection">2.4.12 Resource statistics and control</h4>
- <p>Scheme48 provides several devices for querying statistics about various
- resources and controlling resources, both in the command processor and
- programmatically.
- </p>
- <span id="index-garbage-collection_002c-forcing"></span>
- <span id="index-forcing-garbage-collection"></span>
- <dl>
- <dt id="index-_002ccollect">command: <strong>,collect</strong></dt>
- <dd><p>Forces a garbage collection and prints the amount of space in the heap
- before and after the collection.
- </p></dd></dl>
- <span id="index-timing-execution"></span>
- <span id="index-execution-timing"></span>
- <dl>
- <dt id="index-_002ctime">command: <strong>,time</strong> <em>expression</em></dt>
- <dd><p>Evaluates <var>expression</var> and prints how long it took. Three numbers
- are printed: run time, GC time, and real time. The run time is the
- amount of time in Scheme code; the GC time is the amount of time spent
- in the garbage collector; and the real time is the actual amount of
- time that passed during the expression’s evaluation.
- </p></dd></dl>
- <span id="index-debug-data-storage-control"></span>
- <span id="index-storage-control-of-debug-data"></span>
- <dl>
- <dt id="index-_002ckeep">command: <strong>,keep</strong></dt>
- <dt id="index-_002ckeep-1">command: <strong>,keep</strong> <em>kind …</em></dt>
- <dt id="index-_002cflush">command: <strong>,flush</strong></dt>
- <dt id="index-_002cflush-1">command: <strong>,flush</strong> <em>kind …</em></dt>
- <dd><p>Scheme48 maintains several different kinds of information used for
- debugging information. ‘<samp>,keep</samp>’ with no arguments shows what kinds
- of debugging data are preserved and what kinds are not. ‘<samp>,keep
- <var>kind</var> …</samp>’ requests that the debugging data of the given kinds
- should be kept; the <code>,flush</code> command requests the opposite.
- ‘<samp>,flush</samp>’ with no arguments flushes location names and resets the
- debug data table. The following are the kinds of debugging data:
- </p>
- <dl compact="compact">
- <dt><code>names</code></dt>
- <dd><p>procedure names
- </p></dd>
- <dt><code>maps</code></dt>
- <dd><p>environment maps used by the debugger to show local variable names
- </p></dd>
- <dt><code>files</code></dt>
- <dd><p>filenames where procedures were defined
- </p></dd>
- <dt><code>source</code></dt>
- <dd><p>source code surrounding continuations, printed by the debugger
- </p></dd>
- <dt><code>tabulate</code></dt>
- <dd><p>if true, will store debug data records in a global table that can be
- easily flushed; if false, will store directly in compiled code
- </p></dd>
- </dl>
- <p><code>,flush</code> can also accept <code>location-names</code>, which will
- flush the table of top-level variables’ names (printed, for example, by
- the <code>,bound?</code> command); <code>file-packages</code>, which will flush
- the table that maps filenames to packages in which code from those files
- should be evaluated; or <code>table</code>, in which case the table of debug
- data is flushed.
- </p>
- <p>Removing much debug data can significantly reduce the size of Scheme48
- heap images, but it can also make error messages and debugging much
- more difficult. Usually, all debug data is retained; only for images
- that must be small and that do not need to be debuggable should the
- debugging data flags be turned off.
- </p></dd></dl>
- <span id="index-space-usage-analysis"></span>
- <span id="index-heap-space-analysis"></span>
- <span id="index-displaying-heap-usage"></span>
- <span id="index-spatial"></span>
- <p>The <code>spatial</code> structure exports these utilities for displaying
- various statistics about the heap:
- </p>
- <dl>
- <dt id="index-space">procedure: <strong>space</strong> <em>--> unspecified</em></dt>
- <dt id="index-vector_002dspace">procedure: <strong>vector-space</strong> <em>[predicate] --> unspecified</em></dt>
- <dt id="index-record_002dspace">procedure: <strong>record-space</strong> <em>[predicate] --> unspecified</em></dt>
- <dd><p><code>Space</code> prints out a list of the numbers of all objects and the
- number of bytes allocated for those objects on the heap, partitioned by
- the objects’ primitive types and whether or not they are immutable
- (pure) or mutable (impure). <code>Vector-space</code> prints the number of
- vectors and the number of bytes used to store those vectors of several
- different varieties, based on certain heuristics about their form. If
- the predicate argument is passed, it gathers only vectors that satisfy
- that predicate. <code>Record-space</code> prints out, for each record type
- in the heap, both the number of all instances of that record type and
- the number of bytes used to store all of those instances. Like
- <code>vector-space</code>, if the predicate argument is passed,
- <code>record-space</code> will consider only those records that satisfy the
- predicate.
- </p>
- <p>All of these three procedures first invoke the garbage collector before
- gathering statistics.
- </p></dd></dl>
- <span id="index-object-reference-analysis"></span>
- <span id="index-storage-leak-analysis"></span>
- <span id="index-heap-traversal"></span>
- <span id="index-traverse"></span>
- <p>The <code>traverse</code> structure provides a simple utility for finding
- paths by which objects refer to one another.
- </p>
- <dl>
- <dt id="index-traverse_002dbreadth_002dfirst">procedure: <strong>traverse-breadth-first</strong> <em>object --> unspecified</em></dt>
- <dt id="index-traverse_002ddepth_002dfirst">procedure: <strong>traverse-depth-first</strong> <em>object --> unspecified</em></dt>
- <dd><p>These traverse the heap, starting at <var>object</var>, recording all
- objects transitively referred to. <code>Traverse-breadth-first</code> uses
- a FIFO-queue-directed breadth-first graph traversal, while
- <code>traverse-depth-first</code> uses a LIFO-stack-directed depth-first
- graph traversal. The traversal halts at any leaves in the graph,
- which are distinguished by an internal <em>leaf predicate</em> in the
- module. See below on <code>set-leaf-predicate!</code> on how to customize
- this and what the default is.
- </p>
- <p>The traversal information is recorded in a global resource; it is not
- thread-safe, and intended only for interactive usage. The record can
- be reset by passing some simple object with no references to either
- <code>traverse-breadth-first</code> or <code>traverse-depth-first</code>; <i>e.g.</i>,
- <code>(traverse-depth-first #f)</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-trail">procedure: <strong>trail</strong> <em>object --> unspecified</em></dt>
- <dd><p>After traversing the heap from an initial object, <code>(trail
- <var>object</var>)</code> prints the path of references and intermediate objects
- by which the initial object holds a transitive reference to
- <var>object</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-set_002dleaf_002dpredicate_0021">procedure: <strong>set-leaf-predicate!</strong> <em>predicate --> unspecified</em></dt>
- <dt id="index-usual_002dleaf_002dpredicate">procedure: <strong>usual-leaf-predicate</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Set-leaf-predicate!</code> sets the current leaf predicate to be
- <var>predicate</var>. <code>Usual-leaf-predicate</code> is the default leaf
- predicate; it considers simple numbers (integers and flonums),
- strings, byte vectors, characters, and immediate objects (true, false,
- nil, and the unspecific object) to be leaves, and everything else to
- be branches.
- </p></dd></dl>
- <hr>
- <span id="Module-system"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Module-system-1"></span><h2 class="chapter">3 Module system</h2>
- <p>Scheme48 has an advanced module system that is designed to interact
- well with macros, incremental compilation, and the <a href="#User-environment">interactive development environment’s</a> code reloading
- facilities for rapid program development. For details on the
- integration of the module system and the user environment for rapid
- code reloading, see <a href="#Using-the-module-system">Using the module system</a>.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Module-system-architecture" accesskey="1">Module system architecture</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Module-configuration-language" accesskey="2">Module configuration language</a></td><td> </td><td align="left" valign="top">Language of the module system
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Macros-in-concert-with-modules" accesskey="3">Macros in concert with modules</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Static-type-system" accesskey="4">Static type system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="Module-system-architecture"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Module-system-architecture-1"></span><h3 class="section">3.1 Module system architecture</h3>
- <span id="index-configuration-language"></span>
- <span id="index-module-language"></span>
- <p>The fundamental mechanism by which Scheme code is evaluated is the
- lexical environment. Scheme48’s module system revolves around this
- fundamental concept. Its purpose is to control the denotation of names
- in code<a id="DOCF5" href="#FOOT5"><sup>5</sup></a> in a
- structured, modular manner. The module system is manipulated by a
- static <em>configuration language</em>, described in the next section;
- this section describes the concepts in the architecture of the module
- system.
- </p>
- <span id="index-packages"></span>
- <span id="index-structures"></span>
- <span id="index-interfaces-1"></span>
- <span id="index-modules"></span>
- <p>The <em>package</em> is the entity internal to the module system that
- maps a set of names to denotations. For example, the package that
- represents the Scheme language maps <code>lambda</code> to a descriptor for
- the special form that the compiler interprets to construct a procedure,
- <code>car</code> to the procedure that accesses the car of a pair, <i>&c</i>.
- Packages are not explicitly manipulated by the configuration language,
- but they lie underneath structures, which are described below. A
- package also contains the code of a module and controls the visibility
- of names within that code. It also includes some further information,
- such as optimizer switches. A <em>structure</em> is a view on a package;
- that is, it contains a package and an <em>interface</em> that lists all of
- the names it exports to the outside. Multiple structures may be
- constructed atop a single package; this mechanism is often used to offer
- multiple abstraction levels to the outside. A <em>module</em> is an
- abstract entity: it consists of some code, the namespace visible to the
- code, and the set of abstractions or views upon that code.
- </p>
- <span id="index-opening-structures-1"></span>
- <span id="index-structures_002c-opening-1"></span>
- <p>A package contains a list of the structures whose bindings should be
- available in the code of that package. If a structure is referred to
- in a such a list of a package, the package is said to <em>open</em> that
- structure. It is illegal for a package to open two structures whose
- interfaces contain the same name.<a id="DOCF6" href="#FOOT6"><sup>6</sup></a> Packages may also modify the names of the bindings
- that they import. They may import only selected bindings, exclude
- certain bindings from structures, rename imported bindings, create
- alias bindings, and add prefixes to names.
- </p>
- <span id="index-scheme"></span>
- <span id="index-prescheme"></span>
- <p>Most packages will open the standard <code>scheme</code> structure, although
- it is not implicitly opened, and the module system allows not opening
- <code>scheme</code>. It may seem to be not very useful to not open it, but
- this is necessary if some bindings from it are intended to be shadowed
- by another structure, and it allows for entirely different languages
- from Scheme to be used in a package’s code. For example, Scheme48’s
- byte code interpreter virtual machine is implemented in a subset of
- Scheme called Pre-Scheme, which is described in a later chapter in this
- manual. The modules that compose the VM all open not the <code>scheme</code>
- structure but the <em><code>prescheme</code></em> structure. The configuration
- language itself is controlled by the module system, too. In another
- example, from Scsh, the Scheme shell, there is a structure <code>scsh</code>
- that contains all of the Unix shell programming facilities. However,
- the <code>scsh</code> structure necessarily modifies some of the bindings
- related to I/O that the <code>scheme</code> structure exports. Modules could
- not open both <code>scheme</code> and <code>scsh</code>, because they both provide
- several bindings with the same names, so Scsh defines a more convenient
- <code>scheme-with-scsh</code> structure that opens both <code>scheme</code>, but
- with all of the shadowed bindings excluded, and <code>scsh</code>; modules
- that use Scsh would open neither <code>scsh</code> nor <code>scheme</code>: they
- instead open just <code>scheme-with-scsh</code>.
- </p>
- <span id="index-interface-reuse"></span>
- <span id="index-compound-interfaces"></span>
- <span id="index-interface-abstraction"></span>
- <p>Interfaces are separated from structures in order that they may be
- reüsed and combined. For example, several different modules may
- implement the same abstractions differently. The structures that they
- include would, in such cases, reüse the same interfaces. Also, it is
- sometimes desirable to combine several interfaces into a <em>compound
- interface</em>; see the <code>compound-interface</code> form in the next section.
- Furthermore, during interactive development, interface definitions may
- be reloaded, and the structures that use them will automatically begin
- using the new interfaces; see <a href="#Using-the-module-system">Using the module system</a>.
- </p>
- <span id="index-parameterized-modules"></span>
- <span id="index-generic-modules"></span>
- <span id="index-higher_002dorder-modules"></span>
- <span id="index-functors"></span>
- <p>Scheme48’s module system also supports <em>parameterized modules</em>.
- Parameterized modules, sometimes known as <em>generic modules</em>,
- <em>higher-order modules</em> or <em>functors</em>, are essentially functions
- at the module system level that map structures to structures. They may
- be instantiated or applied arbitrarily many times, and they may accept
- and return arbitrarily many structures. Parameterized modules may also
- accept and return other parameterized modules.
- </p><hr>
- <span id="Module-configuration-language"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Module-configuration-language-1"></span><h3 class="section">3.2 Module configuration language</h3>
- <span id="index-configuration-language-1"></span>
- <span id="index-module-language-1"></span>
- <p>Scheme48’s module system is used through a <em>module configuration
- language</em>. <em>The configuration language is entirely separate from
- Scheme.</em> Typically, in one configuration, or set of components that
- compose a program, there is an <samp>interfaces.scm</samp> file that defines
- all of the interfaces used by the configuration, and there is also a
- <samp>packages.scm</samp> file that defines all of the packages & structures
- that compose it. Note that modules are not necessarily divided into
- files or restricted to one file: modules may include arbitrarily many
- files, and modules’ code may also be written in-line to structure
- expressions (see the <code>begin</code> package clause below), although that
- is usually only for expository purposes and trivial modules.
- </p>
- <span id="index-package-clauses"></span>
- <p>Structures are always created with corresponding <em>package clauses</em>.
- Each clause specifies an attribute of the package that underlies the
- structure or structures created using the clauses. There are several
- different types of clauses:
- </p>
- <span id="index-opening-structures-2"></span>
- <span id="index-structures_002c-opening-2"></span>
- <span id="index-accessing-structures"></span>
- <span id="index-structures_002c-accessing"></span>
- <span id="index-structure_002drefs"></span>
- <span id="index-structure_002dref"></span>
- <dl>
- <dt id="index-open">package clause: <strong>open</strong> <em>structure …</em></dt>
- <dt id="index-access">package clause: <strong>access</strong> <em>structure …</em></dt>
- <dd><p><code>Open</code> specifies that the package should open each of the listed
- structures, whose packages will be loaded if necessary. <code>Access</code>
- specifies that each listed structure should be accessible using the
- <code>(structure-ref <var>structure</var> <var>identifier</var>)</code> special form,
- which evaluates to the value of <var>identifier</var> exported by the
- accessed structure <var>structure</var>. <code>Structure-ref</code> is available
- from the <code>structure-refs</code> structure. Each <var>structure</var> passed
- to <code>access</code> is not opened, however; the bindings exported thereby
- are available only using <code>structure-ref</code>. While the qualified
- <code>structure-ref</code> mechanism is no longer useful in the presence of
- modified structures (see below on <code>modify</code>, <code>subset</code>, &
- <code>with-prefix</code>), some old code still uses it, and <code>access</code> is
- also useful to force that the listed structures’ packages be loaded
- without cluttering the namespace of the package whose clauses the
- <code>access</code> clause is among.
- </p></dd></dl>
- <dl>
- <dt id="index-for_002dsyntax-2">package clause: <strong>for-syntax</strong> <em>package-clause …</em></dt>
- <dd><p>Specifies a set of package clauses for the next floor of the reflective
- tower; see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-files">package clause: <strong>files</strong> <em>file-specifier …</em></dt>
- <dt id="index-begin">package clause: <strong>begin</strong> <em>code …</em></dt>
- <dd><p><code>Files</code> and <code>begin</code> specify the package’s code. <code>Files</code>
- takes a sequence of namelists for the filenames of files that contain
- code; see <a href="#Filenames">Filenames</a>. <code>Begin</code> accepts in-line program code.
- </p></dd></dl>
- <span id="index-compiler-optimization"></span>
- <span id="index-optimizer"></span>
- <dl>
- <dt id="index-optimize">package clause: <strong>optimize</strong> <em>optimizer-specifier …</em></dt>
- <dt id="index-integrate">package clause: <strong>integrate</strong> <em>[on?]</em></dt>
- <dd><p><code>Optimize</code> clauses request that specified compiler optimizers be
- applied to the code. (Actually, ‘optimizer’ is a misnomer. The
- <code>optimize</code> clause may specify arbitrary passes that the compiler
- can be extended with.)
- <code>Integrate</code> clauses specify whether or not integrable procedures
- from other modules, most notably Scheme primitives such as <code>car</code>
- or <code>vector-ref</code>, should actually be integrated in this package.
- This is by default on. Most modules should leave it on for any
- reasonable performance; only a select few, into which code is intended
- to be dynamically loaded frequently and in which redefinition of
- imported procedures is common, need turn this off. The value of the
- argument to <code>integrate</code> clauses should be a literal boolean, <i>i.e.</i>
- <code>#t</code> or <code>#f</code>; if no argument is supplied, integration is
- enabled by default.
- </p>
- <span id="index-auto_002dintegrate-optimizer"></span>
- <span id="index-procedure-integration"></span>
- <span id="index-integrated-procedures"></span>
- <span id="index-in_002dline-procedures"></span>
- <span id="index-flat_002denvironments-optimizer"></span>
- <span id="index-closure-flattening"></span>
- <span id="index-flat-closures"></span>
- <span id="index-environment-flattening"></span>
- <span id="index-flat-environments"></span>
- <p>Currently, the only optimizer built-in to Scheme48 is the automatic
- procedure integrator, or <code>auto-integrate</code>, which attempts stronger
- 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
- integrable (so that the body will be compiled in-line in all known call
- sites). Older versions of Scheme48 also provided another optimizer,
- <code>flat-environments</code>, which would flatten certain lexical closure
- environments, rather than using a nested environment structure. Now,
- however, Scheme48’s byte code compiler always flattens environments;
- specifying <code>flat-environments</code> in an <code>optimize</code> clause does
- nothing.
- </p></dd></dl>
- <span id="index-structure-definition-forms"></span>
- <p>A configuration is a sequence of definitions. There are definition
- forms for only structures and interfaces.
- </p>
- <dl>
- <dt id="index-define_002dstructure">configuration form: <strong>define-structure</strong> <em>name interface package-clause …</em></dt>
- <dt id="index-define_002dstructures">configuration form: <strong>define-structures</strong> <em>((name interface) …) package-clause …</em></dt>
- <dd><p><code>Define-structure</code> creates a package with the given package
- clauses and defines <var>name</var> to be the single view atop it, with the
- interface <var>interface</var>. <code>Define-structures</code> also creates a
- package with the given package clauses; upon that package, it defines
- each <var>name</var> to be a view on it with the corresponding interface.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002dmodule">configuration form: <strong>define-module</strong> <em>(name parameter …) definition … result</em></dt>
- <dt id="index-def">configuration form: <strong>def</strong> <em>name … (parameterized-module argument …)</em></dt>
- <dd><p><code>Define-module</code> defines <var>name</var> to be a parameterized module
- that accepts the given parameters.
- </p></dd></dl>
- <span id="index-interface-definition-forms"></span>
- <dl>
- <dt id="index-define_002dinterface">configuration form: <strong>define-interface</strong> <em>name interface</em></dt>
- <dd><p>Defines <var>name</var> to be the interface that <var>interface</var> evaluates
- to. <var>Interface</var> may either be an interface constructor application
- or simply a name defined to be an interface by some prior
- <code>define-interface</code> form.
- </p></dd></dl>
- <span id="index-simple-interfaces"></span>
- <dl>
- <dt id="index-export">interface constructor: <strong>export</strong> <em>export-specifier …</em></dt>
- <dd><p><code>Export</code> constructs a simple interface with the given export
- specifiers. The export specifiers specify names to export and their
- corresponding static types. Each <var>export-specifier</var> should have
- one of the following forms:
- </p>
- <dl compact="compact">
- <dt><code><var>symbol</var></code></dt>
- <dd><p>in which case <var>symbol</var> is exported with the most general value type;
- </p>
- </dd>
- <dt><code>(<var>symbol</var> <var>type</var>)</code></dt>
- <dd><p>in which case <var>symbol</var> is exported with the given type; or
- </p>
- </dd>
- <dt><code>((<var>symbol</var> …) <var>type</var>)</code></dt>
- <dd><p>in which case each <var>symbol</var> is exported with the same given type
- </p></dd>
- </dl>
- <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
- explicitly annotated with the type <code>:syntax</code>; otherwise they would
- be exported with a Scheme value type, which would confuse the compiler,
- because it would not realize that they are macros: it would instead
- treat them as ordinary variables that have regular run-time values.
- </p></dd></dl>
- <span id="index-compound-interfaces-1"></span>
- <dl>
- <dt id="index-compound_002dinterface">interface constructor: <strong>compound-interface</strong> <em>interface …</em></dt>
- <dd><p>This constructs an interface that contains all of the export specifiers
- from each <var>interface</var>.
- </p></dd></dl>
- <span id="index-anonymous-structures"></span>
- <p>Structures may also be constructed anonymously; this is typically most
- useful in passing them to or returning them from parameterized modules.
- </p>
- <dl>
- <dt id="index-structure">structure constructor: <strong>structure</strong> <em>interface package-clauses</em></dt>
- <dt id="index-structures-1">structure constructor: <strong>structures</strong> <em>(interface …) package-clauses</em></dt>
- <dd><p><code>Structure</code> creates a package with the given clauses and evaluates
- to a structure over it with the given interface. <code>Structures</code>
- does similarly, but it evaluates to a number of structures, each with
- the corresponding <var>interface</var>.
- </p></dd></dl>
- <span id="index-modified-structures"></span>
- <span id="index-modified-interfaces"></span>
- <dl>
- <dt id="index-subset">structure constructor: <strong>subset</strong> <em>structure (name …)</em></dt>
- <dt id="index-with_002dprefix">structure constructor: <strong>with-prefix</strong> <em>structure name</em></dt>
- <dt id="index-modify">structure constructor: <strong>modify</strong> <em>structure modifier …</em></dt>
- <dd><p>These modify the interface of <var>structure</var>. <code>Subset</code> evaluates
- to a structure that exports only <var>name</var> …, excluding any
- other names that <var>structure</var> exported. <code>With-prefix</code> adds a
- prefix <var>name</var> to every name listed in <var>structure</var>’s interface.
- Both <code>subset</code> and <code>with-prefix</code> are syntactic sugar for the
- more general <code>modify</code>, which applies the modifier commands in a
- strictly right-to-left or last-to-first order. <strong>Note:</strong> These
- all <em>denote new structures with new interfaces</em>; they do not
- destructively modify existing structures’ interfaces.
- </p></dd></dl>
- <dl>
- <dt id="index-prefix">modifier command: <strong>prefix</strong> <em>name</em></dt>
- <dt id="index-expose">modifier command: <strong>expose</strong> <em>name …</em></dt>
- <dt id="index-hide">modifier command: <strong>hide</strong> <em>name …</em></dt>
- <dt id="index-alias">modifier command: <strong>alias</strong> <em>(from to) …</em></dt>
- <dt id="index-rename">modifier command: <strong>rename</strong> <em>(from to) …</em></dt>
- <dd><p><code>Prefix</code> adds the prefix <var>name</var> to every exported name in the
- structure’s interface. <code>Expose</code> exposes only <var>name</var> …;
- any other names are hidden. <code>Hide</code> hides <var>name</var> ….
- <code>Alias</code> exports each <var>to</var> as though it were the corresponding
- <var>from</var>, as well as each <var>from</var>. <code>Rename</code> exports each
- <var>to</var> as if it were the corresponding <var>from</var>, but it also hides
- the corresponding <var>from</var>.
- </p>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(modify <var>structure</var>
- (prefix foo:)
- (expose bar baz quux))</pre></div>
- <p>makes only <code>foo:bar</code>, <code>foo:baz</code>, and <code>foo:quux</code>,
- available.
- </p>
- <div class="lisp">
- <pre class="lisp">(modify <var>structure</var>
- (hide baz:quux)
- (prefix baz:)
- (rename (foo bar)
- (mumble frotz))
- (alias (gargle mumph)))</pre></div>
- <p>exports <code>baz:gargle</code> as what was originally <code>mumble</code>,
- <code>baz:mumph</code> as an alias for what was originally <code>gargle</code>,
- <code>baz:frotz</code> as what was originally <code>mumble</code>, <code>baz:bar</code>
- as what was originally <code>foo</code>, <em>not</em> <code>baz:quux</code> — what
- was originally simply <code>quux</code> —, and everything else that
- <var>structure</var> exported, but with a prefix of <code>baz:</code>.
- </p></dd></dl>
- <p>There are several simple utilities for binding variables to structures
- locally and returning multiple structures not necessarily over the same
- package (<i>i.e.</i> not with <code>structures</code>). These are all valid in the
- bodies of <code>define-module</code> and <code>def</code> forms, and in the
- arguments to parameterized modules and <code>open</code> package clauses.
- </p>
- <dl>
- <dt id="index-begin-1">syntax: <strong>begin</strong> <em>body</em></dt>
- <dt id="index-let">syntax: <strong>let</strong> <em>((name value) …) body</em></dt>
- <dt id="index-receive">syntax: <strong>receive</strong> <em>(name …) producer body</em></dt>
- <dt id="index-values">syntax: <strong>values</strong> <em>value …</em></dt>
- <dd><p>These are all as in ordinary Scheme. Note, however, that there is no
- reasonable way by which to use <code>values</code> except to call it, so it
- is considered a syntax; also note that <code>receive</code> may not receive
- a variable number of values — <i>i.e.</i> there are no ‘rest lists’ —,
- because list values in the configuration language are nonsensical.
- </p></dd></dl>
- <span id="index-macros-in-the-module-configuration-language"></span>
- <span id="index-configuration-language-macros"></span>
- <span id="index-module-language-macros"></span>
- <p>Finally, the configuration language also supports syntactic extensions,
- or macros, as in Scheme.
- </p>
- <dl>
- <dt id="index-define_002dsyntax">configuration form: <strong>define-syntax</strong> <em>name transformer-specifier</em></dt>
- <dd><p>Defines the syntax transformer <var>name</var> to be the transformer
- specified by <var>transformer-specifier</var>. <var>Transformer-specifier</var>
- is exactly the same as in Scheme code; it is evaluated as ordinary
- Scheme.
- </p></dd></dl>
- <hr>
- <span id="Macros-in-concert-with-modules"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Macros-in-concert-with-modules-1"></span><h3 class="section">3.3 Macros in concert with modules</h3>
- <p>One reason that the standard Scheme language does not support a module
- system yet is the issue of macros and modularity. There are several
- issues to deal with:
- </p>
- <ul>
- <li> <span id="index-separate-compilation"></span>
- that compilation of code that uses macros requires presence of those
- macros’ definitions, which prevents true separate compilation, because
- those macros may be from other modules;
- </li><li> <span id="index-hygiene-of-macros-in-modules"></span>
- <span id="index-referential-transparency-of-macros-in-modules"></span>
- <span id="index-macro-hygiene-in-modules"></span>
- <span id="index-macro-referential-transparency-in-modules"></span>
- that a macro’s expansion must preserve referential transparency and
- hygiene, for example in cases where it refers to names from within the
- module in which it was defined, even if those names weren’t exported;
- and
- </li><li> <span id="index-phase-separation"></span>
- <span id="index-towers-of-evaluation-phases"></span>
- that a macro’s code may be arbitrary Scheme code, which in turn can use
- other modules, so one module’s compile-time, when macros are expanded,
- is another’s run-time, when the code used in macros is executed by the
- expander: this makes a tower of phases of code evaluation over which
- some coherent control must be provided.
- </li></ul>
- <p>Scheme48’s module system tries to address all of these issues
- coherently and comprehensively. Although it cannot offer <em>total</em>
- separate compilation, it can offer incremental compilation, and
- compiled modules can be dumped to the file system & restored in the
- process of incremental compilation.<a id="DOCF7" href="#FOOT7"><sup>7</sup></a>
- </p>
- <p>Scheme48’s module system is also very careful to preserve non-local
- module references from a macro’s expansion. Macros in Scheme48 are
- required to perform hygienic renaming in order for this preservation,
- however; see <a href="#Explicit-renaming-macros">Explicit renaming macros</a>. For a brief example,
- consider the <code>delay</code> syntax for lazy evaluation. It expands to a
- simple procedure call:
- </p>
- <div class="lisp">
- <pre class="lisp">(delay <var>expression</var>)
- → (make-promise (lambda () <var>expression</var>))</pre></div>
- <p>However, <code>make-promise</code> is not exported from the <code>scheme</code>
- structure. The expansion works correctly due to the hygienic renaming
- performed by the <code>delay</code> macro transformer: when it hygienically
- renames <code>make-promise</code>, the output contains not the symbol but a
- special token that refers exactly to the binding of <code>make-promise</code>
- from the environment in which the <code>delay</code> macro transformer was
- defined. Special care is taken to preserve this information. Had
- <code>delay</code> expanded to a simple S-expression with simple symbols, it
- would have generated a free reference to <code>make-promise</code>, which
- would cause run-time undefined variable errors, or, if the module in
- which <code>delay</code> was used had its <em>own</em> binding of or imported a
- binding of the name <code>make-promise</code>, <code>delay</code>’s expansion
- would refer to the wrong binding, and there could potentially be
- drastic and entirely unintended impact upon its semantics.
- </p>
- <span id="index-reflective-tower"></span>
- <span id="index-syntactic-tower"></span>
- <span id="index-for_002dsyntax"></span>
- <p>Finally, Scheme48’s module system has a special design for the tower of
- phases, called a <em>reflective tower</em>.<a id="DOCF8" href="#FOOT8"><sup>8</sup></a> Every storey represents the environment available at
- successive macro levels. That is, when the right-hand side of a macro
- definition or binding is evaluated in an environment, the next storey
- in that environment’s reflective tower is used to evaluate that macro
- binding. For example, in this code, there are two storeys used in the
- tower:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (foo ...bar...)
- (let-syntax ((baz ...quux...))
- ...zot...))</pre></div>
- <p>In order to evaluate code in one storey of the reflective tower, it is
- necessary to expand all macros first. Most of the code in this example
- will eventually be evaluated in the first storey of the reflective
- tower (assuming it is an ordinary top-level definition), but, in order
- to expand macros in that code, the <code>let-syntax</code> must be expanded.
- This causes <code>...quux...</code> to be evaluated in the <em>second</em>
- storey of the tower, after which macro expansion can proceed, and long
- after which the enclosing program can be evaluated.
- </p>
- <span id="index-for_002dsyntax-1"></span>
- <p>The module system provides a simple way to manipulate the reflective
- tower. There is a package clause, <code>for-syntax</code>, that simply
- contains package clauses for the next storey in the tower. For
- example, a package with the following clauses:
- </p>
- <div class="lisp">
- <pre class="lisp">(open scheme foo bar)
- (for-syntax (open scheme baz quux))</pre></div>
- <p>has all the bindings of <code>scheme</code>, <code>foo</code>, & <code>bar</code>, at the
- ground storey; and the environment in which macros’ definitions are
- evaluated provides everything from <code>scheme</code>, <code>baz</code>, &
- <code>quux</code>.
- </p>
- <p>With no <code>for-syntax</code> clauses, the <code>scheme</code> structure is
- implicitly opened; however, if there are <code>for-syntax</code> clauses,
- <code>scheme</code> must be explicitly opened.<a id="DOCF9" href="#FOOT9"><sup>9</sup></a> Also, <code>for-syntax</code> clauses
- may be arbitrarily nested: reflective towers are theoretically infinite
- in height. (They are internally implemented lazily, so they grow
- exactly as high as they need to be.)
- </p>
- <p>Here is a simple, though contrived, example of using <code>for-syntax</code>.
- The <code>while-loops</code> structure exports <code>while</code>, a macro similar
- to C’s <code>while</code> loop. <code>While</code>’s transformer unhygienically
- binds the name <code>exit</code> to a procedure that exits from the loop.
- It necessarily, therefore, uses <a href="#Explicit-renaming-macros">explicit renaming macros</a> in order to break hygiene; it also, in the
- macro transformer, uses the <code>destructure</code> macro to destructure the
- input form (see <a href="#Library-utilities">Library utilities</a>, in particular, the structure
- <code>destructuring</code> for destructuring S-expressions).
- </p>
- <div class="lisp">
- <pre class="lisp">(define-structure while-loops (export while)
- (open scheme)
- (for-syntax (open scheme destructuring))
- (begin
- (define-syntax while
- (lambda (form r compare)
- (destructure (((WHILE test . body) form))
- `(,(r 'CALL-WITH-CURRENT-CONTINUATION)
- (,(r 'LAMBDA) (EXIT)
- (,(r 'LET) (r 'LOOP) ()
- (,(r 'IF) ,test
- (,(r 'BEGIN)
- ,@body
- (,(r 'LOOP)))))))))
- (CALL-WITH-CURRENT-CONTINUATION LAMBDA LET IF BEGIN))))</pre></div>
- <p>This next <code>while-example</code> structure defines an example procedure
- <code>foo</code> that uses <code>while</code>. Since <code>while-example</code> has no
- macro definitions, there is no need for any <code>for-syntax</code> clauses;
- it imports <code>while</code> from the <code>while-loops</code> structure only at
- the ground storey, because it has no macro bindings to evaluate the
- transformer expressions of:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-structure while-example (export foo)
- (open scheme while-loops)
- (begin
- (define (foo x)
- (while (> x 9)
- (if (integer? (sqrt x))
- (exit (expt x 2))
- (set! x (- x 1)))))))</pre></div>
- <hr>
- <span id="Static-type-system"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Static-type-system-1"></span><h3 class="section">3.4 Static type system</h3>
- <span id="index-type-inference"></span>
- <span id="index-static-type-analysis"></span>
- <p>Scheme48 supports a rudimentary static type system. It is intended
- mainly to catch some classes of type and arity mismatch errors early,
- at compile-time. By default, there is only <em>extremely</em> basic
- analysis, which is typically only good enough to catch arity errors and
- the really egregious type errors. The full reconstructor, which is
- still not very sophisticated, is enabled by specifying an optimizer
- pass that invokes the code usage analyzer. The only optimizer pass
- built-in to Scheme48, the automatic procedure integrator, named
- <code>auto-integrate</code>, does so.
- </p>
- <p>The type reconstructor attempts to assign the most specific type it can
- to program terms, signalling warnings for terms that are certain to be
- invalid by Scheme’s dynamic semantics. Since the reconstructor is not
- very sophisticated, it frequently gives up and assigns very general
- types to many terms. Note, however, that it is very lenient in that it
- only assigns more general types: it will <em>never</em> signal a warning
- because it could not reconstruct a very specific type. For example,
- the following program will produce no warnings:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (foo x y) (if x (+ y 1) (car y)))</pre></div>
- <p>Calls to <code>foo</code> that are clearly invalid, such as <code>(foo #t
- 'a)</code>, could cause the type analyzer to signal warnings, but it is not
- sophisticated enough to determine that <code>foo</code>’s second argument
- must be either a number or a pair; it simply assigns a general value
- type (see below).
- </p>
- <p>There are some tricky cases that depend on the order by which arguments
- are evaluated in a combination, because that order is not specified in
- Scheme. In these cases, the relevant types are narrowed to the most
- specific ones that could not possibly cause errors at run-time for any
- order. For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(lambda (x) (+ (begin (set! x '(3)) 5) (car x)))</pre></div>
- <p>will be assigned the type <code>(proc (:pair) :number)</code>, because, if
- the arguments are evaluated right-to-left, and <code>x</code> is not a pair,
- there will be a run-time type error.
- </p>
- <p>The type reconstructor presumes that all code is potentially reachable,
- so it may signal warnings for code that the most trivial control flow
- analyzer could decide unreachable. For example, it would signal a
- warning for <code>(if #t 3 (car 7))</code>. Furthermore, it does not account
- for continuation throws; for example, though it is a perfectly valid
- Scheme program, the type analyzer might signal a warning for this code:
- </p>
- <div class="lisp">
- <pre class="lisp">(call-with-current-continuation
- (lambda (k) (0 (k))))</pre></div>
- <span id="index-type-lattice"></span>
- <p>The type system is based on a type lattice. There are several maximum
- or ‘top’ elements, such as <code>:values</code>, <code>:syntax</code>, and
- <code>:structure</code>; and one minimum or ‘bottom’ element, <code>:error</code>.
- This description of the type system makes use of the following
- notations: <code><var>E</var> : <var>T</var></code> means that the term <var>E</var> has the
- type, or some compatible subtype of, <var>T</var>; and <code><var>T<sub>a</sub></var>
- <= <var>T<sub>b</sub></var></code> means that <var>T<sub>a</sub></var> is a compatible
- subtype of <var>T<sub>b</sub></var> — that is, any term whose static type is
- <var>T<sub>a</sub></var> is valid in any context that expects the type
- <var>T<sub>b</sub></var> —.
- </p>
- <p>Note that the previous text has used the word ‘term,’ not ‘expression,’
- because static types are assigned to not only Scheme expressions. For
- example, <code>cond</code> macro has the type <code>:syntax</code>. Structures in
- the configuration language also have static types: their interfaces.
- (Actually, they really have the type <code>:structure</code>, but this is a
- deficiency in the current implementation’s design.) Types, in fact,
- have their own type: <code>:type</code>. Here are some examples of values,
- first-class or otherwise, and their types:
- </p>
- <div class="example">
- <pre class="example">cond : :syntax
- (values 1 'foo '(x . y))
- : (some-values :exact-integer :symbol :pair)
- :syntax : :type
- 3 : :exact-integer
- (define-structure foo (export a b) ...)
- foo : (export a b)</pre></div>
- <span id="index-parametric-polymorphism"></span>
- <p>One notable deficiency of the type system is the absence of any sort of
- parametric polymorphism.
- </p>
- <span id="index-join-types"></span>
- <span id="index-meet-types"></span>
- <dl>
- <dt id="index-join">type constructor: <strong>join</strong> <em>type …</em></dt>
- <dt id="index-meet">type constructor: <strong>meet</strong> <em>type …</em></dt>
- <dd><p><code>Join</code> and <code>meet</code> construct the supremum and infimum elements
- in the type lattice of the given types. That is, for any two disjoint
- types <var>T<sub>a</sub></var> and <var>T<sub>b</sub></var>, let <var>T<sub>j</sub></var> be
- <code>(join <var>T<sub>a</sub></var> <var>T<sub>b</sub></var>)</code> and <var>T<sub>m</sub></var> be
- <code>(meet <var>T<sub>a</sub></var> <var>T<sub>b</sub></var>)</code>:
- </p>
- <ul>
- <li> <var>T<sub>j</sub></var> <= <var>T<sub>a</sub></var> and <var>T<sub>j</sub></var> <= <var>T<sub>b</sub></var>
- </li><li> <var>T<sub>a</sub></var> <= <var>T<sub>m</sub></var> and <var>T<sub>b</sub></var> <= <var>T<sub>m</sub></var>
- </li></ul>
- <p>For example, <code>(join :pair :null)</code> allows either pairs or nil,
- <i>i.e.</i> lists, and <code>(meet :integer :exact)</code> accepts only integers
- that are also exact.
- </p>
- <p>(More complete definitions of supremum, infimum, and other elements of
- lattice theory, may be found elsewhere.)
- </p></dd></dl>
- <dl>
- <dt id="index-_003aerror">type: <strong>:error</strong></dt>
- <dd><p>This is the minimal, or ‘bottom,’ element in the type lattice. It is
- the type of, for example, calls to <code>error</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-_003avalues">type: <strong>:values</strong></dt>
- <dt id="index-_003aarguments">type: <strong>:arguments</strong></dt>
- <dd><p>All Scheme <em>expressions</em> have the type <code>:values</code>. They may
- have more specific types as well, but all expressions’ types are
- compatible subtypes of <code>:values</code>. <code>:Values</code> is a maximal
- element of the type lattice. <code>:Arguments</code> is synonymous with
- <code>:values</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-_003avalue">type: <strong>:value</strong></dt>
- <dd><p>Scheme expressions that have a single result have the type
- <code>:value</code>, or some compatible subtype thereof; it is itself a
- compatible subtype of <code>:values</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-some_002dvalues">type constructor: <strong>some-values</strong> <em>type …</em></dt>
- <dd><p><code>Some-values</code> is used to denote the types of expressions that have
- multiple results: if <code><var>E<sub>1</sub></var> … <var>E<sub>n</sub></var></code> have
- the types <code><var>T<sub>1</sub></var> … <var>T<sub>n</sub></var></code>, then the Scheme
- expression <code>(values <var>E<sub>1</sub></var> … <var>E<sub>n</sub></var>)</code> has
- the type <code>(some-values <var>T<sub>1</sub></var> … <var>T<sub>n</sub></var>)</code>.
- </p>
- <p><code>Some-values</code>-constructed types are compatible subtypes of
- <code>:values</code>.
- </p>
- <p><code>Some-values</code> also accepts ‘optional’ and ‘rest’ types, similarly
- to Common Lisp’s ‘optional’ and ‘rest’ formal parameters. The sequence
- of types may contain a <code>&opt</code> token, followed by which is any
- number of further types, which are considered to be optional. For
- example, <code>make-vector</code>’s domain is <code>(some-values
- :exact-integer &opt :value)</code>. There may also be a <code>&rest</code> token,
- which must follow the <code>&opt</code> token if there is one. Following the
- <code>&rest</code> token is one more type, which the rest of the sequents in
- a sequence after the required or optional sequents must satisfy. For
- example, <code>map</code>’s domain is <code>(some-values :procedure (join
- :pair :null) &rest (join :pair :null))</code>: it accepts one procedure and
- at least one list (pair or null) argument.
- </p></dd></dl>
- <dl>
- <dt id="index-procedure">type constructor: <strong>procedure</strong> <em>domain codomain</em></dt>
- <dt id="index-proc">type constructor: <strong>proc</strong> <em>(arg-type …) result-type</em></dt>
- <dd><p>Procedure type constructors. Procedure types are always compatible
- subtypes of <code>:value</code>. <code>Procedure</code> is a simple constructor
- from a specific domain and codomain; <var>domain</var> and <var>codomain</var>
- must be compatible subtypes of <code>:values</code>. <code>Proc</code> is a more
- convenient constructor. It is equivalent to <code>(procedure
- (some-values <var>arg-type</var> …) <var>result-type</var>)</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-_003aboolean">type: <strong>:boolean</strong></dt>
- <dt id="index-_003achar">type: <strong>:char</strong></dt>
- <dt id="index-_003anull">type: <strong>:null</strong></dt>
- <dt id="index-_003aunspecific">type: <strong>:unspecific</strong></dt>
- <dt id="index-_003apair">type: <strong>:pair</strong></dt>
- <dt id="index-_003astring">type: <strong>:string</strong></dt>
- <dt id="index-_003asymbol">type: <strong>:symbol</strong></dt>
- <dt id="index-_003avector">type: <strong>:vector</strong></dt>
- <dt id="index-_003aprocedure">type: <strong>:procedure</strong></dt>
- <dt id="index-_003ainput_002dport">type: <strong>:input-port</strong></dt>
- <dt id="index-_003aoutput_002dport">type: <strong>:output-port</strong></dt>
- <dd><p>Types that represent standard Scheme data. These are all compatible
- subtypes of <code>:value</code>. <code>:Procedure</code> is the general type for
- all procedures; see <code>proc</code> and <code>procedure</code> for procedure
- types with specific domains and codomains.
- </p></dd></dl>
- <dl>
- <dt id="index-_003anumber">type: <strong>:number</strong></dt>
- <dt id="index-_003acomplex">type: <strong>:complex</strong></dt>
- <dt id="index-_003areal">type: <strong>:real</strong></dt>
- <dt id="index-_003arational">type: <strong>:rational</strong></dt>
- <dt id="index-_003ainteger">type: <strong>:integer</strong></dt>
- <dd><p>Types of the Scheme numeric tower. <code>:integer <= :rational
- <= :real <= :complex <= :number</code>
- </p></dd></dl>
- <dl>
- <dt id="index-_003aexact">type: <strong>:exact</strong></dt>
- <dt id="index-_003ainexact">type: <strong>:inexact</strong></dt>
- <dt id="index-_003aexact_002dinteger">type: <strong>:exact-integer</strong></dt>
- <dt id="index-_003ainexact_002dreal">type: <strong>:inexact-real</strong></dt>
- <dd><p><code>:Exact</code> and <code>:inexact</code> are the types of exact and inexact
- numbers, respectively. They are typically met with one of the types in
- the numeric tower above; <code>:exact-integer</code> and <code>:inexact-real</code>
- are two conveniences for the most common meets.
- </p></dd></dl>
- <dl>
- <dt id="index-_003aother">type: <strong>:other</strong></dt>
- <dd><p><code>:Other</code> is for types that do not fall into any of the previous
- value categories. (<code>:other <= :value</code>) All new types
- introduced, for example by <a href="#Type-annotations"><code>loophole</code></a>,
- are compatible subtypes of <code>:other</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-variable">type constructor: <strong>variable</strong> <em>type</em></dt>
- <dd><p>This is the type of all assignable variables, where <code><var>type</var>
- <= :value</code>. Assignment to variables whose types are value
- types, not assignable variable types, is invalid.
- </p></dd></dl>
- <dl>
- <dt id="index-_003asyntax">type: <strong>:syntax</strong></dt>
- <dt id="index-_003astructure">type: <strong>:structure</strong></dt>
- <dd><p><code>:Syntax</code> and <code>:structure</code> are two other maximal elements of
- the type lattice, along with <code>:values</code>. <code>:Syntax</code> is the
- type of macros or syntax transformers. <code>:Structure</code> is the
- general type of all structures.
- </p></dd></dl>
- <span id="Types-in-the-configuration-language"></span><h4 class="subsection">3.4.1 Types in the configuration language</h4>
- <p>Scheme48’s configuration language has several places in which to write
- types. However, due to the definitions of certain elements of the
- configuration language, notably the <code>export</code> syntax, the allowable
- type syntax is far more limited than the above. Only the following are
- provided:
- </p>
- <dl>
- <dt id="index-_003avalues-1">type: <strong>:values</strong></dt>
- <dt id="index-_003avalue-1">type: <strong>:value</strong></dt>
- <dt id="index-_003aarguments-1">type: <strong>:arguments</strong></dt>
- <dt id="index-_003asyntax-1">type: <strong>:syntax</strong></dt>
- <dt id="index-_003astructure-1">type: <strong>:structure</strong></dt>
- <dd><p>All of the built-in maximal elements of the type lattice are provided,
- as well as the simple compatible subtype <code>:values</code>, <code>:value</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-_003aboolean-1">type: <strong>:boolean</strong></dt>
- <dt id="index-_003achar-1">type: <strong>:char</strong></dt>
- <dt id="index-_003anull-1">type: <strong>:null</strong></dt>
- <dt id="index-_003aunspecific-1">type: <strong>:unspecific</strong></dt>
- <dt id="index-_003apair-1">type: <strong>:pair</strong></dt>
- <dt id="index-_003astring-1">type: <strong>:string</strong></dt>
- <dt id="index-_003asymbol-1">type: <strong>:symbol</strong></dt>
- <dt id="index-_003avector-1">type: <strong>:vector</strong></dt>
- <dt id="index-_003aprocedure-1">type: <strong>:procedure</strong></dt>
- <dt id="index-_003ainput_002dport-1">type: <strong>:input-port</strong></dt>
- <dt id="index-_003aoutput_002dport-1">type: <strong>:output-port</strong></dt>
- <dt id="index-_003anumber-1">type: <strong>:number</strong></dt>
- <dt id="index-_003acomplex-1">type: <strong>:complex</strong></dt>
- <dt id="index-_003areal-1">type: <strong>:real</strong></dt>
- <dt id="index-_003arational-1">type: <strong>:rational</strong></dt>
- <dt id="index-_003ainteger-1">type: <strong>:integer</strong></dt>
- <dt id="index-_003aexact_002dinteger-1">type: <strong>:exact-integer</strong></dt>
- <dd><p>These are the only value types provided in the configuration language.
- Note the conspicuous absence of <code>:exact</code>, <code>:inexact</code>, and
- <code>:inexact-real</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-procedure-1">type constructor: <strong>procedure</strong> <em>domain codomain</em></dt>
- <dt id="index-proc-1">type constructor: <strong>proc</strong> <em>(arg-type …) result-type</em></dt>
- <dd><p>These two are the only type constructors available. Note here the
- conspicuous absence of <code>some-values</code>, so procedure types that are
- constructed by <code>procedure</code> can accept only one argument (or use
- the overly general <code>:values</code> type) & return only one result (or,
- again, use <code>:values</code> for the codomain), and procedure types that
- are constructed by <code>proc</code> are similar in the result type.
- </p></dd></dl>
- <hr>
- <span id="System-facilities"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="System-facilities-1"></span><h2 class="chapter">4 System facilities</h2>
- <p>This chapter details many facilities that the Scheme48 run-time system
- provides.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#System-features" accesskey="1">System features</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Condition-system" accesskey="2">Condition system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Bitwise-manipulation" accesskey="3">Bitwise manipulation</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Generic-dispatch-system" accesskey="4">Generic dispatch system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#I_002fO-system" accesskey="5">I/O system</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Reader-_0026-writer" accesskey="6">Reader & writer</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Records" accesskey="7">Records</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Suspending-and-resuming-heap-images" accesskey="8">Suspending and resuming heap images</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="System-features"></span><div class="header">
- <p>
- Next: <a href="#Condition-system" accesskey="n" rel="next">Condition system</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="System-features-1"></span><h3 class="section">4.1 System features</h3>
- <p>Scheme48 provides a variety of miscellaneous features built-in to the
- system.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Miscellaneous-features" accesskey="1">Miscellaneous features</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Various-utilities" accesskey="2">Various utilities</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Filenames" accesskey="3">Filenames</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Fluid_002fdynamic-bindings" accesskey="4">Fluid/dynamic bindings</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#ASCII-character-encoding" accesskey="5">ASCII character encoding</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Integer-enumerations" accesskey="6">Integer enumerations</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Cells" accesskey="7">Cells</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Queues" accesskey="8">Queues</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Hash-tables" accesskey="9">Hash tables</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Weak-references">Weak references</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Type-annotations">Type annotations</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Explicit-renaming-macros">Explicit renaming macros</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Miscellaneous-features"></span><div class="header">
- <p>
- Next: <a href="#Various-utilities" accesskey="n" rel="next">Various utilities</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Miscellaneous-features-1"></span><h4 class="subsection">4.1.1 Miscellaneous features</h4>
- <span id="index-features"></span>
- <p>The structure <code>features</code> provides some very miscellaneous features
- in Scheme48.
- </p>
- <span id="index-immutability"></span>
- <span id="index-mutability"></span>
- <dl>
- <dt id="index-immutable_003f">procedure: <strong>immutable?</strong> <em>object --> boolean</em></dt>
- <dt id="index-make_002dimmutable_0021">procedure: <strong>make-immutable!</strong> <em>object --> object</em></dt>
- <dd><p>All Scheme objects in Scheme48 have a flag determining whether or not
- they may be mutated. All immediate Scheme objects (<code>()</code>,
- <code>#f</code>, <i>&c.</i>) are immutable; all fixnums (small integers) are
- immutable; and all stored objects — vectors, pairs, <i>&c.</i> — may be
- mutable. <code>Immutable?</code> returns <code>#t</code> if <var>object</var> may not
- be mutated, and <code>make-immutable!</code>, a bit ironically, modifies
- <var>object</var> so that it may not be mutated, if it was not already
- immutable, and returns it.
- </p>
- <div class="lisp">
- <pre class="lisp">(immutable? #t) ⇒ #t
- (define p (cons 1 2))
- (immutable? p) ⇒ #f
- (car p) ⇒ 1
- (set-car! p 5)
- (car p) ⇒ 5
- (define q (make-immutable! p))
- (eq? p q) ⇒ #t
- (car p) ⇒ 5
- (immutable? q) ⇒ #t
- (set-car! p 6) error→ immutable pair</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-string_002dhash">procedure: <strong>string-hash</strong> <em>string --> integer-hash-code</em></dt>
- <dd><p>Computes a basic but fast hash of <var>string</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(string-hash "Hello, world!") ⇒ 1161</pre></div>
- </dd></dl>
- <span id="index-forcing-buffered-output"></span>
- <span id="index-output-port-buffer-forcing"></span>
- <span id="index-buffered-output-forcing"></span>
- <span id="index-flushing-output-buffers"></span>
- <dl>
- <dt id="index-force_002doutput">procedure: <strong>force-output</strong> <em>port --> unspecified</em></dt>
- <dd><p>Forces all buffered output to be sent out of <var>port</var>.
- </p>
- <p>This is identical to the binding of the same name exported by the
- <a href="#Ports"><code>i/o</code> structure</a>.
- </p></dd></dl>
- <span id="index-noise-output"></span>
- <dl>
- <dt id="index-current_002dnoise_002dport">procedure: <strong>current-noise-port</strong> <em>--> output-port</em></dt>
- <dd><p>The current noise port is a port for sending noise messages that are
- inessential to the operation of a program.
- </p></dd></dl>
- <span id="index-silly"></span>
- <p>The <code>silly</code> structure exports a single procedure, implemented as
- a VM primitive for the silly reason of efficiency, hence the name of
- the structure.<a id="DOCF10" href="#FOOT10"><sup>10</sup></a> It is used in an inner loop of the reader.
- </p>
- <dl>
- <dt id="index-reverse_002dlist_002d_003estring">procedure: <strong>reverse-list->string</strong> <em>char-list count --> string</em></dt>
- <dd><p>Returns a string of the first <var>count</var> characters in
- <var>char-list</var>, in reverse. It is a serious error if <var>char-list</var>
- is not a list whose length is at least <var>count</var>; the error is not
- detected by the VM, so bogus pointers may be involved as a result.
- Use this routine with care in inner loops.
- </p></dd></dl>
- <span id="index-debug_002dmessages"></span>
- <p>The <code>debug-messages</code> structure exports a procedure for emitting
- very basic debugging messages for low-level problems.
- </p>
- <dl>
- <dt id="index-debug_002dmessage">procedure: <strong>debug-message</strong> <em>item … --> unspecified</em></dt>
- <dd><p>Prints <var>item</var> … directly to an error port,<a id="DOCF11" href="#FOOT11"><sup>11</sup></a>
- eliding buffering and thread synchronization on the Scheme side.
- Objects are printed as follows:
- </p>
- <ul>
- <li> Fixnums (small integers) are written in decimal.
- </li><li> Characters are written literally with a <code>#\</code> prefix. No
- naming translation is performed, so the space and newline characters
- are written literally, not as <code>#\space</code> or <code>#\newline</code>.
- </li><li> Records are written as #{<var>type-name</var>}, where
- <var>type-name</var> is the name of the record’s type.
- </li><li> Strings and symbols are written literally.
- </li><li> Booleans and the empty list are written normally, <i>i.e.</i> as
- <code>#t</code>, <code>#f</code>, or <code>()</code>.
- </li><li> Pairs are written as <code>(...)</code>.
- </li><li> Vectors are written as <code>#(...)</code>.
- </li><li> Objects of certain primitive types are written as
- #{<var>type</var>}: procedures, templates, locations, code (byte)
- vectors, and continuations.<a id="DOCF12" href="#FOOT12"><sup>12</sup></a>
- </li><li> Everything else is printed as #{???}.
- </li></ul>
- </dd></dl>
- <span id="index-code_002dquote-1"></span>
- <p>The <code>code-quote</code> structure exports a variant of <code>quote</code> that
- is useful in some sophisticated macros.
- </p>
- <dl>
- <dt id="index-code_002dquote">special form: <strong>code-quote</strong> <em>object --> object</em></dt>
- <dd><p>Evaluates to the literal value of <var>object</var>. This is semantically
- identical to <code>quote</code>, but <var>object</var> may be anything, and the
- compiler will not signal any warnings regarding its value, while such
- warnings would be signalled for <code>quote</code> expressions that do not
- wrap readable S-expressions: arbitrary, compound, unreadable data may
- be stored in <code>code-quote</code>. Values computed at compile-time may
- thus be transmitted to run-time code. However, care should be taken
- in doing this.
- </p></dd></dl>
- <hr>
- <span id="Various-utilities"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Various-utilities-1"></span><h4 class="subsection">4.1.2 Various utilities</h4>
- <span id="index-util"></span>
- <p>The <code>util</code> structure contains some miscellaneous utility routines
- extensively used internally in the run-time system. While they are not
- meant to compose a comprehensive library (such as, for example, [SRFI
- 1]), they were found useful in building the run-time system without
- introducing massive libraries into the core of the system.
- </p>
- <span id="index-unspecific"></span>
- <span id="index-unspecified"></span>
- <dl>
- <dt id="index-unspecific-1">procedure: <strong>unspecific</strong> <em>--> unspecific</em></dt>
- <dd><p>Returns Scheme48’s <em>unspecific</em> token, which is used wherever R5RS
- uses the term ‘unspecific’ or ‘unspecified.’ In this manual, the term
- ‘unspecified’ is used to mean that the values returned by a particular
- procedure are not specified and may be anything, including a varying
- number of values, whereas ‘unspecific’ refers to Scheme48’s specific
- ‘unspecific’ value that the <code>unspecific</code> procedure returns.
- </p></dd></dl>
- <dl>
- <dt id="index-reduce">procedure: <strong>reduce</strong> <em>kons knil list --> final-knil</em></dt>
- <dd><p>Reduces <var>list</var> by repeatedly applying <var>kons</var> to elements of
- <var>list</var> and the current <var>knil</var> value. This is the fundamental
- list recursion operator.
- </p>
- <div class="lisp">
- <pre class="lisp">(reduce <var>kons</var> <var>knil</var>
- (cons <var>elt<sub>1</sub></var>
- (cons <var>elt<sub>2</sub></var>
- (…(cons <var>elt<sub>N</sub></var> '())…))))
- ≡
- (<var>kons</var> <var>elt<sub>1</sub></var>
- (<var>kons</var> <var>elt<sub>2</sub></var>
- (…(<var>kons</var> <var>elt<sub>N</sub></var> <var>knil</var>)…)))</pre></div>
- <p>Example:
- </p>
- <div class="lisp">
- <pre class="lisp">(reduce append '() '((1 2 3) (4 5 6) (7 8 9)))
- ⇒ (1 2 3 4 5 6 7 8 9)
- (append '(1 2 3)
- (append '(4 5 6)
- (append '(7 8 9) '())))
- ⇒ (1 2 3 4 5 6 7 8 9)</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-fold">procedure: <strong>fold</strong> <em>combiner list accumulator --> final-accumulator</em></dt>
- <dd><p>Folds <var>list</var> into an accumulator by repeatedly combining each
- element into an accumulator with <var>combiner</var>. This is the
- fundamental list iteration operator.
- </p>
- <div class="lisp">
- <pre class="lisp">(fold <var>combiner</var>
- (list <var>elt<sub>1</sub></var> <var>elt<sub>2</sub></var> … <var>elt<sub>N</sub></var>)
- <var>accumulator</var>)
- ≡
- (let* ((accum<sub>1</sub> (<var>combiner</var> <var>elt<sub>1</sub></var> <var>accumulator</var>))
- (accum<sub>2</sub> (<var>combiner</var> <var>elt<sub>2</sub></var> accum<sub>1</sub>))
- …
- (accum<sub>N</sub> (<var>combiner</var> <var>elt<sub>N</sub></var> accum<sub>N-1</sub>)))
- accum<sub>N</sub>)</pre></div>
- <p>Example:
- </p>
- <div class="lisp">
- <pre class="lisp">(fold cons '() '(a b c d))
- ⇒ (d c b a)
- (cons 'd (cons 'c (cons 'b (cons 'a '()))))
- ⇒ (d c b a)</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-fold_002d_003e2">procedure: <strong>fold->2</strong> <em>combiner list accumulator<sub>1</sub> accumulator<sub>2</sub> --> [final-accumulator<sub>1</sub> final-accumulator<sub>2</sub>]</em></dt>
- <dt id="index-fold_002d_003e3">procedure: <strong>fold->3</strong> <em>combiner list accumulator<sub>1</sub> accumulator<sub>2</sub> accumulator<sub>3</sub> --> [final-accumulator<sub>1</sub> final-accumulator<sub>2</sub> final-accumulator<sub>3</sub>]</em></dt>
- <dd><p>Variants of <code>fold</code> for two and three accumulators, respectively.
- </p>
- <div class="lisp">
- <pre class="lisp">;;; Partition <var>list</var> by elements that satisfy <var>pred?</var> and those
- ;;; that do not.
- (fold->2 (lambda (elt satisfied unsatisfied)
- (if (<var>pred?</var> elt)
- (values (cons elt satisfied) unsatisfied)
- (values satisfied (cons elt unsatisfied))))
- <var>list</var>
- '() '())</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-filter">procedure: <strong>filter</strong> <em>predicate list --> filtered-list</em></dt>
- <dd><p>Returns a list of all elements in <var>list</var> that satisfy
- <var>predicate</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(filter odd? '(3 1 4 1 5 9 2 6 5 3 5))
- ⇒ (3 1 1 5 9 5 3 5)</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-posq">procedure: <strong>posq</strong> <em>object list --> integer or <code>#f</code></em></dt>
- <dt id="index-posv">procedure: <strong>posv</strong> <em>object list --> integer or <code>#f</code></em></dt>
- <dt id="index-position">procedure: <strong>position</strong> <em>object list --> integer or <code>#f</code></em></dt>
- <dd><p>These find the position of the first element equal to <var>object</var> in
- <var>list</var>. <code>Posq</code> compares elements by <code>eq?</code>; <code>posv</code>
- compares by <code>eqv?</code>; <code>position</code> compares by <code>equal?</code>.
- </p>
- <div class="lisp">
- <pre class="lisp">(posq 'c '(a b c d e f))
- ⇒ 2
- (posv 1/2 '(1 1/2 2 3/2))
- ⇒ 1
- (position '(d . e) '((a . b) (b . c) (c . d) (d . e) (e . f)))
- ⇒ 3</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-any">procedure: <strong>any</strong> <em>predicate list --> value or <code>#f</code></em></dt>
- <dt id="index-every">procedure: <strong>every</strong> <em>predicate list --> boolean</em></dt>
- <dd><p><code>Any</code> returns the value that <var>predicate</var> returns for the first
- element in <var>list</var> for which <var>predicate</var> returns a true value;
- if no element of <var>list</var> satisfied <var>predicate</var>, <code>any</code>
- returns <code>#f</code>. <code>Every</code> returns <code>#t</code> if every element of
- <var>list</var> satisfies <var>predicate</var>, or <code>#f</code> if there exist any
- that do not.
- </p>
- <div class="lisp">
- <pre class="lisp">(any (lambda (x) (and (even? x) (sqrt x)))
- '(0 1 4 9 16))
- ⇒ 2
- (every odd? '(1 3 5 7 9))
- ⇒ #t</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-sublist">procedure: <strong>sublist</strong> <em>list start end --> list</em></dt>
- <dd><p>Returns a list of the elements in <var>list</var> including & after that at
- the index <var>start</var> and before the index <var>end</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(sublist '(a b c d e f g h i) 3 6) ⇒ (d e f)</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-last">procedure: <strong>last</strong> <em>list --> value</em></dt>
- <dd><p>Returns the last element in <var>list</var>. <code>Last</code>’s effect is
- undefined if <var>list</var> is empty.
- </p>
- <div class="lisp">
- <pre class="lisp">(last '(a b c)) ⇒ c</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-insert">procedure: <strong>insert</strong> <em>object list elt< --> list</em></dt>
- <dd><p>Inserts <var>object</var> into the sorted list <var>list</var>, comparing the
- order of <var>object</var> and each element by <var>elt<</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(insert 3 '(0 1 2 4 5) <) ⇒ (0 1 2 3 4 5)</pre></div>
- </dd></dl>
- <hr>
- <span id="Filenames"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Filenames-1"></span><h4 class="subsection">4.1.3 Filenames</h4>
- <span id="index-filenames"></span>
- <p>There are some basic filename manipulation facilities exported by the
- <code>filenames</code> structure.<a id="DOCF13" href="#FOOT13"><sup>13</sup></a>
- </p>
- <dl>
- <dt id="index-_002ascheme_002dfile_002dtype_002a">constant: <strong>*scheme-file-type*</strong> <em>--> symbol</em></dt>
- <dt id="index-_002aload_002dfile_002dtype_002a">constant: <strong>*load-file-type*</strong> <em>--> symbol</em></dt>
- <dd><p><code>*Scheme-file-type*</code> is a symbol denoting the file extension that
- Scheme48 assumes for Scheme source files; any other extension, for
- instance in the filename list of a structure definition, must be
- written explicitly. <code>*Load-file-type*</code> is a symbol denoting the
- preferable file extension to load files from. (<code>*Load-file-type*</code>
- was used mostly in bootstrapping Scheme48 from Pseudoscheme or T long
- ago and is no longer very useful.)
- </p></dd></dl>
- <dl>
- <dt id="index-file_002dname_002ddirectory">procedure: <strong>file-name-directory</strong> <em>filename --> string</em></dt>
- <dt id="index-file_002dname_002dnondirectory">procedure: <strong>file-name-nondirectory</strong> <em>filename --> string</em></dt>
- <dd><p><code>File-name-directory</code> returns the directory component of the
- filename denoted by the string <var>filename</var>, including a trailing
- separator (on Unix, <code>/</code>). <code>File-name-nondirectory</code> returns
- everything but the directory component of the filename denoted by the
- string <var>filename</var>, including the extension.
- </p>
- <div class="lisp">
- <pre class="lisp">(file-name-directory "/usr/local/lib/scheme48/scheme48.image")
- ⇒ "/usr/local/lib/scheme48/"
- (file-name-nondirectory "/usr/local/lib/scheme48/scheme48.image")
- ⇒ "scheme48.image"
- (file-name-directory "scheme48.image")
- ⇒ ""
- (file-name-nondirectory "scheme48.image")
- ⇒ "scheme48.image"</pre></div>
- </dd></dl>
- <span id="index-namelists"></span>
- <p><em>Namelists</em> are platform-independent means by which to name files.
- They are represented as readable S-expressions of any of the following
- forms:
- </p>
- <dl compact="compact">
- <dt><code><var>basename</var></code></dt>
- <dd><p>represents a filename with only a basename and no directory or file
- type/extension;
- </p>
- </dd>
- <dt><code>(<var>directory</var> <var>basename</var> [<var>type</var>])</code></dt>
- <dd><p>represents a filename with a single preceding directory component and
- an optional file type/extension; and
- </p>
- </dd>
- <dt><code>((<var>directory</var> …) <var>basename</var> [<var>type</var>])</code></dt>
- <dd><p>represents a filename with a sequence of directory components, a
- basename, and an optional file type/extension.
- </p></dd>
- </dl>
- <p>Each atomic component — that is, the basename, the type/extension,
- and each individual directory component — may be either a string or
- a symbol. Symbols are converted to the canonical case of the host
- operating system by <code>namestring</code> (on Unix, lowercase); the case of
- string components is not touched.
- </p>
- <dl>
- <dt id="index-namestring">procedure: <strong>namestring</strong> <em>namelist directory default-type --> string</em></dt>
- <dd><p>Converts <var>namelist</var> to a string in the format required by the host
- operating system.<a id="DOCF14" href="#FOOT14"><sup>14</sup></a> If <var>namelist</var> did not have a directory
- component, <var>directory</var>, a string in the underlying operating
- system’s format for directory prefixes, is added to the resulting
- namestring; and, if <var>namelist</var> did not have a type/extension,
- <var>default-type</var>, which may be a string or a symbol and which should
- <em>not</em> already contain the host operating system’s delimiter
- (usually a dot), is appended to the resulting namestring.
- </p>
- <p><var>Directory</var> or <var>default-type</var> may be <code>#f</code>, in which case
- they are not prefixed or appended to the resulting filename.
- </p>
- <div class="lisp">
- <pre class="lisp">(namestring 'foo #f #f) ⇒ "foo"
- (namestring 'foo "bar" 'baz) ⇒ "bar/foo.baz"
- (namestring '(rts defenum) "scheme" 'scm)
- ⇒ "scheme/rts/defenum.scm"
- (namestring '((foo bar) baz quux) "zot" #f)
- ⇒ "zot/foo/bar/baz.quux"
- (namestring "zot/foo/bar/baz.quux" #f "mumble")
- ⇒ "zot/foo/bar/baz.quux.mumble"</pre></div>
- </dd></dl>
- <span id="Filename-translations"></span><h4 class="subsubsection">4.1.3.1 Filename translations</h4>
- <span id="index-filename-translations"></span>
- <p>Scheme48 keeps a registry of <em>filename translations</em>, translations
- from filename prefixes to the real prefixes. This allows abstraction
- of actual directory prefixes without necessitating running Scheme code
- to construct directory pathnames (for example, in configuration files).
- Interactively, in the usual command processor, users can set filename
- translations with the <code>,translate</code>; see <a href="#Basic-commands">Basic commands</a>.
- </p>
- <dl>
- <dt id="index-translations">procedure: <strong>translations</strong> <em>--> string/string-alist</em></dt>
- <dd><p>Returns the alist of filename translations.
- </p></dd></dl>
- <dl>
- <dt id="index-set_002dtranslation_0021">procedure: <strong>set-translation!</strong> <em>from to --> unspecified</em></dt>
- <dd><p>Adds a filename prefix translation, overwriting an existing one if one
- already existed.
- </p></dd></dl>
- <dl>
- <dt id="index-translate">procedure: <strong>translate</strong> <em>filename --> translated-filename</em></dt>
- <dd><p>Translates the first prefix of <var>filename</var> found in the registry of
- translations and returns the translated filename.
- </p></dd></dl>
- <div class="lisp">
- <pre class="lisp">(set-translation! "s48" "/home/me/scheme/scheme48/scheme")
- (translate (namestring '(bcomp frame) "s48" 'scm))
- ⇒ "/home/me/scheme/scheme48/scheme/bcomp/frame.scm"
- (translate (namestring "comp-packages" "s48" 'scm))
- ⇒ "/home/me/scheme/scheme48/scheme/comp-packages.scm"
- (translate "s48/frobozz")
- ⇒ "/home/me/scheme/scheme48/scheme/frobozz"
- (set-translation! "scheme48" "s48")
- (translate (namestring '((scheme48 big) filename) #f 'scm))
- ⇒ scheme48/big/filename.scm
- (translate (translate (namestring '((scheme48 big) filename) #f 'scm)))
- ⇒ "/home/me/scheme/scheme48/scheme/big/filename.scm"</pre></div>
- <span id="index-_003dscheme48_002f"></span>
- <p>One filename translation is built-in, mapping <code>=scheme48/</code> to the
- directory of system files in a Scheme48 installation, which on Unix is
- typically a directory in <code>/usr/local/lib</code>.
- </p>
- <div class="lisp">
- <pre class="lisp">(translate "=scheme48/scheme48.image")
- ⇒ /usr/local/scheme48/scheme48.image</pre></div>
- <hr>
- <span id="Fluid_002fdynamic-bindings"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Fluid_002fdynamic-bindings-1"></span><h4 class="subsection">4.1.4 Fluid/dynamic bindings</h4>
- <span id="index-fluid-bindings"></span>
- <span id="index-dynamic-bindings"></span>
- <span id="index-fluids"></span>
- <p>The <code>fluids</code> structure provides a facility for dynamically bound
- resources, like special variables in Common Lisp, but with first-class,
- unforgeable objects.
- </p>
- <p>Every <a href="#Multithreading">thread</a> in Scheme48 maintains a
- <em>fluid or dynamic environment</em>. It maps <em>fluid descriptors</em> to
- their values, much like a lexical environment maps names to their
- values. The dynamic environment is implemented by deep binding and
- dynamically scoped. Fluid variables are represented as first-class
- objects for which there is a top-level value and possibly a binding in
- the current dynamic environment. Escape procedures, as created with
- Scheme’s <code>call-with-current-continuation</code>, also store & preserve
- the dynamic environment at the time of their continuation’s capture and
- restore it when invoked.
- </p>
- <p>The convention for naming variables that are bound to fluid objects
- is to add a prefix of <code>$</code> (dollar sign); <i>e.g.</i>, <code>$foo</code>.
- </p>
- <dl>
- <dt id="index-make_002dfluid">procedure: <strong>make-fluid</strong> <em>top-level-value --> fluid</em></dt>
- <dd><p>Fluid constructor.
- </p></dd></dl>
- <dl>
- <dt id="index-fluid">procedure: <strong>fluid</strong> <em>fl --> value</em></dt>
- <dt id="index-set_002dfluid_0021">procedure: <strong>set-fluid!</strong> <em>fl value --> unspecified</em></dt>
- <dt id="index-fluid_002dcell_002dref">procedure: <strong>fluid-cell-ref</strong> <em>fluid-cell --> value</em></dt>
- <dt id="index-fluid_002dcell_002dset_0021">procedure: <strong>fluid-cell-set!</strong> <em>fluid-cell value --> unspecified</em></dt>
- <dd><p><code>Fluid</code> returns the value that the current dynamic environment
- associates with <var>fl</var>, if it has an association; if not, it returns
- <var>fl</var>’s top-level value, as passed to <code>make-fluid</code> to create
- <var>fl</var>. <code>Set-fluid!</code> assigns the value of the association in
- the current dynamic environment for <var>fl</var> to <var>value</var>, or, if
- there is no such association, it assigns the top-level value of
- <var>fl</var> to <var>value</var>. Direct assignment of fluids is deprecated,
- however, and may be removed in a later release; instead, programmers
- should use fluids that are bound to <a href="#Cells">mutable cells</a>.
- <code>Fluid-cell-ref</code> and <code>fluid-cell-set!</code> are conveniences for
- this; they simply call the corresponding cell operations after
- fetching the cell that the fluid refers to by using <code>fluid</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-let_002dfluid">procedure: <strong>let-fluid</strong> <em>fluid value thunk --> values</em></dt>
- <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> … thunk --> values</em></dt>
- <dd><p>These dynamically bind their fluid arguments to the corresponding value
- arguments and apply <var>thunk</var> with the new dynamic environment,
- restoring the old one after <var>thunk</var> returns and returning the value
- it returns.
- </p></dd></dl>
- <div class="lisp">
- <pre class="lisp">(define $mumble (make-fluid 0))
- (let ((a (fluid $mumble))
- (b (let-fluid $mumble 1
- (lambda () (fluid $mumble))))
- (c (fluid $mumble))
- (d (let-fluid $mumble 2
- (lambda ()
- (let-fluid $mumble 3
- (lambda () (fluid $mumble)))))))
- (list a b c d))
- ⇒ (0 1 0 3)
- (let ((note (lambda (when)
- (display when)
- (display ": ")
- (write (fluid $mumble))
- (newline))))
- (note 'initial)
- (let-fluid $mumble 1 (lambda () (note 'let-fluid)))
- (note 'after-let-fluid)
- (let-fluid $mumble 1
- (lambda ()
- (note 'outer-let-fluid)
- (let-fluid $mumble 2 (lambda () (note 'inner-let-fluid)))))
- (note 'after-inner-let-fluid)
- ((call-with-current-continuation
- (lambda (k)
- (lambda ()
- (let-fluid $mumble 1
- (lambda ()
- (note 'let-fluid-within-cont)
- (let-fluid $mumble 2
- (lambda () (note 'inner-let-fluid-within-cont)))
- (k (lambda () (note 'let-fluid-thrown)))))))))
- (note 'after-throw))
- -| initial: 0
- -| let-fluid: 1
- -| after-let-fluid: 0
- -| outer-let-fluid: 1
- -| inner-let-fluid: 2
- -| let-fluid-within-cont: 1
- -| inner-let-fluid-within-cont: 2
- -| let-fluid-thrown: 0
- -| after-throw: 0</pre></div>
- <hr>
- <span id="ASCII-character-encoding"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="ASCII-character-encoding-1"></span><h4 class="subsection">4.1.5 ASCII character encoding</h4>
- <span id="index-ascii"></span>
- <p>These names are exported by the <code>ascii</code> structure.
- </p>
- <dl>
- <dt id="index-char_002d_003eascii">procedure: <strong>char->ascii</strong> <em>char --> ascii-integer</em></dt>
- <dt id="index-ascii_002d_003echar">procedure: <strong>ascii->char</strong> <em>ascii-integer --> character</em></dt>
- <dd><p>These convert characters to and from their integer ASCII encodings.
- <code>Char->ascii</code> and <code>ascii->char</code> are similar to R5RS’s
- <code>char->integer</code> and <code>integer->char</code>, but they are guaranteed
- to use the ASCII encoding. Scheme48’s <code>integer->char</code> and
- <code>char->integer</code> deliberately do not use the ASCII encoding to
- encourage programmers to make use of only what R5RS guarantees.
- </p>
- <div class="lisp">
- <pre class="lisp">(char->ascii #\a) ⇒ 97
- (ascii->char 97) ⇒ #\a</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-ascii_002dlimit">constant: <strong>ascii-limit</strong> <em>--> integer</em></dt>
- <dt id="index-ascii_002dwhitespaces">constant: <strong>ascii-whitespaces</strong> <em>--> ascii-integer-list</em></dt>
- <dd><p><code>Ascii-limit</code> is an integer that is one greater than the highest
- number that <code>char->ascii</code> may return or <code>ascii->char</code> will
- accept. <code>Ascii-whitespaces</code> is a list of the integer encodings of
- all characters that are considered whitespace: space (32), horizontal
- tab (9), line-feed/newline (10), vertical tab (11), form-feed/page (12),
- and carriage return (13).
- </p></dd></dl>
- <hr>
- <span id="Integer-enumerations"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Integer-enumerations-1"></span><h4 class="subsection">4.1.6 Integer enumerations</h4>
- <span id="index-enumerated"></span>
- <p>Scheme48 provides a facility for <em>integer enumerations</em>, somewhat
- akin to C enums. The names described in this section are exported by
- the <code>enumerated</code> structure.
- </p>
- <p><strong>Note:</strong> These enumerations are <em>not</em> compatible with the
- <a href="#Enumerated_002ffinite-types-and-sets">enumerated/finite type
- facility</a>.
- </p>
- <dl>
- <dt id="index-define_002denumeration">syntax: <strong>define-enumeration</strong> <em>enumeration-name (enumerand-name …)</em></dt>
- <dd><p>Defines <var>enumeration-name</var> to be a static enumeration. (Note that
- it is <em>not</em> a regular variable. It is actually a macro, though its
- exact syntax is not exposed; it must be exported with the
- <a href="#Static-type-system"><code>:syntax</code> type</a>.)
- <var>Enumeration-name</var> thereafter may be used with the enumeration
- operators described below.
- </p></dd></dl>
- <dl>
- <dt id="index-enum">syntax: <strong>enum</strong> <em>enumeration-name enumerand-name --> enumerand-integer</em></dt>
- <dt id="index-components">syntax: <strong>components</strong> <em>enumeration-name --> component-vector</em></dt>
- <dd><p><code>Enum</code> expands to the integer value represented symbolically by
- <var>enumerand-name</var> in the enumeration <var>enumeration-name</var> as
- defined by <code>define-enumeration</code>. <code>Components</code> expands to a
- literal vector of the components in <var>enumeration-name</var> as defined
- by <code>define-enumeration</code>. In both cases, <var>enumerand-name</var> must
- be written literally as the name of the enumerand; see
- <code>name->enumerand</code> for extracting an enumerand’s integer given a
- run-time symbol naming an enumerand.
- </p></dd></dl>
- <dl>
- <dt id="index-enumerand_002d_003ename">syntax: <strong>enumerand->name</strong> <em>enumerand-integer enumeration-name --> symbol</em></dt>
- <dt id="index-name_002d_003eenumerand">syntax: <strong>name->enumerand</strong> <em>enumerand-name enumeration-name --> integer-enumerand</em></dt>
- <dd><p><code>Enumerand->name</code> expands to a form that evaluates to the symbolic
- name that the integer value of the expression <var>enumerand-integer</var>
- is mapped to by <var>enumeration-name</var> as defined by
- <code>define-enumeration</code>. <code>Name->enumerand</code> expands to a form
- that evaluates to the integer value of the enumerand in
- <var>enumeration-name</var> that is represented symbolically by the value of
- the expression <var>enumerand-name</var>.
- </p></dd></dl>
- <span id="index-enum_002dcase-1"></span>
- <p>The <code>enum-case</code> structure provides a handy utility of the same
- name for dispatching on enumerands.
- </p>
- <dl>
- <dt id="index-enum_002dcase">syntax: <strong>enum-case</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(enum-case <var>enumeration-name</var> <var>key</var>
- ((<var>enumerand-name</var> …) <var>body</var>)
- …
- [(else <var>else-body</var>)])</pre></div>
- <p>Matches <var>key</var> with the clause one of whose names maps in
- <var>enumeration-name</var> to the integer value of <var>key</var>. <var>Key</var>
- must be an exact, non-negative integer. If no matching clause is
- found, and <var>else-body</var> is present, <code>enum-case</code> will evaluate
- <var>else-body</var>; if <var>else-body</var> is not present, <code>enum-case</code>
- will return an unspecific value.
- </p></dd></dl>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-enumeration foo
- (bar
- baz))
- (enum foo bar) ⇒ 0
- (enum foo baz) ⇒ 1
- (enum-case foo (enum foo bar)
- ((baz) 'x)
- (else 'y))
- ⇒ y
- (enum-case foo (enum foo baz)
- ((bar) 'a)
- ((baz) 'b))
- ⇒ b
- (enumerand->name 1 foo) ⇒ baz
- (name->enumerand 'bar foo) ⇒ 0
- (components foo) ⇒ #(bar baz)</pre></div>
- <hr>
- <span id="Cells"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Cells-1"></span><h4 class="subsection">4.1.7 Cells</h4>
- <span id="index-cells"></span>
- <p>Scheme48 also provides a simple mutable cell data type from the
- <code>cells</code> structure. It uses them internally for local, lexical
- variables that are assigned, but cells are available still to the rest
- of the system for general use.
- </p>
- <dl>
- <dt id="index-make_002dcell">procedure: <strong>make-cell</strong> <em>contents --> cell</em></dt>
- <dt id="index-cell_003f">procedure: <strong>cell?</strong> <em>object --> boolean</em></dt>
- <dt id="index-cell_002dref">procedure: <strong>cell-ref</strong> <em>cell --> value</em></dt>
- <dt id="index-cell_002dset_0021">procedure: <strong>cell-set!</strong> <em>cell value --> unspecified</em></dt>
- <dd><p><code>Make-cell</code> creates a new cell with the given contents.
- <code>Cell?</code> is the disjoint type predicate for cells. <code>Cell-ref</code>
- returns the current contents of <var>cell</var>. <code>Cell-set!</code> assigns
- the contents of <var>cell</var> to <var>value</var>.
- </p></dd></dl>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(define cell (make-cell 42))
- (cell-ref cell) ⇒ 42
- (cell? cell) ⇒ #t
- (cell-set! cell 'frobozz)
- (cell-ref cell) ⇒ frobozz</pre></div>
- <hr>
- <span id="Queues"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Queues-1"></span><h4 class="subsection">4.1.8 Queues</h4>
- <span id="index-FIFOs"></span>
- <span id="index-queues"></span>
- <p>The <code>queues</code> structure exports names for procedures that operate
- on simple first-in, first-out queues.
- </p>
- <dl>
- <dt id="index-make_002dqueue">procedure: <strong>make-queue</strong> <em>--> queue</em></dt>
- <dt id="index-queue_003f">procedure: <strong>queue?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-queue</code> constructs an empty queue. <code>Queue?</code> is the
- disjoint type predicate for queues.
- </p></dd></dl>
- <dl>
- <dt id="index-queue_002dempty_003f">procedure: <strong>queue-empty?</strong> <em>queue --> boolean</em></dt>
- <dt id="index-empty_002dqueue_0021">procedure: <strong>empty-queue!</strong> <em>queue --> unspecified</em></dt>
- <dd><p><code>Queue-empty?</code> returns <code>#t</code> if <var>queue</var> contains zero
- elements or <code>#f</code> if it contains some. <code>Empty-queue!</code> removes
- all elements from <var>queue</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-enqueue_0021">procedure: <strong>enqueue!</strong> <em>queue object --> unspecified</em></dt>
- <dt id="index-dequeue_0021">procedure: <strong>dequeue!</strong> <em>queue --> value</em></dt>
- <dt id="index-maybe_002ddequeue_0021">procedure: <strong>maybe-dequeue!</strong> <em>queue --> value or <code>#f</code></em></dt>
- <dt id="index-queue_002dhead">procedure: <strong>queue-head</strong> <em>queue --> value</em></dt>
- <dd><p><code>Enqueue!</code> adds <var>object</var> to <var>queue</var>. <code>Dequeue!</code>
- removes & returns the next object available from <var>queue</var>; if
- <var>queue</var> is empty, <code>dequeue!</code> signals an error.
- <code>Maybe-dequeue!</code> is like <code>dequeue!</code>, but it returns <code>#f</code>
- in the case of an absence of any element, rather than signalling an
- error. <code>Queue-head</code> returns the next element available from
- <var>queue</var> without removing it, or it signals an error if <var>queue</var>
- is empty.
- </p></dd></dl>
- <dl>
- <dt id="index-queue_002dlength">procedure: <strong>queue-length</strong> <em>queue --> integer</em></dt>
- <dd><p>Returns the number of objects in <var>queue</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-on_002dqueue_003f">procedure: <strong>on-queue?</strong> <em>queue object --> boolean</em></dt>
- <dt id="index-delete_002dfrom_002dqueue_0021">procedure: <strong>delete-from-queue!</strong> <em>queue object --> unspecified</em></dt>
- <dd><p><code>On-queue?</code> returns true if <var>queue</var> contains <var>object</var> or
- <code>#f</code> if not. <code>Delete-from-queue!</code> removes the first
- occurrence of <var>object</var> from <var>queue</var> that would be dequeued.
- </p></dd></dl>
- <dl>
- <dt id="index-queue_002d_003elist">procedure: <strong>queue->list</strong> <em>queue --> list</em></dt>
- <dt id="index-list_002d_003equeue">procedure: <strong>list->queue</strong> <em>list --> queue</em></dt>
- <dd><p>These convert queues to and from lists of their elements.
- <code>Queue->list</code> returns a list in the order in which its elements
- were added to the queue. <code>List->queue</code> returns a queue that will
- produce elements starting at the head of the list.
- </p></dd></dl>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(define q (make-queue))
- (enqueue! q 'foo)
- (enqueue! q 'bar)
- (queue->list q) ⇒ (foo bar)
- (on-queue? q 'bar) ⇒ #t
- (dequeue! q) ⇒ 'foo
- (queue-empty? q) ⇒ #f
- (delete-from-queue! queue 'bar)
- (queue-empty? q) ⇒ #t
- (enqueue! q 'frobozz)
- (empty-queue! q)
- (queue-empty? q) ⇒ #t
- (dequeue! q) error→ empty queue</pre></div>
- <p>Queues are integrated with Scheme48’s <a href="#Optimistic-concurrency">optimistic concurrency</a> facilities, in that every procedure exported
- except for <code>queue->list</code> ensures fusible atomicity in operation
- — that is, every operation except for <code>queue->list</code> ensures that
- the transaction it performs is atomic, and that it may be fused within
- larger atomic transactions, as transactions wrapped within
- <code>call-ensuring-atomicity</code> <i>&c.</i> may be.
- </p>
- <hr>
- <span id="Hash-tables"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Hash-tables-1"></span><h4 class="subsection">4.1.9 Hash tables</h4>
- <span id="index-tables"></span>
- <p>Scheme48 provides a simple hash table facility in the structure
- <code>tables</code>.
- </p>
- <dl>
- <dt id="index-make_002dtable">procedure: <strong>make-table</strong> <em>[hasher] --> table</em></dt>
- <dt id="index-make_002dstring_002dtable">procedure: <strong>make-string-table</strong> <em>--> string-table</em></dt>
- <dt id="index-make_002dsymbol_002dtable">procedure: <strong>make-symbol-table</strong> <em>--> symbol-table</em></dt>
- <dt id="index-make_002dinteger_002dtable">procedure: <strong>make-integer-table</strong> <em>--> integer-table</em></dt>
- <dd><p>Hash table constructors. <code>Make-table</code> creates a table that hashes
- keys either with <var>hasher</var>, if it is passed to <code>make-table</code>, or
- <code>default-hash-function</code>, and it compares keys for equality with
- <code>eq?</code>, unless they are numbers, in which case it compares with
- <code>eqv?</code>. <code>Make-string-table</code> makes a table whose hash function
- is <code>string-hash</code> and that compares the equality of keys with
- <code>string=?</code>. <code>Make-symbol-table</code> constructs a table that
- hashes symbol keys by converting them to strings and hashing them with
- <code>string-hash</code>; it compares keys’ equality by <code>eq?</code>. Tables
- made by <code>make-integer-table</code> hash keys by taking their absolute
- value, and test for key equality with the <code>=</code> procedure.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dtable_002dmaker">procedure: <strong>make-table-maker</strong> <em>comparator hasher --> table-maker</em></dt>
- <dd><p>Customized table constructor constructor: this returns a nullary
- procedure that creates a new table that uses <var>comparator</var> to compare
- keys for equality and <var>hasher</var> to hash keys.
- </p></dd></dl>
- <dl>
- <dt id="index-table_003f">procedure: <strong>table?</strong> <em>object --> boolean</em></dt>
- <dd><p>Hash table disjoint type predicate.
- </p></dd></dl>
- <dl>
- <dt id="index-table_002dref">procedure: <strong>table-ref</strong> <em>table key --> value or <code>#f</code></em></dt>
- <dt id="index-table_002dset_0021">procedure: <strong>table-set!</strong> <em>table key value --> unspecified</em></dt>
- <dd><p><code>Table-ref</code> returns the value associated with <var>key</var> in
- <var>table</var>, or <code>#f</code> if there is no such association.
- If <var>value</var> is <code>#f</code>, <code>table-set!</code> ensures that there is no
- longer an association with <var>key</var> in <var>table</var>; if <var>value</var> is
- any other value, <code>table-set!</code> creates a new association or assigns
- an existing one in <var>table</var> whose key is <var>key</var> and whose
- associated value is <var>value</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-table_002dwalk">procedure: <strong>table-walk</strong> <em>proc table --> unspecified</em></dt>
- <dd><p><code>Table-walk</code> applies <var>proc</var> to the key & value, in that order
- of arguments, of every association in <var>table</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dtable_002dimmutable_0021">procedure: <strong>make-table-immutable!</strong> <em>table --> table</em></dt>
- <dd><p>This makes the structure of <var>table</var> immutable, though not its
- contents. <code>Table-set!</code> may not be used with tables that have been
- made immutable.
- </p></dd></dl>
- <dl>
- <dt id="index-default_002dhash_002dfunction">procedure: <strong>default-hash-function</strong> <em>value --> integer-hash-code</em></dt>
- <dt id="index-string_002dhash-1">procedure: <strong>string-hash</strong> <em>string --> integer-hash-code</em></dt>
- <dd><p>Two built-in hashing functions. <code>Default-hash-function</code> can hash
- any Scheme value that could usefully be used in a <code>case</code> clause.
- <code>String-hash</code> is likely to be fast, as it is implemented as a VM
- primitive. <code>String-hash</code> is the same as what the <code>features</code>
- structure exports under the same name.
- </p></dd></dl>
- <hr>
- <span id="Weak-references"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Weak-references-1"></span><h4 class="subsection">4.1.10 Weak references</h4>
- <span id="index-weak"></span>
- <p>Scheme48 provides an interface to weakly held references in basic weak
- pointers and <em>populations</em>, or sets whose elements are weakly held.
- The facility is in the structure <code>weak</code>.
- </p>
- <span id="Weak-pointers"></span><h4 class="subsubsection">4.1.10.1 Weak pointers</h4>
- <dl>
- <dt id="index-make_002dweak_002dpointer">procedure: <strong>make-weak-pointer</strong> <em>contents --> weak-pointer</em></dt>
- <dt id="index-weak_002dpointer_003f">procedure: <strong>weak-pointer?</strong> <em>object --> boolean</em></dt>
- <dt id="index-weak_002dpointer_002dref">procedure: <strong>weak-pointer-ref</strong> <em>weak-pointer --> value or <code>#f</code></em></dt>
- <dd><p><code>Make-weak-pointer</code> creates a weak pointer that points to
- <var>contents</var>. <code>Weak-pointer?</code> is the weak pointer disjoint type
- predicate. <code>Weak-pointer-ref</code> accesses the value contained within
- <code>weak-pointer</code>, or returns <code>#f</code> if there were no strong
- references to the contents and a garbage collection occurred. Weak
- pointers resemble <a href="#Cells">cells</a>, except that they are
- immutable and hold their contents weakly, not strongly.
- </p></dd></dl>
- <span id="Populations-_0028weak-sets_0029"></span><h4 class="subsubsection">4.1.10.2 Populations (weak sets)</h4>
- <dl>
- <dt id="index-make_002dpopulation">procedure: <strong>make-population</strong> <em>--> population</em></dt>
- <dt id="index-add_002dto_002dpopulation_0021">procedure: <strong>add-to-population!</strong> <em>object population --> unspecified</em></dt>
- <dt id="index-population_002d_003elist">procedure: <strong>population->list</strong> <em>population --> list</em></dt>
- <dt id="index-walk_002dpopulation">procedure: <strong>walk-population</strong> <em>proc population --> unspecified</em></dt>
- <dd><p><code>Make-population</code> constructs an empty population.
- <code>Add-to-population!</code> adds <var>object</var> to the population
- <var>population</var>. <code>Population->list</code> returns a list of the
- elements of <var>population</var>. Note, though, that this can be
- dangerous in that it can create strong references to the population’s
- contents and potentially leak space because of this.
- <code>Walk-population</code> applies <var>proc</var> to every element in
- <var>population</var>.
- </p></dd></dl>
- <hr>
- <span id="Type-annotations"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Type-annotations-1"></span><h4 class="subsection">4.1.11 Type annotations</h4>
- <span id="index-type-system-loopholes"></span>
- <span id="index-loopholes-in-the-type-system"></span>
- <span id="index-loopholes"></span>
- <p>Scheme48 allows optional type annotations with the <code>loophole</code>
- special form from the <code>loopholes</code> structure.
- </p>
- <dl>
- <dt id="index-loophole">syntax: <strong>loophole</strong> <em>type expression --> values</em></dt>
- <dd><p>This is exactly equivalent in semantics to <var>expression</var>, except the
- static type analyzer is informed that the whole expression has the type
- <var>type</var>. For details on the form of <var>type</var>, see <a href="#Static-type-system">Static type system</a>.
- </p></dd></dl>
- <p>Type annotations can be used for several different purposes:
- </p>
- <ul>
- <li> simply to give more information to the static type analyzer;
- </li><li> to work as a simple abstract data type facility: passing a type name
- that does not already exist creates a new disjoint value type; and
- </li><li> to prevent the type system from generating warnings in the rare cases
- where it would do so incorrectly, such as in the <code>primitive-cwcc</code>,
- <code>primitive-catch</code>, and <code>with-continuation</code> devices (to be
- documented in a later edition of this manual).
- </li></ul>
- <p>To see an example of the second use, see <samp>rts/jar-defrecord.scm</samp>
- in Scheme48’s source tree.
- </p>
- <p><strong>Note:</strong> Type annotations do <em>not</em> damage the safety of
- Scheme’s type system. They affect only the static type analyzer, which
- does not change run-time object representations; it only checks type
- soundness of code and generates warnings for programs that would cause
- run-time type errors.
- </p>
- <hr>
- <span id="Explicit-renaming-macros"></span><div class="header">
- <p>
- Previous: <a href="#Type-annotations" accesskey="p" rel="prev">Type annotations</a>, Up: <a href="#System-features" accesskey="u" rel="up">System features</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Explicit-renaming-macros-1"></span><h4 class="subsection">4.1.12 Explicit renaming macros</h4>
- <span id="index-low_002dlevel-macros"></span>
- <span id="index-macros_002c-low_002dlevel"></span>
- <span id="index-unhygienic-macros"></span>
- <span id="index-macros_002c-unhygienic"></span>
- <p>Scheme48 supports a simple low-level macro system based on explicitly
- renaming identifiers to preserve hygiene. The macro system is
- well-integrated with the module system; see <a href="#Macros-in-concert-with-modules">Macros in concert with modules</a>.
- </p>
- <p><em>Explicit renaming</em> macro transformers operate on simple
- S-expressions extended with <em>identifiers</em>, which are like symbols
- but contain more information about lexical context. In order to
- preserve that lexical context, transformers must explicitly call a
- <em>renamer</em> procedure to produce an identifier with the proper scope.
- To test whether identifiers have the same denotation, transformers are
- also given an identifier comparator.
- </p>
- <p>The facility provided by Scheme48 is almost identical to the explicit
- renaming macro facility described in [Clinger 91].<a id="DOCF15" href="#FOOT15"><sup>15</sup></a> It differs only by the <code>transformer</code>
- keyword, which is described in the paper but not used by Scheme48, and
- in the annotation of auxiliary names.
- </p>
- <dl>
- <dt id="index-define_002dsyntax-1">syntax: <strong>define-syntax</strong> <em>name transformer [aux-names]</em></dt>
- <dd><p>Introduces a derived syntax <var>name</var> with the given transformer,
- which may be an explicit renaming transformer procedure, a pair whose
- car is such a procedure and whose cdr is a list of auxiliary
- identifiers, or the value of a <code>syntax-rules</code> expression. In the
- first case, the added operand <var>aux-names</var> may, and usually should
- except in the case of local (non-exported) syntactic bindings, be a
- list of all of the auxiliary top-level identifiers used by the macro.
- </p></dd></dl>
- <p>Explicit renaming transformer procedures are procedures of three
- arguments: an input form, an identifier renamer procedure, and an
- identifier comparator procedure. The input form is the whole form of
- the macro’s invocation (including, at the car, the identifier whose
- denotation was the syntactic binding). The identifier renamer accepts
- an identifier as an argument and returns an identifier that is
- hygienically renamed to refer absolutely to the identifier’s denotation
- in the environment of the macro’s definition, not in the environment of
- the macro’s usage. In order to preserve hygiene of syntactic
- transformations, macro transformers must call this renamer procedure
- for any literal identifiers in the output. The renamer procedure is
- referentially transparent; that is, two invocations of it with the same
- arguments in terms of <code>eq?</code> will produce the same results in the
- sense of <code>eq?</code>.
- </p>
- <p>For example, this simple transformer for a <code>swap!</code> macro is
- incorrect:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax swap!
- (lambda (form rename compare)
- (let ((a (cadr form))
- (b (caddr form)))
- `(LET ((TEMP ,a))
- (SET! ,a ,b)
- (SET! ,b TEMP)))))</pre></div>
- <p>The introduction of the literal identifier <code>temp</code> into the output
- may conflict with one of the input variables if it were to also be
- named <code>temp</code>: <code>(swap! temp foo)</code> or <code>(swap! bar temp)</code>
- would produce the wrong result. Also, the macro would fail in another
- very strange way if the user were to have a local variable named
- <code>let</code> or <code>set!</code>, or it would simply produce invalid output if
- there were no binding of <code>let</code> or <code>set!</code> in the environment
- in which the macro was used. These are basic problems of abstraction:
- the user of the macro should not need to know how the macro is
- internally implemented, notably with a <code>temp</code> variable and using
- the <code>let</code> and <code>set!</code> special forms.
- </p>
- <p>Instead, the macro must hygienically rename these identifiers using
- the renamer procedure it is given, and it should list the top-level
- identifiers it renames (which cannot otherwise be extracted
- automatically from the macro’s definition):
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax swap!
- (lambda (form rename compare)
- (let ((a (cadr form))
- (b (caddr form)))
- `(,(rename 'LET) ((,(rename 'TEMP) ,a))
- (,(rename 'SET!) ,a ,b)
- (,(rename 'SET!) ,b ,(rename 'TEMP)))))
- (LET SET!))</pre></div>
- <p>However, some macros are unhygienic by design, <i>i.e.</i> they insert
- identifiers into the output intended to be used in the environment of
- the macro’s usage. For example, consider a <code>loop</code> macro that
- loops endlessly, but binds a variable named <code>exit</code> to an escape
- procedure to the continuation of the <code>loop</code> expression, with
- which the user of the macro can escape the loop:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax loop
- (lambda (form rename compare)
- (let ((body (cdr form)))
- `(,(rename 'CALL-WITH-CURRENT-CONTINUATION)
- (,(rename 'LAMBDA) (EXIT) ; Literal, unrenamed EXIT.
- (,(rename 'LET) ,(rename 'LOOP) ()
- ,@body
- (,(rename 'LOOP)))))))
- (CALL-WITH-CURRENT-CONTINUATION LAMBDA LET))</pre></div>
- <p>Note that macros that expand to <code>loop</code> must also be unhygienic;
- for instance, this naïve definition of a
- <code>loop-while</code> macro is incorrect, because it hygienically renames
- <code>exit</code> automatically by of the definition of <code>syntax-rules</code>,
- so the identifier it refers to is not the one introduced
- unhygienically by <code>loop</code>:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax loop-while
- (syntax-rules ()
- ((LOOP-WHILE test body ...)
- (LOOP (IF (NOT test)
- (EXIT)) ; Hygienically renamed.
- body ...))))</pre></div>
- <p>Instead, a transformer must be written to not hygienically rename
- <code>exit</code> in the output:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax loop-while
- (lambda (form rename compare)
- (let ((test (cadr form))
- (body (cddr form)))
- `(,(rename 'LOOP)
- (,(rename 'IF) (,(rename 'NOT) ,test)
- (EXIT)) ; Not hygienically renamed.
- ,@body)))
- (LOOP IF NOT))</pre></div>
- <p>To understand the necessity of annotating macros with the list of
- auxiliary names they use, consider the following definition of the
- <code>delay</code> form, which transforms <code>(delay <var>exp</var>)</code> into
- <code>(make-promise (lambda () <var>exp</var>))</code>, where <code>make-promise</code>
- is some non-exported procedure defined in the same module as the
- <code>delay</code> macro:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax delay
- (lambda (form rename compare)
- (let ((exp (cadr form)))
- `(,(rename 'MAKE-PROMISE) (,(rename 'LAMBDA) () ,exp)))))</pre></div>
- <p>This preserves hygiene as necessary, but, while the compiler can know
- whether <code>make-promise</code> is <em>exported</em> or not, it cannot in
- general determine whether <code>make-promise</code> is <em>local</em>, <i>i.e.</i>
- not accessible in any way whatsoever, even in macro output, from any
- other modules. In this case, <code>make-promise</code> is <em>not</em> local,
- but the compiler cannot in general know this, and it would be an
- unnecessarily heavy burden on the compiler, the linker, and related
- code-processing systems to assume that all bindings are not local. It
- is therefore better<a id="DOCF16" href="#FOOT16"><sup>16</sup></a> to annotate such
- definitions with the list of auxiliary names used by the transformer:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax delay
- (lambda (form rename compare)
- (let ((exp (cadr form)))
- `(,(rename 'MAKE-PROMISE) (,(rename 'LAMBDA) () ,exp))))
- (MAKE-PROMISE LAMBDA))</pre></div>
- <hr>
- <span id="Condition-system"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Condition-system-1"></span><h3 class="section">4.2 Condition system</h3>
- <span id="index-exceptions-1"></span>
- <span id="index-conditions-2"></span>
- <p>As of version 1.3 (different from all older versions), Scheme48
- supports two different condition systems. One of them, the original
- one, is a simple system where conditions are represented as tagged
- lists. This section documents the original one. The new condition
- system is [SRFI 34, 35], and there is a complicated translation layer
- between the old one, employed by the run-time system, and the new one,
- which is implemented in a layer high above that as a library, but a
- library which is always loaded in the usual development environment.
- See the [SRFI 34, 35] documents for documentation of the new condition
- system. [SRFI 34] is available from the <code>exceptions</code> structure;
- SRFI 35, from the <code>conditions</code> structure.
- </p>
- <p><strong>Note:</strong> The condition system changed in Scheme48 version 1.3.
- While the old one is still available, the names of the structures that
- implement it changed. <code>Signals</code> is now <code>simple-signals</code>,
- and <code>conditions</code> is now <code>simple-conditions</code>. The structure
- that <code>signals</code> <em>now</em> names implements the same interface,
- but with [SRFI 34, 35] underlying it. The structure that the name
- <code>conditions</code> <em>now</em> identifies [SRFI 35]. You will have to
- update all old code that relied on the old <code>signals</code> and
- <code>conditions</code> structure either by using those structures’ new
- names or by invasively modifying all code to use [SRFI 34, 35]. Also,
- the only way to completely elide the use of the SRFIs is to evaluate
- this in an environment with the <code>exceptions-internal</code> and
- <code>vm-exceptions</code> structure open:
- </p>
- <div class="lisp">
- <pre class="lisp">(begin (initialize-vm-exceptions! really-signal-condition)
- ;; INITIALIZE-VM-EXCEPTIONS! returns a very large object,
- ;; which we probably don't want printed at the REPL.
- #t)</pre></div>
- <span id="Signalling_002c-handling_002c-and-representing-conditions"></span><h4 class="subsection">4.2.1 Signalling, handling, and representing conditions</h4>
- <span id="index-conditions"></span>
- <span id="index-exceptions"></span>
- <span id="index-errors"></span>
- <span id="index-warnings"></span>
- <span id="index-signalling-conditions"></span>
- <span id="index-condition-types"></span>
- <span id="index-condition-handlers"></span>
- <p>Scheme48 provides a simple condition system.<a id="DOCF17" href="#FOOT17"><sup>17</sup></a> <em>Conditions</em> are objects that
- describe exceptional situations. Scheme48 keeps a registry of
- <em>condition types</em>, which just have references to their supertypes.
- Conditions are simple objects that contain only two fields, the type
- and the type-specific data (the <em>stuff</em>). Accessor procedures
- should be defined for particular condition types to extract the data
- contained within the ‘stuff’ fields of instances of of those condition
- types. Condition types are represented as symbols. <em>Condition
- handlers</em> are part of the system’s dynamic context; they are used to
- handle exceptional situations when conditions are signalled that
- describe such exceptional situations. <em>Signalling</em> a condition
- signals that an exceptional situation occurred and invokes the current
- condition handler on the condition.
- </p>
- <p>Scheme48’s condition system is split up into three structures:
- </p>
- <dl compact="compact">
- <dt><code>simple-signals</code></dt>
- <dd><p>Exports procedures to signal conditions and construct conditions, as
- well as some utilities for common kinds of conditions.
- </p>
- </dd>
- <dt><code>handle</code></dt>
- <dd><p>Exports facilities for handling signalled conditions.
- </p>
- </dd>
- <dt><code>simple-conditions</code></dt>
- <dd><p>The system of representing conditions as objects.
- </p></dd>
- </dl>
- <span id="index-simple_002dsignals"></span>
- <p>The <code>simple-signals</code> structure exports these procedures:
- </p>
- <dl>
- <dt id="index-make_002dcondition">procedure: <strong>make-condition</strong> <em>type-name stuff --> condition</em></dt>
- <dd><p>The condition object constructor.
- </p></dd></dl>
- <dl>
- <dt id="index-signal_002dcondition">procedure: <strong>signal-condition</strong> <em>condition --> values (may not return)</em></dt>
- <dt id="index-signal">procedure: <strong>signal</strong> <em>type-name stuff … --> values (may not return)</em></dt>
- <dd><p><code>Signal-condition</code> signals the given condition. <code>Signal</code> is
- a convenience atop the common conjunction of <code>signal-condition</code>
- and <code>make-condition</code>: it constructs a condition with the given
- type name and stuff, whereafter it signals that condition with
- <code>signal-condition</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-error">procedure: <strong>error</strong> <em>message irritant … --> values (may not return)</em></dt>
- <dt id="index-warn">procedure: <strong>warn</strong> <em>message irritant … --> values (may not return)</em></dt>
- <dt id="index-syntax_002derror">procedure: <strong>syntax-error</strong> <em>message irritant … --> expression (may not return)</em></dt>
- <dt id="index-call_002derror">procedure: <strong>call-error</strong> <em>message irritant … --> values (may not return)</em></dt>
- <dt id="index-note">procedure: <strong>note</strong> <em>message irritant … --> values (may not return)</em></dt>
- <dd><p>Conveniences for signalling standard condition types. These procedures
- generally either do not return or return an unspecified value, unless
- specified to by a user of the debugger. <code>Syntax-error</code> returns
- the expression <code>(quote syntax-error)</code>, if the condition handler
- returns to <code>syntax-error</code> in the first place.
- </p>
- <span id="index-error-messages"></span>
- <span id="index-condition-messages"></span>
- <p>By convention, the message should be lowercased (<i>i.e.</i> the first word
- should not be capitalized), and it should not end with punctuation.
- The message is typically not a complete sentence. For example, these
- all follow Scheme48’s convention:
- </p>
- <ul class="no-bullet">
- <li><!-- /@w --> argument type error
- </li><li><!-- /@w --> wrong number of arguments
- </li><li><!-- /@w --> invalid syntax
- </li><li><!-- /@w --> ill-typed right-hand side
- </li><li><!-- /@w --> out of memory, unable to continue
- </li></ul>
- <p>These, on the other hand, do not follow the convention and should be
- avoided:
- </p>
- <ul class="no-bullet">
- <li><!-- /@w --> Argument type error:
- </li><li><!-- /@w --> An argument of the wrong type was passed.
- </li><li><!-- /@w --> possible type mismatch:
- </li><li><!-- /@w --> Luser is an idiot!
- </li></ul>
- <p>Elaboration on a message is performed usually by wrapping an irritant
- in a descriptive list. For example, one might write:
- </p>
- <div class="lisp">
- <pre class="lisp">(error "invalid argument"
- '(not a pair)
- `(while calling ,frobbotz)
- `(received ,object))</pre></div>
- <p>This might be printed as:
- </p>
- <div class="example">
- <pre class="example">Error: invalid argument
- (not a pair)
- (while calling #{Procedure 123 (frobbotz in ...)})
- (received #(a b c d))</pre></div>
- </dd></dl>
- <span id="index-installing-condition-handlers"></span>
- <span id="index-handle"></span>
- <p>The <code>handle</code> structure exports the following procedures:
- </p>
- <dl>
- <dt id="index-with_002dhandler">procedure: <strong>with-handler</strong> <em>handler thunk --> values</em></dt>
- <dd><p>Sets up <var>handler</var> as the condition handler for the dynamic extent
- of <var>thunk</var>. <var>Handler</var> should be a procedure of two arguments:
- the condition that was signalled and a procedure of zero arguments that
- propagates the condition up to the next dynamically enclosing handler.
- When a condition is signalled, <var>handler</var> is tail-called from the
- point that the condition was signalled at. Note that, because
- <var>handler</var> is tail-called at that point, it will <em>return</em> to
- that point also.
- </p>
- <p><strong>Warning:</strong> <code>With-handler</code> is potentially very dangerous.
- If an exception occurs and a condition is raised in the handler, the
- handler itself will be called with that new condition! Furthermore,
- the handler may accidentally return to an unexpecting signaller, which
- can cause very confusing errors. Be careful with <code>with-handler</code>;
- to be perfectly safe, it might be a good idea to throw back out to
- where the handler was initially installed before doing anything:
- </p>
- <div class="lisp">
- <pre class="lisp">((call-with-current-continuation
- (lambda (k)
- (lambda ()
- (with-handler (lambda (c propagate)
- (k (lambda () <var>handler body</var>)))
- (lambda () <var>body</var>))))))</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-ignore_002derrors">procedure: <strong>ignore-errors</strong> <em>thunk --> values or condition</em></dt>
- <dt id="index-report_002derrors_002das_002dwarnings">procedure: <strong>report-errors-as-warnings</strong> <em>thunk message irritant … --> values</em></dt>
- <dd><p><code>Ignore-errors</code> sets up a condition handler that will return error
- conditions to the point where <code>ignore-errors</code> was called, and
- propagate all other conditions. If no condition is signalled during
- the dynamic extent of <var>thunk</var>, <code>ignore-errors</code> simply returns
- whatever <var>thunk</var> returned. <code>Report-errors-as-warnings</code>
- downgrades errors to warnings while executing <var>thunk</var>. If an error
- occurs, a warning is signalled with the given message, and a list of
- irritants constructed by adding the error condition to the end of the
- list <var>irritant</var> ….
- </p></dd></dl>
- <span id="index-conditions-1"></span>
- <span id="index-condition-types-1"></span>
- <span id="index-simple_002dconditions"></span>
- <p>Finally, the <code>simple-conditions</code> structure defines the condition
- type system. (Note that conditions themselves are constructed only by
- <code>make-condition</code> (and <code>signal</code>) from the
- <code>simple-signals</code> structure.) Conditions are very basic values
- that have only two universally defined fields: the type and the stuff.
- The type is a symbol denoting a condition type. The type is specified
- in the first argument to <code>make-condition</code> or <code>signal</code>. The
- stuff field contains whatever a particular condition type stores in
- conditions of that type. The stuff field is always a list; it is
- created from the arguments after the first to <code>make-condition</code> or
- <code>signal</code>. Condition types are denoted by symbols, kept in a
- global registry that maps condition type names to their supertype
- names.
- </p>
- <dl>
- <dt id="index-define_002dcondition_002dtype">procedure: <strong>define-condition-type</strong> <em>name supertype-names --> unspecified</em></dt>
- <dd><p>Registers the symbol <var>name</var> as a condition type. Its supertypes
- are named in the list <var>supertype-names</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-condition_002dpredicate">procedure: <strong>condition-predicate</strong> <em>ctype-name --> predicate</em></dt>
- <dd><p>Returns a procedure of one argument that returns <code>#t</code> if that
- argument is a condition whose type’s name is <var>ctype-name</var> or
- <code>#f</code> if not.
- </p></dd></dl>
- <dl>
- <dt id="index-condition_002dtype">procedure: <strong>condition-type</strong> <em>condition --> type-name</em></dt>
- <dt id="index-condition_002dstuff">procedure: <strong>condition-stuff</strong> <em>condition --> list</em></dt>
- <dd><p>Accessors for the two immutable fields of conditions.
- </p></dd></dl>
- <dl>
- <dt id="index-error_003f">procedure: <strong>error?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-warning_003f">procedure: <strong>warning?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-note_003f">procedure: <strong>note?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-syntax_002derror_003f">procedure: <strong>syntax-error?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-call_002derror_003f">procedure: <strong>call-error?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-read_002derror_003f">procedure: <strong>read-error?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-interrupt_003f">procedure: <strong>interrupt?</strong> <em>condition --> boolean</em></dt>
- <dd><p>Condition predicates for built-in condition types.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dexception">procedure: <strong>make-exception</strong> <em>opcode reason arguments --> exception</em></dt>
- <dt id="index-exception_003f">procedure: <strong>exception?</strong> <em>condition --> boolean</em></dt>
- <dt id="index-exception_002dopcode">procedure: <strong>exception-opcode</strong> <em>exception --> integer-opcode</em></dt>
- <dt id="index-exception_002dreason">procedure: <strong>exception-reason</strong> <em>exception --> symbol</em></dt>
- <dt id="index-exception_002darguments">procedure: <strong>exception-arguments</strong> <em>exception --> list</em></dt>
- <dd><p><em>Exceptions</em> represent run-time errors in the Scheme48 VM. They
- contain information about what opcode the VM was executing when it
- happened, what the reason for the exception occurring was, and the
- relevant arguments.
- </p></dd></dl>
- <span id="Displaying-conditions"></span><h4 class="subsection">4.2.2 Displaying conditions</h4>
- <span id="index-printing-conditions"></span>
- <span id="index-displaying-conditions"></span>
- <p>The <code>display-conditions</code> structure is also relevant in this
- section.
- </p>
- <dl>
- <dt id="index-display_002dcondition">procedure: <strong>display-condition</strong> <em>condition port --> unspecified</em></dt>
- <dd><p>Prints <var>condition</var> to <var>port</var> for a user to read. For example:
- </p>
- <div class="lisp">
- <pre class="lisp">(display-condition (make-condition 'error
- "Foo bar baz"
- 'quux
- '(zot mumble: frotz))
- (current-output-port))
- -| Error: Foo bar baz
- -| quux
- -| (zot mumble: frotz)</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-_0026disclose_002dcondition">method table: <strong>&disclose-condition</strong> <em>condition --> disclosed</em></dt>
- <dd><p>Method table (see <a href="#Generic-dispatch-system">Generic dispatch system</a>) for a generic procedure
- (not exposed) used to translate a condition object into a more readable
- format. See <a href="#Writer">Writer</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-limited_002dwrite">procedure: <strong>limited-write</strong> <em>object port max-depth max-length --> unspecified</em></dt>
- <dd><p>A utility for avoiding excessive output: prints <var>object</var> to
- <var>port</var>, but will never print more than <var>max-length</var> of a
- subobject’s components, leaving a <code>---</code> after the last component,
- and won’t recur further down the object graph from the vertex
- <var>object</var> beyond <var>max-depth</var>, instead printing an octothorpe
- (<code>#</code>).
- </p>
- <div class="lisp">
- <pre class="lisp">(let ((x (cons #f #f)))
- (set-car! x x)
- (set-cdr! x x)
- (limited-write x (current-output-port) 2 2))
- -| ((# # ---) (# # ---) ---)</pre></div>
- </dd></dl>
- <hr>
- <span id="Bitwise-manipulation"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Bitwise-manipulation-1"></span><h3 class="section">4.3 Bitwise manipulation</h3>
- <span id="index-binary-data-operation"></span>
- <span id="index-bitwise-integer-operations"></span>
- <span id="index-byte-manipulation"></span>
- <p>Scheme48 provides two structures for bit manipulation: bitwise integer
- operations, the <code>bitwise</code> structure, and homogeneous vectors of
- bytes (integers between 0 and 255, inclusive), the <code>byte-vectors</code>
- structure.
- </p>
- <span id="Bitwise-integer-operations"></span><h4 class="subsection">4.3.1 Bitwise integer operations</h4>
- <span id="index-bitwise"></span>
- <p>The <code>bitwise</code> structure exports these procedures:
- </p>
- <dl>
- <dt id="index-bitwise_002dand">procedure: <strong>bitwise-and</strong> <em>integer … --> integer</em></dt>
- <dt id="index-bitwise_002dior">procedure: <strong>bitwise-ior</strong> <em>integer … --> integer</em></dt>
- <dt id="index-bitwise_002dxor">procedure: <strong>bitwise-xor</strong> <em>integer … --> integer</em></dt>
- <dt id="index-bitwise_002dnot">procedure: <strong>bitwise-not</strong> <em>integer --> integer</em></dt>
- <dd><p>Basic twos-complement bitwise boolean logic operations.
- </p></dd></dl>
- <dl>
- <dt id="index-arithmetic_002dshift">procedure: <strong>arithmetic-shift</strong> <em>integer count --> integer</em></dt>
- <dd><p>Shifts <var>integer</var> by the given bit count. If <var>count</var> is
- positive, the shift is a left shift; otherwise, it is a right shift.
- <code>Arithmetic-shift</code> preserves <var>integer</var>’s sign.
- </p></dd></dl>
- <dl>
- <dt id="index-bit_002dcount">procedure: <strong>bit-count</strong> <em>integer --> integer</em></dt>
- <dd><p>Returns the number of bits that are set in <var>integer</var>. If
- <var>integer</var> is negative, it is flipped by the bitwise NOT operation
- before counting.
- </p>
- <div class="lisp">
- <pre class="lisp">(bit-count #b11010010) ⇒ 4</pre></div>
- </dd></dl>
-
- <span id="Byte-vectors"></span><h4 class="subsection">4.3.2 Byte vectors</h4>
- <span id="index-byte_002dvectors"></span>
- <p>The structure <code>byte-vectors</code> exports analogues of regular vector
- procedures for <em>byte vectors</em>, homogeneous vectors of bytes:
- </p>
- <dl>
- <dt id="index-make_002dbyte_002dvector">procedure: <strong>make-byte-vector</strong> <em>length fill --> byte-vector</em></dt>
- <dt id="index-byte_002dvector">procedure: <strong>byte-vector</strong> <em>byte … --> byte-vector</em></dt>
- <dt id="index-byte_002dvector_003f">procedure: <strong>byte-vector?</strong> <em>object --> boolean</em></dt>
- <dt id="index-byte_002dvector_002dlength">procedure: <strong>byte-vector-length</strong> <em>byte-vector --> integer</em></dt>
- <dt id="index-byte_002dvector_002dref">procedure: <strong>byte-vector-ref</strong> <em>byte-vector index --> byte</em></dt>
- <dt id="index-byte_002dvector_002dset_0021">procedure: <strong>byte-vector-set!</strong> <em>byte-vector index byte --> unspecified</em></dt>
- <dd><p><var>Fill</var> and each <var>byte</var> must be bytes, <i>i.e.</i> integers within the
- inclusive range 0 to 255. Note that <code>make-byte-vector</code> is not an
- exact analogue of <code>make-vector</code>, because the <var>fill</var> parameter
- is required.
- </p></dd></dl>
- <p>Old versions of Scheme48 referred to byte vectors as ‘code vectors’
- (since they were used to denote byte code). The <code>code-vectors</code>
- structure exports <code>make-code-vector</code>, <code>code-vector?</code>,
- <code>code-vector-length</code>, <code>code-vector-ref</code>, and
- <code>code-vector-set!</code>, identical to the analogously named byte
- vector operations.
- </p><hr>
- <span id="Generic-dispatch-system"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Generic-dispatch-system-1"></span><h3 class="section">4.4 Generic dispatch system</h3>
- <span id="index-multimethod-dispatch"></span>
- <span id="index-type-dispatch"></span>
- <span id="index-generic-functions"></span>
- <span id="index-generic-predicate-dispatch"></span>
- <span id="index-methods"></span>
- <span id="index-meta_002dmethods"></span>
- <p>Scheme48 supports a CLOS-style generic procedure dispatch system, based
- on type predicates. The main interface is exported by <code>methods</code>.
- The internals of the system are exposed by the <code>meta-methods</code>
- structure, but they are not documented here. The generic dispatch
- system is used in Scheme48’s <a href="#Writer">writer</a> and numeric
- system.
- </p>
- <p><em>Types</em> in Scheme48’s generic dispatch system are represented using
- type predicates, rather than having every object have a single,
- well-defined ‘class.’ The naming convention for simple types is to
- prefix the type name with a colon. The types support multiple
- inheritance. Method specificity is determined based on descending
- order of argument importance. That is, given two methods, <var>M</var> &
- <var>N</var>, such that they are both applicable to a given sequence of
- arguments, and an index <var>i</var> into that sequence, such that <var>i</var>
- is the first index in <var>M</var>’s & <var>N</var>’s lists of argument type
- specifiers, from left to right, where the type differs: if the type for
- <var>M</var>’s argument at <var>i</var> is more specific than the corresponding
- type in <var>N</var>’s specifiers, <var>M</var> is considered to be more specific
- than <var>N</var>, even if the remaining argument type specifiers in <var>N</var>
- are more specific.
- </p>
- <dl>
- <dt id="index-define_002dsimple_002dtype">syntax: <strong>define-simple-type</strong> <em>name (supertype …) predicate</em></dt>
- <dd><p>Defines <var>name</var> to be a <em>simple type</em> with the given predicate
- and the given supertypes.
- </p></dd></dl>
- <dl>
- <dt id="index-singleton">procedure: <strong>singleton</strong> <em>value --> simple-type</em></dt>
- <dd><p>Creates a <em>singleton type</em> that matches only <var>value</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002dgeneric">syntax: <strong>define-generic</strong> <em>proc-name method-table-name [prototype]</em></dt>
- <dd><p>Defines <var>proc-name</var> to be a <em>generic procedure</em> that, when
- invoked, will dispatch on its arguments via the <em>method table</em> that
- <var>method-table-name</var> is defined to be and apply the most specific
- method it can determine defined in the <var>method-table-name</var> method
- table to its arguments. The convention for naming variables that will
- be bound to method tables is to add an ampersand to the front of the
- name. <var>Prototype</var> is a suggestion for what method prototypes
- should follow the shape of, but it is currently ignored.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002dmethod">syntax: <strong>define-method</strong> <em>method-table prototype body</em></dt>
- <dd><p>Adds a <em>method</em> to <var>method-table</var>, which is usually one defined
- by <code>define-generic</code>.<a id="DOCF18" href="#FOOT18"><sup>18</sup></a> <var>Prototype</var> should be a list whose elements
- may be either identifiers, in which case that parameter is not used for
- dispatching, or lists of two elements, the <code>car</code> of which is the
- parameter name and the <code>cadr</code> of which should evaluate to the type
- on which to dispatch. As in many generic dispatch systems of similar
- designs, methods may invoke the next-most-specific method. By default,
- the name <code>next-method</code> is bound in <var>body</var> to a nullary
- procedure that calls the next-most-specific method. The name of this
- procedure may be specified by the user by putting the sequence
- <code>"next" <var>next-method-name</var></code> in <var>prototype</var>, in which case
- it will be <var>next-method-name</var> that is bound to that procedure. For
- example:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-method &frob ((foo :bar) "next" frobozz)
- (if (mumble? foo)
- (frobozz) ; Invoke the next method.
- (yargh blargle foo)))</pre></div>
- </dd></dl>
- <p>A number of simple types are already defined & exported by the
- <code>methods</code> structure. Entries are listed as <code><var>type-name</var>
- <- (<var>supertype</var> …), <var>predicate</var></code>
- </p>
- <ul>
- <li> <code>:values <- (), (lambda (x) #t)</code> — Abstract supertype of
- all run-time values
- </li><li> <code>:value <- (:values), (lambda (x) #t)</code> — Abstract
- supertype of all first-class values
- </li><li> <code>:zero <- (:values), (lambda (x) #f)</code> — Type that no
- objects satisfy
- </li><li> <code>:number <- (:value), number?</code>
- </li><li> <code>:complex <- (:number), complex?</code> — (This happens to be
- equivalent to <code>:number</code>.)
- </li><li> <code>:real <- (:complex), real?</code>
- </li><li> <code>:rational <- (:real), rational?</code>
- </li><li> <code>:integer <- (:rational), integer?</code>
- </li><li> <code>:exact-integer <- (:integer),
- (lambda (x) (and (integer? x) (exact? x)))</code>
- </li><li> <code>:boolean <- (:value), boolean?</code>
- </li><li> <code>:symbol <- (:value), symbol?</code>
- </li><li> <code>:char <- (:value), char?</code>
- </li><li> <code>:null <- (:value), null?</code>
- </li><li> <code>:pair <- (:value), pair?</code>
- </li><li> <code>:vector <- (:value), vector?</code>
- </li><li> <code>:string <- (:value), string?</code>
- </li><li> <code>:procedure <- (:value), procedure?</code>
- </li><li> <code>:input-port <- (:value), input-port?</code>
- </li><li> <code>:output-port <- (:value), output-port?</code>
- </li><li> <code>:eof-object <- (:value), eof-object?</code>
- </li><li> <code>:record <- (:value), record?</code>
- </li></ul>
- <hr>
- <span id="I_002fO-system"></span><div class="header">
- <p>
- Next: <a href="#Reader-_0026-writer" accesskey="n" rel="next">Reader & 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="I_002fO-system-1"></span><h3 class="section">4.5 I/O system</h3>
- <p>Scheme48 supports a sophisticated, non-blocking, user-extensible I/O
- system untied to any particular operating system’s I/O facilities. It
- is based in three levels: channels, ports, and the facilities already
- built with both ports and channels in Scheme48, such as buffering.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Ports" accesskey="1">Ports</a></td><td> </td><td align="left" valign="top">Abstract & generalized I/O objects.
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Programmatic-ports" accesskey="2">Programmatic ports</a></td><td> </td><td align="left" valign="top">Designing custom ports.
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Miscellaneous-I_002fO-internals" accesskey="3">Miscellaneous I/O internals</a></td><td> </td><td align="left" valign="top">Various internal I/O system routines.
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Channels" accesskey="4">Channels</a></td><td> </td><td align="left" valign="top">Low-level interface to OS facilities.
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Channel-ports" accesskey="5">Channel ports</a></td><td> </td><td align="left" valign="top">Ports built upon channels.
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Ports"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Ports-1"></span><h4 class="subsection">4.5.1 Ports</h4>
- <p>While channels provide the low-level interface directly to the OS’s I/O
- facilities, <em>ports</em> provide a more abstract & generalized mechanism
- for I/O transmission. Rather than being specific to channels or being
- themselves primitive I/O devices, ports are functionally parameterized.
- This section describes the usual I/O operations on ports. The next
- section describes the programmatic port parameterization mechanism, and
- the section following that describes the most commonly used built-in
- port abstraction, ports atop channels.
- </p>
- <span id="Port-operations"></span><h4 class="subsubsection">4.5.1.1 Port operations</h4>
- <span id="index-i_002fo"></span>
- <p>The following names are exported by the <code>i/o</code> structure.
- </p>
- <dl>
- <dt id="index-input_002dport_003f">procedure: <strong>input-port?</strong> <em>value --> boolean</em></dt>
- <dt id="index-output_002dport_003f">procedure: <strong>output-port?</strong> <em>value --> boolean</em></dt>
- <dd><p>These return <code>#t</code> if their argument is both a port and either an
- input port or output port, respectively, or <code>#f</code> if neither
- condition is true.
- </p></dd></dl>
- <dl>
- <dt id="index-close_002dinput_002dport">procedure: <strong>close-input-port</strong> <em>port --> unspecified</em></dt>
- <dt id="index-close_002doutput_002dport">procedure: <strong>close-output-port</strong> <em>port --> unspecified</em></dt>
- <dd><p>Closes <var>port</var>, which must be an input port or an output port,
- respectively.
- </p></dd></dl>
- <dl>
- <dt id="index-char_002dready_003f">procedure: <strong>char-ready?</strong> <em>[port] --> boolean</em></dt>
- <dt id="index-output_002dport_002dready_003f">procedure: <strong>output-port-ready?</strong> <em>port --> boolean</em></dt>
- <dd><p><code>Char-ready?</code> returns a true value if there is a character ready
- to be read from <var>port</var> and <code>#f</code> if there is no character
- ready. <var>Port</var> defaults to the current input port if absent; see
- below on current ports. <code>Output-port-ready?</code> returns a true value
- if <var>port</var> is ready to receive a single written character and
- <code>#f</code> if not.
- </p></dd></dl>
- <span id="index-block-input-and-output"></span>
- <span id="index-input-and-output-of-blocks"></span>
- <dl>
- <dt id="index-read_002dblock">procedure: <strong>read-block</strong> <em>block start count port [wait?] --> count-read or EOF</em></dt>
- <dt id="index-write_002dblock">procedure: <strong>write-block</strong> <em>block start count port --> count-written</em></dt>
- <dt id="index-write_002dstring">procedure: <strong>write-string</strong> <em>string port --> char-count-written</em></dt>
- <dd><p><code>Read-block</code> attempts to read <var>count</var> elements from <var>port</var>
- into <var>block</var>, which may be a string or a byte vector, starting at
- <var>start</var>. If fewer than <var>count</var> characters or bytes are
- available to read from <var>port</var>, and <var>wait?</var> is a true value or
- absent, <code>read-block</code> will wait until <var>count</var> characters are
- available and read into <var>block</var>; if <var>wait?</var> is <code>#f</code>,
- <code>read-block</code> immediately returns. <code>Read-block</code> returns the
- number of elements read into <var>block</var>, or an end of file object if
- the stream’s end is immediately encountered. <code>Write-block</code> writes
- <var>count</var> elements from <var>block</var>, which may be a string or a byte
- vector, starting at <var>start</var> to <var>port</var>. <code>Write-string</code> is
- a convenience atop <code>write-block</code> for writing the entirety of a
- string to a port.
- </p></dd></dl>
- <dl>
- <dt id="index-newline">procedure: <strong>newline</strong> <em>[port] --> unspecified</em></dt>
- <dd><p>Writes a newline character or character sequence to the output port
- <var>port</var>. <var>Port</var> defaults to the current output port; see below
- on current ports.
- </p></dd></dl>
- <dl>
- <dt id="index-disclose_002dport">procedure: <strong>disclose-port</strong> <em>port --> disclosed</em></dt>
- <dd><p>Returns a disclosed representation of <var>port</var>; see <a href="#Writer">Writer</a>.
- </p></dd></dl>
- <span id="index-forcing-buffered-output-1"></span>
- <span id="index-output-port-buffer-forcing-1"></span>
- <span id="index-buffered-output-forcing-1"></span>
- <span id="index-flushing-output-buffers-1"></span>
- <dl>
- <dt id="index-force_002doutput-1">procedure: <strong>force-output</strong> <em>port --> unspecified</em></dt>
- <dd><p>Forces all buffered output in the output port <var>port</var> to be sent.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dnull_002doutput_002dport">procedure: <strong>make-null-output-port</strong> <em>--> output-port</em></dt>
- <dd><p>Returns an output port that will ignore any output it receives.
- </p></dd></dl>
- <span id="Current-ports"></span><h4 class="subsubsection">4.5.1.2 Current ports</h4>
- <p>Scheme48 keeps in its <a href="#Fluid_002fdynamic-bindings">dynamic
- environment</a> a set of ‘current’ ports. These include R5RS’s current
- input and output ports, as well as ports for general noise produced by
- the system, and ports for where error messages are printed. These
- procedures are exported by the <code>i/o</code> structure.
- </p>
- <dl>
- <dt id="index-current_002dinput_002dport">procedure: <strong>current-input-port</strong> <em>--> input-port</em></dt>
- <dt id="index-current_002doutput_002dport">procedure: <strong>current-output-port</strong> <em>--> output-port</em></dt>
- <dt id="index-current_002dnoise_002dport-1">procedure: <strong>current-noise-port</strong> <em>--> output-port</em></dt>
- <dt id="index-current_002derror_002dport">procedure: <strong>current-error-port</strong> <em>--> output-port</em></dt>
- <dd><p>These return the values in the current dynamic environment of the
- respective ports. <code>Current-input-port</code> and
- <code>current-output-port</code> are also exported by the <code>scheme</code>
- structure.
- </p></dd></dl>
- <dl>
- <dt id="index-input_002dport_002doption">procedure: <strong>input-port-option</strong> <em>arguments --> input-port</em></dt>
- <dt id="index-output_002dport_002doption">procedure: <strong>output-port-option</strong> <em>arguments --> output-port</em></dt>
- <dd><p>These are utilities for retrieving optional input and output port
- arguments from rest argument lists, defaulting to the current input or
- output ports. For example, assuming the newline character sequence is
- simply <code>#\newline</code>, <code>newline</code> might be written as:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (newline . maybe-port)
- (write-char #\newline (output-port-option maybe-port)))</pre></div>
- </dd></dl>
- <span id="index-noise-output-1"></span>
- <dl>
- <dt id="index-silently">procedure: <strong>silently</strong> <em>thunk --> values</em></dt>
- <dd><p>This stifles output from the current noise port in the dynamic extent
- of <var>thunk</var>, which is applied to zero arguments. <code>Silently</code>
- returns the values that <var>thunk</var> returns.
- </p></dd></dl>
- <dl>
- <dt id="index-with_002dcurrent_002dports">procedure: <strong>with-current-ports</strong> <em>input output error thunk --> values</em></dt>
- <dd><p><code>With-current-ports</code> dynamically binds the current input, output,
- and error ports to <var>input</var>, <var>output</var>, and <var>error</var>,
- respectively, in the dynamic extent of <var>thunk</var>, which is applied
- to zero arguments. The current noise port is also bound to
- <var>error</var>. <code>With-current-ports</code> returns the values that
- <var>thunk</var> returns.
- </p></dd></dl>
- <span id="index-i_002fo_002dinternal"></span>
- <p>Similarly to <code>with-current-ports</code>, the <code>i/o-internal</code>
- structure also exports these procedures:
- </p>
- <dl>
- <dt id="index-call_002dwith_002dcurrent_002dinput_002dport">procedure: <strong>call-with-current-input-port</strong> <em>port thunk --> values</em></dt>
- <dt id="index-call_002dwith_002dcurrent_002doutput_002dport">procedure: <strong>call-with-current-output-port</strong> <em>port thunk --> values</em></dt>
- <dt id="index-call_002dwith_002dcurrent_002dnoise_002dport">procedure: <strong>call-with-current-noise-port</strong> <em>port thunk --> values</em></dt>
- <dd><p>These bind individual current ports for the dynamic extent of each
- <var>thunk</var>, which is applied to zero arguments. These all return the
- values that <var>thunk</var> returns.
- </p></dd></dl>
- <hr>
- <span id="Programmatic-ports"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Programmatic-ports-1"></span><h4 class="subsection">4.5.2 Programmatic ports</h4>
- <p>Ports are user-extensible; all primitive port operations on them —
- <code>read-char</code>, <code>write-block</code>, <i>&c.</i> — are completely
- generalized. Abstractions for buffered ports are also available.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Port-data-type" accesskey="1">Port data type</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Port-handlers" accesskey="2">Port handlers</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Buffered-ports-_0026-handlers" accesskey="3">Buffered ports & handlers</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Port-data-type"></span><div class="header">
- <p>
- Next: <a href="#Port-handlers" accesskey="n" rel="next">Port handlers</a>, Up: <a href="#Programmatic-ports" accesskey="u" rel="up">Programmatic ports</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Port-data-type-1"></span><h4 class="subsubsection">4.5.2.1 Port data type</h4>
- <span id="index-ports"></span>
- <p>The <code>ports</code> structure defines the basis of the port data type and
- exports the following procedures.
- </p>
- <dl>
- <dt id="index-make_002dport">procedure: <strong>make-port</strong> <em>handler status lock data buffer index limit pending-eof? --> port</em></dt>
- <dd><p>Port constructor. The arguments are all the fields of ports, which are
- described below. Note that <code>make-port</code> is rarely called directly;
- usually one will use one of the buffered port constructors instead.
- </p></dd></dl>
- <dl>
- <dt id="index-port_002dhandler">procedure: <strong>port-handler</strong> <em>port --> port-handler</em></dt>
- <dt id="index-port_002dbuffer">procedure: <strong>port-buffer</strong> <em>port --> buffer or <code>#f</code></em></dt>
- <dt id="index-port_002dlock">procedure: <strong>port-lock</strong> <em>port --> value</em></dt>
- <dt id="index-port_002dstatus">procedure: <strong>port-status</strong> <em>port --> integer-status</em></dt>
- <dt id="index-port_002ddata">procedure: <strong>port-data</strong> <em>port --> value</em></dt>
- <dt id="index-port_002dindex">procedure: <strong>port-index</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dt id="index-port_002dlimit">procedure: <strong>port-limit</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dt id="index-port_002dpending_002deof_003f">procedure: <strong>port-pending-eof?</strong> <em>port --> boolean</em></dt>
- <dd><p>Accessors for the port fields:
- </p>
- <dl compact="compact">
- <dt><code>handler</code></dt>
- <dd><p>The handler is the functional parameterization mechanism: it provides
- all the port’s operations, such as reading/writing blocks, disclosing
- (see <a href="#Writer">Writer</a>) the port, closing the port, <i>&c</i>.
- See <a href="#Port-handlers">Port handlers</a>.
- </p>
- </dd>
- <dt><code>buffer</code></dt>
- <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.
- </p>
- </dd>
- <dt><code>lock</code></dt>
- <dd><p>This misnamed field was originally used for a mutual exclusion lock,
- before optimistic concurrency was made the native synchronization
- mechanism in Scheme48. It is now used as a ‘timestamp’ for buffered
- ports: it is provisionally written to with a unique value when a thread
- resets the <code>index</code> to reüse the buffer, and it is provisionally
- read from when reading from the buffer. In this way, if the buffer is
- reset while another thread is reading from it, the other thread’s
- proposal is invalidated by the different value in memory than what was
- there when it logged the old timestamp in its proposal.
- </p>
- </dd>
- <dt><code>status</code></dt>
- <dd><p>A mask from the <code>port-status-options</code> enumeration;
- see <a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a>.
- </p>
- </dd>
- <dt><code>data</code></dt>
- <dd><p>Arbitrary data for particular kinds of ports. For example, for a port
- that tracks line & column information (see <a href="#I_002fO-extensions">I/O extensions</a>), this
- might be a record containing the underlying port, the line number, and
- the column number.
- </p>
- </dd>
- <dt><code>index</code></dt>
- <dd><p>The current index into a buffered port’s buffer. If the port is not
- buffered, this is <code>#f</code>.
- </p>
- </dd>
- <dt><code>limit</code></dt>
- <dd><p>The limit of the <code>index</code> field for a buffered port’s buffer. When
- the <code>index</code> field is equal to the <code>limit</code> field, the buffer
- is full. If the port is not buffered, this is <code>#f</code>.
- </p>
- </dd>
- <dt><code>pending-eof?</code></dt>
- <dd><p>For output ports, this is a boolean flag indicating whether the buffer
- has been forced to output recently. For input ports, this is a boolean
- flag indicating whether an end of file is pending after reading through
- the current buffer.
- </p></dd>
- </dl>
- </dd></dl>
- <dl>
- <dt id="index-set_002dport_002dlock_0021">procedure: <strong>set-port-lock!</strong> <em>port value --> unspecified</em></dt>
- <dt id="index-set_002dport_002dstatus_0021">procedure: <strong>set-port-status!</strong> <em>port status --> unspecified</em></dt>
- <dt id="index-set_002dport_002ddata_0021">procedure: <strong>set-port-data!</strong> <em>port data --> unspecified</em></dt>
- <dt id="index-set_002dport_002dindex_0021">procedure: <strong>set-port-index!</strong> <em>port index --> unspecified</em></dt>
- <dt id="index-set_002dport_002dlimit_0021">procedure: <strong>set-port-limit!</strong> <em>port index --> unspecified</em></dt>
- <dt id="index-set_002dport_002dpending_002deof_003f_0021">procedure: <strong>set-port-pending-eof?!</strong> <em>port pending-eof? --> unspecified</em></dt>
- <dd><p>These assign respective fields of ports. The <code>buffer</code> and
- <code>handler</code> fields, however, are immutable.
- </p></dd></dl>
- <span id="index-logging-operations"></span>
- <span id="index-optimistic-concurrency-logging-operations"></span>
- <dl>
- <dt id="index-provisional_002dport_002dhandler">procedure: <strong>provisional-port-handler</strong> <em>port --> port-handler</em></dt>
- <dt id="index-provisional_002dport_002dlock">procedure: <strong>provisional-port-lock</strong> <em>port --> value</em></dt>
- <dt id="index-provisional_002dport_002dstatus">procedure: <strong>provisional-port-status</strong> <em>port --> integer-status</em></dt>
- <dt id="index-provisional_002dport_002ddata">procedure: <strong>provisional-port-data</strong> <em>port --> value</em></dt>
- <dt id="index-provisional_002dport_002dindex">procedure: <strong>provisional-port-index</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dt id="index-provisional_002dport_002dlimit">procedure: <strong>provisional-port-limit</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dt id="index-provisional_002dport_002dpending_002deof_003f">procedure: <strong>provisional-port-pending-eof?</strong> <em>port --> boolean</em></dt>
- <dt id="index-provisional_002dset_002dport_002dlock_0021">procedure: <strong>provisional-set-port-lock!</strong> <em>port value --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dport_002dstatus_0021">procedure: <strong>provisional-set-port-status!</strong> <em>port status --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dport_002ddata_0021">procedure: <strong>provisional-set-port-data!</strong> <em>port data --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dport_002dindex_0021">procedure: <strong>provisional-set-port-index!</strong> <em>port index --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dport_002dlimit_0021">procedure: <strong>provisional-set-port-limit!</strong> <em>port index --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dport_002dpending_002deof_003f_0021">procedure: <strong>provisional-set-port-pending-eof?!</strong> <em>port pending-eof? --> unspecified</em></dt>
- <dd><p>Provisional versions of the above port accessors & modifiers; that is,
- accessors & modifiers that log in the current proposal, if there is
- one.
- </p></dd></dl>
- <hr>
- <span id="Port-handlers"></span><div class="header">
- <p>
- Next: <a href="#Buffered-ports-_0026-handlers" accesskey="n" rel="next">Buffered ports & 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Port-handlers-1"></span><h4 class="subsubsection">4.5.2.2 Port handlers</h4>
- <span id="index-i_002fo_002dinternal-1"></span>
- <p><em>Port handlers</em> store a port’s specific operations for the general
- port operations, such as block reads and writes, buffer flushing,
- <i>&c</i>. Port handler constructors, including <code>make-port-handler</code>
- & the buffered port handlers in the next section, are available from
- the <code>i/o-internal</code> structure.
- </p>
- <dl>
- <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 --> port-handler</em></dt>
- <dd><p>Basic port handler constructor. The arguments are used for the port
- handler fields. Each field contains a procedure. The expected
- semantics of each procedure depend on whether the port is for input or
- output. Input ports do not use the <code>buffer-forcer</code> field. The
- first two fields are independent of the type of port:
- </p>
- <dl compact="compact">
- <dt><strong>discloser</strong> <em>port –> disclosed</em></dt>
- <dd><p>Returns a disclosed representation of the port, <i>i.e.</i> a list whose
- <code>car</code> is the ‘type name’ of this handler (usually with a suffix of
- either <code>-input-port</code> or <code>-output-port</code>) followed by a list of
- all of the components to be printed; see <a href="#Writer">Writer</a>.
- </p>
- </dd>
- <dt><strong>closer</strong> <em>port –> ignored</em></dt>
- <dd><p>Closes <var>port</var>. This operation corresponds with the
- <code>close-input-port</code> & <code>close-output-port</code> procedures.
- </p></dd>
- </dl>
- <p>For input ports, the remaining fields are:
- </p>
- <dl compact="compact">
- <dt><strong>char-reader</strong> <em>port consume? –> char</em></dt>
- <dd><p>Reads a single character from <var>port</var>. If <var>consume?</var> is true,
- the character should be consumed from <var>port</var>; if <var>consume?</var> is
- <code>#f</code>, however, the character should be left in <var>port</var>’s input
- stream. If <var>consume?</var> is true, this operation corresponds with
- <code>read-char</code>; if it is <code>#f</code>, this operation corresponds with
- <code>peek-char</code>.
- </p>
- </dd>
- <dt><strong>block-reader</strong> <em>port block start count wait? –> count-written or EOF</em></dt>
- <dd><p>Attempts to read <var>count</var> characters from <var>port</var>’s input stream
- into the string or byte vector <var>block</var>, starting at <var>start</var>.
- In the case that an insufficient number of characters is available, if
- <var>wait?</var> is true, the procedure should wait until all of the wanted
- characters are available; otherwise, if <var>wait?</var> is <code>#f</code>, the
- block reader should immediately return. In either case, it returns the
- number of characters that were read into <var>block</var>, or an end of file
- object if it immediately reached the end of the stream. Buffered ports
- will typically just copy elements from the buffer into <var>block</var>,
- rather than reading from any internal I/O channel in <var>port</var>. This
- operation corresponds with <code>read-block</code>.
- </p>
- </dd>
- <dt><strong>readiness-tester</strong> <em>port –> boolean</em></dt>
- <dd><p>Returns a true value if there is a character available to be read in
- <var>port</var> or <code>#f</code> if not. This operation corresponds with the
- <code>char-ready?</code> procedure.
- </p></dd>
- </dl>
- <p>For output ports, the remaining fields are:
- </p>
- <dl compact="compact">
- <dt><strong>char-writer</strong> <em>port char –> ignored</em></dt>
- <dd><p>Writes the single character <var>char</var> to <var>port</var>. This operation
- corresponds with <code>write-char</code>.
- </p>
- </dd>
- <dt><strong>block-writer</strong> <em>port block start count –> count-written</em></dt>
- <dd><p>Writes <var>count</var> characters to <var>port</var> from <var>block</var>, starting
- at <var>start</var>. <var>Block</var> may be a string or a byte vector. This
- will usually involve copying contents of <var>block</var> to <var>port</var>’s
- buffer, if it is buffered. This operation corresponds with
- <code>write-block</code>.
- </p>
- </dd>
- <dt><strong>readiness-tester</strong> <em>port –> boolean</em></dt>
- <dd><p>Returns a true value if <var>port</var> is ready to receive a character and
- <code>#f</code> if not.
- </p>
- </dd>
- <dt><strong>buffer-forcer</strong> <em>port necessary? –> ignored</em></dt>
- <dd><p>For buffered ports, this is intended to force all buffered output to
- the actual internal I/O channel of <var>port</var>. <var>Necessary?</var> tells
- whether or not it is absolutely necessary to force all the output
- immediately; if it is <code>#t</code>, the buffer forcer is required to force
- all output in the buffer before it returns. If <var>necessary?</var> is
- <code>#f</code>, not only may it just register an I/O transaction without
- waiting for it to complete, but it also should <em>not</em> signal an
- error if <var>port</var> is already closed. For unbuffered ports, this
- operation need not do anything at all.
- </p></dd>
- </dl>
- </dd></dl>
- <hr>
- <span id="Buffered-ports-_0026-handlers"></span><div class="header">
- <p>
- Previous: <a href="#Port-handlers" accesskey="p" rel="prev">Port handlers</a>, Up: <a href="#Programmatic-ports" accesskey="u" rel="up">Programmatic ports</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Buffered-ports-_0026-handlers-1"></span><h4 class="subsubsection">4.5.2.3 Buffered ports & handlers</h4>
- <span id="index-buffered-input-and-output"></span>
- <span id="index-i_002fo_002dinternal-2"></span>
- <p>Along with bare port handlers, Scheme48 provides conveniences for many
- patterns of buffered ports & port handlers. These names are exported
- by the <code>i/o-internal</code> structure. Buffered ports are integrated
- with Scheme48’s <a href="#Optimistic-concurrency">optimistic
- concurrency</a> facilities.
- </p>
- <p><strong>Note:</strong> Although internally buffered ports are integrated with
- optimistic concurrency, operations on buffered ports, like operations
- on channels, cannot be reliably fusibly atomic.
- </p>
- <dl>
- <dt id="index-make_002dbuffered_002dinput_002dport">procedure: <strong>make-buffered-input-port</strong> <em>handler data buffer index limit --> input-port</em></dt>
- <dt id="index-make_002dbuffered_002doutput_002dport">procedure: <strong>make-buffered-output-port</strong> <em>handler data buffer index limit --> output-port</em></dt>
- <dd><p>Constructors for buffered ports. <var>Handler</var> is the port’s handler,
- which is usually constructed with one of the buffered port handler
- constructors (see below). <var>Data</var> is arbitrary data to go in the
- port’s <code>data</code> field. <var>Buffer</var> is a byte vector whose length
- is greater than or equal to both <var>index</var> & <var>limit</var>.
- <var>Index</var> is the initial index into <var>buffer</var> to go in the port’s
- <code>index</code> field. <var>Limit</var> is the limit in the port’s buffer, to
- go into the port’s <code>limit</code> field; nothing will be written into
- <var>buffer</var> at or past <var>limit</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dunbuffered_002dinput_002dport">procedure: <strong>make-unbuffered-input-port</strong> <em>handler data --> input-port</em></dt>
- <dt id="index-make_002dunbuffered_002doutput_002dport">procedure: <strong>make-unbuffered-output-port</strong> <em>handler data --> output-port</em></dt>
- <dd><p>Conveniences for ports that are explicitly <em>not</em> buffered. Only
- the relevant fields are passed; all fields pertaining to buffering are
- initialized with <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dbuffered_002dinput_002dport_002dhandler">procedure: <strong>make-buffered-input-port-handler</strong> <em>discloser closer buffer-filler readiness-tester --> port-handler</em></dt>
- <dd><p>This creates a port handler for buffered input ports. The arguments
- are as follows:
- </p>
- <dl compact="compact">
- <dt><strong>discloser</strong> <em>port-data –> disclosed</em></dt>
- <dt><strong>closer</strong> <em>port-data –> ignored</em></dt>
- <dd><p><var>Discloser</var> & <var>closer</var> are like the similarly named regular
- port handler fields, but they are applied directly to the port’s data,
- not to the port itself.
- </p>
- </dd>
- <dt><strong>buffer-filler</strong> <em>port wait? –> committed?</em></dt>
- <dd><p>Used to fill <var>port</var>’s buffer when it no longer has contents from
- which to read in its current buffer. <var>Wait?</var> is a boolean flag,
- <code>#t</code> if the operation should wait until the I/O transaction
- necessary to fill the buffer completes, or <code>#f</code> if it may simply
- initiate an I/O transaction but not wait until it completes (<i>e.g.</i>, use
- <code>channel-maybe-commit-and-read</code>, but not wait on the condition
- variable passed to <code>channel-maybe-commit-and-read</code>).
- <var>Buffer-filler</var> is called with a fresh proposal in place, and it is
- the responsibility of <var>buffer-filler</var> to commit it. It returns a
- boolean flag denoting whether the proposal was committed. The last call
- in <var>buffer-filler</var> is usually either <code>(maybe-commit)</code> or a
- call to a procedure that causes that effect (<i>e.g.</i>, one of the
- operation on condition variables that commits the current proposal.
- See <a href="#Higher_002dlevel-synchronization">condition variables</a>.)
- </p>
- </dd>
- <dt><strong>readiness-tester</strong> <em>port –> [committed? ready?]</em></dt>
- <dd><p>Called when <code>char-ready?</code> is applied to <var>port</var> and the buffer
- of <var>port</var> is empty. Like <var>buffer-filler</var>,
- <var>readiness-tester</var> is applied with a fresh proposal in place, which
- it should attempt to commit. <var>Readiness-tester</var> should return two
- values, each a boolean flag: the first denotes whether or not the
- current proposal was successfully committed, and, if it was successful,
- whether or not a character is ready.
- </p></dd>
- </dl>
- </dd></dl>
- <dl>
- <dt id="index-make_002dbuffered_002doutput_002dport_002dhandler">procedure: <strong>make-buffered-output-port-handler</strong> <em>discloser buffer-emptier readiness-tester --> port-handler</em></dt>
- <dd><p>This creates a port handler for buffered output ports. <var>Discloser</var>
- & <var>closer</var> are as with buffered input ports. The remaining fields
- are as follows:
- </p>
- <dl compact="compact">
- <dt><strong>buffer-emptier</strong> <em>port necessary? –> committed?</em></dt>
- <dd><p><var>Buffer-emptier</var> is used when <var>port</var>’s buffer is full and needs
- to be emptied. It is called with a fresh proposal in place. It should
- reset <var>port</var>’s <code>index</code> field, call <code>note-buffer-reuse!</code>
- to invalidate other threads’ transactions on the recycled buffer, and
- attempt to commit the new proposal installed. It returns a boolean
- flag indicating whether or not the commit succeeded.
- </p>
- </dd>
- <dt><strong>readiness-tester</strong> <em>port –> [committed? ready?]</em></dt>
- <dd><p><var>Readiness-tester</var> is applied to <var>port</var> when its buffer is full
- (<i>i.e.</i> its <code>index</code> & <code>limit</code> fields are equal) and
- <code>output-port-ready?</code> is applied to <var>port</var>. After performing
- the test, it should attempt to commit the current proposal and then
- return two values: whether it succeeded in committing the current
- proposal, and, if it was successful, whether or not a character is
- ready to be outputted.
- </p></dd>
- </dl>
- </dd></dl>
- <dl>
- <dt id="index-default_002dbuffer_002dsize">constant: <strong>default-buffer-size</strong> <em>--> integer</em></dt>
- <dd><p>The default size for port buffers. This happens to be 4096 in the
- current version of Scheme48.
- </p></dd></dl>
- <dl>
- <dt id="index-note_002dbuffer_002dreuse_0021">procedure: <strong>note-buffer-reuse!</strong> <em>port --> unspecified</em></dt>
- <dt id="index-check_002dbuffer_002dtimestamp_0021">procedure: <strong>check-buffer-timestamp!</strong> <em>port --> unspecified</em></dt>
- <dd><p>These are used to signal the resetting of a buffer between multiple
- threads. <code>Note-buffer-reuse!</code> is called — in the case of an
- output port — when a buffer fills up, is emptied, and flushed; or —
- in the case of an input port — when a buffer is emptied and needs to
- be refilled. <code>Note-buffer-reuse!</code> logs in the current proposal a
- fresh value to store in <var>port</var>. When that proposal is committed,
- this fresh value is stored in the port. Other threads that were using
- <var>port</var>’s buffer call <code>check-buffer-timestamp!</code>, which logs a
- read in the current proposal. If another thread commits a buffer
- reüse to memory, that read will be invalidated, invalidating the
- whole transaction.
- </p></dd></dl>
- <hr>
- <span id="Miscellaneous-I_002fO-internals"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Miscellaneous-I_002fO-internals-1"></span><h4 class="subsection">4.5.3 Miscellaneous I/O internals</h4>
- <span id="index-i_002fo_002dinternal-3"></span>
- <span id="index-architecture"></span>
- <p>All of these but <code>port-status-options</code> are exported by the
- <code>i/o-internal</code> structure; the <code>port-status-options</code>
- enumeration is exported by the <code>architecture</code> structure, but it
- deserves mention in this section.
- </p>
- <dl>
- <dt id="index-port_002dstatus_002doptions">enumeration: <strong>port-status-options</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-enumeration port-status-options
- (input
- output
- open-for-input
- open-for-output))</pre></div>
- <p>Enumeration of indices into a port’s <code>status</code> field bit set.
- </p></dd></dl>
- <dl>
- <dt id="index-open_002dinput_002dport_003f">procedure: <strong>open-input-port?</strong> <em>port --> boolean</em></dt>
- <dt id="index-open_002doutput_002dport_003f">procedure: <strong>open-output-port?</strong> <em>port --> boolean</em></dt>
- <dd><p>These return true values if <var>port</var> is both an input or output port,
- respectively, and open.
- </p></dd></dl>
- <dl>
- <dt id="index-open_002dinput_002dport_002dstatus">constant: <strong>open-input-port-status</strong> <em>--> integer-status</em></dt>
- <dt id="index-open_002doutput_002dport_002dstatus">constant: <strong>open-output-port-status</strong> <em>--> integer-status</em></dt>
- <dd><p>The bitwise masks of enumerands from the <code>port-status-options</code>
- enumeration signifying an open input or output port, respectively.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dinput_002dport_002dclosed_0021">procedure: <strong>make-input-port-closed!</strong> <em>port --> unspecified</em></dt>
- <dt id="index-make_002doutput_002dport_002dclosed_0021">procedure: <strong>make-output-port-closed!</strong> <em>port --> unspecified</em></dt>
- <dd><p>These set the status of <var>port</var>, which must be an input or output
- port, respectively, to indicate that it is closed.
- </p></dd></dl>
- <dl>
- <dt id="index-eof_002dobject">procedure: <strong>eof-object</strong> <em>--> eof-object</em></dt>
- <dd><p>Returns the EOF object token. This is the only value that will answer
- true to R5RS’s <code>eof-object?</code> predicate.
- </p></dd></dl>
- <dl>
- <dt id="index-force_002doutput_002dif_002dopen">procedure: <strong>force-output-if-open</strong> <em>port --> unspecified</em></dt>
- <dd><p>This forces <var>port</var>’s output if it is an open output port, and does
- not block.
- </p></dd></dl>
- <dl>
- <dt id="index-periodically_002dforce_002doutput_0021">procedure: <strong>periodically-force-output!</strong> <em>port --> unspecified</em></dt>
- <dt id="index-periodically_002dflushed_002dports">procedure: <strong>periodically-flushed-ports</strong> <em>--> port-list</em></dt>
- <dd><p><code>Periodically-force-output!</code> registers <var>port</var> to be forced
- periodically. Only a weak reference to <var>port</var> in this registry is
- held, however, so this cannot cause accidental space leaks.
- <code>Periodically-flushed-ports</code> returns a list of all ports in this
- registry. Note that the returned list holds strong references to all
- of its elements. <code>Periodically-flushed-ports</code> does not permit
- thread context switches, or interrupts of any sort, while it runs.
- </p></dd></dl>
- <hr>
- <span id="Channels"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Channels-1"></span><h4 class="subsection">4.5.4 Channels</h4>
- <span id="index-channels"></span>
- <p><em>Channels</em> represent the OS’s native I/O transmission channels. On
- Unix, channels are essentially boxed file descriptors, for example.
- The only operations on channels are block reads & writes. Blocks in
- this sense may be either strings or <a href="#Bitwise-manipulation">byte vectors</a>.
- </p>
- <span id="Low_002dlevel-channel-operations"></span><h4 class="subsubsection">4.5.4.1 Low-level channel operations</h4>
- <span id="index-channels-3"></span>
- <p>The low-level base of the interface to channels described here is
- exported from the <code>channels</code> structure.
- </p>
- <dl>
- <dt id="index-channel_003f">procedure: <strong>channel?</strong> <em>--> boolean</em></dt>
- <dd><p>Disjoint type predicate for channels.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002did">procedure: <strong>channel-id</strong> <em>channel --> value</em></dt>
- <dt id="index-channel_002dstatus">procedure: <strong>channel-status</strong> <em>channel --> integer-enumerand</em></dt>
- <dt id="index-channel_002dos_002dindex">procedure: <strong>channel-os-index</strong> <em>channel --> integer</em></dt>
- <dd><p><code>Channel-id</code> returns <var>channel</var>’s id. The id is some
- identifying characteristic of channels. For example, file channels’
- ids are usually the corresponding filenames; channels such as the
- standard input, output, or error output channels have names like
- <code>"standard input"</code> and <code>"standard output"</code>.
- <code>Channel-status</code> returns the current status of <var>channel</var>; see
- the <code>channel-status-option</code> enumeration below.
- <code>Channel-os-index</code> returns the OS-specific integer index of
- <var>channel</var>. On Unix, for example, this is the channel’s file
- descriptor.
- </p></dd></dl>
- <span id="index-file-channels"></span>
- <dl>
- <dt id="index-open_002dchannel">procedure: <strong>open-channel</strong> <em>filename option close-silently? --> channel</em></dt>
- <dd><p><code>Open-channel</code> opens a channel for a file given its filename.
- <var>Option</var> specifies what type of channel this is; see the
- <code>channel-status-option</code> enumeration below. <var>Close-silently?</var>
- is a boolean that specifies whether a message should be printed (on
- Unix, to <code>stderr</code>) when the resulting channel is closed after a
- garbage collector finds it unreachable.
- </p></dd></dl>
- <span id="index-closing-channels"></span>
- <dl>
- <dt id="index-close_002dchannel">procedure: <strong>close-channel</strong> <em>channel --> unspecified</em></dt>
- <dd><p>Closes <var>channel</var> after aborting any potential pending I/O
- transactions it may have been involved with.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002dready_003f">procedure: <strong>channel-ready?</strong> <em>channel --> boolean</em></dt>
- <dd><p>If <var>channel</var> is an input channel: returns <code>#t</code> if there is
- input ready to be read from <var>channel</var> or <code>#f</code> if not; if
- <var>channel</var> is an output channel: returns <code>#t</code> if a write would
- immediately take place upon calling <code>channel-maybe-write</code>, <i>i.e.</i>
- <code>channel-maybe-write</code> would not return <code>#f</code>, or <code>#f</code> if
- not.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002dmaybe_002dread">procedure: <strong>channel-maybe-read</strong> <em>channel buffer start-index octet-count wait? --> octet count read, error status cell, EOF object, or <code>#f</code></em></dt>
- <dt id="index-channel_002dmaybe_002dwrite">procedure: <strong>channel-maybe-write</strong> <em>channel buffer start-index octet-count --> octet count written, error status cell, or <code>#f</code></em></dt>
- <dt id="index-channel_002dabort">procedure: <strong>channel-abort</strong> <em>channel --> unspecified</em></dt>
- <dd><p><code>Channel-maybe-read</code> attempts to read <var>octet-count</var> octets
- from <var>channel</var> into <var>buffer</var>, starting at <var>start-index</var>.
- If a low-level I/O error occurs, it returns a cell containing a token
- given by the operating system indicating what kind of error occurred.
- If <var>wait?</var> is <code>#t</code>, and <var>channel</var> is not ready to be read
- from, <var>channel</var> is registered for the VM’s event polling mechanism,
- and <code>channel-maybe-read</code> returns <code>#f</code>. Otherwise, it returns
- either the number of octets read, or an EOF object if <var>channel</var> was
- was at the end.
- </p>
- <p><code>Channel-maybe-write</code> attempts to write <var>octet-count</var> octets
- to <var>channel</var> from <var>buffer</var>, starting at <var>start-index</var>. If
- a low-level I/O error occurs, it returns a cell indicating a token
- given by the operating system indicating what kind of error occurred.
- If no such low-level error occurs, it registers <var>channel</var> for the
- VM’s event polling mechanism and returns <code>#f</code> iff zero octets were
- immediately written or the number of octets immediately written if any
- were.
- </p>
- <p><code>Channel-abort</code> aborts any pending operation registered for the
- VM’s event polling mechanism.
- </p></dd></dl>
- <dl>
- <dt id="index-open_002dchannels_002dlist">procedure: <strong>open-channels-list</strong> <em>--> channel-list</em></dt>
- <dd><p>Returns a list of all open channels in order of the <code>os-index</code>
- field.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002dstatus_002doption">enumeration: <strong>channel-status-option</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-enumeration channel-status-option
- (closed
- input
- output
- special-input
- special-output))</pre></div>
- <p>Enumeration for a channel’s status. The <code>closed</code> enumerand is
- used only after a channel has been closed. Note that this is
- <em>not</em> suitable for a bit mask; that is, one may choose exactly
- one of the enumerands, not use a bit mask of status options. For
- example, to open a file <samp>frob</samp> for input that one wishes the
- garbage collector to be silent about on closing it:
- </p>
- <div class="lisp">
- <pre class="lisp">(open-channel "frob"
- (enum channel-status-option input)
- #t)
- ⇒ #{Input-channel "frob"}</pre></div>
- </dd></dl>
- <span id="Higher_002dlevel-channel-operations"></span><h4 class="subsubsection">4.5.4.2 Higher-level channel operations</h4>
- <span id="index-channel-utilities_002c-higher_002dlevel"></span>
- <span id="index-higher_002dlevel-channel-utilities"></span>
- <span id="index-channel_002di_002fo"></span>
- <p>More convenient abstractions for operating on channels, based on
- <a href="#Higher_002dlevel-synchronization">condition variables</a>, are
- provided from the <code>channel-i/o</code> structure. They are integrated
- with Scheme48’s <a href="#Optimistic-concurrency">optimistic
- concurrency</a> facilities.
- </p>
- <p><strong>Note:</strong> Transactions on channels can <em>not</em> be atomic in the
- sense of optimistic concurrency. Since they involve communication with
- the outside world, they are irrevocable transactions, and thus an
- invalidated proposal cannot retract the transaction on the channel.
- </p>
- <dl>
- <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? --> committed?</em></dt>
- <dt id="index-channel_002dmaybe_002dcommit_002dand_002dwrite">procedure: <strong>channel-maybe-commit-and-write</strong> <em>channel buffer start-index octet-count condvar --> committed?</em></dt>
- <dd><p>These attempt to commit the current proposal. If they fail, they
- immediately return <code>#f</code>; otherwise, they proceed, and return
- <code>#t</code>. If the commit succeeded, these procedures attempt an I/O
- transaction, without blocking. <code>Channel-maybe-commit-and-read</code>
- attempts to read <var>octet-count</var> octets into <var>buffer</var>, starting
- at <var>start-index</var>, from <var>channel</var>.
- <code>Channel-maybe-commit-and-write</code> attempts to write
- <var>octet-count</var> octets from <var>buffer</var>, starting at
- <var>start-index</var>, to <var>channel</var>. <var>Condvar</var> is noted as waiting
- for the completion of the I/O transaction. When the I/O transaction
- finally completes — in the case of a read, there are octets ready to
- be read into <var>buffer</var> from <var>channel</var> or the end of the file was
- struck; in the case of a write, <var>channel</var> is ready to receive some
- octets —, <var>condvar</var> is set to the result of the I/O transaction:
- the number of octets read, an I/O error condition, or an EOF object,
- for reads; and the number of octets written or an I/O error condition,
- for writes.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002dmaybe_002dcommit_002dand_002dclose">procedure: <strong>channel-maybe-commit-and-close</strong> <em>channel closer --> committed?</em></dt>
- <dd><p>Attempts to commit the current proposal; if successful, this aborts any
- wait on <var>channel</var>, sets the result of any condvars waiting on
- <var>channel</var> to the EOF object, closes <var>channel</var> by applying
- <var>closer</var> to <var>channel</var> (in theory, <var>closer</var> could be
- anything; usually, however, it is <code>close-channel</code> from the
- <code>channels</code> structure or some wrapper around it), and returns
- <code>#t</code>. If the commit failed, <code>channel-maybe-commit-and-close</code>
- immediately returns <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-channel_002dwrite">procedure: <strong>channel-write</strong> <em>channel buffer start-index octet-count --> octet-count-written</em></dt>
- <dd><p>Atomically attempts to write <var>octet-count</var> octets to <var>channel</var>
- from <var>buffer</var>, starting at <var>start-index</var> in <var>buffer</var>. If
- no I/O transaction immediately occurs — what would result in
- <code>channel-maybe-write</code> returning <code>#f</code> —,
- <code>channel-write</code> blocks until something does happen. It returns
- the number of octets written to <var>channel</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-wait_002dfor_002dchannel">procedure: <strong>wait-for-channel</strong> <em>channel condvar --> unspecified</em></dt>
- <dd><p>Registers <var>condvar</var> so that it will be set to the result of some
- prior I/O transaction when some I/O event regarding <var>channel</var>
- occurs. (Contrary to the name, this does not actually wait or block.
- One must still use <code>maybe-commit-and-wait-for-condvar</code> on
- <var>condvar</var>; see <a href="#Higher_002dlevel-synchronization">condition
- variables</a>.) This is useful primarily in conjunction with calling
- foreign I/O routines that register channels with the VM’s event polling
- system.
- </p>
- <p><strong>Note:</strong> <code>wait-for-channel</code> must be called with interrupts
- disabled.
- </p></dd></dl>
- <hr>
- <span id="Channel-ports"></span><div class="header">
- <p>
- Previous: <a href="#Channels" accesskey="p" rel="prev">Channels</a>, Up: <a href="#I_002fO-system" accesskey="u" rel="up">I/O system</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Channel-ports-1"></span><h4 class="subsection">4.5.5 Channel ports</h4>
- <span id="index-channel_002dports"></span>
- <p>Built-in to Scheme48 are ports made atop channels. These are what are
- created by R5RS’s standard file operations. The following names are
- exported by the <code>channel-ports</code> structure.
- </p>
- <dl>
- <dt id="index-call_002dwith_002dinput_002dfile">procedure: <strong>call-with-input-file</strong> <em>filename receiver --> values</em></dt>
- <dt id="index-call_002dwith_002doutput_002dfile">procedure: <strong>call-with-output-file</strong> <em>filename receiver --> values</em></dt>
- <dt id="index-with_002dinput_002dfrom_002dfile">procedure: <strong>with-input-from-file</strong> <em>filename thunk --> values</em></dt>
- <dt id="index-with_002doutput_002dto_002dfile">procedure: <strong>with-output-to-file</strong> <em>filename thunk --> values</em></dt>
- <dt id="index-open_002dinput_002dfile">procedure: <strong>open-input-file</strong> <em>filename --> input-port</em></dt>
- <dt id="index-open_002doutput_002dfile">procedure: <strong>open-output-file</strong> <em>filename --> output-port</em></dt>
- <dd><p>Standard R5RS file I/O operations. (These are also exported by the
- <code>scheme</code> structure.) The <code>call-with-...put-file</code> operations
- open the specified type of port and apply <var>receiver</var> to it; after
- <var>receiver</var> returns normally (<i>i.e.</i> nothing is done if there is a
- throw out of <var>receiver</var>), they close the port and return the
- values that <var>receiver</var> returned. <code>With-input-from-file</code> &
- <code>with-output-to-file</code> do similarly, but, rather than applying
- <var>thunk</var> to the port, they dynamically bind the current input &
- output ports, respectively, to the newly opened ports.
- <code>Call-with-input-file</code>, <code>call-with-output-file</code>,
- <code>with-input-from-file</code>, and <code>with-output-to-file</code> return the
- values that <var>thunk</var> returns. <code>Open-input-file</code> &
- <code>open-output-file</code> just open input & output ports; users of these
- operations must close them manually.
- </p></dd></dl>
- <dl>
- <dt id="index-input_002dchannel_002d_003eport">procedure: <strong>input-channel->port</strong> <em>channel [buffer-size] --> port</em></dt>
- <dt id="index-output_002dchannel_002d_003eport">procedure: <strong>output-channel->port</strong> <em>channel [buffer-size] --> port</em></dt>
- <dd><p>These create input & output ports atop the given channels and optional
- buffer sizes. The default buffer size is 4096 bytes.
- </p></dd></dl>
- <dl>
- <dt id="index-input_002dchannel_002bcloser_002d_003eport">procedure: <strong>input-channel+closer->port</strong> <em>channel closer [buffer-size] --> port</em></dt>
- <dt id="index-output_002dchannel_002bcloser_002d_003eport">procedure: <strong>output-channel+closer->port</strong> <em>channel closer [buffer-size] --> port</em></dt>
- <dd><p>Similarly, these create input & output ports atop the given channels
- and optional buffer sizes, but they allow for extra cleanup when the
- resulting ports are closed.
- </p></dd></dl>
- <span id="index-port-to-channel-conversion"></span>
- <span id="index-accessing-file-ports_0027-channels"></span>
- <dl>
- <dt id="index-port_002d_003echannel">procedure: <strong>port->channel</strong> <em>port --> channel or <code>#f</code></em></dt>
- <dd><p>If <var>port</var> is a port created by the system’s channel ports facility,
- <code>port->channel</code> returns the channel it was created atop; otherwise
- <code>port->channel</code> returns <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-force_002dchannel_002doutput_002dports_0021">procedure: <strong>force-channel-output-ports!</strong> <em>--> unspecified</em></dt>
- <dd><p>This attempts to force as much output as possible from all of the ports
- based on channels. This is used by Scheme48’s POSIX libraries before
- forking the current process.
- </p></dd></dl>
- <hr>
- <span id="Reader-_0026-writer"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Reader-_0026-writer-1"></span><h3 class="section">4.6 Reader & writer</h3>
- <p>Scheme48 has simple S-expression reader & writer libraries, with some
- facilities beyond R5RS’s <code>read</code> & <code>write</code> procedures.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Reader" accesskey="1">Reader</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Writer" accesskey="2">Writer</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Reader"></span><div class="header">
- <p>
- Next: <a href="#Writer" accesskey="n" rel="next">Writer</a>, Up: <a href="#Reader-_0026-writer" accesskey="u" rel="up">Reader & writer</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Reader-1"></span><h4 class="subsection">4.6.1 Reader</h4>
- <span id="index-reading"></span>
- <p>Scheme48’s reader facility is exported by the <code>reading</code>
- structure. The <code>read</code> binding thereby exported is identical to
- that of the <code>scheme</code> structure, which is the binding that R5RS
- specifies under the name <code>read</code>.
- </p>
- <dl>
- <dt id="index-read">procedure: <strong>read</strong> <em>[port] --> readable-value</em></dt>
- <dd><p>Reads a single S-expression from <var>port</var>, whose default value is the
- current input port. If the end of the stream is encountered before the
- beginning of an S-expression, <code>read</code> will return an EOF object.
- It will signal a read error if text read from <var>port</var> does not
- constitute a complete, well-formed S-expression.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002dsharp_002dmacro">procedure: <strong>define-sharp-macro</strong> <em>char proc --> unspecified</em></dt>
- <dd><p>Defines a sharp/pound/hash/octothorpe (<code>#</code>) reader macro. The
- next time the reader is invoked, if it encounters an octothorpe/sharp
- followed by <var>char</var>, it applies <var>proc</var> to <var>char</var> and the
- input port being read from. <var>Char</var> is <em>not</em> consumed in the
- input port. If <var>char</var> is alphabetic, it should be lowercase;
- otherwise the reader will not recognize it, since the reader converts
- the character following octothorpes to lowercase.
- </p></dd></dl>
- <dl>
- <dt id="index-reading_002derror">procedure: <strong>reading-error</strong> <em>port message irritant … --> unspecified</em></dt>
- <dd><p>Signals an error while reading, for custom sharp macros. It is not
- likely that calls to <code>reading-error</code> will return.
- </p></dd></dl>
- <dl>
- <dt id="index-gobble_002dline">procedure: <strong>gobble-line</strong> <em>port --> unspecified</em></dt>
- <dd><p>Reads until a newline from <var>port</var>. The newline character sequence
- is consumed.
- </p></dd></dl>
- <hr>
- <span id="Writer"></span><div class="header">
- <p>
- Previous: <a href="#Reader" accesskey="p" rel="prev">Reader</a>, Up: <a href="#Reader-_0026-writer" accesskey="u" rel="up">Reader & writer</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Writer-1"></span><h4 class="subsection">4.6.2 Writer</h4>
- <span id="index-writing"></span>
- <p>Scheme48’s <code>writing</code> structure exports its writer facility. The
- <code>write</code> and <code>display</code> bindings from it are identical to those
- from the <code>scheme</code> structure, which are the same bindings that R5RS
- specifies.
- </p>
- <dl>
- <dt id="index-write">procedure: <strong>write</strong> <em>object [port] --> unspecified</em></dt>
- <dd><p>Writes <var>object</var> to <var>port</var>, which defaults to the current output
- port, in a machine-readable manner. Strings are written with
- double- quotes; characters are prefixed by <code>#\</code>. Any object that
- is unreadable — anything that does not have a written representation
- as an S-expression — is written based on its <em>disclosed</em>
- representation. Such unreadable objects are converted to a disclosed
- representation by the <code>disclose</code> generic procedure (see below).
- </p></dd></dl>
- <dl>
- <dt id="index-display">procedure: <strong>display</strong> <em>object [port] --> unspecified</em></dt>
- <dd><p>Displays <var>object</var> to <var>port</var>, which defaults to the value of the
- current output port, in a more human-readable manner. Strings are
- written without surrounding double-quotes; characters are written as
- themselves with no prefix.
- </p></dd></dl>
- <span id="index-customized-writer"></span>
- <span id="index-writer_002c-customized"></span>
- <dl>
- <dt id="index-recurring_002dwrite">procedure: <strong>recurring-write</strong> <em>object port recur --> unspecified</em></dt>
- <dd><p>Writes <var>object</var> to <var>port</var>. Every time this recurs upon a new
- object, rather than calling itself or its own looping procedure, it
- calls <var>recur</var>. This allows customized printing routines that still
- take advantage of the existence of Scheme48’s writer. For example,
- <code>display</code> simply calls <code>recurring-write</code> with a recurring
- procedure that prints strings and characters specially and lets
- <code>recurring-write</code> handle everything else.
- </p></dd></dl>
- <dl>
- <dt id="index-display_002dtype_002dname">procedure: <strong>display-type-name</strong> <em>name port --> unspecified</em></dt>
- <dd><p>If <var>name</var> is a symbol with an alphabetic initial character, this
- writes <var>name</var> to <var>port</var> with the first character uppercased and
- the remaining character lowercased; otherwise, <code>display-type-name</code>
- simply writes <var>name</var> to <var>port</var> with <code>display</code>.
- </p>
- <div class="lisp">
- <pre class="lisp">(display-type-name 'foo)
- -| Foo
- (display-type-name (string->symbol "42foo"))
- -| 42foo
- (display-type-name (cons "foo" "bar"))
- -| (foo . bar)
- (display-type-name (string->symbol "fOo-BaR"))
- -| Foo-bar</pre></div>
- <p>This is used when printing disclosed representations (see below).
- </p></dd></dl>
- <span id="Object-disclosure"></span><h4 class="subsubsection">4.6.2.1 Object disclosure</h4>
- <span id="index-customized-writer-1"></span>
- <span id="index-writer_002c-customized-1"></span>
- <span id="index-methods-1"></span>
- <p>The <a href="#Generic-dispatch-system"><code>methods</code> structure</a>
- exports the generic procedure <code>disclose</code> and its method table
- <code>&disclose</code>. When <code>recurring-write</code> encounters an object it
- is unable to write in a rereadable manner, it applies <code>disclose</code>
- to the unreadable object to acquire a <em>disclosed representation.</em>
- (If <code>disclose</code> returns <code>#f</code>, <i>i.e.</i> the object has no
- disclosed representation, the writer will write <code>#{Random
- object}</code>.) After converting a value to its disclosed representation,
- <i>e.g.</i> a list consisting of the symbol <code>foo</code>, the symbol
- <code>bar</code>, a byte vector, and a pair <code>(1 . 2)</code>, the writer will
- write <code>#{Foo #{Byte-vector} bar (1 . 2)}</code>. That is: contents
- of the list are surrounded by <code>#{</code> and <code>}</code>, the first
- element of the list (the ‘type name’) is written with
- <code>display-type-name</code>, and then the remaining elements of the list
- are recursively printed out with the <var>recur</var> argument.
- </p>
- <p>Typically, when a programmer creates an abstract data type by using
- Scheme48’s record facility, he will not add methods to <code>&disclose</code>
- but instead define the record type’s discloser with the
- <code>define-record-discloser</code> procedure; see <a href="#Records">Records</a>.
- </p>
- <p>Example:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type pare rtd/pare
- (kons a d)
- pare?
- (a kar set-kar!)
- (d kdr set-kdr!))
- (define-record-discloser rtd/pare
- (lambda (pare)
- `(pare ,(kar pare) *dot* ,(kdr pare))))
- (write (kons (kons 5 3) (kons 'a 'b)))
- -| #{Pare #{Pare 5 *dot* 3} *dot* #{Pare a *dot* b}}</pre></div>
- <hr>
- <span id="Records"></span><div class="header">
- <p>
- 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 & writer</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Records-1"></span><h3 class="section">4.7 Records</h3>
- <span id="index-abstract-data-types"></span>
- <span id="index-opaque-data-types"></span>
- <p>Scheme48 provides several different levels of a record facility. Most
- programmers will probably not care about the two lower levels; the
- syntactic record type definers are sufficient for abstract data types.
- </p>
- <span id="index-defining-record-types"></span>
- <span id="index-record-types_002c-defining"></span>
- <span id="index-define_002drecord_002dtypes"></span>
- <span id="index-defrecord"></span>
- <span id="index-srfi_002d9"></span>
- <p>At the highest level, there are two different record type definition
- macros. Richard Kelsey’s is exported from the <code>defrecord</code>
- structure; Jonathan Rees’s is exported from <code>define-record-types</code>.
- They both export a <code>define-record-type</code> macro and the same
- <code>define-record-discloser</code> procedure; however, the macros are
- dramatically different. Scheme48 also provides [SRFI 9], which is
- essentially Jonathan Rees’s record type definition macro with a slight
- syntactic difference, in the <code>srfi-9</code> structure. Note, however,
- that <code>srfi-9</code> does not export <code>define-record-discloser</code>. The
- difference between Jonathan Rees’s and Richard Kelsey’s record type
- definition macros is merely syntactic convenience; Jonathan Rees’s more
- conveniently allows for arbitrary naming of the generated variables,
- whereas Richard Kelsey’s is more convenient if the naming scheme varies
- little.
- </p>
- <span id="Jonathan-Rees_0027s-define_002drecord_002dtype-macro"></span><h4 class="subsection">4.7.1 Jonathan Rees’s <code>define-record-type</code> macro</h4>
- <dl>
- <dt id="index-define_002drecord_002dtype">syntax: <strong>define-record-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-record-type <var>record-type-name</var> <var>record-type-variable</var>
- (<var>constructor</var> <var>constructor-argument</var> …)
- [<var>predicate</var>]
- (<var>field-tag</var> <var>field-accessor</var> [<var>field-modifier</var>])
- …)</pre></div>
- <p>This defines <var>record-type-variable</var> to be a record type descriptor.
- <var>Constructor</var> is defined to be a procedure that accepts the listed
- field arguments and creates a record of the newly defined type with
- those fields initialized to the corresponding arguments.
- <var>Predicate</var>, if present, is defined to be the disjoint (as long as
- abstraction is not violated by the lower-level record interface) type
- predicate for the new record type. Each <var>field-accessor</var> is
- defined to be a unary procedure that accepts a record type and returns
- the value of the field named by the corresponding <var>field-tag</var>.
- Each <var>field-modifier</var>, if present, is defined to be a binary
- procedure that accepts a record of the new type and a value, which it
- assigns the field named by the corresponding <var>field-tag</var> to. Every
- <var>constructor-argument</var> must have a corresponding <var>field-tag</var>,
- though <var>field-tag</var>s that are not used as arguments to the record
- type’s constructor are simply uninitialized when created. They should
- have modifiers: otherwise they will never be initialized.
- </p>
- <p>It is worth noting that Jonathan Rees’s <code>define-record-type</code> macro
- does not introduce identifiers that were not in the original macro’s
- input form.
- </p>
- <p>For example:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type pare rtd/pare
- (kons a d)
- pare?
- (a kar)
- (d kdr set-kdr!))
- (kar (kons 5 3))
- ⇒ 5
- (let ((p (kons 'a 'c)))
- (set-kdr! p 'b)
- (kdr p))
- ⇒ b
- (pare? (kons 1 2))
- ⇒ #t
- (pare? (cons 1 2))
- ⇒ #f</pre></div>
- </dd></dl>
- <p>There is also a variant of Jonathan Rees’s <code>define-record-type</code>
- macro for defining record types with fields whose accessors and
- modifiers respect <a href="#Optimistic-concurrency">optimistic
- concurrency</a> by logging in the current proposal.
- </p>
- <span id="Richard-Kelsey_0027s-define_002drecord_002dtype-macro"></span><h4 class="subsection">4.7.2 Richard Kelsey’s <code>define-record-type</code> macro</h4>
- <dl>
- <dt id="index-define_002drecord_002dtype-1">syntax: <strong>define-record-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-record-type <var>type-name</var>
- (<var>argument-field-specifier</var> …)
- (<var>nonargument-field-specifier</var> …))
- <var>argument-field-specifier</var> -->
- <var>field-tag</var> Immutable field
- | (<var>field-tag</var>) Mutable field
- <var>nonargument-field-specifier</var> -->
- <var>field-tag</var> Uninitialized field
- | (<var>field-tag</var> <var>exp</var>) Initialized with <var>exp</var>'s value</pre></div>
- <p>This defines <code>type/<var>type-name</var></code> to be a record type descriptor
- for the newly defined record type, <code><var>type-name</var>-maker</code> to be
- a constructor for the new record type that accepts arguments for every
- field in the argument field specifier list, <code><var>type-name</var>?</code> to
- be the disjoint type predicate for the new record type, accessors for
- each field tag <var>field-tag</var> by constructing an identifier
- <code><var>type-name</var>-<var>field-tag</var></code>, and modifiers for each argument
- field tag that was specified to be mutable as well as each nonargument
- field tag. The name of the modifier for a field tag <var>field-tag</var> is
- constructed to be
- <code>set-<var>type-name</var>-<var>field-tag</var>!</code>.
- </p>
- <p>Note that Richard Kelsey’s <code>define-record-type</code> macro <em>does</em>
- concatenate & introduce new identifiers, unlike Jonathan Rees’s.
- </p>
- <p>For example, a use of Richard Kelsey’s <code>define-record-type</code> macro
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type pare
- (kar
- (kdr))
- (frob
- (mumble 5)))</pre></div>
- <p>is equivalent to the following use of Jonathan Rees’s macro
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type pare type/pare
- (%pare-maker kar kdr mumble)
- pare?
- (kar pare-kar)
- (kdr pare-kdr set-pare-kdr!)
- (frob pare-frob set-pare-frob!)
- (mumble pare-mumble set-pare-mumble!))
- (define (pare-maker kar kdr)
- (%pare-maker kar kdr 5))</pre></div>
- </dd></dl>
- <span id="Record-types"></span><h4 class="subsection">4.7.3 Record types</h4>
- <span id="index-programmatic-record-types"></span>
- <span id="index-record-types_002c-programmatic"></span>
- <span id="index-record_002dtypes"></span>
- <p>Along with two general record type definition facilities, there are
- operations directly on the record type descriptors themselves, exported
- by the <code>record-types</code> structure. (Record type descriptors are
- actually records themselves.)
- </p>
- <dl>
- <dt id="index-make_002drecord_002dtype">procedure: <strong>make-record-type</strong> <em>name field-tags --> record-type-descriptor</em></dt>
- <dt id="index-record_002dtype_003f">procedure: <strong>record-type?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-record-type</code> makes a record type descriptor with the given
- name and field tags. <code>Record-type?</code> is the disjoint type
- predicate for record types.
- </p></dd></dl>
- <dl>
- <dt id="index-record_002dtype_002dname">procedure: <strong>record-type-name</strong> <em>rtype-descriptor --> symbol</em></dt>
- <dt id="index-record_002dtype_002dfield_002dnames">procedure: <strong>record-type-field-names</strong> <em>rtype-descriptor --> symbol-list</em></dt>
- <dd><p>Accessors for the two record type descriptor fields.
- </p></dd></dl>
- <dl>
- <dt id="index-record_002dconstructor">procedure: <strong>record-constructor</strong> <em>rtype-descriptor argument-field-tags --> constructor-procedure</em></dt>
- <dt id="index-record_002dpredicate">procedure: <strong>record-predicate</strong> <em>rtype-descriptor --> predicate-procedure</em></dt>
- <dt id="index-record_002daccessor">procedure: <strong>record-accessor</strong> <em>rtype-descriptor field-tag --> accessor-procedure</em></dt>
- <dt id="index-record_002dmodifier">procedure: <strong>record-modifier</strong> <em>rtype-descriptor field-tag --> modifier-procedure</em></dt>
- <dd><p>Constructors for the various procedures relating to record types.
- <code>Record-constructor</code> returns a procedure that accepts arguments
- for each field in <var>argument-field-tags</var> and constructs a record
- whose record type descriptor is <var>rtype-descriptor</var>, initialized
- with its arguments. <code>Record-predicate</code> returns a disjoint type
- predicate for records whose record type descriptor is
- <var>rtype-descriptor</var>. <code>Record-accessor</code> and
- <code>record-modifier</code> return accessors and modifiers for records
- whose record type descriptor is <var>rtype-descriptor</var> for the given
- fields.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002drecord_002ddiscloser">procedure: <strong>define-record-discloser</strong> <em>rtype-descriptor discloser --> unspecific</em></dt>
- <dd><p>Defines the method by which records of type <var>rtype-descriptor</var> are
- disclosed (see <a href="#Writer">Writer</a>). This is also exported by
- <code>define-record-types</code> and <code>defrecord</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002drecord_002dresumer">procedure: <strong>define-record-resumer</strong> <em>rtype-descriptor resumer --> unspecified</em></dt>
- <dd><p>Sets <var>rtype-descriptor</var>’s record resumer to be <var>resumer</var>. If
- <var>resumer</var> is <code>#t</code> (the default), records of this type require
- no particular reinitialization when found in <a href="#Suspending-and-resuming-heap-images">dumped heap images</a>; if <var>resumer</var> is
- <code>#f</code>, records of the type <var>rtype-descriptor</var> may not be
- dumped in heap images; finally, if it is a procedure, and the heap
- image is resumed with the <a href="#Suspending-and-resuming-heap-images">usual image resumer</a>, it is applied to each record whose
- record type descriptor is <var>rtype-descriptor</var> after the run-time
- system has been initialized and before the argument to
- <code>usual-resumer</code> is called.
- </p></dd></dl>
- <span id="index-records_002dinternal"></span>
- <p>The <code>records-internal</code> structure also exports these:
- </p>
- <dl>
- <dt id="index-_003arecord_002dtype">record type: <strong>:record-type</strong></dt>
- <dd><p>The record type of record types.
- </p></dd></dl>
- <dl>
- <dt id="index-disclose_002drecord">procedure: <strong>disclose-record</strong> <em>record --> disclosed</em></dt>
- <dd><p>This applies <var>record</var>’s record type descriptor’s discloser procedure
- to <var>record</var> to acquire a disclosed representation; see <a href="#Writer">Writer</a>.
- </p></dd></dl>
- <p>For expository purposes, the record type record type might have been
- defined like so with Jonathan Rees’s <code>define-record-type</code> macro:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type record-type :record-type
- (make-record-type name field-names)
- record-type?
- (name record-type-name)
- (field-names record-type-field-names))</pre></div>
- <p>or like so with Richard Kelsey’s <code>define-record-type</code> macro:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type record-type
- (name field-names)
- ())</pre></div>
- <p>Of course, in reality, these definitions would have severe problems
- with circularity of definition.
- </p>
- <span id="Low_002dlevel-record-manipulation"></span><h4 class="subsection">4.7.4 Low-level record manipulation</h4>
- <span id="index-records_002c-low_002dlevel-access-to"></span>
- <span id="index-low_002dlevel-access-to-records"></span>
- <span id="index-records"></span>
- <p>Internally, records are represented very similarly to vectors, and as
- such have low-level operations on them similar to vectors, exported by
- the <code>records</code> structure. Records usually reserve the slot at
- index 0 for their record type descriptor.
- </p>
- <p><strong>Warning:</strong> The procedures described here can be very easily
- misused to horribly break abstractions. Use them very carefully, only
- in very limited & extreme circumstances!
- </p>
- <dl>
- <dt id="index-make_002drecord">procedure: <strong>make-record</strong> <em>length init --> record</em></dt>
- <dt id="index-record">procedure: <strong>record</strong> <em>elt … --> record</em></dt>
- <dt id="index-record_003f">procedure: <strong>record?</strong> <em>object --> boolean</em></dt>
- <dt id="index-record_002dlength">procedure: <strong>record-length</strong> <em>record --> integer</em></dt>
- <dt id="index-record_002dref">procedure: <strong>record-ref</strong> <em>record index --> value</em></dt>
- <dt id="index-record_002dset_0021">procedure: <strong>record-set!</strong> <em>record index object --> unspecified</em></dt>
- <dd><p>Exact analogues of similarly named vector operation procedures.
- </p></dd></dl>
- <dl>
- <dt id="index-record_002dtype">procedure: <strong>record-type</strong> <em>record --> value</em></dt>
- <dd><p>This returns the record type descriptor of <var>record</var>, <i>i.e.</i> the
- value of the slot at index 0 in <var>record</var>.
- </p></dd></dl>
- <hr>
- <span id="Suspending-and-resuming-heap-images"></span><div class="header">
- <p>
- Previous: <a href="#Records" accesskey="p" rel="prev">Records</a>, Up: <a href="#System-facilities" accesskey="u" rel="up">System facilities</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Suspending-and-resuming-heap-images-1"></span><h3 class="section">4.8 Suspending and resuming heap images</h3>
- <span id="index-dumping-heap-images-1"></span>
- <span id="index-heap-image-dumping-1"></span>
- <span id="index-image-dumping-1"></span>
- <span id="index-writing-heap-images-1"></span>
- <span id="index-heap-image-writing-1"></span>
- <span id="index-image-writing-1"></span>
- <p>Scheme48’s virtual machine operates by loading a heap image into memory
- and calling the initialization procedure specified in the image dump.
- Heap images can be produced in several different ways: programmatically
- with <code>write-image</code>, using the <a href="#Image_002dbuilding-commands">command processor’s facilities</a>, or with the static linker. This
- section describes only <code>write-image</code> and the related system
- resumption & initialization.
- </p>
- <p>Heap image dumps begin with a sequence of characters terminated by an
- ASCII form-feed/page character (codepoint 12). This content may be
- anything; for example, it might be a Unix <code>#!</code> line that invokes
- <code>scheme48vm</code> on the file, or it might be a silly message to
- whomever reads the top of the heap image dump file. (The command
- processor’s <code>,dump</code> & <code>,build</code> commands
- (see <a href="#Image_002dbuilding-commands">Image-building commands</a>) write a blank line at the top; the
- static linker
- puts a message stating that the
- image was built by the static linker.)
- </p>
- <span id="index-write_002dimages"></span>
- <p><code>Write-image</code> is exported by the <code>write-images</code> structure.
- </p>
- <dl>
- <dt id="index-write_002dimage">procedure: <strong>write-image</strong> <em>filename startup-proc message --> unspecified</em></dt>
- <dd><p>Writes a heap image whose startup procedure is <var>startup-proc</var> and
- that consists of every object accessible in some way from
- <var>startup-proc</var>. <var>Message</var> is put at the start of the heap
- image file before the ASCII form-feed/page character. When the image
- is resumed, <var>startup-proc</var> is passed a vector of program arguments,
- an input channel for standard input, an output channel for standard
- output, an output channel for standard error, and a vector of records
- to be resumed. This is typically simplified by <code>usual-resumer</code>
- (see below). On Unix, <var>startup-proc</var> must return an integer exit
- code; otherwise the program will crash and burn with a very low-level
- VM error message when <var>startup-proc</var> returns.
- </p></dd></dl>
- <span id="System-initialization"></span><h4 class="subsection">4.8.1 System initialization</h4>
- <span id="index-usual-resumer"></span>
- <span id="index-heap-image-resumption-1"></span>
- <span id="index-resuming-heap-images-1"></span>
- <span id="index-usual_002dresumer-1"></span>
- <p>When suspended heap images are resumed by the VM, the startup procedure
- specified in the heap image is applied to five arguments: a vector of
- command-line arguments (passed after the <code>-a</code> argument to the VM),
- an input channel for standard input, an output channel for standard
- output, an output channel for standard error, and a vector of records
- to be resumed. The startup procedure is responsible for performing any
- initialization necessary — including initializing the Scheme48
- run-time system — as well as simply running the program. Typically,
- this procedure is not written manually: resumers are ordinarily created
- using the <em>usual resumer</em> abstraction, exported from the structure
- <code>usual-resumer</code>.
- </p>
- <dl>
- <dt id="index-usual_002dresumer">procedure: <strong>usual-resumer</strong> <em>startup-proc --> resumer-proc</em></dt>
- <dd><p>This returns a procedure that is suitable as a heap image resumer
- procedure. When the heap image is resumed, it initializes the run-time
- system — it resumes all the records, initializes the thread system,
- the dynamic state, the interrupt system, I/O system, <i>&c.</i> — and
- applies <var>startup-proc</var> to a list (not a vector) of the command-line
- arguments.
- </p></dd></dl>
- <p>Some records may contain machine-, OS-, or other session-specific data.
- When suspended in heap images and later resumed, this data may be
- invalidated, and it may be necessary to reinitialize this data upon
- resumption of suspended heap images. For this reason Scheme48 provides
- <em>record resumers</em>; see <code>define-record-resumer</code> from the
- <a href="#Records"><code>record-types</code> structure</a>.
- </p>
- <span id="Manual-system-initialization"></span><h4 class="subsection">4.8.2 Manual system initialization</h4>
- <p>If a programmer chooses not to use <code>usual-resumer</code> — which is
- <em>not</em> a very common thing to do —, he is responsible for manual
- initialization of the run-time system, including the I/O system,
- resumption of records, the thread system and the root thread scheduler,
- the interrupt system, and the condition system.
- </p>
- <p><strong>Warning:</strong> Manual initialization of the run-time system is a
- <em>very</em> delicate operation. Although one can potentially vastly
- decrease the size of dumped heap images by doing it manually,
- <a id="DOCF19" href="#FOOT19"><sup>19</sup></a> it is very error-prone and
- difficult to do without exercising great care, which is why the usual
- resumer facility exists. Unless you <em><strong>really</strong></em> know what
- you are doing, you should just use the usual resumer.
- </p>
- <p>At the present, documentation of manual system initialization is
- absent. However, if the reader knows enough about what he is doing
- that he desires to manually initialize the run-time system, he is
- probably sufficiently familiar with it already to be able to find the
- necessary information directly from Scheme48’s source code and module
- descriptions.
- </p><hr>
- <span id="Multithreading"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Multithreading-1"></span><h2 class="chapter">5 Multithreading</h2>
- <p>This chapter describes Scheme48’s fully preëmptive and sophisticated
- user-level thread system. Scheme48 supports customized and nested
- thread schedulers, user-designed synchronization mechanisms, optimistic
- concurrency, useful thread synchronization libraries, a high-level
- event algebra based on Reppy’s Concurrent ML [Reppy 99], and common
- pessimistic concurrency/mutual-exclusion-based thread synchronization
- facilities.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Basic-thread-operations" accesskey="1">Basic thread operations</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Optimistic-concurrency" accesskey="2">Optimistic concurrency</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Higher_002dlevel-synchronization" accesskey="3">Higher-level synchronization</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Concurrent-ML" accesskey="4">Concurrent ML</a></td><td> </td><td align="left" valign="top">High-level event synchronization
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pessimistic-concurrency" accesskey="5">Pessimistic concurrency</a></td><td> </td><td align="left" valign="top">Mutual exclusion/locking
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Custom-thread-synchronization" accesskey="6">Custom thread synchronization</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="Basic-thread-operations"></span><div class="header">
- <p>
- Next: <a href="#Optimistic-concurrency" accesskey="n" rel="next">Optimistic concurrency</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Basic-thread-operations-1"></span><h3 class="section">5.1 Basic thread operations</h3>
- <span id="index-threads"></span>
- <p>This section describes the <code>threads</code> structure.
- </p>
- <span id="index-spawning-threads"></span>
- <span id="index-threads_002c-spawning"></span>
- <dl>
- <dt id="index-spawn">procedure: <strong>spawn</strong> <em>thunk [name] --> thread</em></dt>
- <dd><p><code>Spawn</code> constructs a new thread and instructs the current thread
- scheduler to commence running the new thread. <var>Name</var>, if present,
- is used for debugging. The new thread has a fresh
- <a href="#Fluid_002fdynamic-bindings">dynamic environment</a>.
- </p></dd></dl>
- <p>There are several miscellaneous facilities for thread operations.
- </p>
- <span id="index-yielding-threads"></span>
- <span id="index-thread-yielding"></span>
- <span id="index-sleeping-threads"></span>
- <span id="index-thread-sleeping"></span>
- <dl>
- <dt id="index-relinquish_002dtimeslice">procedure: <strong>relinquish-timeslice</strong> <em>--> unspecified</em></dt>
- <dt id="index-sleep">procedure: <strong>sleep</strong> <em>count --> unspecified</em></dt>
- <dd><p><code>Relinquish-timeslice</code> relinquishes the remaining quantum that the
- current thread has to run; this allows the current scheduler run the
- next thread immediately. <code>Sleep</code> suspends the current thread for
- <var>count</var> milliseconds.
- </p></dd></dl>
- <span id="index-thread-termination"></span>
- <span id="index-terminating-threads"></span>
- <dl>
- <dt id="index-terminate_002dcurrent_002dthread">procedure: <strong>terminate-current-thread</strong> <em>--> (does not return)</em></dt>
- <dd><p>Terminates the current thread, running all <code>dynamic-wind</code> exit
- points. <code>Terminate-current-thread</code> obviously does not return.
- </p></dd></dl>
- <span id="index-thread-descriptors"></span>
- <p>Threads may be represented and manipulated in first-class thread
- descriptor objects.
- </p>
- <dl>
- <dt id="index-current_002dthread">procedure: <strong>current-thread</strong> <em>--> thread</em></dt>
- <dt id="index-thread_003f">procedure: <strong>thread?</strong> <em>object --> boolean</em></dt>
- <dt id="index-thread_002dname">procedure: <strong>thread-name</strong> <em>thread --> value</em></dt>
- <dt id="index-thread_002duid">procedure: <strong>thread-uid</strong> <em>thread --> unique-integer-id</em></dt>
- <dd><p><code>Current-thread</code> returns the thread descriptor for the currently
- running thread. <code>Thread?</code> is the thread descriptor disjoint type
- predicate. <code>Thread-name</code> returns the name that was passed to
- <code>spawn</code> when spawning <var>thread</var>, or <code>#f</code> if no name was
- passed. <code>Thread-uid</code> returns a thread descriptor’s unique integer
- identifier, assigned by the thread system.
- </p></dd></dl>
- <hr>
- <span id="Optimistic-concurrency"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Optimistic-concurrency-1"></span><h3 class="section">5.2 Optimistic concurrency</h3>
- <p>Scheme48’s fundamental thread synchronization mechanism is based on a
- device often used in high-performance database systems: optimistic
- concurrency. The basic principle of optimistic concurrency is that,
- rather than mutually excluding other threads from data involved in one
- thread’s transaction, a thread keeps a log of its transaction, not
- actually modifying the data involved, only touching the log. When the
- thread is ready to commit its changes, it checks that all of the reads
- from memory retained their integrity — that is, all of the memory
- that was read from during the transaction has remained the same, and is
- consistent with what is there at the time of the commit. If, and only
- if, all of the reads remained valid, the logged writes are committed;
- otherwise, the transaction has been invalidated. While a thread is
- transacting, any number of other threads may be also transacting on the
- same resource. All that matters is that the values each transaction
- read are consistent with every write that was committed during the
- transaction. This synchronization mechanism allows for wait-free,
- lockless systems that easily avoid confusing problems involving careful
- sequences of readily deadlock-prone mutual exclusion.
- </p>
- <span id="index-proposals"></span>
- <span id="index-logs"></span>
- <span id="index-transaction-logs"></span>
- <span id="index-optimistic-concurrency-proposals"></span>
- <span id="index-optimistic-concurrency-logs"></span>
- <p>In the Scheme48 system, every thread has its own log of transactions,
- called a <em>proposal</em>. There are variants of all data accessors &
- modifiers that operate on the current thread’s proposal, rather than
- actual memory: after the initial read of a certain part of memory —
- which <em>does</em> perform a real read —, the value from that location
- in memory is cached in the proposal, and thenceforth reads from that
- location in memory will actually read the cache; modifications touch
- only the proposal, until the proposal is committed.
- </p>
- <span id="index-proposals-2"></span>
- <p>All of the names described in this section are exported by the
- <code>proposals</code> structure.
- </p>
- <span id="High_002dlevel-optimistic-concurrency"></span><h4 class="subsection">5.2.1 High-level optimistic concurrency</h4>
- <span id="index-atomic-regions"></span>
- <p>There are several high-level operations that abstract the manipulation
- of the current thread’s proposal.
- </p>
- <dl>
- <dt id="index-call_002densuring_002datomicity">procedure: <strong>call-ensuring-atomicity</strong> <em>thunk --> values</em></dt>
- <dt id="index-call_002densuring_002datomicity_0021">procedure: <strong>call-ensuring-atomicity!</strong> <em>thunk --> unspecified</em></dt>
- <dd><p>These ensure that the operation of <var>thunk</var> is atomic. If there is
- already a current proposal in place, these are equivalent to calling
- <var>thunk</var>. If there is not a current proposal in place, these
- install a new proposal, call <var>thunk</var>, and attempt to commit the new
- proposal. If the commit succeeded, these return. If it failed, these
- retry with a new proposal until they do succeed.
- <code>Call-ensuring-atomicity</code> returns the values that <var>thunk</var>
- returned when the commit succeeded; <code>call-ensuring-atomicity!</code>
- returns zero values — it is intended for when <var>thunk</var> is used for
- its effects only.
- </p></dd></dl>
- <dl>
- <dt id="index-call_002datomically">procedure: <strong>call-atomically</strong> <em>thunk --> values</em></dt>
- <dt id="index-call_002datomically_0021">procedure: <strong>call-atomically!</strong> <em>thunk --> unspecified</em></dt>
- <dd><p>These are like <var>call-ensuring-atomicity</var> and
- <var>call-ensuring-atomicity!</var>, respectively, except that they always
- install a new proposal (saving the old one and restoring it when they
- are done).
- </p></dd></dl>
- <dl>
- <dt id="index-ensure_002datomicity">syntax: <strong>ensure-atomicity</strong> <em>body --> values</em></dt>
- <dt id="index-ensure_002datomicity_0021">syntax: <strong>ensure-atomicity!</strong> <em>body --> unspecified</em></dt>
- <dt id="index-atomically">syntax: <strong>atomically</strong> <em>body --> values</em></dt>
- <dt id="index-atomically_0021">syntax: <strong>atomically!</strong> <em>body --> unspecified</em></dt>
- <dd><p>These are syntactic sugar over <code>call-ensuring-atomicity</code>,
- <code>call-ensuring-atomicity!</code>, <code>call-atomically</code>, and
- <code>call-atomically!</code>, respectively.
- </p></dd></dl>
- <p>Use these high-level optimistic concurrency operations to make the
- body atomic. <code>Call-ensuring-atomicity</code> <i>&c.</i> simply ensure that
- the transaction will be atomic, and may ‘fuse’ it with an enclosing
- atomic transaction if there already is one, <i>i.e.</i> use the proposal for
- that transaction already in place, creating one only if there is not
- already one. <code>Call-atomically</code> <i>&c.</i> are for what might be
- called ‘subatomic’ transactions, which cannot be fused with other
- atomic transactions, and for which there is always created a new
- proposal.
- </p>
- <p>However, code within <code>call-ensuring-atomicity</code> <i>&c.</i> or
- <code>call-atomically</code> <i>&c.</i> should <em>not</em> explicitly commit the
- current proposal; those operations above <em>automatically</em> commit
- the current proposal when the atomic transaction is completed. (In
- the case of <code>call-atomically</code> <i>&c.</i>, this is when the procedure
- passed returns; in the case of <code>call-ensuring-atomicity</code> <i>&c.</i>,
- this is when the outermost enclosing atomic transaction completes, or
- the same as <code>call-atomically</code> if there was no enclosing atomic
- transaction.) To explicitly commit the current proposal — for
- example, to perform some particular action if the commit fails rather
- than just to repeatedly retry the transaction, or to use operations
- from the <a href="#Custom-thread-synchronization">customized thread
- synchronization</a> facilities that commit the current proposal after
- their regular function, or the operations on <a href="#Higher_002dlevel-synchronization">condition variables</a> that operate on the condition
- variable and then commit the current proposal —, one must use the
- <code>with-new-proposal</code> syntax as described below, not these
- operations.
- </p>
- <span id="Logging-variants-of-Scheme-procedures"></span><h4 class="subsection">5.2.2 Logging variants of Scheme procedures</h4>
- <span id="index-logging-operations-1"></span>
- <span id="index-optimistic-concurrency-logging-operations-1"></span>
- <dl>
- <dt id="index-provisional_002dcar">procedure: <strong>provisional-car</strong> <em>pair --> value</em></dt>
- <dt id="index-provisional_002dcdr">procedure: <strong>provisional-cdr</strong> <em>pair --> value</em></dt>
- <dt id="index-provisional_002dset_002dcar_0021">procedure: <strong>provisional-set-car!</strong> <em>pair value --> unspecified</em></dt>
- <dt id="index-provisional_002dset_002dcdr_0021">procedure: <strong>provisional-set-cdr!</strong> <em>pair value --> unspecified</em></dt>
- <dt id="index-provisional_002dcell_002dref">procedure: <strong>provisional-cell-ref</strong> <em>cell --> value</em></dt>
- <dt id="index-provisional_002dcell_002dset_0021">procedure: <strong>provisional-cell-set!</strong> <em>cell value --> unspecified</em></dt>
- <dt id="index-provisional_002dvector_002dref">procedure: <strong>provisional-vector-ref</strong> <em>vector index --> value</em></dt>
- <dt id="index-provisional_002dvector_002dset_0021">procedure: <strong>provisional-vector-set!</strong> <em>vector index value --> unspecified</em></dt>
- <dt id="index-provisional_002dstring_002dref">procedure: <strong>provisional-string-ref</strong> <em>string index --> char</em></dt>
- <dt id="index-provisional_002dstring_002dset_0021">procedure: <strong>provisional-string-set!</strong> <em>string index value --> unspecified</em></dt>
- <dt id="index-provisional_002dbyte_002dvector_002dref">procedure: <strong>provisional-byte-vector-ref</strong> <em>byte-vector index --> char</em></dt>
- <dt id="index-provisional_002dbyte_002dvector_002dset_0021">procedure: <strong>provisional-byte-vector-set!</strong> <em>byte-vector index byte --> unspecified</em></dt>
- <dt id="index-attempt_002dcopy_002dbytes_0021">procedure: <strong>attempt-copy-bytes!</strong> <em>from fstart to tstart count --> unspecified</em></dt>
- <dd><p>These are variants of most basic Scheme memory accessors & modifiers
- that log in the current proposal, rather than performing the actual
- memory access/modification. All of these do perform the actual memory
- access/modification, however, if there is no current proposal in place
- when they are called. <code>Attempt-copy-bytes!</code> copies a sequence of
- <var>count</var> bytes from the byte vector or string <var>from</var>, starting
- at the index <var>fstart</var>, to the byte vector or string <var>to</var>,
- starting at the index <var>tstart</var>.
- </p></dd></dl>
- <span id="Synchronized-records"></span><h4 class="subsection">5.2.3 Synchronized records</h4>
- <span id="index-optimistically-concurrent-record-types"></span>
- <dl>
- <dt id="index-define_002dsynchronized_002drecord_002dtype">syntax: <strong>define-synchronized-record-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-synchronized-record-type <var>tag</var> <var>type-name</var>
- (<var>constructor-name</var> <var>parameter-field-tag</var> …)
- [(<var>sync-field-tag</var> …)]
- <var>predicate-name</var>
- (<var>field-tag</var> <var>accessor-name</var> [<var>modifier-name</var>])
- …)</pre></div>
- <p>This is exactly like <code>define-record-type</code> from the
- <code>define-record-types</code> structure, except that the accessors &
- modifiers for each field in <var>sync-field-tag</var> … are defined to
- be provisional, <i>i.e.</i> to log in the current proposal. If the list of
- synchronized fields is absent, all of the fields are synchronized,
- <i>i.e.</i> it is as if all were specified in that list.
- </p></dd></dl>
- <span id="index-define_002dsync_002drecord_002dtypes"></span>
- <p>The <code>proposals</code> structure also exports
- <code>define-record-discloser</code> (see <a href="#Records">Records</a>). Moreover, the
- <code>define-sync-record-types</code> structure, too, exports
- <code>define-synchronized-record-type</code>, though it does not export
- <code>define-record-discloser</code>.
- </p>
- <span id="Optimistic-concurrency-example"></span><h4 class="subsection">5.2.4 Optimistic concurrency example</h4>
- <p>Here is a basic example of using optimistic concurrency to ensure the
- synchronization of memory. We first present a simple mechanism for
- counting integers by maintaining internal state, which is expressed
- easily with closures:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (make-counter value)
- (lambda ()
- (let ((v value))
- (set! value (+ v 1))
- v)))</pre></div>
- <p>This has a problem: between obtaining the value of the closure’s slot
- for <code>value</code> and updating that slot, another thread might be given
- control and modify the counter, producing unpredictable results in
- threads in the middle of working with the counter. To remedy this, we
- might add a mutual exclusion lock to counters to prevent threads from
- simultaneously accessing the cell:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (make-counter value)
- (let ((lock (make-lock)))
- (lambda ()
- (dynamic-wind
- (lambda () (obtain-lock lock))
- (lambda ()
- (let ((v value))
- (set! value (+ v 1))
- v))
- (lambda () (release-lock lock))))))</pre></div>
- <p>This poses another problem, however. Suppose we wish to write an
- atomic <code>(step-counters! <var>counter …</var>)</code> procedure that
- increments each of the supplied counters by one; supplying a counter
- <var>n</var> times should have the effect of incrementing it by <var>n</var>.
- The naïve definition of it is this:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (step-counters! . counters)
- (for-each (lambda (counter) (counter))
- counters))</pre></div>
- <p>Obviously, though, this is not atomic, because each individual counter
- is locked when it is used, but not the whole iteration across them.
- To work around this, we might use an obfuscated control structure to
- allow nesting the locking of counters:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (make-counter value)
- (let ((lock (make-lock)))
- (lambda args
- (dynamic-wind
- (lambda () (obtain-lock lock))
- (lambda ()
- (if (null? args)
- (let ((v value))
- (set! value (+ v 1))
- v)
- ((car args))))
- (lambda () (release-lock lock))))))
- (define (step-counters! . counters)
- (let loop ((cs counters))
- (if (null? cs)
- (for-each (lambda (counter) (counter))
- counters)
- ((car cs) (lambda () (loop (cdr cs)))))))</pre></div>
- <p>Aside from the obvious matter of the obfuscation of the control
- structures used here, however, this has another problem: we cannot
- step one counter multiple times atomically. Though different locks
- can be nested, nesting is very dangerous, because accidentally
- obtaining a lock that is already obtained can cause deadlock, and
- there is no modular, transparent way to avoid this in the general
- case.
- </p>
- <p>Instead, we can implement counters using optimistic concurrency to
- synchronize the shared data. The state of counters is kept explicitly
- in a <a href="#Cells">cell</a>, in order to use a provisional accessor &
- modifier, as is necessary to make use of optimistic concurrency, and
- we surround with <code>call-ensuring-atomicity</code> any regions we wish to
- be atomic:
- </p>
- <div class="lisp">
- <pre class="lisp">(define (make-counter initial)
- (let ((cell (make-cell initial)))
- (lambda ()
- (call-ensuring-atomicity
- (lambda ()
- (let ((value (provisional-cell-ref cell)))
- (provisional-cell-set! cell (+ value 1))
- value))))))
- (define (step-counters! . counters)
- (call-ensuring-atomicity!
- (lambda ()
- (for-each (lambda (counter) (counter))
- counters))))</pre></div>
- <p>This approach has a number of advantages:
- </p>
- <ul>
- <li> The original control structure is preserved, only with
- provisional operators for shared memory access that we explicitly wish
- to be synchronized and with <code>call-ensuring-atomicity</code> wrapping
- the portions of code that we explicitly want to be atomic.
- </li><li> Composition of transactions is entirely transparent; it is
- accomplished automatically simply by <code>call-ensuring-atomicity</code>.
- </li><li> Transactions can be nested arbitrarily deeply, and there is no
- problem of accidentally locking the same resource again at a deeper
- nesting level to induce deadlock.
- </li><li> No explicit mutual exclusion or blocking is necessary. Threads
- proceed without heed to others, but do not actually write data to the
- shared memory until its validity is ensured. There is no deadlock at
- all.
- </li></ul>
- <span id="Low_002dlevel-optimistic-concurrency"></span><h4 class="subsection">5.2.5 Low-level optimistic concurrency</h4>
- <p>Along with the higher-level operations described above, there are some
- lower-level primitives for finer control over optimistic concurrency.
- </p>
- <span id="index-proposals-1"></span>
- <dl>
- <dt id="index-make_002dproposal">procedure: <strong>make-proposal</strong> <em>--> proposal</em></dt>
- <dt id="index-current_002dproposal">procedure: <strong>current-proposal</strong> <em>--> proposal</em></dt>
- <dt id="index-set_002dcurrent_002dproposal_0021">procedure: <strong>set-current-proposal!</strong> <em>proposal --> unspecified</em></dt>
- <dt id="index-remove_002dcurrent_002dproposal_0021">procedure: <strong>remove-current-proposal!</strong> <em>--> unspecified</em></dt>
- <dd><p><code>Make-proposal</code> creates a fresh proposal. <code>Current-proposal</code>
- returns the current thread’s proposal. <code>Set-current-proposal!</code>
- sets the current thread’s proposal to <var>proposal</var>.
- <code>Remove-current-proposal!</code> sets the current thread’s proposal to
- <code>#f</code>.
- </p></dd></dl>
- <span id="index-committing-proposals"></span>
- <span id="index-proposals_002c-committing"></span>
- <dl>
- <dt id="index-maybe_002dcommit">procedure: <strong>maybe-commit</strong> <em>--> boolean</em></dt>
- <dt id="index-invalidate_002dcurrent_002dproposal_0021">procedure: <strong>invalidate-current-proposal!</strong> <em>--> unspecified</em></dt>
- <dd><p><code>Maybe-commit</code> checks that the current thread’s proposal is still
- valid. If it is, the proposal’s writes are committed, and
- <code>maybe-commit</code> returns <code>#t</code>; if not, the current thread’s
- proposal is set to <code>#f</code> and <code>maybe-commit</code> returns <code>#f</code>.
- <code>Invalidate-current-proposal!</code> causes an inconsistency in the
- current proposal by caching a read and then directly writing to the
- place that read was from.
- </p></dd></dl>
- <span id="index-installing-proposals"></span>
- <span id="index-proposals_002c-installing"></span>
- <dl>
- <dt id="index-with_002dnew_002dproposal">syntax: <strong>with-new-proposal</strong> <em>(lose) body --> values</em></dt>
- <dd><p>Convenience for repeating a transaction. <code>With-new-proposal</code>
- saves the current proposal and will reinstates it when everything is
- finished. After saving the current proposal, it binds <var>lose</var> to a
- nullary procedure that installs a fresh proposal and that evaluates
- <var>body</var>; it then calls <var>lose</var>. Typically, the last thing, or
- close to last thing, that <var>body</var> will do is attempt to commit the
- current proposal, and, if that fails, call <var>lose</var> to retry.
- <code>With-new-proposal</code> expands to a form that returns the values
- that <var>body</var> returns.
- </p>
- <p>This <code>retry-at-most</code> example tries running the transaction of
- <var>thunk</var>, and, if it fails to commit, retries at most <var>n</var>
- times. If the transaction is successfully committed before <var>n</var>
- repeated attempts, it returns true; otherwise, it returns false.
- </p>
- <div class="lisp">
- <pre class="lisp">(define (retry-at-most n thunk)
- (with-new-proposal (lose)
- (thunk)
- (cond ((maybe-commit) #t)
- ((zero? n) #f)
- (else (set! n (- n 1))
- (lose)))))</pre></div>
- </dd></dl>
- <hr>
- <span id="Higher_002dlevel-synchronization"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Higher_002dlevel-synchronization-1"></span><h3 class="section">5.3 Higher-level synchronization</h3>
- <p>This section details the various higher-level thread synchronization
- devices that Scheme48 provides.
- </p>
- <span id="Condition-variables"></span><h4 class="subsection">5.3.1 Condition variables</h4>
- <span id="index-condvars"></span>
- <p><em>Condition variables</em> are multiple-assignment cells on which
- readers block. Threads may wait on condition variables; when some
- other thread assigns a condition variable, all threads waiting on it
- are revived. The <code>condvars</code> structure exports all of these
- condition-variable-related names.
- </p>
- <p>In many concurrency systems, condition variables are operated in
- conjunction with mutual exclusion locks. On the other hand, in
- Scheme48, they are used in conjunction with its optimistic concurrency
- devices.
- </p>
- <dl>
- <dt id="index-make_002dcondvar">procedure: <strong>make-condvar</strong> <em>[id] --> condvar</em></dt>
- <dt id="index-condvar_003f">procedure: <strong>condvar?</strong> <em>object --> boolean</em></dt>
- <dd><p>Condition variable constructor & disjoint type predicate. <var>Id</var> is
- used purely for debugging.
- </p></dd></dl>
- <dl>
- <dt id="index-maybe_002dcommit_002dand_002dwait_002dfor_002dcondvar">procedure: <strong>maybe-commit-and-wait-for-condvar</strong> <em>condvar --> boolean</em></dt>
- <dt id="index-maybe_002dcommit_002dand_002dset_002dcondvar_0021">procedure: <strong>maybe-commit-and-set-condvar!</strong> <em>condvar value --> boolean</em></dt>
- <dd><p><code>Maybe-commit-and-wait-for-condvar</code> attempts to commit the current
- proposal. If the commit succeeded, the current thread is blocked on
- <var>condvar</var>, and when the current thread is woken up,
- <code>maybe-commit-and-wait-for-condvar</code> returns <code>#t</code>. If the
- commit did not succeed, <code>maybe-commit-and-wait-for-condvar</code>
- immediately returns <code>#f</code>. <code>Maybe-commit-and-set-condvar!</code>
- attempts to commit the current proposal as well. If it succeeds, it is
- noted that <var>condvar</var> has a value, <var>condvar</var>’s value is set to
- be <var>value</var>, and all threads waiting on <var>condvar</var> are woken up.
- </p>
- <p><strong>Note:</strong> Do not use these in atomic transactions as delimited by
- <code>call-ensuring-atomicity</code> <i>&c.</i>; see the note in <a href="#Optimistic-concurrency">Optimistic concurrency</a> on this matter for details.
- </p></dd></dl>
- <dl>
- <dt id="index-condvar_002dhas_002dvalue_003f">procedure: <strong>condvar-has-value?</strong> <em>condvar --> boolean</em></dt>
- <dt id="index-condvar_002dvalue">procedure: <strong>condvar-value</strong> <em>condvar --> value</em></dt>
- <dd><p><code>Condvar-has-value?</code> tells whether or not <var>condvar</var> has been
- assigned. If it has been assigned, <code>condvar-value</code> accesses the
- value to which it was assigned.
- </p></dd></dl>
- <dl>
- <dt id="index-set_002dcondvar_002dhas_002dvalue_003f_0021">procedure: <strong>set-condvar-has-value?!</strong> <em>condvar boolean --> unspecified</em></dt>
- <dt id="index-set_002dcondvar_002dvalue_0021">procedure: <strong>set-condvar-value!</strong> <em>condvar value --> unspecified</em></dt>
- <dd><p><code>Set-condvar-has-value?!</code> is used to tell whether or not
- <var>condvar</var> is assigned. <code>Set-condvar-value!</code> sets
- <var>condvar</var>’s value.
- </p>
- <p><strong>Note:</strong> <code>Set-condvar-has-value?!</code> should be used only with
- a second argument of <code>#f</code>. <code>Set-condvar-value!</code> is a very
- dangerous routine, and <code>maybe-commit-and-set-condvar!</code> is what one
- should almost always use, except if one wishes to clean up after
- unassigning a condition variable.
- </p></dd></dl>
- <span id="Placeholders"></span><h4 class="subsection">5.3.2 Placeholders</h4>
- <span id="index-placeholders"></span>
- <p><em>Placeholders</em> are similar to condition variables, except that they
- may be assigned only once; they are in general a much simpler mechanism
- for throw-away temporary synchronization devices. They are provided by
- the <code>placeholders</code> structure.
- </p>
- <dl>
- <dt id="index-make_002dplaceholder">procedure: <strong>make-placeholder</strong> <em>[id] --> placeholder</em></dt>
- <dt id="index-placeholder_003f">procedure: <strong>placeholder?</strong> <em>object --> boolean</em></dt>
- <dd><p>Placeholder constructor & disjoint type predicate. <var>Id</var> is used
- only for debugging purposes when printing placeholders.
- </p></dd></dl>
- <dl>
- <dt id="index-placeholder_002dvalue">procedure: <strong>placeholder-value</strong> <em>placeholder --> value</em></dt>
- <dt id="index-placeholder_002dset_0021">procedure: <strong>placeholder-set!</strong> <em>placeholder value --> unspecified</em></dt>
- <dd><p><code>Placeholder-value</code> blocks until <var>placeholder</var> is assigned, at
- which point it returns the value assigned. <code>Placeholder-set!</code>
- assigns <var>placeholder</var>’s value to <var>value</var>, awakening all threads
- waiting for <var>placeholder</var>. It is an error to assign a placeholder
- with <code>placeholder-set!</code> that has already been assigned.
- </p></dd></dl>
- <span id="Value-pipes"></span><h4 class="subsection">5.3.3 Value pipes</h4>
- <span id="index-thread-communication-channels_002c-asynchronous"></span>
- <span id="index-asynchronous-thread-communication-channels"></span>
- <p><em>Value pipes</em> are asynchronous communication pipes between threads.
- The <code>value-pipes</code> structure exports these value pipe operations.
- </p>
- <dl>
- <dt id="index-make_002dpipe">procedure: <strong>make-pipe</strong> <em>[size [id]] --> value-pipe</em></dt>
- <dt id="index-pipe_003f">procedure: <strong>pipe?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-pipe</code> is the value pipe constructor. <var>Size</var> is a limit
- on the number of elements the pipe can hold at one time. <var>Id</var> is
- used for debugging purposes only in printing pipes. <code>Pipe?</code> is
- the disjoint type predicate for value pipes.
- </p></dd></dl>
- <dl>
- <dt id="index-empty_002dpipe_003f">procedure: <strong>empty-pipe?</strong> <em>pipe --> boolean</em></dt>
- <dt id="index-empty_002dpipe_0021">procedure: <strong>empty-pipe!</strong> <em>pipe --> unspecified</em></dt>
- <dd><p><code>Empty-pipe?</code> returns <code>#t</code> if <var>pipe</var> has no elements in
- it and <code>#f</code> if not. <code>Empty-pipe!</code> removes all elements from
- <code>pipe</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-pipe_002dread_0021">procedure: <strong>pipe-read!</strong> <em>pipe --> value</em></dt>
- <dt id="index-pipe_002dmaybe_002dread_0021">procedure: <strong>pipe-maybe-read!</strong> <em>pipe --> value or <code>#f</code></em></dt>
- <dt id="index-pipe_002dmaybe_002dread_003f_0021">procedure: <strong>pipe-maybe-read?!</strong> <em>pipe --> [boolean value]</em></dt>
- <dd><p><code>Pipe-read!</code> reads a value from <var>pipe</var>, removing it from the
- queue. It blocks if there are no elements available in the queue.
- <code>Pipe-maybe-read!</code> attempts to read & return a single value from
- <var>pipe</var>; if no elements are available in its queue, it instead
- returns <code>#f</code>. <code>Pipe-maybe-read?!</code> does similarly, but it
- returns two values: a boolean, signifying whether or not a value was
- read; and the value, or <code>#f</code> if no value was read.
- <code>Pipe-maybe-read?!</code> is useful when <var>pipe</var> may contain the
- value <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-pipe_002dwrite_0021">procedure: <strong>pipe-write!</strong> <em>pipe value --> unspecified</em></dt>
- <dt id="index-pipe_002dpush_0021">procedure: <strong>pipe-push!</strong> <em>pipe value --> unspecified</em></dt>
- <dt id="index-pipe_002dmaybe_002dwrite_0021">procedure: <strong>pipe-maybe-write!</strong> <em>pipe value --> boolean</em></dt>
- <dd><p><code>Pipe-write!</code> attempts to add <var>value</var> to <var>pipe</var>’s queue.
- If <var>pipe</var>’s maximum size, as passed to <code>make-pipe</code> when
- constructing the pipe, is either <code>#f</code> or greater than the number
- of elements in <var>pipe</var>’s queue, <code>pipe-write!</code> will not block;
- otherwise it will block until a space has been made available in the
- pipe’s queue by another thread reading from it. <code>Pipe-push!</code> does
- similarly, but, in the case where the pipe is full, it pushes the first
- element to be read out of the pipe. <code>Pipe-maybe-write!</code> is also
- similar to <code>pipe-write!</code>, but it returns <code>#t</code> if the pipe was
- not full, and it <em>immediately</em> returns <code>#f</code> if the pipe was
- full.
- </p></dd></dl>
- <hr>
- <span id="Concurrent-ML"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Concurrent-ML-1"></span><h3 class="section">5.4 Concurrent ML</h3>
- <span id="index-rendezvous"></span>
- <span id="index-event"></span>
- <p>Scheme48 provides a high-level event synchronization facility based on
- on Reppy’s <em>Concurrent ML</em> [Reppy 99]. The primary object in CML
- is the <em>rendezvous</em><a id="DOCF20" href="#FOOT20"><sup>20</sup></a>, which represents a point of
- process synchronization. A rich library for manipulating rendezvous
- and several useful, high-level synchronization abstractions are built
- atop rendezvous.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Rendezvous-concepts" accesskey="1">Rendezvous concepts</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Rendezvous-base-combinators" accesskey="2">Rendezvous base combinators</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Rendezvous-communication-channels" accesskey="3">Rendezvous communication channels</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Rendezvous_002dsynchronized-cells" accesskey="4">Rendezvous-synchronized cells</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Concurrent-ML-to-Scheme-correspondence" accesskey="5">Concurrent ML to Scheme correspondence</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Rendezvous-concepts"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Rendezvous-concepts-1"></span><h4 class="subsection">5.4.1 Rendezvous concepts</h4>
- <p>When access to a resource must be synchronized between multiple
- processes, for example to transmit information from one process to
- another over some sort of communication channel, the resource provides
- a <em>rendezvous</em> to accomplish this, which represents a potential
- point of synchronization between processes. The use of rendezvous
- occurs in two stages: <em>synchronization</em> and <em>enablement</em>. Note
- that creation of rendezvous is an unrelated matter, and it does not (or
- should not) itself result in any communication or synchronization
- between processes.
- </p>
- <p>When a process requires an external resource for which it has a
- rendezvous, it <em>synchronizes</em> that rendezvous. This first polls
- whether the resource is immediately available; if so, the rendezvous is
- already <em>enabled</em>, and a value from the resource is immediately
- produced from the synchronization. Otherwise, the synchronization of
- the rendezvous is recorded somehow externally, and the process is
- blocked until the rendezvous is enabled by an external entity, usually
- one that made the resource available. Rendezvous may be reüsed
- arbitrarily many times; the value produced by an enabled, synchronized
- rendezvous is not cached. Note, however, that the construction of a
- rendezvous does not (or should not) have destructive effect, such as
- sending a message to a remote server or locking a mutex; the only
- destructive effects should be incurred at synchronization or enablement
- time. For effecting initialization prior to the synchronization of a
- rendezvous, see below on <em>delayed rendezvous</em>.
- </p>
- <p>Rendezvous may consist of multiple rendezvous choices, any of which may
- be taken when enabled but only one of which actually is. If, when a
- composite rendezvous is initially synchronized, several components are
- immediately enabled, each one has a particular numeric priority which
- is used to choose among them. If several are tied for the highest
- priority, a random one is chosen. If none is enabled when the choice
- is synchronized, however, the synchronizer process is suspended until
- the first one is enabled and revives the process. When this happens,
- any or all of the other rendezvous components may receive a negative
- acknowledgement; see below on <em>delayed rendezvous with negative
- acknowledgement</em>.
- </p>
- <p>A rendezvous may also be a rendezvous <em>wrapped</em> with a procedure,
- which means that, when the internal rendezvous becomes enabled, the
- wrapper one also becomes enabled, and the value it produces is the
- result of applying its procedure to the value that the internal
- rendezvous produced. This allows the easy composition of complex
- rendezvous from simpler ones, and it also provides a simple mechanism
- for performing different actions following the enablement of different
- rendezvous, rather than conflating the results of several possible
- rendezvous choices into one value and operating on that (though this,
- too, can be a useful operation).
- </p>
- <span id="Delayed-rendezvous"></span><h4 class="subsection">5.4.2 Delayed rendezvous</h4>
- <p>A rendezvous may be <em>delayed</em>, which means that its synchronization
- requires some processing that could not or would not be reasonable to
- perform at its construction. It consists of a nullary procedure to
- generate the actual rendezvous to synchronize when the delayed
- rendezvous is itself synchronized.
- </p>
- <p>For example, a rendezvous for generating unique identifiers, by sending
- a request over a network to some server and waiting for a response,
- could not be constructed by waiting for a response from the server,
- because that may block, which should not occur until synchronization.
- It also could not be constructed by first sending a request to the
- server at all, because that would have a destructive effect, which is
- not meant to happen when creating a rendezvous, only when synchronizing
- or enabling one.
- </p>
- <p>Instead, the unique identifier rendezvous would be implemented as a
- delayed rendezvous that, when synchronized, would send a request to
- the server and generate a rendezvous for the actual synchronization
- that would become enabled on receiving the server’s response.
- </p>
- <span id="Negative-acknowledgements"></span><h4 class="subsubsection">5.4.2.1 Negative acknowledgements</h4>
- <p>Delayed rendezvous may also receive negative acknowledgements. Rather
- than a simple nullary procedure being used to generate the actual
- rendezvous for synchronization, the procedure is unary, and it is
- passed a <em>negative acknowledgement rendezvous</em>, or <em>nack</em> for
- short. This nack is enabled if the actual rendezvous was not chosen
- among a composite group of rendezvous being synchronized. This allows
- not only delaying initialization of rendezvous until necessary but also
- aborting or rescinding initialized transactions if their rendezvous are
- unchosen and therefore unused.
- </p>
- <p>For example, a complex database query might be the object of some
- rendezvous, but it is pointless to continue constructing the result if
- that rendezvous is not chosen. A nack can be used to prematurely abort
- the query to the database if another rendezvous was chosen in the stead
- of that for the database query.
- </p>
- <hr>
- <span id="Rendezvous-base-combinators"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Rendezvous-combinators"></span><h4 class="subsection">5.4.3 Rendezvous combinators</h4>
- <span id="index-rendezvous-1"></span>
- <p>The <code>rendezvous</code> structure exports several basic rendezvous
- combinators.
- </p>
- <dl>
- <dt id="index-never_002drv">Constant: <strong>never-rv</strong> <em>--> rendezvous</em></dt>
- <dd><p>A rendezvous that is never enabled. If synchronized, this will block
- the synchronizing thread indefinitely.
- </p></dd></dl>
- <dl>
- <dt id="index-always_002drv">procedure: <strong>always-rv</strong> <em>value --> rendezvous</em></dt>
- <dd><p>Returns a rendezvous that is always enabled with the given value. This
- rendezvous will never block the synchronizing thread.
- </p></dd></dl>
- <dl>
- <dt id="index-guard">procedure: <strong>guard</strong> <em>rv-generator --> rendezvous</em></dt>
- <dt id="index-with_002dnack">procedure: <strong>with-nack</strong> <em>rv-generator --> rendezvous</em></dt>
- <dd><p><code>Guard</code> returns a delayed rendezvous, generated by the given
- procedure <var>rv-generator</var>, which is passed zero arguments whenever
- the resultant rendezvous is synchronized. <code>With-nack</code> returns a
- delayed rendezvous for which a negative acknowledgement rendezvous is
- constructed. If the resultant rendezvous is synchronized as a part of
- a composite rendezvous, the procedure <code>rv-generator</code> is passed a
- nack for the synchronization, and it returns the rendezvous to actually
- synchronize. If the delayed rendezvous was synchronized as part of a
- composite group of rendezvous, and another rendezvous among that group
- is enabled and chosen first, the nack is enabled.
- </p></dd></dl>
- <dl>
- <dt id="index-choose">procedure: <strong>choose</strong> <em>rendezvous … --> composite-rendezvous</em></dt>
- <dd><p>Returns a rendezvous that, when synchronized, synchronizes all of the
- given components, and chooses only the first one to become enabled, or
- the highest priority one if there are any that are already enabled. If
- any of the rendezvous that were not chosen when the composite became
- enabled were delayed rendezvous with nacks, their nacks are enabled.
- </p></dd></dl>
- <dl>
- <dt id="index-wrap">procedure: <strong>wrap</strong> <em>rendezvous procedure --> rendezvous</em></dt>
- <dd><p>Returns a rendezvous equivalent to <var>rendezvous</var> but wrapped with
- <var>procedure</var>, so that, when the resultant rendezvous is
- synchronized, <var>rendezvous</var> is transitively synchronized, and when
- <var>rendezvous</var> is enabled, the resultant rendezvous is also enabled,
- with the value that <var>procedure</var> returns when passed the value
- produced by <var>rendezvous</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(sync (wrap (always-rv 4)
- (lambda (x) (* x x)))) --> 16</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-sync">procedure: <strong>sync</strong> <em>rendezvous --> value (may block)</em></dt>
- <dt id="index-select">procedure: <strong>select</strong> <em>rendezvous … --> value (may block)</em></dt>
- <dd><p><code>Sync</code> and <code>select</code> synchronize rendezvous. <code>Sync</code>
- synchronizes a single one; <code>select</code> synchronizes any from the
- given set of them. <code>Select</code> is equivalent to <code>(sync (apply
- choose <var>rendezvous …</var>))</code>, but it may be implemented more
- efficiently.
- </p></dd></dl>
- <span id="Timing-rendezvous"></span><h4 class="subsubsection">5.4.3.1 Timing rendezvous</h4>
- <span id="index-time"></span>
- <span id="index-rendezvous_002dtime"></span>
- <p>The <code>rendezvous-time</code> structure exports two constructors for
- rendezvous that become enabled only at a specific time or after a delay
- in time.
- </p>
- <dl>
- <dt id="index-at_002dreal_002dtime_002drv">procedure: <strong>at-real-time-rv</strong> <em>milliseconds --> rendezvous</em></dt>
- <dt id="index-after_002dtime_002drv">procedure: <strong>after-time-rv</strong> <em>milliseconds --> rendezvous</em></dt>
- <dd><p><code>At-real-time-rv</code> returns a rendezvous that becomes enabled at the
- time <var>milliseconds</var> relative to the start of the Scheme program.
- <code>After-time-rv</code> returns a rendezvous that becomes enabled at least
- <var>milliseconds</var> after synchronization (<em>not</em> construction).
- </p></dd></dl>
- <hr>
- <span id="Rendezvous-communication-channels"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Rendezvous-communication-channels-1"></span><h4 class="subsection">5.4.4 Rendezvous communication channels</h4>
- <span id="Synchronous-channels"></span><h4 class="subsubsection">5.4.4.1 Synchronous channels</h4>
- <span id="index-channels-1"></span>
- <span id="index-synchronous-channels"></span>
- <span id="index-message_002dpassing"></span>
- <span id="index-rendezvous_002dchannels"></span>
- <p>The <code>rendezvous-channels</code> structure provides a facility for
- <em>synchronous channels</em>: channels for communication between threads
- such that any receiver blocks until another thread sends a message, or
- any sender blocks until another thread receives the sent message. In
- CML, synchronous channels are also called merely ‘channels.’
- </p>
- <dl>
- <dt id="index-make_002dchannel">procedure: <strong>make-channel</strong> <em>--> channel</em></dt>
- <dt id="index-channel_003f-1">procedure: <strong>channel?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-channel</code> creates and returns a new channel. <code>Channel?</code>
- is the disjoint type predicate for channels.
- </p></dd></dl>
- <dl>
- <dt id="index-send_002drv">procedure: <strong>send-rv</strong> <em>channel message --> rendezvous</em></dt>
- <dt id="index-send">procedure: <strong>send</strong> <em>channel message --> unspecified (may block)</em></dt>
- <dd><p><code>Send-rv</code> returns a rendezvous that, when synchronized, becomes
- enabled when a reception rendezvous for <var>channel</var> is synchronized,
- at which point that reception rendezvous is enabled with a value of
- <var>message</var>. When enabled, the rendezvous returned by <code>send-rv</code>
- produces an unspecified value. <code>Send</code> is like <code>send-rv</code>, but
- it has the effect of immediately synchronizing the rendezvous, so it
- therefore may block, and it does not return a rendezvous; <code>(send
- <var>channel</var> <var>message</var>)</code> is equivalent to <code>(sync (send-rv
- <var>channel</var> <var>message</var>))</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-receive_002drv">procedure: <strong>receive-rv</strong> <em>channel --> rendezvous</em></dt>
- <dt id="index-receive-1">procedure: <strong>receive</strong> <em>channel --> value (may block)</em></dt>
- <dd><p><code>Receive-rv</code> returns a rendezvous that, when synchronized, and
- when a sender rendezvous for <var>channel</var> with some message is
- synchronized, becomes enabled with that message, at which point the
- sender rendezvous is enabled with an unspecified value. <code>Receive</code>
- is like <code>receive-rv</code>, but it has the effect of immediately
- synchronizing the reception rendezvous, so it therefore may block, and
- it does not return the rendezvous but rather the message that was sent;
- <code>(receive <var>channel</var>)</code> is equivalent to <code>(sync (receive-rv
- <var>channel</var>))</code>.
- </p></dd></dl>
- <span id="Asynchronous-channels"></span><h4 class="subsubsection">5.4.4.2 Asynchronous channels</h4>
- <span id="index-channels-2"></span>
- <span id="index-asynchronous-channels"></span>
- <span id="index-message_002dpassing-1"></span>
- <span id="index-rendezvous_002dasync_002dchannels"></span>
- <p>The <code>rendezvous-async-channels</code> provides an <em>asynchronous
- channel</em><a id="DOCF21" href="#FOOT21"><sup>21</sup></a>
- facility. Like synchronous channels, any attempts to read from an
- asynchronous channel will block if there are no messages waiting to be
- read. Unlike synchronous channels, however, sending a message will
- never block. Instead, a queue of messages or a queue of recipients is
- maintained: if a message is sent and there is a waiting recipient, the
- message is delivered to that recipient; otherwise it is added to the
- queue of messages. If a thread attempts to receive a message from an
- asynchronous channel and there is a pending message, it receives that
- message; otherwise it adds itself to the list of waiting recipients and
- then blocks.
- </p>
- <p><strong>Note:</strong> Operations on synchronous channels from the structure
- <code>rendezvous-channels</code> do not work on asynchronous channels.
- </p>
- <dl>
- <dt id="index-make_002dasync_002dchannel">procedure: <strong>make-async-channel</strong> <em>--> async-channel</em></dt>
- <dt id="index-async_002dchannel_003f">procedure: <strong>async-channel?</strong> <em>obj --> boolean</em></dt>
- <dd><p><code>Make-async-channel</code> creates and returns an asynchronous channel.
- <code>Async-channel?</code> is the disjoint type predicate for asynchronous
- channels.
- </p></dd></dl>
- <dl>
- <dt id="index-receive_002dasync_002drv">procedure: <strong>receive-async-rv</strong> <em>channel --> rendezvous</em></dt>
- <dt id="index-receive_002dasync">procedure: <strong>receive-async</strong> <em>channel --> value (may block)</em></dt>
- <dd><p><code>Receive-async-rv</code> returns a rendezvous that, when synchronized,
- becomes enabled when a message is available in <var>channel</var>’s queue of
- messages. <code>Receive-async</code> has the effect of immediately
- synchronizing such a rendezvous and, when the rendezvous becomes
- enabled, returning the value itself, rather than the rendezvous;
- <code>(receive-async <var>channel</var>)</code> is equivalent to <code>(sync
- (receive-async-rv <var>channel</var>))</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-send_002dasync">procedure: <strong>send-async</strong> <em>channel message --> unspecified</em></dt>
- <dd><p>Sends a message to the asynchronous channel <var>channel</var>. Unlike the
- synchronous channel <code>send</code> operation, this procedure never blocks
- arbitrarily long.<a id="DOCF22" href="#FOOT22"><sup>22</sup></a> There is, therefore,
- no need for a <code>send-async-rv</code> like the <code>send-rv</code> for
- synchronous channels. If there is a waiting message recipient, the
- message is delivered to that recipient; otherwise, it is added to the
- channel’s message queue.
- </p></dd></dl>
- <hr>
- <span id="Rendezvous_002dsynchronized-cells"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Rendezvous_002dsynchronized-cells-1"></span><h4 class="subsection">5.4.5 Rendezvous-synchronized cells</h4>
- <span id="Placeholders_003a-single_002dassignment-cells"></span><h4 class="subsubsection">5.4.5.1 Placeholders: single-assignment cells</h4>
- <span id="index-rendezvous_002dplaceholders"></span>
- <p><em>Placeholders</em><a id="DOCF23" href="#FOOT23"><sup>23</sup></a> are single-assignment cells on which
- readers block until they are assigned.
- </p>
- <p><strong>Note:</strong> These placeholders are disjoint from and incompatible
- with the placeholder mechanism provided in the <code>placeholders</code>
- structure, and attempts to apply operations on one to values of the
- other are errors.
- </p>
- <dl>
- <dt id="index-make_002dplaceholder-1">procedure: <strong>make-placeholder</strong> <em>[id] --> empty placeholder</em></dt>
- <dt id="index-placeholder_003f-1">procedure: <strong>placeholder?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-placeholder</code> creates and returns a new, empty placeholder.
- <var>Id</var> is used only for debugging purposes; it is included in the
- printed representation of the placeholder. <code>Placeholder?</code> is the
- disjoint type predicate for placeholders.
- </p></dd></dl>
- <dl>
- <dt id="index-placeholder_002dvalue_002drv">procedure: <strong>placeholder-value-rv</strong> <em>placeholder --> rendezvous</em></dt>
- <dt id="index-placeholder_002dvalue-1">procedure: <strong>placeholder-value</strong> <em>placeholder --> value (may block)</em></dt>
- <dd><p><code>Placeholder-value-rv</code> returns a rendezvous that, when
- synchronized, becomes enabled when <var>placeholder</var> has a value, with
- that value. <code>Placeholder-value</code> has the effect of immediately
- synchronizing such a rendezvous, and it returns the value directly, but
- possibly after blocking.
- </p></dd></dl>
- <dl>
- <dt id="index-placeholder_002dset_0021-1">procedure: <strong>placeholder-set!</strong> <em>placeholder value --> unspecified</em></dt>
- <dd><p>Sets <var>placeholder</var>’s value to be <var>value</var>, and enables all
- rendezvous for <var>placeholder</var>’s value with that value. It is an
- error if <var>placeholder</var> has already been assigned.
- </p></dd></dl>
- <span id="Jars_003a-multiple_002dassignment-cells"></span><h4 class="subsubsection">5.4.5.2 Jars: multiple-assignment cells</h4>
- <span id="index-rendezvous_002djars"></span>
- <p><em>Jars</em><a id="DOCF24" href="#FOOT24"><sup>24</sup></a> are
- multiple-assignment cells on which readers block. Reading from a full
- jar has the effect of emptying it, enabling the possibility of
- subsequent assignment, unlike placeholders; and jars may be assigned
- multiple times, but, like placeholders, only jars that are empty may be
- assigned.
- </p>
- <dl>
- <dt id="index-make_002djar">procedure: <strong>make-jar</strong> <em>[id] --> empty jar</em></dt>
- <dt id="index-jar_003f">procedure: <strong>jar?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-jar</code> creates and returns a new, empty jar. <var>Id</var> is used
- only for debugging purposes; it is included in the printed
- representation of the jar. <code>Jar?</code> is the disjoint type predicate
- for jars.
- </p></dd></dl>
- <dl>
- <dt id="index-jar_002dtake_002drv">procedure: <strong>jar-take-rv</strong> <em>jar --> rendezvous</em></dt>
- <dt id="index-jar_002dtake">procedure: <strong>jar-take</strong> <em>jar --> value (may block)</em></dt>
- <dd><p><code>Jar-take-rv</code> returns a rendezvous that, when synchronized,
- becomes enabled when <var>jar</var> has a value, which is what value the
- rendezvous becomes enabled with; when that rendezvous is enabled, it
- also removes the value from <var>jar</var>, putting the jar into an empty
- state. <code>Jar-take</code> has the effect of synchronizing such a
- rendezvous, may block because of that, and returns the value of the jar
- directly, not a rendezvous.
- </p></dd></dl>
- <dl>
- <dt id="index-jar_002dput_0021">procedure: <strong>jar-put!</strong> <em>jar value --> unspecified</em></dt>
- <dd><p><code>Jar-put!</code> puts <var>value</var> into the empty jar <var>jar</var>. If any
- taker rendezvous are waiting, the first is enabled with the value, and
- the jar is returned to its empty state; otherwise, the jar is put in
- the full state. <code>Jar-put!</code> is an error if applied to a full jar.
- </p></dd></dl>
- <hr>
- <span id="Concurrent-ML-to-Scheme-correspondence"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Concurrent-ML-to-Scheme-correspondence-1"></span><h4 class="subsection">5.4.6 Concurrent ML to Scheme correspondence</h4>
- <table>
- <tr><td>CML name</td><td>Scheme name</td></tr>
- <tr><td>structure <code>CML</code></td><td>structure <code>threads</code></td></tr>
- <tr><td><code>version</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>banner</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>spawnc</code></td><td>(no equivalent; use <code>spawn</code> and <code>lambda</code>)</td></tr>
- <tr><td><code>spawn</code></td><td><code>spawn</code></td></tr>
- <tr><td><code>yield</code></td><td><code>relinquish-timeslice</code></td></tr>
- <tr><td><code>exit</code></td><td><code>terminate-current-thread</code></td></tr>
- <tr><td><code>getTid</code></td><td><code>current-thread</code></td></tr>
- <tr><td><code>sameTid</code></td><td><code>eq?</code> (R5RS)</td></tr>
- <tr><td><code>tidToString</code></td><td>(no equivalent; use the writer)</td></tr>
- <tr><td></td><td>structure <code>threads-internal</code></td></tr>
- <tr><td><code>hashTid</code></td><td><code>thread-uid</code></td></tr>
- <tr><td></td><td>structure <code>rendezvous</code></td></tr>
- <tr><td><code>wrap</code></td><td><code>wrap</code></td></tr>
- <tr><td><code>guard</code></td><td><code>guard</code></td></tr>
- <tr><td><code>withNack</code></td><td><code>with-nack</code></td></tr>
- <tr><td><code>choose</code></td><td><code>choose</code></td></tr>
- <tr><td><code>sync</code></td><td><code>sync</code></td></tr>
- <tr><td><code>select</code></td><td><code>select</code></td></tr>
- <tr><td><code>never</code></td><td><code>never-rv</code></td></tr>
- <tr><td><code>alwaysEvt</code></td><td><code>always-rv</code></td></tr>
- <tr><td><code>joinEvt</code></td><td>(no equivalent)</td></tr>
- <tr><td></td><td>structure <code>rendezvous-channels</code></td></tr>
- <tr><td><code>channel</code></td><td><code>make-channel</code></td></tr>
- <tr><td><code>sameChannel</code></td><td><code>eq?</code> (R5RS)</td></tr>
- <tr><td><code>send</code></td><td><code>send</code></td></tr>
- <tr><td><code>recv</code></td><td><code>receive</code></td></tr>
- <tr><td><code>sendEvt</code></td><td><code>send-rv</code></td></tr>
- <tr><td><code>recvEvt</code></td><td><code>receive-rv</code></td></tr>
- <tr><td><code>sendPoll</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>recvPoll</code></td><td>(no equivalent)</td></tr>
- <tr><td></td><td>structure <code>rendezvous-time</code></td></tr>
- <tr><td><code>timeOutEvt</code></td><td><code>after-time-rv</code></td></tr>
- <tr><td><code>atTimeEvt</code></td><td><code>at-real-time-rv</code></td></tr>
- <tr><td>structure <code>SyncVar</code></td><td>structure <code>rendezvous-placeholders</code></td></tr>
- <tr><td>exception <code>Put</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>iVar</code></td><td><code>make-placeholder</code></td></tr>
- <tr><td><code>iPut</code></td><td><code>placeholder-set!</code></td></tr>
- <tr><td><code>iGet</code></td><td><code>placeholder-value</code></td></tr>
- <tr><td><code>iGetEvt</code></td><td><code>placeholder-value-rv</code></td></tr>
- <tr><td><code>iGetPoll</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>sameIVar</code></td><td><code>eq?</code> (R5RS)</td></tr>
- <tr><td></td><td>structure <code>jars</code></td></tr>
- <tr><td><code>mVar</code></td><td><code>make-jar</code></td></tr>
- <tr><td><code>mVarInit</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mPut</code></td><td><code>jar-put!</code></td></tr>
- <tr><td><code>mTake</code></td><td><code>jar-take</code></td></tr>
- <tr><td><code>mTakeEvt</code></td><td><code>jar-take-rv</code></td></tr>
- <tr><td><code>mGet</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mGetEvt</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mTakePoll</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mGetPoll</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mSwap</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>mSwapEvt</code></td><td>(no equivalent)</td></tr>
- <tr><td><code>sameMVar</code></td><td><code>eq?</code> (R5RS)</td></tr>
- <tr><td>structure <code>Mailbox</code></td><td>structure <code>rendezvous-async-channels</code></td></tr>
- <tr><td><code>mailbox</code></td><td><code>make-async-channel</code></td></tr>
- <tr><td><code>sameMailbox</code></td><td><code>eq?</code> (R5RS)</td></tr>
- <tr><td><code>send</code></td><td><code>send-async</code></td></tr>
- <tr><td><code>recv</code></td><td><code>receive-async</code></td></tr>
- <tr><td><code>recvEvt</code></td><td><code>receive-async-rv</code></td></tr>
- <tr><td><code>recvPoll</code></td><td>(no equivalent)</td></tr>
- </table>
- <hr>
- <span id="Pessimistic-concurrency"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Pessimistic-concurrency-1"></span><h3 class="section">5.5 Pessimistic concurrency</h3>
- <span id="index-mutual-exclusion"></span>
- <span id="index-mutex-locks"></span>
- <span id="index-locks-for-mutual-exclusion"></span>
- <p>While Scheme48’s primitive thread synchronization mechanisms revolve
- around optimistic concurrency, Scheme48 still provides the more
- well-known mechanism of pessimistic concurrency, or mutual exclusion,
- with locks. Note that Scheme48’s pessimistic concurrency facilities
- are discouraged, and very little of the system uses them (at the time
- this documentation was written, none of the system uses locks), and the
- pessimistic concurrency libraries are limited to just locks; condition
- variables are integrated only with optimistic concurrency. Except for
- inherent applications of pessimistic concurrency, it is usually better
- to use optimistic concurrency in Scheme48.
- </p>
- <span id="index-locks"></span>
- <p>These names are exported by the <code>locks</code> structure.
- </p>
- <dl>
- <dt id="index-make_002dlock">procedure: <strong>make-lock</strong> <em>--> lock</em></dt>
- <dt id="index-lock_003f">procedure: <strong>lock?</strong> <em>--> boolean</em></dt>
- <dt id="index-obtain_002dlock">procedure: <strong>obtain-lock</strong> <em>lock --> unspecified</em></dt>
- <dt id="index-maybe_002dobtain_002dlock">procedure: <strong>maybe-obtain-lock</strong> <em>lock --> boolean</em></dt>
- <dt id="index-release_002dlock">procedure: <strong>release-lock</strong> <em>lock --> unspecified</em></dt>
- <dd><p><code>Make-lock</code> creates a new lock in the ‘released’ lock state.
- <code>Lock?</code> is the disjoint type predicate for locks.
- <code>Obtain-lock</code> atomically checks to see if <var>lock</var> is in the
- ‘released’ state: if it is, <var>lock</var> is put into the ‘obtained’ lock
- state; otherwise, <code>obtain-lock</code> waits until <var>lock</var> is ready to
- be obtained, at which point it is put into the ‘obtained’ lock state.
- <code>Maybe-obtain-lock</code> atomically checks to see if <var>lock</var> is in
- the ‘released’ state: if it is, <var>lock</var> is put into the ‘obtained’
- lock state, and <code>maybe-obtain-lock</code> returns <code>#t</code>; if it is in
- the ‘obtained’ state, <code>maybe-obtain-lock</code> immediately returns
- <code>#f</code>. <code>Release-lock</code> sets <var>lock</var>’s state to be
- ‘released,’ letting the next thread waiting to obtain it do so.
- </p></dd></dl>
- <hr>
- <span id="Custom-thread-synchronization"></span><div class="header">
- <p>
- Previous: <a href="#Pessimistic-concurrency" accesskey="p" rel="prev">Pessimistic concurrency</a>, Up: <a href="#Multithreading" accesskey="u" rel="up">Multithreading</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Custom-thread-synchronization-1"></span><h3 class="section">5.6 Custom thread synchronization</h3>
- <span id="index-suspending-threads"></span>
- <span id="index-resuming-suspended-threads"></span>
- <span id="index-threads_002dinternal"></span>
- <p>Along with several useful thread synchronization abstraction facilities
- built-in to Scheme48, there is also a simple and lower-level mechanism
- for suspending & resuming threads. The following bindings are exported
- from the <code>threads-internal</code> structure.
- </p>
- <span id="index-thread-cells"></span>
- <span id="index-thread-queues"></span>
- <p>Threads have a field for a <a href="#Cells">cell</a> that is used when the
- thread is suspended. When it is ready to run, it is simply <code>#f</code>.
- Suspending a thread involves setting its cell to a cell accessible
- outside, so the thread can later be awoken. When the thread is awoken,
- its cell field and the contents of the cell are both set to <code>#f</code>.
- Often, objects involved in the synchronization of threads will have a
- <a href="#Queues">queue</a> of thread cells. There are two specialized
- operations on thread cell queues that simplify filtering out cells of
- threads that have already been awoken.
- </p>
- <dl>
- <dt id="index-maybe_002dcommit_002dand_002dblock">procedure: <strong>maybe-commit-and-block</strong> <em>cell --> boolean</em></dt>
- <dt id="index-maybe_002dcommit_002dand_002dblock_002don_002dqueue">procedure: <strong>maybe-commit-and-block-on-queue</strong> <em>--> boolean</em></dt>
- <dd><p>These attempt to commit the current proposal. If the commit fails,
- they immediately return <code>#f</code>. Otherwise, they suspend the current
- thread. <code>Maybe-commit-and-block</code> first sets the current thread’s
- cell to <var>cell</var>, which should contain the current thread.
- <code>Maybe-commit-and-block-on-queue</code> adds a cell containing the
- current thread to <var>queue</var> first. When the current thread is
- finally resumed, these return <code>#t</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-maybe_002dcommit_002dand_002dmake_002dready">procedure: <strong>maybe-commit-and-make-ready</strong> <em>thread-or-queue --> boolean</em></dt>
- <dd><p>Attempts to commit the current proposal. If the commit fails, this
- returns <code>#f</code>. Otherwise, <code>maybe-commit-and-make-ready</code>
- awakens the specified thread[s] by clearing the thread/each thread’s
- cell and sending a message to the relevant scheduler[s] and returns
- <code>#t</code>. If <var>thread-or-queue</var> is a thread, it simply awakens
- that; if it is a queue, it empties the queue and awakens each thread in
- it.
- </p></dd></dl>
- <dl>
- <dt id="index-maybe_002ddequeue_002dthread_0021">procedure: <strong>maybe-dequeue-thread!</strong> <em>thread-cell-queue --> thread or boolean</em></dt>
- <dt id="index-thread_002dqueue_002dempty_003f">procedure: <strong>thread-queue-empty?</strong> <em>thread-cell-queue --> boolean</em></dt>
- <dd><p><code>Maybe-dequeue-thread!</code> returns the next thread cell’s contents in
- the queue of thread cells <var>thread-cell-queue</var>. It removes cells
- that have been emptied, <i>i.e.</i> whose threads have already been awoken.
- <code>Thread-queue-empty?</code> returns <code>#t</code> if there are no cells in
- <var>thread-cell-queue</var> that contain threads, <i>i.e.</i> threads that are
- still suspended. It too removes cells that have been emptied.
- </p></dd></dl>
- <p>For example, the definition of <a href="#Higher_002dlevel-synchronization">placeholders</a> is presented here. Placeholders contain two fields: the
- cached value (set when the placeholder is set) & a queue of threads
- waiting (set to <code>#f</code> when the placeholder is assigned).
- </p>
- <div class="lisp">
- <pre class="lisp">(define-synchronized-record-type placeholder :placeholder
- (really-make-placeholder queue)
- (value queue) ; synchronized fields
- placeholder?
- (queue placeholder-queue set-placeholder-queue!)
- (value placeholder-real-value set-placeholder-value!))
- (define (make-placeholder)
- (really-make-placeholder (make-queue)))
- (define (placeholder-value placeholder)
- ;; Set up a new proposal for the transaction.
- (with-new-proposal (lose)
- (cond ((placeholder-queue placeholder)
- ;; There's a queue of waiters. Attempt to commit the
- ;; proposal and block. We'll be added to the queue if the
- ;; commit succeeds; if it fails, retry.
- => (lambda (queue)
- (or (maybe-commit-and-block-on-queue queue)
- (lose))))))
- ;; Once our thread has been awoken, the placeholder will be set.
- (placeholder-real-value placeholder))
- (define (placeholder-set! placeholder value)
- ;; Set up a new proposal for the transaction.
- (with-new-proposal (lose)
- (cond ((placeholder-queue placeholder)
- => (lambda (queue)
- ;; Clear the queue, set the value field.
- (set-placeholder-queue! placeholder #f)
- (set-placeholder-value! placeholder value)
- ;; Attempt to commit our changes and awaken all of the
- ;; waiting threads. If the commit fails, retry.
- (if (not (maybe-commit-and-make-ready queue))
- (lose))))
- (else
- ;; Someone assigned it first. Since placeholders are
- ;; single-assignment cells, this is an error.
- (error "placeholder is already assigned"
- placeholder
- (placeholder-real-value placeholder))))))</pre></div>
- <hr>
- <span id="Libraries"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Libraries-1"></span><h2 class="chapter">6 Libraries</h2>
- <p>This chapter details a number of useful libraries built-in to Scheme48.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Boxed-bitwise_002dinteger-masks" accesskey="1">Boxed bitwise-integer masks</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Enumerated_002ffinite-types-and-sets" accesskey="2">Enumerated/finite types and sets</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Macros-for-writing-loops" accesskey="3">Macros for writing loops</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Library-data-structures" accesskey="4">Library data structures</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#I_002fO-extensions" accesskey="5">I/O extensions</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#TCP-_0026-UDP-sockets" accesskey="6">TCP & UDP sockets</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Common_002dLisp_002dstyle-formatting" accesskey="7">Common-Lisp-style formatting</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Library-utilities" accesskey="8">Library utilities</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="Boxed-bitwise_002dinteger-masks"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Boxed-bitwise_002dinteger-masks-1"></span><h3 class="section">6.1 Boxed bitwise-integer masks</h3>
- <span id="index-mask_002dtypes"></span>
- <span id="index-masks"></span>
- <p>Scheme48 provides a facility for generalized boxed bitwise-integer
- masks. Masks represent sets of elements. An element is any arbitrary
- object that represents an index into a bit mask; mask types are
- parameterized by an isomorphism between elements and their integer
- indices. Usual abstract set operations are available on masks. The
- mask facility is divided into two parts: the <code>mask-types</code>
- structure, which provides the operations on the generalized mask type
- descriptors; and the <code>masks</code> structure, for the operations on
- masks themselves.
- </p>
- <span id="Mask-types"></span><h4 class="subsection">6.1.1 Mask types</h4>
- <dl>
- <dt id="index-make_002dmask_002dtype">procedure: <strong>make-mask-type</strong> <em>name elt? index->elt elt->index size --> mask-type</em></dt>
- <dt id="index-mask_002dtype_003f">procedure: <strong>mask-type?</strong> <em>object --> boolean</em></dt>
- <dt id="index-mask_003f">procedure: <strong>mask?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-mask-type</code> constructs a mask type with the given name.
- Elements of this mask type must satisfy the predicate <var>elt?</var>.
- <var>Integer->elt</var> is a unary procedure that maps bit mask indices to
- possible set elements; <var>elt->integer</var> maps possible set elements to
- bit mask indices. <var>Size</var> is the number of possible elements of
- masks of the new type, <i>i.e.</i> the number of bits needed to represent the
- internal bit mask. <code>Mask?</code> is the disjoint type predicate for
- mask objects.
- </p></dd></dl>
- <dl>
- <dt id="index-mask_002dtype">procedure: <strong>mask-type</strong> <em>mask --> mask-type</em></dt>
- <dt id="index-mask_002dhas_002dtype_003f">procedure: <strong>mask-has-type?</strong> <em>mask type --> boolean</em></dt>
- <dd><p><code>Mask-type</code> returns <var>mask</var>’s type. <code>Mask-has-type?</code>
- returns <code>#t</code> if <var>mask</var>’s type is the mask type <var>type</var> or
- <code>#f</code> if not.
- </p></dd></dl>
- <p>The <code>mask-types</code> structure, not the <code>masks</code> structure,
- exports <code>mask?</code> and <code>mask-has-type?</code>: it is expected that
- programmers who implement mask types will define type predicates for
- masks of their type based on <code>mask?</code> and <code>mask-has-type?</code>,
- along with constructors <i>&c.</i> for their masks.
- </p>
- <dl>
- <dt id="index-integer_002d_003emask">procedure: <strong>integer->mask</strong> <em>type integer --> mask</em></dt>
- <dt id="index-list_002d_003emask">procedure: <strong>list->mask</strong> <em>type elts --> mask</em></dt>
- <dd><p><code>Integer->mask</code> returns a mask of type <var>type</var> that contains
- all the possible elements <var>e</var> of the type <var>type</var> such that
- the bit at <var>e</var>’s index is set. <code>List->mask</code> returns a mask
- whose type is <var>type</var> containing all of the elements in the list
- <var>elts</var>.
- </p></dd></dl>
- <span id="Masks"></span><h4 class="subsection">6.1.2 Masks</h4>
- <dl>
- <dt id="index-mask_002d_003einteger">procedure: <strong>mask->integer</strong> <em>mask --> integer</em></dt>
- <dt id="index-mask_002d_003elist">procedure: <strong>mask->list</strong> <em>mask --> element-list</em></dt>
- <dd><p><code>Mask->integer</code> returns the integer bit set that <var>mask</var> uses
- to represent the element set. <code>Mask->list</code> returns a list of all
- the elements that <var>mask</var> contains.
- </p></dd></dl>
- <dl>
- <dt id="index-mask_002dmember_003f">procedure: <strong>mask-member?</strong> <em>mask elt --> boolean</em></dt>
- <dt id="index-mask_002dset">procedure: <strong>mask-set</strong> <em>mask elt … --> mask</em></dt>
- <dt id="index-mask_002dclear">procedure: <strong>mask-clear</strong> <em>mask elt … --> mask</em></dt>
- <dd><p><code>Mask-member?</code> returns true if <var>elt</var> is a member of the mask
- <var>mask</var>, or <code>#f</code> if not. <code>Mask-set</code> returns a mask with
- all the elements in <var>mask</var> as well as each <var>elt</var> ….
- <code>Mask-clear</code> returns a mask with all the elements in <var>mask</var>
- but with none of <var>elt</var> ….
- </p></dd></dl>
- <dl>
- <dt id="index-mask_002dunion">procedure: <strong>mask-union</strong> <em>mask<sub>1</sub> mask<sub>2</sub> … --> mask</em></dt>
- <dt id="index-mask_002dintersection">procedure: <strong>mask-intersection</strong> <em>mask<sub>1</sub> mask<sub>2</sub> … --> mask</em></dt>
- <dt id="index-mask_002dsubtract">procedure: <strong>mask-subtract</strong> <em>mask<sub>a</sub> mask<sub>b</sub> --> mask</em></dt>
- <dt id="index-mask_002dnegate">procedure: <strong>mask-negate</strong> <em>mask --> mask</em></dt>
- <dd><p>Set operations on masks. <code>Mask-union</code> returns a mask containing
- every element that is a member of any one of its arguments.
- <code>Mask-intersection</code> returns a mask containing every element that
- is a member of every one of its arguments. <code>Mask-subtract</code>
- returns a mask of every element that is in <var>mask<sub>a</sub></var> but not
- also in <var>mask<sub>b</sub></var>. <code>Mask-negate</code> returns a mask whose
- members are every possible element of <var>mask</var>’s type that is not in
- <var>mask</var>.
- </p></dd></dl>
- <hr>
- <span id="Enumerated_002ffinite-types-and-sets"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Enumerated_002ffinite-types-and-sets-1"></span><h3 class="section">6.2 Enumerated/finite types and sets</h3>
- <p><i>(This section was derived from work copyrighted ©
- 1993–2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
- </p>
- <span id="index-finite_002dtypes"></span>
- <span id="index-enum_002dsets"></span>
- <p>The structure <code>finite-types</code> has two macros for defining
- <em>finite</em> or <em>enumerated record types</em>. These are record types
- for which there is a fixed set of instances, all of which are created
- at the same time as the record type itself. Also, the structure
- <code>enum-sets</code> has several utilities for building sets of the
- instances of those types, although it is generalized beyond the
- built-in enumerated/finite type device. There is considerable overlap
- between the <a href="#Boxed-bitwise_002dinteger-masks">boxed bitwise-integer
- mask library</a> and the enumerated set facility.
- </p>
- <span id="Enumerated_002ffinite-types"></span><h4 class="subsection">6.2.1 Enumerated/finite types</h4>
- <dl>
- <dt id="index-define_002denumerated_002dtype">syntax: <strong>define-enumerated-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-enumerated-type <var>dispatcher</var> <var>type</var>
- <var>predicate</var>
- <var>instance-vector</var>
- <var>name-accessor</var>
- <var>index-accessor</var>
- (<var>instance-name</var>
- …))</pre></div>
- <p>This defines a new record type, to which <var>type</var> is bound, with as
- many instances as there are <var>instance-name</var>s. <var>Predicate</var> is
- defined to be the record type’s predicate. <var>Instance-vector</var> is
- defined to be a vector containing the instances of the type in the same
- order as the <var>instance-name</var> list. <var>Dispatcher</var> is defined to
- be a macro of the form (<var>dispatcher</var> <var>instance-name</var>); it
- evaluates to the instance with the given name, which is resolved at
- macro-expansion time. <var>Name-accessor</var> & <var>index-accessor</var> are
- defined to be unary procedures that return the symbolic name & index
- into the instance vector, respectively, of the new record type’s
- instances.
- </p>
- <p>For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(define-enumerated-type colour :colour
- colour?
- colours
- colour-name
- colour-index
- (black white purple maroon))
- (colour-name (vector-ref colours 0)) ⇒ black
- (colour-name (colour white)) ⇒ white
- (colour-index (colour purple)) ⇒ 2</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-define_002dfinite_002dtype">syntax: <strong>define-finite-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-finite-type <var>dispatcher</var> <var>type</var>
- (<var>field-tag</var> …)
- <var>predicate</var>
- <var>instance-vector</var>
- <var>name-accessor</var>
- <var>index-accessor</var>
- (<var>field-tag</var> <var>accessor</var> [<var>modifier</var>])
- …
- ((<var>instance-name</var> <var>field-value</var> …)
- …))</pre></div>
- <p>This is like <code>define-enumerated-type</code>, but the instances can also
- have added fields beyond the name and the accessor. The first list of
- field tags lists the fields that each instance is constructed with, and
- each instance is constructed by applying the unnamed constructor to the
- initial field values listed. Fields not listed in the first field tag
- list must be assigned later.
- </p>
- <p>For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(define-finite-type colour :colour
- (red green blue)
- colour?
- colours
- colour-name
- colour-index
- (red colour-red)
- (green colour-green)
- (blue colour-blue)
- ((black 0 0 0)
- (white 255 255 255)
- (purple 160 32 240)
- (maroon 176 48 96)))
- (colour-name (colour black)) ⇒ black
- (colour-name (vector-ref colours 1)) ⇒ white
- (colour-index (colour purple)) ⇒ 2
- (colour-red (colour maroon)) ⇒ 176</pre></div>
- </dd></dl>
- <span id="Sets-over-enumerated-types"></span><h4 class="subsection">6.2.2 Sets over enumerated types</h4>
- <dl>
- <dt id="index-define_002denum_002dset_002dtype">syntax: <strong>define-enum-set-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-enum-set-type <var>set-syntax</var> <var>type</var>
- <var>predicate</var>
- <var>list->x-set</var>
- <var>element-syntax</var>
- <var>element-predicate</var>
- <var>element-vector</var>
- <var>element-index</var>)</pre></div>
- <p>This defines <var>set-syntax</var> to be a syntax for constructing sets,
- <var>type</var> to be an object that represents the type of enumerated sets,
- <var>predicate</var> to be a predicate for those sets, and
- <var>list->x-set</var> to be a procedure that converts a list of elements
- into a set of the new type.
- </p>
- <p><var>Element-syntax</var> must be the name of a macro for constructing set
- elements from names (akin to the <var>dispatcher</var> argument to the
- <code>define-enumerated-type</code> & <code>define-finite-type</code> forms).
- <var>Element-predicate</var> must be a predicate for the element type,
- <var>element-vector</var> a vector of all values of the element type, and
- <var>element-index</var> a procedure that returns the index of an element
- within <var>element-vector</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-enum_002dset_002d_003elist">procedure: <strong>enum-set->list</strong> <em>enum-set --> element list</em></dt>
- <dt id="index-enum_002dset_002dmember_003f">procedure: <strong>enum-set-member?</strong> <em>enum-set element --> boolean</em></dt>
- <dt id="index-enum_002dset_003d_003f">procedure: <strong>enum-set=?</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --> boolean</em></dt>
- <dt id="index-enum_002dset_002dunion">procedure: <strong>enum-set-union</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --> enum-set</em></dt>
- <dt id="index-enum_002dset_002dintersection">procedure: <strong>enum-set-intersection</strong> <em>enum-set<sub>a</sub> enum-set<sub>b</sub> --> enum-set</em></dt>
- <dt id="index-enum_002dset_002dnegation">procedure: <strong>enum-set-negation</strong> <em>enum-set --> enum-set</em></dt>
- <dd><p><code>Enum-set->list</code> returns a list of elements within <var>enum-set</var>.
- <code>Enum-set-member?</code> tests whether <var>element</var> is a member of
- <var>enum-set</var>. <code>Enum-set=?</code> tests whether two enumerated sets
- are equal, <i>i.e.</i> contain all the same elements. The other procedures
- perform standard set algebra operations on enumerated sets. It is an
- error to pass an element that does not satisfy <var>enum-set</var>’s
- predicate to <code>enum-set-member?</code> or to pass two enumerated sets of
- different types to <code>enum-set=?</code> or the enumerated set algebra
- operators.
- </p></dd></dl>
- <p>Here is a simple example of enumerated sets built atop the enumerated
- types described in the previous section:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-enumerated-type colour :colour
- colour?
- colours
- colour-name
- colour-index
- (red blue green))
- (define-enum-set-type colour-set :colour-set
- colour-set?
- list->colour-set
- colour colour? colours colour-index)
- (enum-set->list (colour-set red blue))
- ⇒ (#{Colour red} #{Colour blue})
- (enum-set->list (enum-set-negation (colour-set red blue)))
- ⇒ (#{Colour green})
- (enum-set-member? (colour-set red blue) (colour blue))
- ⇒ #t</pre></div>
- <hr>
- <span id="Macros-for-writing-loops"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Macros-for-writing-loops-1"></span><h3 class="section">6.3 Macros for writing loops</h3>
- <p><i>(This section was derived from work copyrighted ©
- 1993–2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
- </p>
- <p><span id="index-reduce-2"></span>
- <code>Iterate</code> & <code>reduce</code> are extensions of named-<code>let</code> for
- writing loops that walk down one or more sequences, such as the
- elements of a list or vector, the characters read from a port, or an
- arithmetic series. Additional sequences can be defined by the user.
- <code>Iterate</code> & <code>reduce</code> are exported by the structure
- <code>reduce</code>.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Main-looping-macros" accesskey="1">Main looping macros</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Sequence-types" accesskey="2">Sequence types</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Synchronous-sequences" accesskey="3">Synchronous sequences</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Examples" accesskey="4">Examples</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Defining-sequence-types" accesskey="5">Defining sequence types</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Loop-macro-expansion" accesskey="6">Loop macro expansion</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Main-looping-macros"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Main-looping-macros-1"></span><h4 class="subsection">6.3.1 Main looping macros</h4>
- <dl>
- <dt id="index-iterate">syntax: <strong>iterate</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(iterate <var>loop-name</var> ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> …)
- …)
- ((<var>state-var</var> <var>init</var>)
- …)
- <var>body</var>
- [<var>tail-exp</var>])</pre></div>
- <p><code>Iterate</code> steps the <var>elt-var</var>s in parallel through the
- sequences, while each <var>state-var</var> has the corresponding <var>init</var>
- for the first iteration and later values supplied by the body. If any
- sequence has reached the limit, the value of the <code>iterate</code>
- expression is the value of <var>tail-exp</var>, if present, or the current
- values of the <var>state-var</var>s, returned as multiple values. If no
- sequence has reached its limit, <var>body</var> is evaluated and either
- calls <var>loop-name</var> with new values for the <var>state-var</var>s or
- returns some other value(s).
- </p>
- <p>The <var>loop-name</var> and the <var>state-var</var>s & <var>init</var>s behave
- exactly as in named-<code>let</code>, in that <var>loop-name</var> is bound only
- in the scope of <var>body</var>, and each <var>init</var> is evaluated parallel
- in the enclosing scope of the whole expression. Also, the arguments
- to the sequence constructors will be evaluated in the enclosing scope
- of the whole expression, or in an extension of that scope peculiar to
- the sequence type. The named-<code>let</code> expression
- </p>
- <div class="lisp">
- <pre class="lisp">(let <var>loop-name</var> ((<var>state-var</var> <var>init</var>) …)
- <var>body</var>
- …)</pre></div>
- <p>is equivalent to an iterate expression with no sequences (and with an
- explicit <code>let</code> wrapped around the body expressions to take care of
- any internal definitions):
- </p>
- <div class="lisp">
- <pre class="lisp">(iterate <var>loop-name</var> ()
- ((<var>state-var</var> <var>init</var>) …)
- (let () <var>body</var> …))</pre></div>
- <p>The <var>seq-type</var>s are keywords (actually, macros of a particular
- form, which makes it easy to add additional types of sequences; see
- below). Examples are <code>list*</code>, which walks down the elements of a
- list, and <code>vector*</code>, which does the same for vectors. For each
- iteration, each <var>elt-var</var> is bound to the next element of the
- sequence. The <var>arg</var>s are supplied to the sequence processors as
- other inputs, such as the list or vector to walk down.
- </p>
- <p>If there is a <var>tail-exp</var>, it is evaluated when the end of one or
- more sequences is reached. If the body does not call <var>loop-name</var>,
- however, the <var>tail-exp</var> is not evaluated. Unlike named-<code>let</code>,
- the behaviour of a non-tail-recursive call to <var>loop-name</var> is
- unspecified, because iterating down a sequence may involve side
- effects, such as reading characters from a port.
- </p></dd></dl>
- <dl>
- <dt id="index-reduce-1">syntax: <strong>reduce</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(reduce ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> …)
- …)
- ((<var>state-var</var> <var>init</var>)
- …)
- <var>body</var>
- [<var>tail-exp</var>])</pre></div>
- <p>If an <code>iterate</code> expression is not meant to terminate before a
- sequence has reached its end, the body will always end with a tail call
- to <var>loop-name</var>. <code>Reduce</code> is a convenient macro that makes
- this common case explicit. The syntax of <code>reduce</code> is the same as
- that of <code>iterate</code>, except that there is no <var>loop-name</var>, and
- the body updates the state variables by returning multiple values in
- the stead of passing the new values to <var>loop-name</var>: the body must
- return as many values as there are state variables. By special
- dispension, if there are no state variables, then the body may return
- any number of values, all of which are ignored.
- </p>
- <p>The value(s) returned by an instance of <code>reduce</code> is (are) the
- value(s) returned by the <var>tail-exp</var>, if present, or the current
- value(s) of the state variables when the end of one or more sequences
- is reached.
- </p>
- <p>A <code>reduce</code> expression can be rewritten as an equivalent
- <code>iterate</code> expression by adding a <var>loop-name</var> and a wrapper for
- the body that calls the <var>loop-name</var>:
- </p>
- <div class="lisp">
- <pre class="lisp">(iterate loop ((<var>seq-type</var> <var>elt-var</var> <var>arg</var> …)
- …)
- ((<var>state-var</var> <var>init</var>)
- …)
- (call-with-values (lambda () <var>body</var>)
- loop)
- [<var>tail-exp</var>])</pre></div>
- </dd></dl>
- <hr>
- <span id="Sequence-types"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Sequence-types-1"></span><h4 class="subsection">6.3.2 Sequence types</h4>
- <dl>
- <dt id="index-list_002a">sequence type: <strong>list*</strong> <em>elt-var list</em></dt>
- <dt id="index-vector_002a">sequence type: <strong>vector*</strong> <em>elt-var vector</em></dt>
- <dt id="index-string_002a">sequence type: <strong>string*</strong> <em>elt-var string</em></dt>
- <dt id="index-count_002a">sequence type: <strong>count*</strong> <em>elt-var start [end [step]]</em></dt>
- <dt id="index-input_002a">sequence type: <strong>input*</strong> <em>elt-var input-port reader-proc</em></dt>
- <dt id="index-stream_002a">sequence type: <strong>stream*</strong> <em>elt-var proc initial-seed</em></dt>
- <dd><p>For lists, vectors, & strings, the <var>elt-var</var> is bound to the
- successive elements of the list or vector, or the successive characters
- of the string.
- </p>
- <p>For <code>count*</code>, the <var>elt-var</var> is bound to the elements of the
- sequence <code>start, start + step, start + 2*step, …, end</code>,
- inclusive of <var>start</var> and exclusive of <var>end</var>. The default
- <var>step</var> is <code>1</code>, and the sequence does not terminate if no
- <var>end</var> is given or if there is no <var>N</var> > 0 such that <var>end</var> =
- <var>start</var> + <var>N</var><var>step</var>. (<code>=</code> is used to test for
- termination.) For example, <code>(count* i 0 -1)</code> does not terminate
- because it begins past the <var>end</var> value, and <code>(count* i 0 1 2)</code>
- does not terminate because it skips over the <var>end</var> value.
- </p>
- <p>For <code>input*</code>, the elements are the results of successive
- applications of <var>reader-proc</var> to <var>input-port</var>. The sequence
- ends when the <var>reader-proc</var> returns an end-of-file object, <i>i.e.</i>
- a value that satisfies <code>eof-object?</code>.
- </p>
- <p>For <code>stream*</code>, the <var>proc</var> receives the current seed as an
- argument and must return two values, the next value of the sequence &
- the next seed. If the new seed is <code>#f</code>, then the previous element
- was the last one. For example, <code>(list* elt list)</code> is the same as
- </p>
- <div class="lisp">
- <pre class="lisp">(stream* elt
- (lambda (list)
- (if (null? list)
- (values 'ignored #f)
- (values (car list) (cdr list))))
- list)</pre></div>
- </dd></dl>
- <hr>
- <span id="Synchronous-sequences"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Synchronous-sequences-1"></span><h4 class="subsection">6.3.3 Synchronous sequences</h4>
- <p>When using the sequence types described above, a loop terminates when
- any of its sequences terminate. To help detect bugs, it is useful to
- also have sequence types that check whether two or more sequences end
- on the same iteration. For this purpose, there is a second set of
- sequence types called <em>synchronous sequences</em>. Synchronous
- sequences are like ordinary asynchronous sequences in every respect
- except that they cause an error to be signalled if a loop is terminated
- by a synchronous sequence and some other synchronous sequence did not
- reach its end on the same iteration.
- </p>
- <p>Sequences are checked for termination in order from left to right, and
- if a loop is terminated by an asynchronous sequence no further checking
- is done.
- </p>
- <dl>
- <dt id="index-list_0025">synchronous sequence type: <strong>list%</strong> <em>elt-var list</em></dt>
- <dt id="index-vector_0025">synchronous sequence type: <strong>vector%</strong> <em>elt-var vector</em></dt>
- <dt id="index-string_0025">synchronous sequence type: <strong>string%</strong> <em>elt-var string</em></dt>
- <dt id="index-count_0025">synchronous sequence type: <strong>count%</strong> <em>elt-var start end [step]</em></dt>
- <dt id="index-input_0025">synchronous sequence type: <strong>input%</strong> <em>elt-var input-port reader-proc</em></dt>
- <dt id="index-stream_0025">synchronous sequence type: <strong>stream%</strong> <em>elt-var proc initial-seed</em></dt>
- <dd><p>These are all identical to their asynchronous equivalents above, except
- that they are synchronous. Note that <code>count%</code>’s <var>end</var>
- argument is required, unlike <code>count*</code>’s, because it would be
- nonsensical to check for termination of a sequence that does not
- terminate.
- </p></dd></dl>
- <hr>
- <span id="Examples"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Examples-1"></span><h4 class="subsection">6.3.4 Examples</h4>
- <p>Gathering the indices of list elements that answer true to some
- predicate.
- </p>
- <div class="lisp">
- <pre class="lisp">(define (select-matching-items list pred)
- (reduce ((list* elt list)
- (count* i 0))
- ((hits '()))
- (if (pred elt)
- (cons i hits)
- hits)
- (reverse hits)))</pre></div>
- <p>Finding the index of an element of a list that satisfies a predicate.
- </p>
- <div class="lisp">
- <pre class="lisp">(define (find-matching-item list pred)
- (iterate loop ((list* elt list)
- (count* i 0))
- () ; no state variables
- (if (pred elt)
- i
- (loop))))</pre></div>
- <p>Reading one line of text from an input port.
- </p>
- <div class="lisp">
- <pre class="lisp">(define (read-line port)
- (iterate loop ((input* c port read-char))
- ((chars '()))
- (if (char=? c #\newline)
- (list->string (reverse chars))
- (loop (cons c chars)))
- (if (null? chars)
- (eof-object) ; from the PRIMITIVES structure
- (list->string (reverse chars)))))</pre></div>
- <p>Counting the lines in a file. This must be written in a way other than
- with <code>count*</code> because it needs the value of the count after the
- loop has finished, but the count variable would not be bound then.
- </p>
- <div class="lisp">
- <pre class="lisp">(define (line-count filename)
- (call-with-input-file filename
- (lambda (inport)
- (reduce ((input* line inport read-line))
- ((count 0))
- (+ count 1)))))</pre></div>
- <hr>
- <span id="Defining-sequence-types"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Defining-sequence-types-1"></span><h4 class="subsection">6.3.5 Defining sequence types</h4>
- <p>The sequence types are object-oriented macros similar to enumerations.
- An asynchronous sequence macro needs to supply three values: <code>#f</code>
- to indicate that it is not synchronous, a list of state variables and
- their initializers, and the code for one iteration. The first two
- methods are written in continuation-passing style: they take another
- macro and argument to which to pass their result. See [Friedman 00]
- for more details on the theory behind how CPS macros work. The
- <code>sync</code> method receives no extra arguments. The <code>state-vars</code>
- method is passed a list of names that will be bound to the arguments of
- the sequence. The final method, for stepping the sequence forward, is
- passed the list of names bound to the arguments and the list of state
- variables. In addition, there is a variable to be bound to the next
- element of the sequence, the body expression for the loop, and an
- expression for terminating the loop.
- </p>
- <p>As an example, the definition of <code>list*</code> is:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax list*
- (syntax-rules (SYNC STATE-VARS STEP)
- ((LIST* SYNC (next more))
- (next #F more))
- ((LIST* STATE-VARS (start-list) (next more))
- (next ((list-var start-list)) more))
- ((LIST* STEP (start-list) (list-var) value-var loop-body tail-exp)
- (IF (NULL? list-var)
- tail-exp
- (LET ((value-var (CAR list-var))
- (list-var (CDR list-var)))
- loop-body)))))</pre></div>
- <p>Synchronized sequences are similar, except that they need to provide a
- termination test to be used when some other synchronized method
- terminates the loop. To continue the example:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-syntax list%
- (syntax-rules (SYNC DONE)
- ((LIST% SYNC (next more))
- (next #T more))
- ((LIST% DONE (start-list) (list-var))
- (NULL? list-var))
- ((LIST% . anything-else)
- (LIST* . anything-else))))</pre></div>
- <hr>
- <span id="Loop-macro-expansion"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Loop-macro-expansion-1"></span><h4 class="subsection">6.3.6 Loop macro expansion</h4>
- <p>Here is an example of the expansion of the <code>reduce</code> macro:
- </p>
- <div class="lisp">
- <pre class="lisp">(reduce ((list* x '(1 2 3)))
- ((r '()))
- (cons x r))
- →
- (let ((final (lambda (r) (values r)))
- (list '(1 2 3))
- (r '()))
- (let loop ((list list) (r r))
- (if (null? list)
- (final r)
- (let ((x (car list))
- (list (cdr list)))
- (let ((continue (lambda (r)
- (loop list r))))
- (continue (cons x r)))))))</pre></div>
- <p>The only mild inefficiencies in this code are the <code>final</code> &
- <code>continue</code> procedures, both of which could trivially be
- substituted in-line. The macro expander could easily perform the
- substitution for <code>continue</code> when there is no explicit proceed
- variable, as in this case, but not in general.
- </p><hr>
- <span id="Library-data-structures"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Library-data-structures-1"></span><h3 class="section">6.4 Library data structures</h3>
- <p>Scheme48 includes several libraries for a variety of data structures.
- </p>
- <span id="Multi_002ddimensional-arrays"></span><h4 class="subsection">6.4.1 Multi-dimensional arrays</h4>
- <span id="index-arrays"></span>
- <span id="index-arrays-1"></span>
- <p>The <code>arrays</code> structure exports a facility for multi-dimensional
- arrays, based on Alan Bawden’s interface.
- </p>
- <dl>
- <dt id="index-make_002darray">procedure: <strong>make-array</strong> <em>value dimension … --> array</em></dt>
- <dt id="index-array">procedure: <strong>array</strong> <em>dimensions element … --> array</em></dt>
- <dt id="index-copy_002darray">procedure: <strong>copy-array</strong> <em>array … --> array</em></dt>
- <dd><p>Array constructors. <code>Make-array</code> constructs an array with the
- given dimensions, each of which must be an exact, non-negative integer,
- and fills all of the elements with <var>value</var>. <code>Array</code> creates
- an array with the given list of dimensions, which must be a list of
- exact, non-negative integers, and fills it with the given elements in
- row-major order. The number of elements must be equal to the product
- of <var>dimensions</var>. <code>Copy-array</code> constructs an array with the
- same dimensions and contents as <var>array</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-array_003f">procedure: <strong>array?</strong> <em>object --> boolean</em></dt>
- <dd><p>Disjoint type predicate for arrays.
- </p></dd></dl>
- <dl>
- <dt id="index-array_002dshape">procedure: <strong>array-shape</strong> <em>array --> integer-list</em></dt>
- <dd><p>Returns the list of dimensions of <var>array</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-array_002dref">procedure: <strong>array-ref</strong> <em>array index … --> value</em></dt>
- <dt id="index-array_002dset_0021">procedure: <strong>array-set!</strong> <em>array value index … --> unspecified</em></dt>
- <dd><p>Array element dereferencing and assignment. Each <var>index</var> must be
- in the half-open interval [0,<var>d</var>), where <var>d</var> is the respective
- dimension of <var>array</var> corresponding with that index.
- </p></dd></dl>
- <dl>
- <dt id="index-array_002d_003evector">procedure: <strong>array->vector</strong> <em>array --> vector</em></dt>
- <dd><p>Creates a vector of the elements in <var>array</var> in row-major order.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dshared_002darray">procedure: <strong>make-shared-array</strong> <em>array linear-map dimension … --> array</em></dt>
- <dd><p>Creates a new array that shares storage with <var>array</var> and uses the
- procedure <var>linear-map</var> to map indices in the new array to indices in
- <var>array</var>. <var>Linear-map</var> must accept as many arguments as
- <var>dimension</var> …, each of which must be an exact, non-negative
- integer; and must return a list of exact, non-negative integers equal
- in length to the number of dimensions of <var>array</var>, and which must
- be valid indices into <var>array</var>.
- </p></dd></dl>
- <span id="Red_002fblack-search-trees"></span><h4 class="subsection">6.4.2 Red/black search trees</h4>
- <span id="index-binary-search-trees"></span>
- <span id="index-search_002dtrees"></span>
- <p>Along with hash tables for general object maps, Scheme48 also provides
- red/black binary search trees generalized across key equality
- comparison & ordering functions, as opposed to key equality comparison
- & hash functions with hash tables. These names are exported by the
- <code>search-trees</code> structure.
- </p>
- <dl>
- <dt id="index-make_002dsearch_002dtree">procedure: <strong>make-search-tree</strong> <em>key= key< --> search-tree</em></dt>
- <dt id="index-search_002dtree_003f">procedure: <strong>search-tree?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-search-tree</code> creates a new search tree with the given key
- equality comparison & ordering functions. <code>Search-tree?</code> is the
- disjoint type predicate for red/black binary search trees.
- </p></dd></dl>
- <dl>
- <dt id="index-search_002dtree_002dref">procedure: <strong>search-tree-ref</strong> <em>search-tree key --> value or <code>#f</code></em></dt>
- <dt id="index-search_002dtree_002dset_0021">procedure: <strong>search-tree-set!</strong> <em>search-tree key value --> unspecified</em></dt>
- <dt id="index-search_002dtree_002dmodify_0021">procedure: <strong>search-tree-modify!</strong> <em>search-tree key modifier --> unspecified</em></dt>
- <dd><p><code>Search-tree-ref</code> returns the value associated with <var>key</var> in
- <var>search-tree</var>, or <code>#f</code> if no such association exists.
- <code>Search-tree-set!</code> assigns the value of an existing association in
- <var>search-tree</var> for <var>key</var> to be <var>value</var>, if the association
- already exists; or, if not, it creates a new association with the given
- key and value. If <var>value</var> is <code>#f</code>, however, any association
- is removed. <code>Search-tree-modify!</code> modifies the association in
- <var>search-tree</var> for <var>key</var> by applying <var>modifier</var> to the
- previous value of the association. If no association previously
- existed, one is created whose key is <var>key</var> and whose value is the
- result of applying <var>modifier</var> to <code>#f</code>. If <var>modifier</var>
- returns <code>#f</code>, the association is removed. This is equivalent to
- <code>(search-tree-set! <var>search-tree</var> <var>key</var> (<var>modifier</var>
- (search-tree-ref <var>search-tree</var> <var>key</var>)))</code>, but it is implemented
- more efficiently.
- </p></dd></dl>
- <dl>
- <dt id="index-search_002dtree_002dmax">procedure: <strong>search-tree-max</strong> <em>search-tree --> value or <code>#f</code></em></dt>
- <dt id="index-search_002dtree_002dmin">procedure: <strong>search-tree-min</strong> <em>search-tree --> value or <code>#f</code></em></dt>
- <dt id="index-pop_002dsearch_002dtree_002dmax_0021">procedure: <strong>pop-search-tree-max!</strong> <em>search-tree --> value or <code>#f</code></em></dt>
- <dt id="index-pop_002dsearch_002dtree_002dmin_0021">procedure: <strong>pop-search-tree-min!</strong> <em>search-tree --> value or <code>#f</code></em></dt>
- <dd><p>These all return two values: the key & value for the association in
- <var>search-tree</var> whose key is the maximum or minimum of the tree.
- <code>Search-tree-max</code> and <code>search-tree-min</code> do not remove the
- association from <var>search-tree</var>; <code>pop-search-tree-max!</code> and
- <code>pop-search-tree-min!</code> do. If <var>search-tree</var> is empty, these
- all return the two values <code>#f</code> and <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-walk_002dsearch_002dtree">procedure: <strong>walk-search-tree</strong> <em>proc search-tree --> unspecified</em></dt>
- <dd><p>This applies <var>proc</var> to two arguments, the key & value, for every
- association in <var>search-tree</var>.
- </p></dd></dl>
- <span id="Sparse-vectors"></span><h4 class="subsection">6.4.3 Sparse vectors</h4>
- <span id="index-resizable-vectors"></span>
- <span id="index-growing-vectors"></span>
- <span id="index-sparse_002dvectors"></span>
- <p>Sparse vectors, exported by the structure <code>sparse-vectors</code>, are
- vectors that grow as large as necessary without leaving large, empty
- spaces in the vector. They are implemented as trees of subvectors.
- </p>
- <dl>
- <dt id="index-make_002dsparse_002dvector">procedure: <strong>make-sparse-vector</strong> <em>--> sparse-vector</em></dt>
- <dd><p>Sparse vector constructor.
- </p></dd></dl>
- <dl>
- <dt id="index-sparse_002dvector_002dref">procedure: <strong>sparse-vector-ref</strong> <em>sparse-vector index --> value or <code>#f</code></em></dt>
- <dt id="index-sparse_002dvector_002dset_0021">procedure: <strong>sparse-vector-set!</strong> <em>sparse-vector index value --> unspecified</em></dt>
- <dd><p>Sparse vector element accessor and modifier. In the case of
- <code>sparse-vector-ref</code>, if <var>index</var> is beyond the highest index
- that was inserted into <var>sparse-vector</var>, it returns <code>#f</code>; if
- <code>sparse-vector-set!</code> is passed an index beyond what was already
- assigned, it simply extends the vector.
- </p></dd></dl>
- <dl>
- <dt id="index-sparse_002dvector_002d_003elist">procedure: <strong>sparse-vector->list</strong> <em>sparse-vector --> list</em></dt>
- <dd><p>Creates a list of the elements in <var>sparse-vector</var>. Elements that
- uninitialized gaps comprise are denoted by <code>#f</code> in the list.
- </p></dd></dl>
- <hr>
- <span id="I_002fO-extensions"></span><div class="header">
- <p>
- Next: <a href="#TCP-_0026-UDP-sockets" accesskey="n" rel="next">TCP & 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="I_002fO-extensions-1"></span><h3 class="section">6.5 I/O extensions</h3>
- <span id="index-extended_002dports"></span>
- <p>These facilities are all exported from the <code>extended-ports</code>
- structure.
- </p>
- <span id="index-ports-with-line-_0026-column-numbers"></span>
- <span id="index-line_002d-_0026-column_002dtracking-ports"></span>
- <span id="index-ports-that-track-line-_0026-column-numbers"></span>
- <p>Tracking ports track the line & column number that they are on.
- </p>
- <dl>
- <dt id="index-make_002dtracking_002dinput_002dport">procedure: <strong>make-tracking-input-port</strong> <em>sub-port --> input-port</em></dt>
- <dt id="index-make_002dtracking_002doutput_002dport">procedure: <strong>make-tracking-output-port</strong> <em>sub-port --> output-port</em></dt>
- <dd><p>Tracking port constructors. These simply create wrapper ports around
- <var>sub-port</var> that track the line & column numbers.
- </p></dd></dl>
- <dl>
- <dt id="index-current_002drow">procedure: <strong>current-row</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dt id="index-current_002dcolumn">procedure: <strong>current-column</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dd><p>Accessors for line (row) & column number information. If <var>port</var> is
- a not a tracking port, these simply return <code>#f</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-fresh_002dline">procedure: <strong>fresh-line</strong> <em>port --> unspecified</em></dt>
- <dd><p>This writes a newline to port with <code>newline</code>, unless it can be
- determined that the previous character was a newline — that is, if
- <code>(current-column <var>port</var>)</code> does not evaluate to zero.
- </p></dd></dl>
- <span id="index-character-source-input-ports"></span>
- <span id="index-character-sink-output-ports"></span>
- <span id="index-simple-character-source-input-ports"></span>
- <span id="index-simple-character-sink-output-ports"></span>
- <p>These are ports based on procedures that produce and consume single
- characters at a time.
- </p>
- <dl>
- <dt id="index-char_002dsource_002d_003einput_002dport">procedure: <strong>char-source->input-port</strong> <em>char-producer [readiness-tester closer] --> input-port</em></dt>
- <dt id="index-char_002dsink_002d_003eoutput_002dport">procedure: <strong>char-sink->output-port</strong> <em>char-consumer --> output-port</em></dt>
- <dd><p><code>Char-source->input-port</code> creates an input port that calls
- <var>char-producer</var> with zero arguments when a character is read from
- it. If <var>readiness-tester</var> is present, it is used for the
- <code>char-ready?</code> operation on the resulting port; likewise with
- <var>closer</var> and <code>close-input-port</code>.
- <code>Char-sink->output-port</code> creates an output port that calls
- <var>char-consumer</var> for every character written to it.
- </p></dd></dl>
- <span id="index-string-ports"></span>
- <span id="index-string-input-ports"></span>
- <span id="index-string-output-ports"></span>
- <span id="index-input-ports-from-strings"></span>
- <span id="index-output-ports-to-strings"></span>
- <p>Scheme48 also provides ports that collect and produce output to and
- from strings.
- </p>
- <dl>
- <dt id="index-make_002dstring_002dinput_002dport">procedure: <strong>make-string-input-port</strong> <em>string --> input-port</em></dt>
- <dd><p>Constructs an input port whose contents are read from <var>string</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dstring_002doutput_002dport">procedure: <strong>make-string-output-port</strong> <em>--> output-port</em></dt>
- <dt id="index-string_002doutput_002dport_002doutput">procedure: <strong>string-output-port-output</strong> <em>string-port --> string</em></dt>
- <dt id="index-call_002dwith_002dstring_002doutput_002dport">procedure: <strong>call-with-string-output-port</strong> <em>receiver --> string</em></dt>
- <dd><p><code>Make-string-output-port</code> makes an output port that collects its
- output in a string. <code>String-output-port-output</code> returns the
- string that <var>string-port</var> collected.
- <code>Call-with-string-output-port</code> creates a string output port,
- applies <var>receiver</var> to it, and returns the string that the string
- output port collected.
- </p></dd></dl>
- <span id="index-limiting-output"></span>
- <p>Finally, there is a facility for writing only a limited quantity of
- output to a given port.
- </p>
- <dl>
- <dt id="index-limit_002doutput">procedure: <strong>limit-output</strong> <em>port count receiver --> unspecified</em></dt>
- <dd><p><code>Limit-output</code> applies <var>receiver</var> to a port that will write at
- most <var>count</var> characters to <var>port</var>.
- </p></dd></dl>
- <hr>
- <span id="TCP-_0026-UDP-sockets"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="TCP-_0026-UDP-sockets-1"></span><h3 class="section">6.6 TCP & UDP sockets</h3>
- <span id="index-networking"></span>
- <span id="index-sockets"></span>
- <span id="index-udp_002dsockets"></span>
- <p>Scheme48 provides a simple facility for TCP & UDP sockets. Both the
- structures <code>sockets</code> and <code>udp-sockets</code> export several general
- socket-related procedures:
- </p>
- <dl>
- <dt id="index-close_002dsocket">procedure: <strong>close-socket</strong> <em>socket --> unspecified</em></dt>
- <dt id="index-socket_002dport_002dnumber">procedure: <strong>socket-port-number</strong> <em>socket --> integer</em></dt>
- <dt id="index-get_002dhost_002dname">procedure: <strong>get-host-name</strong> <em>--> string</em></dt>
- <dd><p><code>Close-socket</code> closes <var>socket</var>, which may be any type of
- socket. <code>Socket-port-number</code> returns the port number through
- which <var>socket</var> is communicating. <code>Get-host-name</code> returns the
- network name of the current machine.
- </p>
- <p><strong>Note:</strong> Programmers should be wary of storing the result of a
- call to <code>get-host-name</code> in a dumped heap image, because the actual
- machine’s host name may vary from invocation to invocation of the
- Scheme48 VM on that image, since heap images may be resumed on multiple
- different machines.
- </p></dd></dl>
- <span id="TCP-sockets"></span><h4 class="subsection">6.6.1 TCP sockets</h4>
- <span id="index-sockets-1"></span>
- <p>The <code>sockets</code> structure provides simple TCP socket facilities.
- </p>
- <dl>
- <dt id="index-open_002dsocket">procedure: <strong>open-socket</strong> <em>[port-number] --> socket</em></dt>
- <dt id="index-socket_002daccept">procedure: <strong>socket-accept</strong> <em>socket --> [input-port output-port]</em></dt>
- <dd><p>The server interface. <code>Open-socket</code> creates a socket that listens
- on <var>port-number</var>, which defaults to a random number above 1024.
- <code>Socket-accept</code> blocks until there is a client waiting to be
- accepted, at which point it returns two values: an input port & an
- output port to send & receive data to & from the client.
- </p></dd></dl>
- <dl>
- <dt id="index-socket_002dclient">procedure: <strong>socket-client</strong> <em>host-name port-number --> [input-port output-port]</em></dt>
- <dd><p>Connects to the server at <var>port-number</var> denoted by the machine name
- <var>host-name</var> and returns an input port and an output port for
- sending & receiving data to & from the server. <code>Socket-client</code>
- blocks the current thread until the server accepts the connection
- request.
- </p></dd></dl>
- <span id="UDP-sockets"></span><h4 class="subsection">6.6.2 UDP sockets</h4>
- <span id="index-udp_002dsockets-1"></span>
- <p>The <code>udp-sockets</code> structure defines a UDP socket facility.
- </p>
- <dl>
- <dt id="index-open_002dudp_002dsocket">procedure: <strong>open-udp-socket</strong> <em>[port-number] --> socket</em></dt>
- <dd><p>Opens a UDP socket on <var>port-number</var>, or a random port number if
- none was passed. <code>Open-udp-socket</code> returns two values: an input
- UDP socket and an output UDP socket.
- </p></dd></dl>
- <dl>
- <dt id="index-udp_002dsend">procedure: <strong>udp-send</strong> <em>socket address buffer count --> count-sent</em></dt>
- <dt id="index-udp_002dreceive">procedure: <strong>udp-receive</strong> <em>socket buffer --> [count-received remote-address]</em></dt>
- <dd><p><code>Udp-send</code> attempts to send <var>count</var> elements from the string
- or byte vector <var>buffer</var> from the output UDP socket <var>socket</var> to
- the UDP address <var>address</var>, and returns the number of octets it
- successfully sent. <code>Udp-receive</code> receives a UDP message from
- <var>socket</var>, reading it into <var>buffer</var> destructively. It returns
- two values: the number of octets read into <var>buffer</var> and the address
- whence the octets came.
- </p></dd></dl>
- <dl>
- <dt id="index-lookup_002dudp_002daddress">procedure: <strong>lookup-udp-address</strong> <em>name port --> udp-address</em></dt>
- <dt id="index-udp_002daddress_003f">procedure: <strong>udp-address?</strong> <em>object --> boolean</em></dt>
- <dt id="index-udp_002daddress_002daddress">procedure: <strong>udp-address-address</strong> <em>address --> c-byte-vector</em></dt>
- <dt id="index-udp_002daddress_002dport">procedure: <strong>udp-address-port</strong> <em>address --> port-number</em></dt>
- <dt id="index-udp_002daddress_002dhostname">procedure: <strong>udp-address-hostname</strong> <em>address --> string-address</em></dt>
- <dd><p><code>Lookup-udp-address</code> returns a UDP address for the machine name
- <var>name</var> at the port number <var>port</var>. <code>Udp-address?</code> is the
- disjoint type predicate for UDP addresses. <code>Udp-address-address</code>
- returns a byte vector that contains the C representation of
- <var>address</var>, suitable for passing to C with Scheme48’s C FFI.
- <code>Udp-address-port</code> returns the port number of <var>address</var>.
- <code>Udp-address-hostname</code> returns a string representation of the IP
- address of <var>address</var>.
- </p></dd></dl>
- <hr>
- <span id="Common_002dLisp_002dstyle-formatting"></span><div class="header">
- <p>
- Next: <a href="#Library-utilities" accesskey="n" rel="next">Library utilities</a>, Previous: <a href="#TCP-_0026-UDP-sockets" accesskey="p" rel="prev">TCP & UDP sockets</a>, Up: <a href="#Libraries" accesskey="u" rel="up">Libraries</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Common_002dLisp_002dstyle-formatting-1"></span><h3 class="section">6.7 Common-Lisp-style formatting</h3>
- <span id="index-formats"></span>
- <p>Scheme48 provides a simple Common-Lisp-style <code>format</code> facility in
- the <code>formats</code> structure. It does not provide nearly as much
- functionality as Common Lisp, however: the considerable complexity of
- Common Lisp’s <code>format</code> was deliberately avoided because it was
- deemed inconsistent with Scheme48’s design goals. Scheme48’s
- <code>format</code> is suitable for most simple purposes, anyhow.
- </p>
- <dl>
- <dt id="index-format">procedure: <strong>format</strong> <em>port control-string argument … --> unspecified or string</em></dt>
- <dd><p>Prints <var>control-string</var> to <var>port</var>. If, anywhere in
- <var>control-string</var>, the character <code>~</code> (tilde) occurs, the
- following character determines what to print in the place of the tilde
- and following character. Some formatting directives consume arguments
- from <var>argument</var> …. Formatting directive characters are
- case-insensitive. If <var>port</var> is <code>#t</code>, the output is printed to
- to the value of <code>(current-output-port)</code>; if <var>port</var> is false,
- the output is collected in a string and returned.
- </p>
- <p>The complete list of formatting directives:
- </p>
- <dl compact="compact">
- <dt><code>~~</code></dt>
- <dd><p>Prints a single <code>~</code> (tilde), and does not consume an argument.
- </p>
- </dd>
- <dt><code>~A</code></dt>
- <dd><p>Consumes and prints the first remaining argument with <code>display</code>.
- (‘A’ny)
- </p>
- </dd>
- <dt><code>~D</code></dt>
- <dd><p>Consumes and prints the first remaining argument as a decimal number
- using <code>number->string</code>. (‘D’ecimal)
- </p>
- </dd>
- <dt><code>~S</code></dt>
- <dd><p>Consumes and prints the first remaining argument with <code>write</code>.
- (‘S’-expression)
- </p>
- </dd>
- <dt><code>~%</code></dt>
- <dd><p>Prints a newline with <code>newline</code>.
- </p>
- </dd>
- <dt><code>~&</code></dt>
- <dd><p>Prints a newline with <code>newline</code>, unless it can be determined that
- a newline was immediately previously printed to <var>port</var>
- (see <a href="#I_002fO-extensions">I/O extensions</a>).
- </p>
- </dd>
- <dt><code>~?</code></dt>
- <dd><p>Recursively formats. The first remaining argument is consumed and must
- be another control string; the argument directly thereafter is also
- consumed, and it must be a list of arguments corresponding with that
- control string. The control string is formatted with those arguments
- using <code>format</code>.
- </p>
- </dd>
- </dl>
- <p><code>Format</code> examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(format #t "Hello, ~A!~%" "world")
- -| Hello, world!
- -|
- (format #t "Hello~?~S~%" "~A world" '(#\,) '!)
- -| Hello, world!
- -|
- (format #f "~A~A ~A." "cH" "uMBLE" "spuZz")
- ⇒ "cHuMBLE spuZz."
- (let ((x 10) (y .1))
- (format #t "x: ~D~%~&y: ~D~%~&" x y))
- -| x: 10
- -| y: .1</pre></div>
- </dd></dl>
- <hr>
- <span id="Library-utilities"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Library-utilities-1"></span><h3 class="section">6.8 Library utilities</h3>
- <p>Scheme48 provides various miscellaneous library utilities for common
- general-purpose tasks.
- </p>
- <span id="Destructuring"></span><h4 class="subsection">6.8.1 Destructuring</h4>
- <span id="index-S_002dexpression-destructuring"></span>
- <span id="index-destructuring-S_002dexpressions"></span>
- <span id="index-destructuring"></span>
- <p>The <code>destructuring</code> structure exports a form for destructuring
- S-expressions.
- </p>
- <dl>
- <dt id="index-destructure">syntax: <strong>destructure</strong> <em>((pattern value) …) body</em></dt>
- <dd><p>For each <code>(<var>pattern</var> <var>value</var>)</code> pair, binds every name in
- <var>pattern</var> to the corresponding location in the S-expression
- <var>value</var>. For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(destructure (((x . y) (cons 5 3))
- ((#(a b) c) '(#((1 2) 3) (4 5))))
- <var>body</var>)</pre></div>
- <p>binds <var>x</var> to <code>5</code>, <var>y</var> to <code>3</code>, <var>a</var> to
- <code>(1 2)</code>, <var>b</var> to <code>3</code>, and <var>c</var> to <code>(4 5)</code>, in
- <var>body</var>.
- </p></dd></dl>
- <span id="Pretty_002dprinting"></span><h4 class="subsection">6.8.2 Pretty-printing</h4>
- <span id="index-pretty_002dprinting"></span>
- <span id="index-printing"></span>
- <span id="index-pp"></span>
- <p>The <code>pp</code> structure exports a simple pretty-printer.
- </p>
- <dl>
- <dt id="index-p">procedure: <strong>p</strong> <em>object [port] --> unspecified</em></dt>
- <dt id="index-pretty_002dprint">procedure: <strong>pretty-print</strong> <em>object port position --> unspecified</em></dt>
- <dd><p><code>P</code> is a convenient alias for <code>pretty-print</code>; it passes 0 for
- <var>position</var> and the value of <code>(current-output-port)</code> if
- <var>port</var> is not passed. <code>Pretty-print</code> pretty-prints
- <var>object</var> to <var>port</var>, using a left margin of <var>position</var>. For
- example:
- </p>
- <div class="lisp">
- <pre class="lisp">(p '(define (fact n)
- (let loop ((p 1) (c 1))
- (if (> c n) p (loop (* p c) (+ c 1))))))
- -| (define (fact n)
- -| (let loop ((p 1) (c 1))
- -| (if (> c n)
- -| p
- -| (loop (* p c) (+ c 1)))))</pre></div>
- </dd></dl>
- <p>The pretty-printer is somewhat extensible as well:
- </p>
- <dl>
- <dt id="index-define_002dindentation">procedure: <strong>define-indentation</strong> <em>name count --> unspecified</em></dt>
- <dd><p>Sets the number of subforms to be indented past <var>name</var> in
- pretty-printed output to be <var>count</var>. For example:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-indentation 'frobozz 3)
- (p '(frobozz (foo bar baz quux zot) (zot quux baz bar foo)
- (mumble frotz gargle eek) (froomble zargle hrumph)))
- -| (frobozz (foo bar baz quux zot)
- -| (zot quux baz bar foo)
- -| (mumble frotz gargle eek)
- -| (froomble zargle hrumph))</pre></div>
- </dd></dl>
- <span id="Strongly-connected-graph-components"></span><h4 class="subsection">6.8.3 Strongly connected graph components</h4>
- <span id="index-strongly_002dconnected-graph-components"></span>
- <span id="index-graph-algorithms"></span>
- <span id="index-strong"></span>
- <p>The <code>strong</code> structure exports a routine for finding a list of the
- strongly connected components in a graph.
- </p>
- <dl>
- <dt id="index-strongly_002dconnected_002dcomponents">procedure: <strong>strongly-connected-components</strong> <em>vertices to slot set-slot! --> sorted-strong-vertices</em></dt>
- <dd><p>Returns the components of a graph containing vertices from the list
- <var>vertices</var> that are strongly connected, in a reversed topologically
- sorted list. <var>To</var> should be a procedure of one argument, a vertex,
- that returns a list of all vertices that have an edge to its argument.
- <var>Slot</var> & <var>set-slot!</var> should be procedures of one & two
- arguments, respectively, that access & modify arbitrary slots used by
- the algorithm. The slot for every vertex should initially be <code>#f</code>
- before calling <code>strongly-connected-components</code>, and the slots are
- reverted to <code>#f</code> before <code>strongly-connected-components</code>
- returns.
- </p></dd></dl>
- <span id="Nondeterminism"></span><h4 class="subsection">6.8.4 Nondeterminism</h4>
- <span id="index-nondeterminism"></span>
- <span id="index-backtracking"></span>
- <span id="index-amb-operator"></span>
- <span id="index-nondeterminism-1"></span>
- <p>The <code>nondeterminism</code> structure provides a simple nondeterministic
- ambivalence operator, like McCarthy’s <code>AMB</code>, and a couple utilities
- atop it, built with Scheme’s <code>call-with-current-continuation</code>.
- </p>
- <dl>
- <dt id="index-with_002dnondeterminism">procedure: <strong>with-nondeterminism</strong> <em>thunk --> values</em></dt>
- <dd><p>Initializes the nondeterminism system and calls <var>thunk</var>; this
- returns the values <var>thunk</var> returns after then tearing down what was
- set up.
- </p></dd></dl>
- <dl>
- <dt id="index-either">syntax: <strong>either</strong> <em>option … --> value</em></dt>
- <dt id="index-one_002dvalue">syntax: <strong>one-value</strong> <em>exp --> value</em></dt>
- <dt id="index-all_002dvalues">syntax: <strong>all-values</strong> <em>exp --> list</em></dt>
- <dd><p><code>Either</code> evaluates to the value of any one of the options. It is
- equivalent to McCarthy’s <code>AMB</code>. It may return any number of times.
- <code>One-value</code> returns the only value that <var>exp</var> could produce; it
- will return only once, although it may actually return any number of
- values (if <var>exp</var> contains a call to <code>values</code>).
- <code>All-values</code> returns a list of all of the single values, not
- multiple values, that <var>exp</var> could nondeterministically evaluate to.
- </p></dd></dl>
- <dl>
- <dt id="index-fail">procedure: <strong>fail</strong> <em>--> does not return</em></dt>
- <dd><p>Signals a nondeterministic failure. This is invalid outside of a
- <code>with-nondeterminism</code>-protected dynamic extent.
- </p></dd></dl>
- <span id="Miscellaneous-utilities"></span><h4 class="subsection">6.8.5 Miscellaneous utilities</h4>
- <span id="index-big_002dutil"></span>
- <p>The <code>big-util</code> structure exports a variety of miscellaneous
- utilities.
- </p>
- <dl>
- <dt id="index-concatenate_002dsymbol">procedure: <strong>concatenate-symbol</strong> <em>elt … --> symbol</em></dt>
- <dd><p>Returns a symbol containing the contents of the sequence <var>elt</var>
- …. Each <var>elt</var> may be another symbol, a string, or a number.
- Numbers are converted to strings in base ten.
- </p></dd></dl>
- <dl>
- <dt id="index-error-1">procedure: <strong>error</strong> <em>format-string argument … --> values (may not return)</em></dt>
- <dt id="index-breakpoint">procedure: <strong>breakpoint</strong> <em>format-string argument … --> values (may not return)</em></dt>
- <dd><p><code>Error</code> signals an error whose message is formatted by
- <a href="#Common_002dLisp_002dstyle-formatting"><code>format</code></a> with the given
- formatting template string and arguments. <code>Breakpoint</code> signals a
- breakpoint with a message similarly constructed and causes the command
- processor to push a new <a href="#Command-levels">command level</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-atom_003f">procedure: <strong>atom?</strong> <em>x --> boolean</em></dt>
- <dd><p>Returns true if <var>x</var> is not a pair or false if it is.
- </p></dd></dl>
- <dl>
- <dt id="index-neq_003f">procedure: <strong>neq?</strong> <em>x y --> boolean</em></dt>
- <dt id="index-n_003d">procedure: <strong>n=</strong> <em>x y --> boolean</em></dt>
- <dd><p>Negations of the <code>eq?</code> and <code>=</code> predicates.
- </p></dd></dl>
- <dl>
- <dt id="index-identity">procedure: <strong>identity</strong> <em>value --> value</em></dt>
- <dt id="index-no_002dop">procedure: <strong>no-op</strong> <em>value --> value</em></dt>
- <dd><p>These simply return their arguments. The difference between them is
- that <code>no-op</code> is guaranteed not to be integrated by the compiler,
- whereas <code>identity</code> may be.
- </p></dd></dl>
- <dl>
- <dt id="index-null_002dlist_003f">procedure: <strong>null-list?</strong> <em>object --> boolean</em></dt>
- <dd><p>Returns <code>#t</code> if <var>object</var> is the null list, returns <code>#f</code>
- if <var>object</var> is a pair, or signals an error if <var>object</var> is
- neither the null list nor a pair.
- </p></dd></dl>
- <dl>
- <dt id="index-reverse_0021">procedure: <strong>reverse!</strong> <em>list --> reversed-list</em></dt>
- <dd><p>Returns a list containing the reverse elements of <var>list</var>. Note
- that the original <var>list</var> is <em>not</em> reversed; it becomes
- garbage. <code>Reverse!</code> simply re-uses its structure.
- </p></dd></dl>
- <dl>
- <dt id="index-memq_003f">procedure: <strong>memq?</strong> <em>object list --> boolean</em></dt>
- <dd><p>Returns <code>#t</code> if <var>object</var> is a member of <var>list</var>, as
- determined by <code>eq?</code>; or <code>#f</code> if not.
- </p></dd></dl>
- <dl>
- <dt id="index-first">procedure: <strong>first</strong> <em>predicate list --> elt or <code>#f</code></em></dt>
- <dt id="index-any-1">procedure: <strong>any</strong> <em>predicate list --> elt or <code>#f</code></em></dt>
- <dd><p><code>First</code> returns the first element of <var>list</var> that satisfies
- <var>predicate</var>, or <code>#f</code> if no element does. <code>Any</code> returns
- an element of <var>list</var> that satisfies <var>predicate</var>. Note that
- <code>any</code> may choose any element of the list, whereas <code>first</code>
- explicitly returns the <em>first</em> element that satisfies
- <var>predicate</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-any_003f">procedure: <strong>any?</strong> <em>predicate list --> boolean</em></dt>
- <dt id="index-every_003f">procedure: <strong>every?</strong> <em>predicate list --> boolean</em></dt>
- <dd><p><code>Any?</code> returns <code>#t</code> if any element of <var>list</var> satisfies
- <var>predicate</var>, or <code>#f</code> if none do. <code>Every?</code> returns
- <code>#t</code> if every element of <var>list</var> satisfies <var>predicate</var>, or
- <code>#f</code> if there exists an element that does not.
- </p></dd></dl>
- <dl>
- <dt id="index-filter-1">procedure: <strong>filter</strong> <em>predicate list --> filtered-list</em></dt>
- <dt id="index-filter_0021">procedure: <strong>filter!</strong> <em>predicate list --> filtered-list</em></dt>
- <dd><p>These return a list of all elements in <var>list</var> that satisfy
- <var>predicate</var>. <code>Filter</code> is not allowed to modify <var>list</var>’s
- structure; <code>filter!</code> may, however.
- </p></dd></dl>
- <dl>
- <dt id="index-filter_002dmap">procedure: <strong>filter-map</strong> <em>proc list --> list</em></dt>
- <dd><p>This is a combination of <code>filter</code> and <code>map</code>. For each
- element <var>e</var> in <var>list</var>: if <code>(<var>proc</var> <var>e</var>)</code> returns a
- true value, that true value is collected in the output list.
- <code>Filter-map</code> does not modify <var>list</var>’s structure.
- </p></dd></dl>
- <dl>
- <dt id="index-remove_002dduplicates">procedure: <strong>remove-duplicates</strong> <em>list --> uniquified-list</em></dt>
- <dd><p>Returns a unique list of all elements in <var>list</var>; that is, if there
- were any duplicates of any element <var>e</var> in <var>list</var>, only a single
- <var>e</var> will occur in the returned list. <code>Remove-duplicates</code> does
- not modify <var>list</var>’s structure.
- </p></dd></dl>
- <dl>
- <dt id="index-partition_002dlist">procedure: <strong>partition-list</strong> <em>predicate list --> [satisfied unsatisfied]</em></dt>
- <dt id="index-partition_002dlist_0021">procedure: <strong>partition-list!</strong> <em>predicate list --> [satisfied unsatisfied]</em></dt>
- <dd><p>These return two values: a list of all elements in <var>list</var> that do
- satisfy <var>predicate</var> and a list of all elements that do not.
- <code>Partition-list</code> is not allowed to modify <var>list</var>’s structure;
- <code>partition-list!</code> is.
- </p></dd></dl>
- <dl>
- <dt id="index-delq">procedure: <strong>delq</strong> <em>object list --> list</em></dt>
- <dt id="index-delq_0021">procedure: <strong>delq!</strong> <em>object list --> list</em></dt>
- <dd><p>These return a list containing all elements of <var>list</var> except for
- <var>object</var>. <code>Delq</code> is not allowed to modify <var>list</var>’s
- structure; <code>delq!</code> is.
- </p></dd></dl>
- <dl>
- <dt id="index-delete">procedure: <strong>delete</strong> <em>predicate list --> list</em></dt>
- <dd><p>Returns a list of all elements in <var>list</var> that do not satisfy
- <var>predicate</var>. Note that, despite the lack of exclamation mark in
- the name, this <em>may</em> modify <var>list</var>’s structure.
- </p></dd></dl>
- <dl>
- <dt id="index-string_002d_003eimmutable_002dstring">procedure: <strong>string->immutable-string</strong> <em>string --> immutable-string</em></dt>
- <dd><p>Returns an immutable string with <var>string</var>’s contents. If
- <var>string</var> is already immutable, it is returned; otherwise, an
- immutable copy is returned.
- </p></dd></dl>
- <span id="Multiple-value-binding"></span><h4 class="subsection">6.8.6 Multiple value binding</h4>
- <span id="index-binding-multiple-values"></span>
- <span id="index-multiple-value-binding"></span>
- <span id="index-receiving"></span>
- <p>The <code>receiving</code> structure exports the <code>receive</code> macro, a
- convenient syntax atop R5RS’s <code>call-with-values</code>.
- </p>
- <dl>
- <dt id="index-receive-2">syntax: <strong>receive</strong> <em>formals producer body</em></dt>
- <dd><p>Binds the variables in the lambda parameter list <var>formals</var> to the
- return values of <var>producer</var> in <var>body</var>.
- </p>
- <div class="lisp">
- <pre class="lisp">(receive <var>formals</var>
- <var>producer</var>
- <var>body</var>)
- ≡
- (call-with-values
- (lambda () <var>producer</var>)
- (lambda <var>formals</var> <var>body</var>))</pre></div>
- </dd></dl>
- <span id="index-mvlet-1"></span>
- <p>For sequences of multiple value bindings, the <code>mvlet</code> structure
- exports two convenient macros.
- </p>
- <dl>
- <dt id="index-mvlet_002a">syntax: <strong>mvlet*</strong></dt>
- <dt id="index-mvlet">syntax: <strong>mvlet</strong></dt>
- <dd><p><code>Mvlet*</code> is a multiple-value version of <code>let</code> or a linearly
- nested version of <code>receive</code>:
- </p>
- <div class="lisp">
- <pre class="lisp">(mvlet* ((<var>formals<sub>0</sub></var> <var>producer<sub>0</sub></var>)
- (<var>formals<sub>1</sub></var> <var>producer<sub>1</sub></var>)
- …)
- <var>body</var>)
- ≡
- (call-with-values
- (lambda () <var>producer<sub>0</sub></var>)
- (lambda <var>formals<sub>0</sub></var>
- (call-with-values
- (lambda () <var>producer<sub>1</sub></var>)
- (lambda <var>formals<sub>1</sub></var>
- …<var>body</var>…))))</pre></div>
- <p><code>Mvlet</code> is similar, but each <var>producer</var> is evaluated in an
- environment where none of the variables in any of the <var>formals</var> is
- bound, and the order in which each producer expression is evaluated is
- unspecified.
- </p></dd></dl>
- <span id="Object-dumper"></span><h4 class="subsection">6.8.7 Object dumper</h4>
- <span id="index-serialization"></span>
- <span id="index-marshalling"></span>
- <span id="index-object-dumping"></span>
- <span id="index-dump_002frestore"></span>
- <p>Scheme48 has a rudimentary object dumper and retriever in the structure
- <code>dump/restore</code>. It is not a ‘real’ object dumper in the sense that
- it will not handle cycles in object graphs correctly; it simply performs
- a recursive descent and will diverge if it reaches a cycle or stop after
- a recursive depth parameter.
- </p>
- <p>The types of objects that the dumper supports are: several miscellaneous
- constants (<code>()</code>, <code>#t</code>, <code>#f</code>, & the unspecific token),
- pairs, vectors, symbols, numbers, strings, characters, and byte vectors.
- </p>
- <dl>
- <dt id="index-dump">procedure: <strong>dump</strong> <em>object char-writer depth --> unspecified</em></dt>
- <dd><p>Dumps <var>object</var> by repeatedly calling <var>char-writer</var>, which must
- be a procedure that accepts exactly one character argument, on the
- characters of the serialized representation. If the dumper descends
- into the object graph whose root is <var>object</var> for more than
- <var>depth</var> recursions, an ellipsis token is dumped in the place of the
- vertex at <var>depth</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-restore">procedure: <strong>restore</strong> <em>char-reader --> object</em></dt>
- <dd><p>Restores the object whose serialized components are retrieved by
- repeatedly calling <var>char-reader</var>, which must be a procedure that
- accepts zero arguments and returns a character.
- </p></dd></dl>
- <span id="Simple-time-access"></span><h4 class="subsection">6.8.8 Simple time access</h4>
- <span id="index-time-1"></span>
- <span id="index-run-time"></span>
- <span id="index-real-time"></span>
- <span id="index-time-2"></span>
- <p>The <code>time</code> structure exports a simple facility for accessing time
- offsets in two different flavours.
- </p>
- <dl>
- <dt id="index-real_002dtime">procedure: <strong>real-time</strong> <em>--> milliseconds</em></dt>
- <dd><p>Returns the real time in milliseconds that has passed since some
- unspecified moment in time.<a id="DOCF25" href="#FOOT25"><sup>25</sup></a> Though not suitable
- for measurements relative to entities outside the Scheme48 image, the
- real time is useful for measuring time differences within the Scheme
- image with reasonable precision; for example, thread sleep timing is
- implemented with this real time primitive.
- </p></dd></dl>
- <dl>
- <dt id="index-run_002dtime">procedure: <strong>run-time</strong> <em>--> ticks</em></dt>
- <dd><p>Returns the run time as an integer representing processor clock ticks
- since the start of the Scheme48 process. This is much less precise
- than the real time, but it is useful for measuring time actually spent
- in the Scheme48 process, as opposed to time in general.
- </p></dd></dl>
- <hr>
- <span id="C-interface"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="C-interface-1"></span><h2 class="chapter">7 C interface</h2>
- <p><i>(This chapter was derived from work copyrighted ©
- 1993–2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
- </p>
- <p>This chapter describes an interface for calling C functions from
- Scheme, calling Scheme procedures from C, and working with the Scheme
- heap in C. Scheme48 manages stub functions in C that negotiate between
- the calling conventions of Scheme & C and the memory allocation
- policies of both worlds. No stub generator is available yet, but
- writing stubs is a straightforward task.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Shared-bindings-between-Scheme-and-C" accesskey="1">Shared bindings between Scheme and C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Calling-C-functions-from-Scheme" accesskey="2">Calling C functions from Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Dynamic-loading-of-C-modules" accesskey="3">Dynamic loading of C modules</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Accessing-Scheme-data-from-C" accesskey="4">Accessing Scheme data from C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Calling-Scheme-procedures-from-C" accesskey="5">Calling Scheme procedures from C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Interacting-with-the-Scheme-heap-in-C" accesskey="6">Interacting with the Scheme heap in C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Using-Scheme-records-in-C" accesskey="7">Using Scheme records in C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Raising-exceptions-from-C" accesskey="8">Raising exceptions from C</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Unsafe-C-macros" accesskey="9">Unsafe C macros</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <span id="Overview-of-the-C-interface"></span><h3 class="section">7.1 Overview of the C interface</h3>
- <p>The following facilities are available for interfacing between Scheme48
- & C:
- </p>
- <ul>
- <li> Scheme code can call C functions.
- </li><li> The external interface provides full introspection for all Scheme
- objects. External code may inspect, modify, and allocate Scheme
- objects arbitrarily.
- </li><li> External code may raise exceptions back to Scheme48 to signal
- errors.
- </li><li> External code may call back into Scheme. Scheme48 correctly
- unrolls the process stack on non-local exits.
- </li><li> External modules may register bindings of names to values with a
- central registry accessible from Scheme. Conversely, Scheme code can
- register shared bindings for access by C code.
- </li></ul>
- <span id="Scheme-structures"></span><h4 class="subsection">7.1.1 Scheme structures</h4>
- <span id="index-external_002dcalls"></span>
- <span id="index-load_002ddynamic_002dexternals-1"></span>
- <span id="index-shared_002dbindings"></span>
- <span id="index-dynamic_002dexternals"></span>
- <p>On the Scheme side of the C interface, there are three pertinent
- structures: <a href="#Shared-bindings-between-Scheme-and-C"><code>shared-bindings</code></a>, which provides the Scheme side of the
- facility for sharing data between Scheme and C; <a href="#Calling-C-functions-from-Scheme"><code>external-calls</code></a>, which exports several
- ways to call C functions from Scheme, along with some useful
- facilities, such as object finalizers, which are also available from
- elsewhere; and <a href="#Dynamic-loading-of-C-modules"><code>load-dynamic-externals</code></a>, which provides a dynamic external
- object loading facility. Also, the old dynamic loading facility is
- still available from the <code>dynamic-externals</code> structure, but its
- use is deprecated, and it will most likely vanish in a later release.
- </p>
- <span id="C-naming-conventions"></span><h4 class="subsection">7.1.2 C naming conventions</h4>
- <span id="index-C-naming-conventions"></span>
- <p>Scheme48’s C bindings all have strict naming conventions. Variables
- & procedures have <code>s48_</code> prefixed to them; macros, <code>S48_</code>.
- Whenever a C name is derived from a Scheme identifier, hyphens are
- replaced with underscores. Also, procedures or variables are converted
- to lowercase, while macros are converted to uppercase. The <code>?</code>
- suffix, generally appended to predicates, is converted to <code>_p</code> (or
- <code>_P</code> in macro names). Trailing <code>!</code> is dropped. For example,
- the C macro that corresponds with Scheme’s <code>pair?</code> predicate is
- named <code>S48_PAIR_P</code>, and the C macro to assign the car of a pair is
- named <code>S48_SET_CAR</code>. Procedures and macros that do not verify the
- types of their arguments have ‘unsafe’ in their names.
- </p>
- <p>All of the C functions and macros described have prototypes or
- definitions in the file <samp>c/scheme48.h</samp> of Scheme48’s standard
- distribution. The C type for Scheme values is defined there to be
- <code>s48_value</code>.
- </p>
- <span id="Garbage-collection"></span><h4 class="subsection">7.1.3 Garbage collection</h4>
- <p>Scheme48 uses a copying garbage collector. The collector must be able
- to locate all references to objects allocated in the Scheme48 heap in
- order to ensure that storage is not reclaimed prematurely and to
- update references to objects moved by the collector. The garbage
- collector may run whenever an object is allocated in the heap. C
- variables whose values are Scheme48 objects and which are live across
- heap allocation calls need to be registered with the garbage
- collector. For more information, see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
- </p>
- <hr>
- <span id="Shared-bindings-between-Scheme-and-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Shared-bindings-between-Scheme-and-C-1"></span><h3 class="section">7.2 Shared bindings between Scheme and C</h3>
- <span id="index-sharing-data-between-Scheme-and-C"></span>
- <span id="index-shared_002dbindings-1"></span>
- <p>Shared bindings are the means by which named values are shared between
- Scheme & C code. There are two separate tables of shared bindings, one
- for values defined in Scheme and accessed from C and the other for the
- opposite direction. Shared bindings actually bind names to cells, to
- allow a name to be resolved before it has been assigned. This is
- necessary because C initialization code may run before or after the
- corresponding Scheme code, depending on whether the Scheme code is in
- the resumed image or run in the current session. The Scheme bindings
- described here are available from the <code>shared-bindings</code>
- structure.
- </p>
- <span id="Scheme-shared-binding-interface"></span><h4 class="subsection">7.2.1 Scheme shared binding interface</h4>
- <dl>
- <dt id="index-shared_002dbinding_003f">Scheme procedure: <strong>shared-binding?</strong> <em>object --> boolean</em></dt>
- <dt id="index-shared_002dbinding_002dis_002dimport_003f">Scheme procedure: <strong>shared-binding-is-import?</strong> <em>shared-binding --> boolean</em></dt>
- <dd><p><code>Shared-binding?</code> is the disjoint type predicate for all shared
- bindings, imported or exported; <code>shared-binding-is-import?</code>
- returns true if <var>shared-binding</var> was imported into Scheme from C,
- and false if it has the converse direction.
- </p></dd></dl>
- <dl>
- <dt id="index-shared_002dbinding_002dref">Scheme procedure: <strong>shared-binding-ref</strong> <em>shared-binding --> value</em></dt>
- <dt id="index-shared_002dbinding_002dset_0021">Scheme procedure: <strong>shared-binding-set!</strong> <em>shared-binding value --> unspecified</em></dt>
- <dd><p><code>Shared-binding-ref</code> returns the value of <var>shared-binding</var>;
- <code>shared-binding-set!</code> sets the value of <var>shared-binding</var> to
- be <var>value</var>.
- </p></dd></dl>
- <span id="index-importing-bindings-into-Scheme-from-C"></span>
- <dl>
- <dt id="index-lookup_002dimported_002dbinding">Scheme procedure: <strong>lookup-imported-binding</strong> <em>name --> shared-binding</em></dt>
- <dt id="index-define_002dimported_002dbinding">Scheme procedure: <strong>define-imported-binding</strong> <em>name value --> unspecified</em></dt>
- <dt id="index-undefine_002dimported_002dbinding">Scheme procedure: <strong>undefine-imported-binding</strong> <em>name --> unspecified</em></dt>
- <dd><p><code>Lookup-imported-binding</code> returns the binding imported from C to
- Scheme with the given name; a binding is created if none exists.
- <code>Define-imported-binding</code> creates a new such binding, anomalously
- from within Scheme; such bindings are usually created instead from
- within C using the C <code>s48_define_exported_binding</code> function.
- <code>Undefine-imported-binding</code> removes the shared binding whose name
- is <var>name</var> from the table of imported bindings.
- </p></dd></dl>
- <span id="index-exporting-bindings-from-Scheme-to-C"></span>
- <dl>
- <dt id="index-lookup_002dexported_002dbinding">Scheme procedure: <strong>lookup-exported-binding</strong> <em>name --> shared-binding</em></dt>
- <dt id="index-define_002dexported_002dbinding">Scheme procedure: <strong>define-exported-binding</strong> <em>name value --> unspecified</em></dt>
- <dt id="index-undefine_002dexported_002dbinding">Scheme procedure: <strong>undefine-exported-binding</strong> <em>name --> unspecified</em></dt>
- <dd><p>Equivalents of the above three procedures, but for bindings exported
- from Scheme to C. <code>Define-imported-binding</code>, unlike
- <code>define-exported-binding</code>, is customary to use in Scheme, as its
- intended use is to make a Scheme value available to C code from within
- Scheme.
- </p></dd></dl>
- <dl>
- <dt id="index-find_002dundefined_002dimported_002dbindings">Scheme procedure: <strong>find-undefined-imported-bindings</strong> <em>--> vector</em></dt>
- <dd><p>Returns a vector of all bindings imported into Scheme from C with
- undefined values, <i>i.e.</i> those created implicitly by lookups that have
- not yet been assigned rather than those created explicitly by the
- shared binding definers (<code>define-exported-binding</code>, <i>&c.</i>).
- </p></dd></dl>
- <span id="C-shared-binding-interface"></span><h4 class="subsection">7.2.2 C shared binding interface</h4>
- <dl>
- <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>
- <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>
- <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>
- <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>
- <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>
- <dd><p>These macros are C counterparts to Scheme’s <code>shared-binding?</code>,
- <code>shared-binding-name</code>, <code>shared-binding-is-import?</code>,
- <code>shared-binding-ref</code>, and <code>shared-binding-set!</code>,
- respectively.
- </p></dd></dl>
- <dl>
- <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>
- <dd><p>Signals an exception if and only if <var>binding</var>’s value is
- Scheme48’s ‘unspecific’ value.
- </p>
- <p><strong>Huh?:</strong> Undefined shared bindings are not initialized with the
- ‘unspecific’ value, but rather with an entirely different special
- token referred to internally as ‘undefined,’ used in circumstances
- such as this — yet <code>S48_SHARED_BINDING_CHECK</code>, as defined in
- <samp>scheme48.h</samp>, definitely checks whether <var>binding</var>’s value is
- the ‘unspecific’ value.
- </p></dd></dl>
- <span id="index-importing-bindings-into-C-from-Scheme"></span>
- <dl>
- <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>
- <dd><p>Returns the shared binding defined in Scheme for <var>name</var>, creating
- it if necessary.
- </p></dd></dl>
- <span id="index-exporting-bindings-from-C-to-Scheme"></span>
- <dl>
- <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>
- <dd><p>Defines a shared binding named <var>name</var> with the value <var>value</var>
- that can be accessed from Scheme.
- </p></dd></dl>
- <span id="index-exporting-C-functions-to-Scheme"></span>
- <dl>
- <dt id="index-S48_005fEXPORT_005fFUNCTION">C macro: <em>void</em> <strong>S48_EXPORT_FUNCTION</strong> <em>(<var>fn</var>)</em></dt>
- <dd><p>This is a convenience for the common case of exporting a C function to
- Scheme. This expands into
- </p>
- <div class="example">
- <pre class="example">s48_define_exported_binding("<var>fn</var>",
- s48_enter_pointer(<var>fn</var>))</pre></div>
- <p>which boxes the function into a Scheme48 byte vector and then exports
- it as a shared binding. Note that <code>s48_enter_pointer</code> allocates
- space in the Scheme heap and may trigger a garbage collection;
- see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
- </p></dd></dl>
- <hr>
- <span id="Calling-C-functions-from-Scheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Calling-C-functions-from-Scheme-1"></span><h3 class="section">7.3 Calling C functions from Scheme</h3>
- <span id="index-importing-C-functions-to-Scheme"></span>
- <span id="index-external_002dcalls-1"></span>
- <p>The <code>external-calls</code> structure exports several ways to call C
- functions from Scheme, along with several other related utilities,
- many of which are also available from other structures. There are two
- different ways to call C functions from Scheme, depending on how the C
- function was obtained:
- </p>
- <dl>
- <dt id="index-call_002dimported_002dbinding">Scheme procedure: <strong>call-imported-binding</strong> <em>binding argument … --> value</em></dt>
- <dt id="index-call_002dexternal_002dvalue">Scheme procedure: <strong>call-external-value</strong> <em>byte-vector name argument … --> value</em></dt>
- <dd><p>Each of these applies its first argument, a C function, to the rest of
- the arguments. For <code>call-imported-binding</code>, the function argument
- must be an imported binding. For <code>call-external-value</code>, the
- function argument must be a byte vector that contains a pointer to a C
- function, and <var>name</var> should be a string that names the function.
- The <var>name</var> argument is used only for printing error messages.
- </p>
- <p>For both of these, the C function is passed the argument values, and
- the value returned is that returned by the C function. No automatic
- representation conversion occurs for either arguments or return
- values. Up to twelve arguments may be passed. There is no method
- supplied for returning multiple values to Scheme from C or vice versa
- (mainly because C does not have multiple return values).
- </p>
- <p>Keyboard interrupts that occur during a call to a C function are
- ignored until the function returns to Scheme.<a id="DOCF26" href="#FOOT26"><sup>26</sup></a>
- </p></dd></dl>
- <span id="index-importing-C-functions-to-Scheme-1"></span>
- <dl>
- <dt id="index-import_002ddefinition">Scheme syntax: <strong>import-definition</strong> <em>name [c-string]</em></dt>
- <dt id="index-import_002dlambda_002ddefinition">Scheme syntax: <strong>import-lambda-definition</strong> <em>name formals [c-string]</em></dt>
- <dd><p>These macros simplify importing bindings from C into Scheme and
- wrapping such bindings in Scheme procedures. <code>Import-definition</code>
- defines <var>name</var> to be the shared binding named by <var>c-string</var>,
- whose value, if it is not supplied, is by default a string of
- <var>name</var>, downcased and with all hyphens translated to underscores.
- </p>
- <div class="lisp">
- <pre class="lisp">(define <var>name</var> (lookup-imported-binding <var>c-string</var>))</pre></div>
- <p>For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(import-definition my-foo)
- → (define my-foo (lookup-imported-binding "my_foo"))</pre></div>
- <p><code>Import-lambda-definition</code> imports the named C binding, using
- either the provided C binding name or by translating the Scheme name
- as with <code>import-definition</code>, and defines <var>name</var> to be a
- procedure with the given formal parameter list that calls the imported
- C binding with its arguments:
- </p>
- <div class="lisp">
- <pre class="lisp">(define <var>binding</var> (lookup-imported-binding <var>c-string</var>))
- (define (<var>name</var> <var>formal</var> …)
- (call-imported-binding <var>binding</var> <var>formal</var> …))</pre></div>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(import-lambda-definition integer->process-id (int)
- "posix_getpid")
- →
- (define <var>binding<sub>0</sub></var>
- (lookup-imported-binding "posix_getpid"))
- (define (integer->process-id int)
- (call-imported-binding <var>binding<sub>0</sub></var> int))
- (import-lambda-definition s48-system (string))
- →
- (define <var>binding<sub>1</sub></var>
- (lookup-imported-binding "s48_system"))
- (define (s48-system string)
- (call-imported-binding <var>binding<sub>1</sub></var> string))</pre></div>
- <p>where <var>binding<sub>0</sub></var> and <var>binding<sub>1</sub></var> are fresh, unused
- variable names.
- </p>
- <p><strong>Warning:</strong> <code>Import-lambda-definition</code>, as presently
- implemented, requires a fixed parameter list; it does not allow ‘rest
- list’ arguments.
- </p></dd></dl>
- <dl>
- <dt id="index-lookup_002dimported_002dbinding-1">Scheme procedure: <strong>lookup-imported-binding</strong> <em>name --> shared-binding</em></dt>
- <dt id="index-define_002dexported_002dbinding-1">Scheme procedure: <strong>define-exported-binding</strong> <em>shared-binding --> unspecified</em></dt>
- <dt id="index-shared_002dbinding_002dref-1">Scheme procedure: <strong>shared-binding-ref</strong> <em>shared-binding --> value</em></dt>
- <dd><p>These are identical to the procedures accessible with the same names
- from the <a href="#Shared-bindings-between-Scheme-and-C"><code>shared-bindings</code> structure</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-add_002dfinalizer_0021">Scheme procedure: <strong>add-finalizer!</strong> <em>object procedure --> unspecified</em></dt>
- <dd><p>Registers <var>procedure</var> as the finalizer for <var>object</var>. When
- <var>object</var> is later about to be reclaimed by the garbage collector,
- <var>procedure</var> is applied to one argument, <var>object</var>. All
- finalizers are applied in a child of the root scheduler thread that is
- spawned after every garbage collection. If an error occurs in any
- finalizer, it will be printed to the standard error output port, and
- all other finalizers will be aborted before they are given a chance to
- run. Because of this, and the fact that finalizers are collected and
- run after every garbage collection, they should perform as little
- computation as possible. <var>Procedure</var> may also create new
- references to <var>object</var> elsewhere in the heap, in which case the
- object will not be reclaimed, but its associated finalizer will be
- forgotten.
- </p>
- <p><strong>Warning:</strong> Finalizers are expensive. Use sparingly.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002drecord_002dresumer-1">Scheme procedure: <strong>define-record-resumer</strong> <em>record-type resumer --> unspecified</em></dt>
- <dd><p>Identical to the procedure accessible with the same name from the
- <a href="#Records"><code>record-types</code> structure</a>. Record resumers
- are often useful in working with foreign C data, which is in many
- cases specific to the program image within the operating system, and
- which cannot straightforwardly be relocated to a different address
- space.
- </p></dd></dl>
- <hr>
- <span id="Dynamic-loading-of-C-modules"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Dynamic-loading-of-C-modules-1"></span><h3 class="section">7.4 Dynamic loading of C modules</h3>
- <span id="index-C-dynamic-loading"></span>
- <span id="index-C-shared-objects"></span>
- <span id="index-load_002ddynamic_002dexternals-2"></span>
- <p>External code can be loaded into a running Scheme48 on most Unices and
- on Windows. Such external code must be stored in shared objects; see
- below on details of the C side. The relevant Scheme procedures are
- available in the <code>load-dynamic-externals</code> structure:
- </p>
- <dl>
- <dt id="index-load_002ddynamic_002dexternals">procedure: <strong>load-dynamic-externals</strong> <em>filename add-file-type? reload-on-repeat? reload-on-resume? --> dynamic-externals</em></dt>
- <dt id="index-import_002ddynamic_002dexternals">procedure: <strong>import-dynamic-externals</strong> <em>filename --> dynamic-externals</em></dt>
- <dt id="index-unload_002ddynamic_002dexternals">procedure: <strong>unload-dynamic-externals</strong> <em>dynamic-externals --> unspecified</em></dt>
- <dd><p><code>Load-dynamic-external</code> loads a shared object from
- <var>filename</var>, with an appropriate file type appended if
- <var>add-file-type?</var> is true (<code>.so</code> on Unix and <code>.dll</code> on
- Windows), and returns a <em>dynamic externals</em> object representing
- the loaded shared object. If the shared object was already loaded,
- then if <var>reload-on-repeat?</var> is true, it is reloaded; otherwise,
- the <code>load-dynamic-externals</code> call has no effect. If the dynamic
- externals descriptor is stored in a dumped heap image, when that heap
- image is resumed, if <code>reload-on-resume?</code> is true, the shared
- object corresponding with that dynamic external descriptor is
- reloaded. <code>Unload-dynamic-externals</code> unloads the given dynamic
- externals object.
- </p>
- <p><code>Import-dynamic-externals</code> is a convenient wrapper for the common
- case of <code>load-dynamic-externals</code>; it is equivalent to
- <code>(load-dynamic-externals #t #f #t)</code>, <i>i.e.</i> it will append a file
- type, it will not reload the shared object if it was already loaded,
- and the shared object will be loaded if part of a resumed heap image.
- </p></dd></dl>
- <dl>
- <dt id="index-reload_002ddynamic_002dexternals">procedure: <strong>reload-dynamic-externals</strong> <em>filename --> unspecified</em></dt>
- <dd><p>Reloads the shared object named by <var>filename</var>. This is intended
- as an interactive utility, which is why it accepts the filename of the
- shared object and not a dynamic externals descriptor.
- </p></dd></dl>
- <p>Shared objects intended to be loaded into Scheme48 must define two
- functions:
- </p>
- <dl>
- <dt id="index-s48_005fon_005fload">C function: <em>void</em> <strong>s48_on_load</strong> <em>(void)</em></dt>
- <dt id="index-s48_005fon_005freload">C function: <em>void</em> <strong>s48_on_reload</strong> <em>(void)</em></dt>
- <dd><p><code>s48_on_load</code> is called when the shared object is initially
- loaded by Scheme48. It typically consists of a number of invocations
- of <code>S48_EXPORT_FUNCTION</code> to make C functions available to
- Scheme48 code. <code>s48_on_reload</code> is called when the shared object
- is reloaded after it has been initially loaded once; it typically just
- calls <code>s48_on_load</code>, but it may perform other reinitializations.
- </p></dd></dl>
- <p>On Linux, the following commands compile the C source file
- <samp>foo.c</samp> into a shared object <samp>foo.so</samp> that can be loaded
- dynamically by Scheme48:
- </p>
- <div class="example">
- <pre class="example">% gcc -c -o foo.o foo.c
- % ld -shared -o foo.so foo.o</pre></div>
- <span id="Old-dynamic-loading-interface"></span><h4 class="subsection">7.4.1 Old dynamic loading interface</h4>
- <p>The old <code>dynamic-externals</code> structures, which exported
- <code>dynamic-load</code>, <code>get-external</code>, <code>lookup-external</code>,
- <code>lookup-all-externals</code>, <code>external?</code>, <code>external-name</code>,
- <code>external-value</code>, and <code>call-external</code>, is still supported,
- but it will not work on Windows, its use is deprecated, and it is
- likely to vanish in a future release. The old documentation is
- preserved to aid updating of old code:
- </p>
- <span id="index-dynamic_002dexternals-1"></span>
- <p>On architectures that support it, external code can be loaded into a
- running Scheme48 process, and C object file bindings can be accessed
- at runtime & their values called. These Scheme procedures are exported
- by the structure <code>dynamic-externals</code>.
- </p>
- <p>In some Unices, retrieving a value from the current process may require
- a non-trivial amount of computation. We recommend that a dynamically
- loaded file contain a single initialization function that creates
- shared bindings for the values exported by the file.
- </p>
- <dl>
- <dt id="index-dynamic_002dload">Scheme procedure: <strong>dynamic-load</strong> <em>string --> unspecified</em></dt>
- <dd><p>Loads the filename named by <var>string</var> into the current process.
- An exception is raised if the file cannot be found or if dynamic
- loading is not supported by the host operating system. The file must
- have been compiled & linked appropriately. For Linux, for example,
- the following commands compile <samp>foo.c</samp> into a file <samp>foo.so</samp>
- that can be loaded dynamically:
- </p>
- <div class="example">
- <pre class="example">% gcc -c -o foo.o foo.c
- % ld -shared -o foo.so foo.o</pre></div>
- </dd></dl>
- <dl>
- <dt id="index-get_002dexternal">Scheme procedure: <strong>get-external</strong> <em>string --> external</em></dt>
- <dt id="index-external_003f">Scheme procedure: <strong>external?</strong> <em>object --> boolean</em></dt>
- <dt id="index-external_002dname">Scheme procedure: <strong>external-name</strong> <em>external --> string</em></dt>
- <dt id="index-external_002dvalue">Scheme procedure: <strong>external-value</strong> <em>external --> byte-vector</em></dt>
- <dd><p>These procedures access external values bound in the current process.
- <code>Get-external</code> returns a <em>external</em> object that contains the
- value of the C binding with the name <var>string</var>. It signals a
- warning if there is no such binding in the current process.
- <code>External?</code> is the disjoint type predicate for externals, and
- <code>external-name</code> & <code>external-value</code> return the name & value of
- an external. The value is represented as a <a href="#Bitwise-manipulation">byte vector</a> of length four on 32-bit architectures. The
- value is that of the C binding from when <code>get-external</code> (or
- <code>lookup-external</code>, as described below) was called.
- </p></dd></dl>
- <dl>
- <dt id="index-lookup_002dexternal">Scheme procedure: <strong>lookup-external</strong> <em>external --> boolean</em></dt>
- <dt id="index-lookup_002dall_002dexternals">Scheme procedure: <strong>lookup-all-externals</strong> <em>--> boolean</em></dt>
- <dd><p><code>Lookup-external</code> updates the value of <var>external</var> by looking
- up its binding in the current process. It returns <code>#t</code> if the
- external is bound and <code>#f</code> if not. <code>Lookup-all-externals</code>
- calls <code>lookup-external</code> on all externals in the current Scheme48
- image. It returns <code>#t</code> if all were bound and <code>#f</code> if there
- was at least one unbound external.
- </p></dd></dl>
- <dl>
- <dt id="index-call_002dexternal">Scheme procedure: <strong>call-external</strong> <em>external argument … --> value</em></dt>
- <dd><p>Calls the C function pointed to by <var>external</var> with the given
- arguments, and returns the value that the C function returned. This
- is like <code>call-imported-binding</code> and <code>call-external-value</code>
- except that the function argument is represented as an external, not as
- an imported binding or byte vector containing a pointer. For more
- details, see <a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a>.
- </p></dd></dl>
- <hr>
- <span id="Accessing-Scheme-data-from-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Accessing-Scheme-data-from-C-1"></span><h3 class="section">7.5 Accessing Scheme data from C</h3>
- <span id="index-s48_005fvalue"></span>
- <span id="index-scheme48_002eh"></span>
- <p>The C header file <samp>scheme48.h</samp> provides access to Scheme48 data
- structures. The type <code>s48_value</code> is used for Scheme values. When
- the type of a value is known, such as the integer returned by the
- Scheme procedure <code>vector-length</code> or the boolean returned by
- <code>pair</code>, the corresponding C function returns a C value of the
- appropriate type, not an <code>s48_value</code>. Predicates return <code>1</code>
- for true and <code>0</code> for false.
- </p>
- <span id="index-Scheme-constants-in-C"></span>
- <span id="index-C-macros-for-Scheme-constants"></span>
- <dl>
- <dt id="index-S48_005fFALSE">C macro: <em>s48_value</em> <strong>S48_FALSE</strong></dt>
- <dt id="index-S48_005fTRUE">C macro: <em>s48_value</em> <strong>S48_TRUE</strong></dt>
- <dt id="index-S48_005fNULL">C macro: <em>s48_value</em> <strong>S48_NULL</strong></dt>
- <dt id="index-S48_005fUNSPECIFIC">C macro: <em>s48_value</em> <strong>S48_UNSPECIFIC</strong></dt>
- <dt id="index-S48_005fEOF">C macro: <em>s48_value</em> <strong>S48_EOF</strong></dt>
- <dt id="index-S48_005fMAX_005fFIXNUM_005fVALUE">C macro: <em>long</em> <strong>S48_MAX_FIXNUM_VALUE</strong></dt>
- <dt id="index-S48_005fMIN_005fFIXNUM_005fVALUE">C macro: <em>long</em> <strong>S48_MIN_FIXNUM_VALUE</strong></dt>
- <dd><p>These C macros denote various Scheme constants. <code>S48_FALSE</code> is
- the boolean false value, written in Scheme as <code>#f</code>.
- <code>S48_TRUE</code> is the boolean true value, or <code>#t</code>.
- <code>S48_NULL</code> is the empty list <code>()</code>. <code>S48_UNSPECIFIC</code> is
- a miscellaneous value returned by procedures that have no meaningful
- return value (accessed in Scheme48 by the nullary procedure
- <code>unspecific</code> in the <code>util</code> structure). <code>S48_EOF</code> is
- the end-of-file object (which the Scheme procedure <code>eof-object?</code>
- answers true for). <code>S48_MAX_FIXNUM_VALUE</code> is the maximum integer
- as a <code>long</code> that can be represented in a Scheme48 fixnum.
- <code>S48_MIN_FIXNUM_VALUE</code> is similar, but the minimum integer.
- </p></dd></dl>
- <span id="index-C-and-Scheme-data-conversion"></span>
- <span id="index-Scheme-and-C-data-conversion"></span>
- <dl>
- <dt id="index-S48_005fEXTRACT_005fBOOLEAN">C macro: <em>int</em> <strong>S48_EXTRACT_BOOLEAN</strong> <em>(s48_value <var>boolean</var>)</em></dt>
- <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>
- <dt id="index-s48_005fextract_005fstring">C function: <em>char *</em> <strong>s48_extract_string</strong> <em>(s48_value <var>string</var>)</em></dt>
- <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>
- <dt id="index-s48_005fextract_005finteger">C function: <em>long</em> <strong>s48_extract_integer</strong> <em>(s48_value <var>integer</var>)</em></dt>
- <dt id="index-s48_005fextract_005fdouble">C function: <em>double</em> <strong>s48_extract_double</strong> <em>(s48_value <var>double</var>)</em></dt>
- <dt id="index-S48_005fENTER_005fBOOLEAN">C macro: <em>s48_value</em> <strong>S48_ENTER_BOOLEAN</strong> <em>(int <var>boolean</var>)</em></dt>
- <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>
- <dt id="index-s48_005fenter_005fstring">C function: <em>s48_value</em> <strong>s48_enter_string</strong> <em>(char *<var>string</var>)</em></dt>
- <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>
- <dt id="index-s48_005fenter_005finteger">C function: <em>s48_value</em> <strong>s48_enter_integer</strong> <em>(long <var>integer</var>)</em></dt>
- <dt id="index-s48_005fenter_005fdouble">C function: <em>s48_value</em> <strong>s48_enter_double</strong> <em>(double <var>double</var>)</em></dt>
- <dd><p>These functions & macros convert values between their respective Scheme
- & C representations.
- </p>
- <p><code>S48_EXTRACT_BOOLEAN</code> returns <code>0</code> if <var>boolean</var> is
- <code>#f</code> and <code>1</code> otherwise. <code>S48_ENTER_BOOLEAN</code> returns the
- Scheme value <code>#f</code> if its argument is zero and <code>#t</code> otherwise.
- </p>
- <p><code>s48_extract_char</code> & <code>s48_enter_char</code> convert between Scheme
- characters and C <code>char</code>s.
- </p>
- <p><code>s48_extract_string</code> & <code>s48_extract_byte_vector</code> return
- pointers to the actual storage used by <var>string</var> or <var>bytev</var>.
- These pointers are valid only until the next garbage collection,
- however; see <a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a>.
- <code>s48_enter_string</code> & <code>s48_enter_byte_vector</code> allocate
- space on the Scheme48 heap for the given strings or byte vectors.
- <code>s48_enter_string</code> copies the data starting from the pointer it
- is given up to the first ASCII <code>NUL</code> character, whereas
- <code>s48_enter_byte_vector</code> is given the number of bytes to copy into
- the Scheme heap.
- </p>
- <p><code>s48_extract_integer</code> returns a C <code>long</code> that represents the
- Scheme integer as input. If the Scheme integer is too large to be
- represented in a long, an exception is signalled. (The Scheme integer
- may be a fixnum or a bignum.) <code>s48_enter_integer</code> converts back
- to Scheme integers, and it will never signal an exception.
- </p>
- <p><code>s48_extract_double</code> & <code>s48_enter_double</code> convert between
- Scheme & C double-precision floating point representations.
- </p>
- <p>Of these, <code>s48_enter_string</code>, <code>s48_enter_byte_vector</code>,
- <code>s48_enter_integer</code>, & <code>s48_enter_double</code> may cause the
- garbage collector to be invoked: the former two copy the string or
- byte vector onto the Scheme heap first, <code>s48_enter_integer</code> may
- need to allocate a bignum (since C <code>long</code>s are wider than Scheme48
- fixnums), and floats are heap-allocated in Scheme48.
- </p></dd></dl>
- <span id="index-Scheme-boolean-testing-in-C"></span>
- <span id="index-C-macros-on-Scheme-booleans"></span>
- <dl>
- <dt id="index-S48_005fTRUE_005fP">C macro: <em>int</em> <strong>S48_TRUE_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fFALSE_005fP">C macro: <em>int</em> <strong>S48_FALSE_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dd><p><code>S48_TRUE_P</code> returns true if <var>object</var> is the true constant
- <code>S48_TRUE</code> and false if otherwise. <code>S48_FALSE_P</code> returns
- true if its argument is the false constant <code>S48_FALSE</code> and false
- if otherwise.
- </p></dd></dl>
- <span id="index-Scheme-fixnums-from-C"></span>
- <span id="index-C-access-to-Scheme-fixnums"></span>
- <dl>
- <dt id="index-S48_005fFIXNUM_005fP">C macro: <em>int</em> <strong>S48_FIXNUM_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-s48_005fextract_005ffixnum">C function: <em>long</em> <strong>s48_extract_fixnum</strong> <em>(s48_value <var>fixnum</var>)</em></dt>
- <dt id="index-s48_005fenter_005ffixnum">C function: <em>s48_value</em> <strong>s48_enter_fixnum</strong> <em>(long <var>integer</var>)</em></dt>
- <dd><p><code>S48_FIXNUM_P</code> is the C predicate for Scheme48 fixnums, delimited
- in range by <code>S48_MIN_FIXNUM_VALUE</code> & <code>S48_MAX_FIXNUM_VALUE</code>.
- <code>s48_extract_fixnum</code> returns the C <code>long</code> representation of
- the Scheme fixnum, and <code>s48_enter_fixnum</code> returns the Scheme
- fixnum representation of the C <code>long</code>. These are identical to
- <code>s48_extract_integer</code> & <code>s48_enter_integer</code>, except that
- <code>s48_extract_fixnum</code> will never raise a range exception, but
- <code>s48_enter_fixnum</code> may, and <code>s48_enter_fixnum</code> will never
- return a bignum; this is due to the fact that C <code>long</code>s have a
- wider range than Scheme48 fixnums.
- </p></dd></dl>
- <span id="index-Scheme-data-predicates-in-C"></span>
- <span id="index-C-predicates-for-Scheme-data"></span>
- <dl>
- <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>
- <dt id="index-S48_005fCHAR_005fP">C macro: <em>int</em> <strong>S48_CHAR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fPAIR_005fP">C macro: <em>int</em> <strong>S48_PAIR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fVECTOR_005fP">C macro: <em>int</em> <strong>S48_VECTOR_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fSTRING_005fP">C macro: <em>int</em> <strong>S48_STRING_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fSYMBOL_005fP">C macro: <em>int</em> <strong>S48_SYMBOL_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <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>
- <dd><span id="index-Scheme-pair-operations-in-C"></span>
- <span id="index-C-access-to-Scheme-pairs"></span>
- </dd><dt id="index-S48_005fCAR">C macro: <em>s48_value</em> <strong>S48_CAR</strong> <em>(s48_value <var>pair</var>)</em></dt>
- <dt id="index-S48_005fCDR">C macro: <em>s48_value</em> <strong>S48_CDR</strong> <em>(s48_value <var>pair</var>)</em></dt>
- <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>
- <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>
- <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>
- <dt id="index-s48_005flength">C function: <em>s48_value</em> <strong>s48_length</strong> <em>(s48_value <var>list</var>)</em></dt>
- <dd><span id="index-Scheme-vector-operations-in-C"></span>
- <span id="index-C-access-to-Scheme-vectors"></span>
- </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>
- <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>
- <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>
- <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>
- <dd><span id="index-Scheme-string-operations-in-C"></span>
- <span id="index-C-access-to-Scheme-strings"></span>
- </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>
- <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>
- <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>
- <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>
- <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>
- <dd><span id="index-Scheme-byte-vector-operations-in-C"></span>
- <span id="index-C-access-to-Scheme-byte-vectors"></span>
- </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>
- <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>
- <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>
- <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>
- <dd><p>C versions of miscellaneous Scheme procedures. The names were derived
- from their Scheme counterparts by replacing hyphens with underscores,
- <code>?</code> suffixes with <code>_P</code>, and dropping <code>!</code> suffixes.
- </p></dd></dl>
- <hr>
- <span id="Calling-Scheme-procedures-from-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Calling-Scheme-procedures-from-C-1"></span><h3 class="section">7.6 Calling Scheme procedures from C</h3>
- <span id="index-Scheme-callbacks-in-C"></span>
- <dl>
- <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>
- <dd><p>Calls the Scheme procedure <var>proc</var> on <var>nargs</var> arguments, which
- are passed as additional arguments to <code>s48_call_scheme</code>. There
- may be at most twelve arguments. The value returned by the Scheme
- procedure is returned to the C procedure. Calling any Scheme procedure
- may potentially cause a garbage collection.
- </p></dd></dl>
- <span id="index-callbacks-from-C-and-continuations"></span>
- <span id="index-continuations-and-callbacks-from-C"></span>
- <span id="index-callbacks-from-C-and-threads"></span>
- <span id="index-threads-and-callbacks-from-C"></span>
- <span id="index-interaction-between-continuations-and-C"></span>
- <p>There are some complications that arise when mixing calls from C to
- Scheme with continuations & threads. C supports only downward
- continuations (via <code>longjmp()</code>). Scheme continuations that
- capture a portion of the C stack have to follow the same restriction.
- For example, suppose Scheme procedure <code>s0</code> captures continuation
- <code>a</code> and then calls C function <code>c0</code>, which in turn calls
- Scheme procedure <code>s1</code>. <code>S1</code> can safely call the continuation
- <code>a</code>, because that is a downward use. When <code>a</code> is called,
- Scheme48 will remove the portion of the C stack used by the call to
- <code>c0</code>. On the other hand, if <code>s1</code> captures a continuation,
- that continuation cannot be used from <code>s0</code>, because, by the time
- control returns to <code>s0</code>, the C stack used by <code>s0</code> will no
- longer be valid. An attempt to invoke an upward continuation that is
- closed over a portion of the C stack will raise an exception.
- </p>
- <p>In Scheme48, threads are implemented using continuations, so the
- downward restriction applies to them as well. An attempt to return
- from Scheme to C at a time when the appropriate C frame is not on the
- top of the C stack will cause the current thread to block until the
- frame is available. For example, suppose thread <code>t0</code> calls a C
- function that calls back to Scheme, at which point control switches to
- thread <code>t1</code>, which also calls C & then back to Scheme. At this
- point, both <code>t0</code> & <code>t1</code> have active calls to C on the C
- stack, with <code>t1</code>’s C frame above <code>t0</code>’s. If <code>t0</code>
- attempts to return from Scheme to C, it will block, because the frame
- is not yet accessible. Once <code>t1</code> has returned to C and from there
- back to Scheme, <code>t0</code> will be able to resume. The return to Scheme
- is required because context switches can occur only while Scheme code
- is running. <code>T0</code> will also be able to resume if <code>t1</code> uses a
- continuation to throw past its call out to C.
- </p><hr>
- <span id="Interacting-with-the-Scheme-heap-in-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Interacting-with-the-Scheme-heap-in-C-1"></span><h3 class="section">7.7 Interacting with the Scheme heap in C</h3>
- <span id="index-GC-protection-in-C"></span>
- <p>Scheme48 uses a precise copying garbage collector. Any code that
- allocates objects within the Scheme48 heap may trigger a garbage
- collection. Variables bound to values in the Scheme48 heap need to be
- registered with the garbage collector so that the value will be safely
- held and so that the variables will be updated if the garbage collector
- moves the object. The garbage collector has no facility for updating
- pointers to the interiors of objects, so such pointers, for example the
- ones returned by <code>S48_EXTRACT_STRING</code>, will likely become invalid
- when a garbage collection occurs.
- </p>
- <dl>
- <dt id="index-S48_005fDECLARE_005fGC_005fPROTECT">C macro: <em></em> <strong>S48_DECLARE_GC_PROTECT</strong> <em>(<var>n</var>)</em></dt>
- <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>, …, s48_value <var>var</var><sub><var>n</var></sub>)</em></dt>
- <dt id="index-S48_005fGC_005fUNPROTECT">C macro: <em>void</em> <strong>S48_GC_UNPROTECT</strong> <em>()</em></dt>
- <dd><p><code>S48_DECLARE_GC_PROTECT</code>, where 1 <= <var>n</var> <= 9, allocates
- storage for registering <var>n</var> variables. At most one use of
- <code>S48_DECLARE_GC_PROTECT</code> may occur in a block. After declaring a
- GC protection, <code>S48_GC_PROTECT_<var>n</var></code> registers the <var>n</var>
- variables with the garbage collector. It must be within the scope that
- the <code>S48_DECLARE_GC_PROTECT</code> occurred in and before any code that
- can cause a garbage collection. <code>S48_GC_UNPROTECT</code> removes the
- current block’s protected variables from the garbage collector’s list.
- It must be called at the end of the block after any code that may cause
- a garbage collection. Omitting any of the three may cause serious and
- hard-to-debug problems, because the garbage collector may relocate an
- object and invalidate unprotected <code>s48_value</code> pointers. If not
- <code>S48_DECLARE_GC_PROTECT</code> is matched with a <code>S48_GC_UNPROTECT</code>
- or vice versa, a <code>gc-protection-mismatch</code> exception is raised when
- a C procedure returns to Scheme.
- </p></dd></dl>
- <dl>
- <dt id="index-S48_005fGC_005fPROTECT_005fGLOBAL">C macro: <em>void *</em> <strong>S48_GC_PROTECT_GLOBAL</strong> <em>(<var>global</var>)</em></dt>
- <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>
- <dd><p><code>S48_GC_PROTECT_GLOBAL</code> permanently registers the l-value
- <var>global</var> with the system as a garbage collection root. It returns
- a pointer which may then be supplied to <code>S48_GC_UNPROTECT_GLOBAL</code>
- to unregister the l-value as a root.
- </p></dd></dl>
- <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>
- <span id="index-storing-C-data-in-the-Scheme-heap"></span>
- <p>C data structures can be stored within the Scheme heap by embedding
- them inside <a href="#Bitwise-manipulation">byte vectors</a>. The
- following macros can be used to create and access embedded C objects.
- </p>
- <dl>
- <dt id="index-S48_005fMAKE_005fVALUE">C macro: <em>s48_value</em> <strong>S48_MAKE_VALUE</strong> <em>(<var>type</var>)</em></dt>
- <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>
- <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>
- <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>
- <dd><p><code>S48_MAKE_VALUE</code> allocates a byte vector large enough to hold a C
- value whose type is <var>type</var>. <code>S48_EXTRACT_VALUE</code> returns the
- contents of the byte vector <var>bytev</var> cast to <var>type</var>, and
- <code>S48_EXTRACT_VALUE_POINTER</code> returns a pointer to the contents of
- the byte vector, which is valid only until the next garbage collection.
- <code>S48_SET_VALUE</code> stores a value into the byte vector.
- </p></dd></dl>
- <span id="C-code-and-heap-images"></span><h4 class="subsection">7.7.2 C code and heap images</h4>
- <span id="index-restoring-C-data-after-resuming-images"></span>
- <span id="index-dumping-Scheme-heap-images-with-C-data"></span>
- <span id="index-record-resumers"></span>
- <p>Scheme48 uses dumped heap images to restore a previous system state.
- The Scheme48 heap is written into a file in a machine-independent and
- operating-system-independent format. The procedures described above,
- however, may be used to create objects in the Scheme heap that contain
- information specific to the current machine, operating system, or
- process. A heap image containing such objects may not work correctly
- when resumed.
- </p>
- <p>To address this problem, a record type may be given a <em>resumer</em>
- procedure. On startup, the resumer procedure for a record type is
- applied to each record of that type in the image being restarted. This
- procedure can update the record in a manner appropriate to the machine,
- operating system, or process used to resume the image. Note, though,
- that there is no reliable order in which record resumer procedures are
- applied. To specify the resumer for a record type, use the
- <code>define-record-resumer</code> procedure from the <a href="#Records"><code>record-types</code> structure</a>.
- </p><hr>
- <span id="Using-Scheme-records-in-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Using-Scheme-records-in-C-1"></span><h3 class="section">7.8 Using Scheme records in C</h3>
- <p>External C code can create records and access record slots positionally
- using these functions & macros. Note, however, that named access to
- record fields is not supported, only indexed access, so C code must be
- synchronized carefully with the corresponding Scheme that defines
- record types.
- </p>
- <dl>
- <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>
- <dt id="index-S48_005fRECORD_005fP">C macro: <em>int</em> <strong>S48_RECORD_P</strong> <em>(s48_value <var>object</var>)</em></dt>
- <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>
- <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>
- <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>
- <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>
- <dd><p><code>s48_make_record</code> allocates a record on Scheme’s heap with the
- given record type; its arguments must be a shared binding whose value
- is a record type descriptor (see <a href="#Records">Records</a>). <code>S48_RECORD_P</code>
- is the type predicate for records. <code>S48_RECORD_TYPE</code> returns the
- record type descriptor of <var>record</var>. <code>S48_RECORD_REF</code> &
- <code>S48_RECORD_SET</code> operate on records similarly to how
- <code>S48_VECTOR_REF</code> & <code>S48_VECTOR_SET</code> work on vectors.
- <code>s48_check_record_type</code> checks whether <var>record</var> is a record
- whose type is the value of the shared binding <var>type_binding</var>. If
- this is not the case, it signals an exception. (It also signals an
- exception if <var>type_binding</var>’s value is not a record.) Otherwise,
- it returns normally.
- </p></dd></dl>
- <p>For example, with this record type definition:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-record-type thing :thing
- (make-thing a b)
- thing?
- (a thing-a)
- (b thing-b))</pre></div>
- <p>the identifier <code>:thing</code> is bound to the record type and can be
- exported to C thus:
- </p>
- <div class="lisp">
- <pre class="lisp">(define-exported-binding "thing-record-type" :thing)</pre></div>
- <p>and <code>thing</code> records can be made in C:
- </p>
- <div class="example">
- <pre class="example">static s48_value thing_record_type = S48_FALSE;
- void initialize_things(void)
- {
- S48_GC_PROTECT_GLOBAL(thing_record_type);
- thing_record_type = s48_get_imported_binding("thing-record-type");
- }
- s48_value make_thing(s48_value a, s48_value b)
- {
- s48_value thing;
- S48_DECLARE_GC_PROTECT(2);
- S48_GC_PROTECT_2(a, b);
- thing = s48_make_record(thing_record_type);
- S48_RECORD_SET(thing, 0, a);
- S48_RECORD_SET(thing, 1, b);
- S48_GC_UNPROTECT();
- return thing;
- }</pre></div>
- <p>Note that the variables <code>a</code> & <code>b</code> must be protected against
- the possibility of a garbage collection occurring during the call to
- <code>s48_make_record</code>.
- </p><hr>
- <span id="Raising-exceptions-from-C"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Raising-exceptions-from-C-1"></span><h3 class="section">7.9 Raising exceptions from C</h3>
- <p>The following macros raise certain errors, immediately returning to
- Scheme48. Raising an exception performs all necessary clean-up actions
- to properly return to Scheme48, including adjusting the stack of
- protected variables.
- </p>
- <dl>
- <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>
- <dd><p>The base procedure for raising exceptions. <var>Type</var> is the type of
- exception; it should be one of the <code>S48_EXCEPTION_…</code>
- constants defined in <samp>scheme48.h</samp>. <var>Nargs</var> is the number of
- additional values to be included in the exception; these follow the
- <var>nargs</var> argument and should all have the type <code>s48_value</code>.
- <var>Nargs</var> may not be greater than ten.
- <code>s48_raise_scheme_exception</code> never returns.
- </p></dd></dl>
- <dl>
- <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>
- <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>
- <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>
- <dt id="index-s48_005fraise_005fclosed_005fchannel_005ferror">C function: <em></em> <strong>s48_raise_closed_channel_error</strong> <em>()</em></dt>
- <dt id="index-s48_005fraise_005fos_005ferror">C function: <em></em> <strong>s48_raise_os_error</strong> <em>(int <var>errno</var>)</em></dt>
- <dt id="index-s48_005fraise_005fout_005fof_005fmemory_005ferror">C function: <em></em> <strong>s48_raise_out_of_memory_error</strong> <em>()</em></dt>
- <dd><p>Conveniences for raising certain kinds of exceptions. Argument type
- errors are due to procedures receiving arguments of the incorrect type.
- Argument number errors are due to the number of arguments being passed
- to a procedure, <var>nargs</var>, not being between <var>min</var> or <var>max</var>,
- inclusive. Range errors are similar, but they are intended for larger
- ranges, not argument numbers. Closed channel errors occur when a
- <a href="#Channels">channel</a> was operated upon with the expectation
- that it would not be closed. OS errors originate from the OS, and they
- are denoted with Unix <code>errno</code> values.
- </p></dd></dl>
- <dl>
- <dt id="index-S48_005fCHECK_005fBOOLEAN">C macro: <em>void</em> <strong>S48_CHECK_BOOLEAN</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fCHECK_005fSYMBOL">C macro: <em>void</em> <strong>S48_CHECK_SYMBOL</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fCHECK_005fPAIR">C macro: <em>void</em> <strong>S48_CHECK_PAIR</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fCHECK_005fSTRING">C macro: <em>void</em> <strong>S48_CHECK_STRING</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fCHECK_005fINTEGER">C macro: <em>void</em> <strong>S48_CHECK_INTEGER</strong> <em>(s48_value <var>object</var>)</em></dt>
- <dt id="index-S48_005fCHECK_005fCHANNEL">C macro: <em>void</em> <strong>S48_CHECK_CHANNEL</strong> <em>(s48_value <var>object</var>)</em></dt>
- <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>
- <dt id="index-S48_005fCHECK_005fRECORD">C macro: <em>void</em> <strong>S48_CHECK_RECORD</strong> <em>(s48_value <var>object</var>)</em></dt>
- <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>
- <dd><p>Conveniences for checking argument types. These signal argument type
- errors with <code>s48_raise_argument_type_error</code> if their argument is
- not of the type being tested.
- </p></dd></dl>
- <hr>
- <span id="Unsafe-C-macros"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Unsafe-C-macros-1"></span><h3 class="section">7.10 Unsafe C macros</h3>
- <p>All of the C functions & macros described previously verify that their
- arguments have the appropriate types and lie in the appropriate ranges.
- The following macros are identical to their safe counterparts, except
- that the unsafe variants, by contrast, do <em>not</em> verify coherency
- of their arguments. They are provided for the purpose of writing more
- efficient code; their general use is not recommended.
- </p>
- <dl>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- <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>
- </dl>
- <br>
- <dl>
- <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>
- <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>
- <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>
- </dl>
- <hr>
- <span id="POSIX-interface"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="POSIX-interface-1"></span><h2 class="chapter">8 POSIX interface</h2>
- <p><i>(This chapter was derived from work copyrighted ©
- 1993–2005 by Richard Kelsey, Jonathan Rees, and Mike Sperber.)</i>
- </p>
- <p>This chapter describes Scheme48’s interface to POSIX C calls. Scheme
- versions of most of the C functions in POSIX are provided. Both the
- interface and implementation are new and likely to change significantly
- in future releases. The implementation may also contain many bugs.
- </p>
- <p>The POSIX bindings are available in several structures:
- </p>
- <dl compact="compact">
- <dd><span id="index-posix_002dprocesses"></span>
- </dd>
- <dt><code>posix-processes</code></dt>
- <dd><p><code>fork</code>, <code>exec</code>, and other process manipulation procedures
- </p>
- <span id="index-posix_002dprocess_002ddata"></span>
- </dd>
- <dt><code>posix-process-data</code></dt>
- <dd><p>procedures for accessing information about processes
- </p>
- <span id="index-posix_002dfiles"></span>
- </dd>
- <dt><code>posix-files</code></dt>
- <dd><p>POSIX file system access procedures
- </p>
- <span id="index-posix_002di_002fo"></span>
- </dd>
- <dt><code>posix-i/o</code></dt>
- <dd><p>pipes and various POSIX I/O controls
- </p>
- <span id="index-posix_002dtime"></span>
- </dd>
- <dt><code>posix-time</code></dt>
- <dd><p>POSIX time operations
- </p>
- <span id="index-posix_002dusers"></span>
- </dd>
- <dt><code>posix-users</code></dt>
- <dd><p>user and group manipulation procedures
- </p>
- <span id="index-posix_002dregexps"></span>
- </dd>
- <dt><code>posix-regexps</code></dt>
- <dd><p>POSIX regular expression construction and matching
- </p>
- <span id="index-posix"></span>
- </dd>
- <dt><code>posix</code></dt>
- <dd><p>all of the above
- </p></dd>
- </dl>
- <p>Scheme48’s POSIX interface differs from scsh [Shivers 94; Shivers 96;
- Shivers <i>et al.</i> 04] in several ways. The interface here lacks scsh’s
- high-level constructs and utilities such as the process notation,
- <code>awk</code> facility, and parsing utilities. Scheme48 uses disjoint
- types for some values that scsh leaves as symbols or simple integers;
- these include file types, file modes, and user & group ids. Many of
- the names and other interface details are different as well.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#POSIX-processes" accesskey="1">POSIX processes</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-signals" accesskey="2">POSIX signals</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-process-environment" accesskey="3">POSIX process environment</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-users-and-groups" accesskey="4">POSIX users and groups</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-host-OS-and-machine-identification" accesskey="5">POSIX host OS and machine identification</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-file-system-access" accesskey="6">POSIX file system access</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-time" accesskey="7">POSIX time</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-I_002fO-utilities" accesskey="8">POSIX I/O utilities</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-regular-expressions" accesskey="9">POSIX regular expressions</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#POSIX-C-to-Scheme-correspondence">POSIX C to Scheme correspondence</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="POSIX-processes"></span><div class="header">
- <p>
- Next: <a href="#POSIX-signals" accesskey="n" rel="next">POSIX signals</a>, Up: <a href="#POSIX-interface" accesskey="u" rel="up">POSIX interface</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Processes"></span><h3 class="section">8.1 Processes</h3>
- <span id="index-posix_002dprocesses-1"></span>
- <p>The procedures described in this section control the creation of
- subprocesses and the execution of programs. They exported by both the
- <code>posix-processes</code> and <code>posix</code> structures.
- </p>
- <span id="index-forking"></span>
- <span id="index-process-forking"></span>
- <span id="index-POSIX-fork"></span>
- <dl>
- <dt id="index-fork">procedure: <strong>fork</strong> <em>--> process id or <code>#f</code></em></dt>
- <dt id="index-fork_002dand_002dforget">procedure: <strong>fork-and-forget</strong> <em>thunk --> unspecified</em></dt>
- <dd><p><code>Fork</code> creates a new child process. In the parent process, it
- returns the child’s process id; in the child process, it returns
- <code>#f</code>. <code>Fork-and-forget</code> calls <var>thunk</var> in a new process;
- no process id is returned. <code>Fork-and-forget</code> uses an intermediate
- process to avoid creating a zombie.
- </p></dd></dl>
- <span id="index-process-ids"></span>
- <span id="index-POSIX-process-ids"></span>
- <dl>
- <dt id="index-process_002did_003f">procedure: <strong>process-id?</strong> <em>object --> boolean</em></dt>
- <dt id="index-process_002did_003d_003f">procedure: <strong>process-id=?</strong> <em>pid<sub>a</sub> pid<sub>b</sub> --> boolean</em></dt>
- <dt id="index-process_002did_002d_003einteger">procedure: <strong>process-id->integer</strong> <em>pid --> integer</em></dt>
- <dt id="index-integer_002d_003eprocess_002did">procedure: <strong>integer->process-id</strong> <em>integer --> pid</em></dt>
- <dd><p><code>Process-id?</code> is the disjoint type predicate for process ids.
- <code>Process-id=?</code> tests whether two process ids are the same.
- <code>Process-id->integer</code> & <code>integer->process-id</code> convert between
- Scheme48’s opaque process id type and POSIX process id integers.
- </p></dd></dl>
- <span id="index-process-termination"></span>
- <span id="index-POSIX-process-termination"></span>
- <span id="index-waiting-for-POSIX-processes"></span>
- <dl>
- <dt id="index-process_002did_002dexit_002dstatus">procedure: <strong>process-id-exit-status</strong> <em>pid --> integer or <code>#f</code></em></dt>
- <dt id="index-process_002did_002dterminating_002dsignal">procedure: <strong>process-id-terminating-signal</strong> <em>pid --> signal or <code>#f</code></em></dt>
- <dt id="index-wait_002dfor_002dchild_002dprocess">procedure: <strong>wait-for-child-process</strong> <em>pid --> unspecified</em></dt>
- <dd><p>If the process identified by <var>pid</var> exited normally or is running,
- <code>process-id-exit-status</code> and <code>process-id-terminating-signal</code>
- will both return <code>#f</code>. If, however, it terminated abnormally,
- <code>process-id-exit-status</code> returns its exit status, and if it exited
- due to a signal then <code>process-id-terminating-signal</code> returns the
- signal due to which it exited. <code>Wait-for-child-process</code> blocks
- the current process until the process identified by <var>pid</var> has
- terminated. Scheme48 may reap child processes before the user requests
- their exit status, but it does not always do so.
- </p></dd></dl>
- <span id="index-exiting-processes"></span>
- <span id="index-POSIX-process-exiting"></span>
- <dl>
- <dt id="index-exit">procedure: <strong>exit</strong> <em>status --> does not return</em></dt>
- <dd><p>Terminates the current process with the integer <var>status</var> as its
- exit status.
- </p></dd></dl>
- <span id="index-executing-processes"></span>
- <span id="index-POSIX-exec"></span>
- <dl>
- <dt id="index-exec">procedure: <strong>exec</strong> <em>program argument … --> does not return</em></dt>
- <dt id="index-exec_002dwith_002denvironment">procedure: <strong>exec-with-environment</strong> <em>program env argument … --> does not return</em></dt>
- <dt id="index-exec_002dfile">procedure: <strong>exec-file</strong> <em>filename argument … --> does not return</em></dt>
- <dt id="index-exec_002dfile_002dwith_002denvironment">procedure: <strong>exec-file-with-environment</strong> <em>filename env argument … --> does not return</em></dt>
- <dd><p>These all replace the current program with a new one. They differ in
- how the program is found and what process environment the program
- should receive. <code>Exec</code> & <code>exec-with-environment</code> look up
- the program in the search path (the <code>PATH</code> environment variable),
- while <code>exec-file</code> & <code>exec-file-with-environment</code> execute a
- particular file. The environment is either inherited from the
- current process, in the cases of <code>exec</code> & <code>exec-file</code>, or
- explicitly specified, in the cases of <code>exec-with-environment</code> &
- <code>exec-file-with-environment</code>. <var>Program</var>, <var>filename</var>, &
- all <var>argument</var>s should be strings. <var>Env</var> should be a list of
- strings of the form <code>"<var>name</var>=<var>value</var>"</code>. When the new
- program is invoked, its arguments consist of the program name prepended
- to the remaining specified arguments.
- </p></dd></dl>
- <dl>
- <dt id="index-exec_002dwith_002dalias">procedure: <strong>exec-with-alias</strong> <em>name lookup? maybe-env arguments --> does not return</em></dt>
- <dd><p>General omnibus procedure that subsumes the other <code>exec</code> variants.
- <var>Name</var> is looked up in the search path if <var>lookup?</var> is true or
- used as an ordinary filename if it is false. <var>Maybe-env</var> is either
- <code>#f</code>, in which case the new program’s environment should be
- inherited from the current process, or a list of strings of the above
- form for environments, which specifies the new program’s environment.
- <var>Arguments</var> is a list of <em>all</em> of the program’s arguments;
- <code>exec-with-alias</code> does <em>not</em> prepend <var>name</var> to that list
- (hence <code>-with-alias</code>).
- </p></dd></dl>
- <hr>
- <span id="POSIX-signals"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Signals"></span><h3 class="section">8.2 Signals</h3>
- <span id="index-posix_002dsignals"></span>
- <p>There are two varieties of signals available, named & anonymous. A
- <em>named</em> signal is one for which there is provided a symbolic name,
- such as <code>kill</code> or <code>pipe</code>. Anonymous signals are those that
- the operating system provided but for which POSIX does not define a
- symbolic name, only a number, and which may not have meaning on other
- operating systems. Named signals preserve their meaning through heap
- image dumps; anonymous signals may not be dumped in heap images. (If
- they are, a warning is signalled, and they are replaced with a special
- token that denotes a non-portable signal.) Not all named signals are
- available from all operating systems, and there may be multiple names
- for a single operating system signal number.
- </p>
- <dl>
- <dt id="index-signal-1">syntax: <strong>signal</strong> <em>name --> signal</em></dt>
- <dt id="index-name_002d_003esignal">procedure: <strong>name->signal</strong> <em>symbol --> signal or <code>#f</code></em></dt>
- <dt id="index-integer_002d_003esignal">procedure: <strong>integer->signal</strong> <em>integer --> signal</em></dt>
- <dt id="index-signal_003f">procedure: <strong>signal?</strong> <em>object --> boolean</em></dt>
- <dt id="index-signal_002dname">procedure: <strong>signal-name</strong> <em>signal --> symbol or <code>#f</code></em></dt>
- <dt id="index-signal_002dos_002dnumber">procedure: <strong>signal-os-number</strong> <em>signal --> integer</em></dt>
- <dt id="index-signal_003d_003f">procedure: <strong>signal=?</strong> <em>signal<sub>a</sub> signal<sub>b</sub> --> boolean</em></dt>
- <dd><p><code>Signal</code> evaluates to the signal object with the known symbolic
- name <var>name</var>. It is an error if <var>name</var> is not recognized as any
- signal’s name. <code>Name->signal</code> returns the signal corresponding
- with the given <var>name</var> or <code>#f</code> if no such signal is known.
- <code>Integer->signal</code> returns a signal, named or anonymous, with the
- given OS number. <code>Signal?</code> is the disjoint type predicate for
- signal objects. <code>Signal-name</code> returns the symbolic name of
- <var>signal</var> if it is a named signal or <code>#f</code> if it is an anonymous
- signal. <code>Signal-OS-number</code> returns the operating system’s integer
- value of <var>signal</var>. <code>Signal=?</code> tests whether two signals are
- the same, <i>i.e.</i> whether their OS numbers are equal equal.
- </p>
- <p>These are all of the symbols that POSIX defines.
- </p>
- <dl compact="compact">
- <dt><code>abrt</code></dt>
- <dd><p>abnormal termination (as by <code>abort(3)</code>)
- </p></dd>
- <dt><code>alrm</code></dt>
- <dd><p>timeout signal (as by <code>alarm(2)</code>)
- </p></dd>
- <dt><code>fpe</code></dt>
- <dd><p>floating point exception
- </p></dd>
- <dt><code>hup</code></dt>
- <dd><p>hangup on controlling terminal or death of controlling process
- </p></dd>
- <dt><code>ill</code></dt>
- <dd><p>illegal instruction
- </p></dd>
- <dt><code>int</code></dt>
- <dd><p>interrupt — interaction attention
- </p></dd>
- <dt><code>kill</code></dt>
- <dd><p>termination signal, cannot be caught or ignored
- </p></dd>
- <dt><code>pipe</code></dt>
- <dd><p>write was attempted on a pipe with no readers
- </p></dd>
- <dt><code>quit</code></dt>
- <dd><p>interaction termination
- </p></dd>
- <dt><code>segv</code></dt>
- <dd><p>segmentation violation — invalid memory reference
- </p></dd>
- <dt><code>term</code></dt>
- <dd><p>termination signal
- </p></dd>
- <dt><code>usr1</code></dt>
- <dt><code>usr2</code></dt>
- <dd><p>for use by applications
- </p></dd>
- <dt><code>chld</code></dt>
- <dd><p>child process stopped or terminated
- </p></dd>
- <dt><code>cont</code></dt>
- <dd><p>continue if stopped
- </p></dd>
- <dt><code>stop</code></dt>
- <dd><p>stop immediately, cannot be caught or ignored
- </p></dd>
- <dt><code>tstp</code></dt>
- <dd><p>interactive stop
- </p></dd>
- <dt><code>ttin</code></dt>
- <dd><p>read from control terminal attempted by a background process
- </p></dd>
- <dt><code>ttou</code></dt>
- <dd><p>write to control terminal attempted by a background process
- </p></dd>
- <dt><code>bus</code></dt>
- <dd><p>bus error — access to undefined portion of memory
- </p></dd>
- </dl>
- <p>There are also several other signals whose names are allowed to be
- passed to <code>signal</code> that are not defined by POSIX, but that are
- recognized by many operating systems.
- </p>
- <dl compact="compact">
- <dt><code>trap</code></dt>
- <dd><p>trace or breakpoint trap
- </p></dd>
- <dt><code>iot</code></dt>
- <dd><p>synonym for <code>abrt</code>
- </p></dd>
- <dt><code>emt</code></dt>
- <dt><code>sys</code></dt>
- <dd><p>bad argument to routine (SVID)
- </p></dd>
- <dt><code>stkflt</code></dt>
- <dd><p>stack fault on coprocessor
- </p></dd>
- <dt><code>urg</code></dt>
- <dd><p>urgent condition on socket (4.2 BSD)
- </p></dd>
- <dt><code>io</code></dt>
- <dd><p>I/O now possible (4.2 BSD)
- </p></dd>
- <dt><code>poll</code></dt>
- <dd><p>synonym for <code>io</code> (System V)
- </p></dd>
- <dt><code>cld</code></dt>
- <dd><p>synonym for <code>chld</code>
- </p></dd>
- <dt><code>xcpu</code></dt>
- <dd><p>CPU time limit exceeded (4.2 BSD)
- </p></dd>
- <dt><code>xfsz</code></dt>
- <dd><p>file size limit exceeded (4.2 BSD)
- </p></dd>
- <dt><code>vtalrm</code></dt>
- <dd><p>virtual alarm clock (4.2 BSD)
- </p></dd>
- <dt><code>prof</code></dt>
- <dd><p>profile alarm clock
- </p></dd>
- <dt><code>pwr</code></dt>
- <dd><p>power failure (System V)
- </p></dd>
- <dt><code>info</code></dt>
- <dd><p>synonym for <code>pwr</code>
- </p></dd>
- <dt><code>lock</code></dt>
- <dd><p>file lock lost
- </p></dd>
- <dt><code>winch</code></dt>
- <dd><p>Window resize signal (4.3 BSD, Sun)
- </p></dd>
- <dt><code>unused</code></dt>
- </dl>
- </dd></dl>
- <span id="Sending-_0026-receiving-signals"></span><h4 class="subsection">8.2.1 Sending & receiving signals</h4>
- <dl>
- <dt id="index-signal_002dprocess">procedure: <strong>signal-process</strong> <em>pid signal --> unspecified</em></dt>
- <dd><p>Sends a signal represented by <var>signal</var> to the process identified by
- <var>pid</var>.
- </p></dd></dl>
- <span id="index-signal-queues"></span>
- <p>Signals received by the Scheme process can be obtained via one or more
- <em>signal queues</em>. Each signal queue has a list of monitored signals
- and a queue of received signals that have yet to be consumed from the
- queue. When the Scheme process receives a signal, that signal is added
- to the signal queues that are currently monitoring the signal received.
- </p>
- <dl>
- <dt id="index-make_002dsignal_002dqueue">procedure: <strong>make-signal-queue</strong> <em>signal-list --> signal-queue</em></dt>
- <dt id="index-signal_002dqueue_003f">procedure: <strong>signal-queue?</strong> <em>object --> boolean</em></dt>
- <dt id="index-signal_002dqueue_002dmonitored_002dsignals">procedure: <strong>signal-queue-monitored-signals</strong> <em>signal-queue --> signal-list</em></dt>
- <dt id="index-dequeue_002dsignal_0021">procedure: <strong>dequeue-signal!</strong> <em>signal-queue --> signal (may block)</em></dt>
- <dt id="index-maybe_002ddequeue_002dsignal_0021">procedure: <strong>maybe-dequeue-signal!</strong> <em>signal-queue --> signal or <code>#f</code></em></dt>
- <dd><p><code>Make-signal-queue</code> returns a new signal queue that will monitor
- all of the signals in the given list. <code>Signal-queue?</code> is the
- disjoint type predicate for signal queues.
- <code>Signal-queue-monitored-signals</code> returns a freshly-allocated list
- of the signals currently monitored by <var>signal-queue</var>.
- <code>Dequeue-signal!</code> & <code>maybe-dequeue-signal!</code> both access the
- next signal ready to be read from <var>signal-queue</var>. If the signal
- queue is empty, <code>dequeue-signal!</code> will block until a signal is
- received, while <code>maybe-dequeue-signal!</code> will immediately return
- <code>#f</code>.
- </p></dd></dl>
- <p><strong>Note:</strong> There is a bug in the current system that causes an
- erroneous deadlock to occur if threads are blocked waiting for signals
- and no other threads are available to run. A workaround is to create a
- thread that sleeps for a long time, which prevents any deadlock errors
- (including real ones):
- </p>
- <div class="lisp">
- <pre class="lisp">> ,open threads
- > (spawn (lambda ()
- ;; Sleep for a year.
- (sleep (* 1000 60 60 24 365))))</pre></div>
- <dl>
- <dt id="index-add_002dsignal_002dqueue_002dsignal_0021">procedure: <strong>add-signal-queue-signal!</strong> <em>signal-queue signal --> unspecified</em></dt>
- <dt id="index-remove_002dsignal_002dqueue_002dsignal_0021">procedure: <strong>remove-signal-queue-signal!</strong> <em>signal-queue signal --> unspecified</em></dt>
- <dd><p>These add & remove signals from signal queues’ list of signals to
- monitor. Note that <code>remove-signal-queue-signal!</code> also removes any
- pending signals from the queue, so <code>dequeue-signal!</code> &
- <code>maybe-dequeue-signal!</code> will only ever return signals that are
- on the queue’s list of monitored signals when they are called.
- </p></dd></dl>
- <hr>
- <span id="POSIX-process-environment"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Process-environment"></span><h3 class="section">8.3 Process environment</h3>
- <span id="index-posix_002dprocess_002ddata-1"></span>
- <p>These procedures are exported by the structures <code>posix</code> &
- <code>posix-process-data</code>.
- </p>
- <span id="index-process-ids-1"></span>
- <span id="index-POSIX-process-ids-1"></span>
- <dl>
- <dt id="index-get_002dprocess_002did">procedure: <strong>get-process-id</strong> <em>--> process-id</em></dt>
- <dt id="index-get_002dparent_002dprocess_002did">procedure: <strong>get-parent-process-id</strong> <em>--> process-id</em></dt>
- <dd><p>These return the <a href="#POSIX-processes">process id</a> of the current
- process or the current process’s parent, respectively.
- </p></dd></dl>
- <span id="index-user-ids"></span>
- <span id="index-group-ids"></span>
- <span id="index-POSIX-user-ids"></span>
- <span id="index-POSIX-group-ids"></span>
- <dl>
- <dt id="index-get_002duser_002did">procedure: <strong>get-user-id</strong> <em>--> user-id</em></dt>
- <dt id="index-get_002deffective_002duser_002did">procedure: <strong>get-effective-user-id</strong> <em>--> user-id</em></dt>
- <dt id="index-set_002duser_002did_0021">procedure: <strong>set-user-id!</strong> <em>user-id --> unspecified</em></dt>
- <dt id="index-get_002dgroup_002did">procedure: <strong>get-group-id</strong> <em>--> group-id</em></dt>
- <dt id="index-get_002deffective_002dgroup_002did">procedure: <strong>get-effective-group-id</strong> <em>--> group-id</em></dt>
- <dt id="index-set_002dgroup_002did_0021">procedure: <strong>set-group-id!</strong> <em>group-id --> unspecified</em></dt>
- <dd><p>These access the original and effective <a href="#POSIX-users-and-groups">user & group ids</a> of the current process. The effective ids
- may be set, but not the original ones.
- </p></dd></dl>
- <dl>
- <dt id="index-get_002dgroups">procedure: <strong>get-groups</strong> <em>--> group-id list</em></dt>
- <dt id="index-get_002dlogin_002dname">procedure: <strong>get-login-name</strong> <em>--> string</em></dt>
- <dd><p><code>Get-groups</code> returns a list of the supplementary groups of the
- current process. <code>Get-login-name</code> returns a user name for the
- current process.
- </p></dd></dl>
- <span id="index-environment-variables"></span>
- <span id="index-POSIX-environment-variables"></span>
- <dl>
- <dt id="index-lookup_002denvironment_002dvariable">procedure: <strong>lookup-environment-variable</strong> <em>string --> string or <code>#f</code></em></dt>
- <dt id="index-environment_002dalist">procedure: <strong>environment-alist</strong> <em>--> alist</em></dt>
- <dd><p><code>Lookup-environment-variable</code> looks up its argument in the
- environment list of the current process and returns the corresponding
- string, or <code>#f</code> if there is none. <code>Environment-alist</code>
- returns the entire environment as a list of <code>(<var>name-string</var> .
- <var>value-string</var>)</code> pairs.
- </p></dd></dl>
- <hr>
- <span id="POSIX-users-and-groups"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Users-and-groups"></span><h3 class="section">8.4 Users and groups</h3>
- <span id="index-posix_002dusers-1"></span>
- <span id="index-user-ids-1"></span>
- <span id="index-group-ids-1"></span>
- <p><em>User ids</em> & <em>group ids</em> are boxed integers that represent Unix
- users & groups. Also, every user & group has a corresponding <em>user
- info</em> or <em>group info</em> record, which contains miscellaneous
- information about the user or group. The procedures in this section
- are exported by the structures <code>posix-users</code> & <code>posix</code>.
- </p>
- <dl>
- <dt id="index-user_002did_003f">procedure: <strong>user-id?</strong> <em>object --> boolean</em></dt>
- <dt id="index-user_002did_003d_003f">procedure: <strong>user-id=?</strong> <em>uid<sub>a</sub> uid<sub>b</sub> --> boolean</em></dt>
- <dt id="index-user_002did_002d_003einteger">procedure: <strong>user-id->integer</strong> <em>uid --> integer</em></dt>
- <dt id="index-integer_002d_003euser_002did">procedure: <strong>integer->user-id</strong> <em>integer --> uid</em></dt>
- <dt id="index-group_002did_003f">procedure: <strong>group-id?</strong> <em>object --> boolean</em></dt>
- <dt id="index-group_002did_003d_003f">procedure: <strong>group-id=?</strong> <em>gid<sub>a</sub> gid<sub>b</sub> --> boolean</em></dt>
- <dt id="index-group_002did_002d_003einteger">procedure: <strong>group-id->integer</strong> <em>gid --> integer</em></dt>
- <dt id="index-integer_002d_003egroup_002did">procedure: <strong>integer->group-id</strong> <em>integer --> gid</em></dt>
- <dd><p><code>User-id?</code> & <code>group-id?</code> are the disjoint type predicates for
- user & group ids. <code>User-id=?</code> & <code>group-id=?</code> test whether
- two user or group ids, respectively, are the same, <i>i.e.</i> whether their
- numbers are equal. <code>User-id->integer</code>, <code>group-id->integer</code>,
- <code>integer->user-id</code>, & <code>integer->group-id</code> convert between
- user or group ids and integers.
- </p></dd></dl>
- <span id="index-POSIX-user-info"></span>
- <span id="index-POSIX-group-info"></span>
- <dl>
- <dt id="index-user_002did_002d_003euser_002dinfo">procedure: <strong>user-id->user-info</strong> <em>uid --> user-info</em></dt>
- <dt id="index-name_002d_003euser_002dinfo">procedure: <strong>name->user-info</strong> <em>string --> user-info</em></dt>
- <dt id="index-group_002did_002d_003egroup_002dinfo">procedure: <strong>group-id->group-info</strong> <em>gid --> group-info</em></dt>
- <dt id="index-name_002d_003egroup_002dinfo">procedure: <strong>name->group-info</strong> <em>string --> group-info</em></dt>
- <dd><p>These provide access for the user or group info records that correspond
- with the given user or group ids or names.
- </p></dd></dl>
- <dl>
- <dt id="index-user_002dinfo_003f">procedure: <strong>user-info?</strong> <em>object --> boolean</em></dt>
- <dt id="index-user_002dinfo_002dname">procedure: <strong>user-info-name</strong> <em>user-info --> string</em></dt>
- <dt id="index-user_002dinfo_002did">procedure: <strong>user-info-id</strong> <em>user-info --> user-id</em></dt>
- <dt id="index-user_002dinfo_002dgroup">procedure: <strong>user-info-group</strong> <em>user-info --> group-id</em></dt>
- <dt id="index-user_002dinfo_002dhome_002ddirectory">procedure: <strong>user-info-home-directory</strong> <em>user-info --> string</em></dt>
- <dt id="index-user_002dinfo_002dshell">procedure: <strong>user-info-shell</strong> <em>user-info --> string</em></dt>
- <dt id="index-group_002dinfo_003f">procedure: <strong>group-info?</strong> <em>object --> boolean</em></dt>
- <dt id="index-group_002dinfo_002dname">procedure: <strong>group-info-name</strong> <em>group-info --> string</em></dt>
- <dt id="index-group_002dinfo_002did">procedure: <strong>group-info-id</strong> <em>group-info --> group-id</em></dt>
- <dt id="index-group_002dinfo_002dmembers">procedure: <strong>group-info-members</strong> <em>group-info --> user-id-list</em></dt>
- <dd><p><code>User-info?</code> & <code>group-info?</code> are the disjoint type predicates
- for user info & group info records. The others are accessors for the
- various data available in those records.
- </p></dd></dl>
- <hr>
- <span id="POSIX-host-OS-and-machine-identification"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Host-OS-and-machine-identification"></span><h3 class="section">8.5 Host OS and machine identification</h3>
- <span id="index-posix_002dplatform_002dnames"></span>
- <dl>
- <dt id="index-host_002dname">procedure: <strong>host-name</strong> <em>--> string</em></dt>
- <dt id="index-os_002dnode_002dname">procedure: <strong>os-node-name</strong> <em>--> string</em></dt>
- <dt id="index-os_002drelease_002dname">procedure: <strong>os-release-name</strong> <em>--> string</em></dt>
- <dt id="index-os_002dversion_002dname">procedure: <strong>os-version-name</strong> <em>--> string</em></dt>
- <dt id="index-machine_002dname">procedure: <strong>machine-name</strong> <em>--> string</em></dt>
- <dd><p>These procedures return strings that are intended to identify various
- aspects of the current operating system and physical machine. POSIX
- does not specify the format of the strings. These procedures are
- provided by both the structure <code>posix-platform-names</code> and the
- structure <code>posix</code>.
- </p></dd></dl>
- <hr>
- <span id="POSIX-file-system-access"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="File-system-access"></span><h3 class="section">8.6 File system access</h3>
- <span id="index-posix_002dfiles-1"></span>
- <p>These procedures operate on the file system via the facilities defined
- by POSIX and offer more than standard & portable R5RS operations. All
- of these names are exported by the structures <code>posix-files</code> and
- <code>posix</code>.
- </p>
- <span id="index-POSIX-directory-access"></span>
- <span id="index-directory-streams"></span>
- <dl>
- <dt id="index-open_002ddirectory_002dstream">procedure: <strong>open-directory-stream</strong> <em>filename --> dir-stream</em></dt>
- <dt id="index-directory_002dstream_003f">procedure: <strong>directory-stream?</strong> <em>object --> boolean</em></dt>
- <dt id="index-read_002ddirectory_002dstream">procedure: <strong>read-directory-stream</strong> <em>dir-stream --> filename or <code>#f</code></em></dt>
- <dt id="index-close_002ddirectory_002dstream">procedure: <strong>close-directory-stream</strong> <em>dir-stream --> unspecified</em></dt>
- <dd><p>Directory streams are the low-level interface provided by POSIX to
- enumerate the contents of a directory. <code>Open-directory-stream</code>
- opens a new directory stream that will enumerate all of the files
- within the directory named by <var>filename</var>. <code>Directory-stream?</code>
- is the disjoint type predicate for directory streams.
- <code>Read-directory-stream</code> consumes the next filename from
- <var>dir-stream</var> and returns it, or returns <code>#f</code> if the stream has
- finished. Note that <code>read-directory-stream</code> will return only
- simple filenames, not full pathnames. <code>Close-directory-stream</code>
- closes <var>dir-stream</var>, removing any storage it required in the
- operating system. Closing an already closed directory stream has no
- effect.
- </p></dd></dl>
- <span id="index-directory-listing"></span>
- <span id="index-listing-directories"></span>
- <dl>
- <dt id="index-list_002ddirectory">procedure: <strong>list-directory</strong> <em>filename --> string list</em></dt>
- <dd><p>Returns the list of filenames in the directory named by <var>filename</var>.
- This is equivalent to opening a directory stream, repeatedly reading
- from it & accumulating the list of filenames, and closing the stream.
- </p></dd></dl>
- <span id="index-POSIX-working-directory"></span>
- <span id="index-working-directory"></span>
- <dl>
- <dt id="index-working_002ddirectory">procedure: <strong>working-directory</strong> <em>--> string</em></dt>
- <dt id="index-set_002dworking_002ddirectory_0021">procedure: <strong>set-working-directory!</strong> <em>string --> unspecified</em></dt>
- <dd><p>These access the working directory’s filename of the current process.
- </p></dd></dl>
- <span id="index-POSIX-file-opening"></span>
- <dl>
- <dt id="index-open_002dfile">procedure: <strong>open-file</strong> <em>pathname file-options [file-mode] --> port</em></dt>
- <dd><p>Opens a port to the file named by the string <var>pathname</var>.
- <var>File-options</var> specifies various aspects of the port. The optional
- <var>file-mode</var> argument is used only if the file to be opened does not
- already exist; it specifies the permissions to be assigned to the file
- if it is created. The returned port is an input port if the given
- options include <code>read-only</code>; otherwise <code>open-file</code> returns an
- output port. Because Scheme48 does not support combined input/output
- ports, <code>dup-switching-mode</code> can be used to open an input port for
- output ports opened with the <code>read-write</code> option.
- </p></dd></dl>
- <p>File options are stored in a boxed mask representation. File option
- sets are created with <code>file-options</code> and tested with
- <code>file-options-on?</code>.
- </p>
- <dl>
- <dt id="index-file_002doptions">syntax: <strong>file-options</strong> <em>name … --> file-options</em></dt>
- <dt id="index-file_002doptions_002don_003f">procedure: <strong>file-options-on?</strong> <em>options<sub>a</sub> options<sub>b</sub> --> boolean</em></dt>
- <dd><p><code>File-options</code> evaluates to a file option set, suitable for passing
- to <code>open-file</code>, that includes all of the given named options.
- <code>File-options-on?</code> returns true if <var>options<sub>a</sub></var> includes
- all of the options in <var>options<sub>b</sub></var>, or false if otherwise.
- </p>
- <p>The following file option names are supported as arguments to the
- <code>file-options</code> syntax:
- </p>
- <dl compact="compact">
- <dt><code>create</code></dt>
- <dd><p>create file if it does not already exist; a <var>file-mode</var> argument is
- required to be passed to <code>open-file</code> if the <code>create</code> option
- is specified
- </p>
- </dd>
- <dt><code>exclusive</code></dt>
- <dd><p>an error will be signalled if this option & <code>create</code> are both set
- and the file already exists
- </p>
- </dd>
- <dt><code>no-controlling-tty</code></dt>
- <dd><p>if the pathname being opened is a terminal device, the terminal will
- not become the controlling terminal of the process
- </p>
- </dd>
- <dt><code>truncate</code></dt>
- <dd><p>file is truncated
- </p>
- </dd>
- <dt><code>append</code></dt>
- <dd><p>written data to the newly opened file will be appended to the existing
- contents
- </p>
- </dd>
- <dt><code>nonblocking</code></dt>
- <dd><p>read & write operations will not block
- </p>
- </dd>
- <dt><code>read-only</code></dt>
- <dd><p>file may not be written to, only read from
- </p>
- </dd>
- <dt><code>read-write</code></dt>
- <dd><p>file may be both read from & written to
- </p>
- </dd>
- <dt><code>write-only</code></dt>
- <dd><p>file may not be read from, only written to
- </p></dd>
- </dl>
- <p>The last three are all mutually exclusive.
- </p></dd></dl>
- <p>Examples:
- </p>
- <div class="lisp">
- <pre class="lisp">(open-file "some-file.txt"
- (file-options create write-only)
- (file-mode read owner-write))</pre></div>
- <p>returns an output port that writes to a newly-created file that can be
- read from by anyone but written to only by the owner. Once the file
- <samp>some-file.txt</samp> exists,
- </p>
- <div class="lisp">
- <pre class="lisp">(open-file "some-file.txt"
- (file-options append write-only))</pre></div>
- <p>will open an output port that appends to the file.
- </p>
- <p><a href="#POSIX-I_002fO-utilities"><code>I/o-flags</code> & <code>set-i/o-flags!</code></a>
- can be used to access the <code>append</code>, <code>nonblocking</code>, and
- read/write file options of ports, as well as modify the <code>append</code> &
- <code>nonblocking</code> options.
- </p>
- <span id="index-nonblocking-I_002fO"></span>
- <span id="index-blocking-I_002fO"></span>
- <p>To keep port operations from blocking in the Scheme48 process, output
- ports are set to be nonblocking at the time of creation. (Input ports
- are managed using <code>select(2)</code>.) <code>Set-i/o-flags!</code> can be used
- to make an output port blocking, for example directly before forking,
- but care should be exercised, because the Scheme48 run-time system may
- be confused if an I/O operation blocks.
- </p>
- <span id="index-POSIX-file-creation-masks"></span>
- <dl>
- <dt id="index-set_002dfile_002dcreation_002dmask_0021">procedure: <strong>set-file-creation-mask!</strong> <em>file-mode --> file-mode</em></dt>
- <dd><p>Sets the file creation mask to be <var>file-mode</var>. Bits set in
- <var>file-mode</var> are cleared in the modes of any files or directories
- subsequently created by the current process.
- </p></dd></dl>
- <span id="index-POSIX-links"></span>
- <span id="index-creating-POSIX-links"></span>
- <span id="index-creating-directories"></span>
- <span id="index-making-directories"></span>
- <span id="index-directory-creation"></span>
- <span id="index-POSIX-FIFOs"></span>
- <span id="index-creating-POSIX-FIFOs"></span>
- <dl>
- <dt id="index-link">procedure: <strong>link</strong> <em>existing-pathname new-pathname --> unspecified</em></dt>
- <dt id="index-make_002ddirectory">procedure: <strong>make-directory</strong> <em>pathname file-mode --> unspecified</em></dt>
- <dt id="index-make_002dfifo">procedure: <strong>make-fifo</strong> <em>pathname file-mode --> unspecified</em></dt>
- <dd><p><code>Link</code> creates a hard link for the file at <var>existing-pathname</var>
- at <var>new-pathname</var>. <code>Make-directory</code> creates a new directory
- at the locations specified by <var>pathname</var> with the the file mode
- <var>file-mode</var>. <code>Make-fifo</code> does similarly, but it creates a
- FIFO (first-in first-out) file instead of a directory.
- </p></dd></dl>
- <span id="index-deleting-files"></span>
- <span id="index-file-deletion"></span>
- <span id="index-removing-files"></span>
- <span id="index-deleting-directories"></span>
- <span id="index-directory-deletion"></span>
- <span id="index-removing-directories"></span>
- <span id="index-renaming-files"></span>
- <dl>
- <dt id="index-unlink">procedure: <strong>unlink</strong> <em>pathname --> unspecified</em></dt>
- <dt id="index-remove_002ddirectory">procedure: <strong>remove-directory</strong> <em>pathname --> unspecified</em></dt>
- <dt id="index-rename-1">procedure: <strong>rename</strong> <em>old-pathname new-pathname --> unspecified</em></dt>
- <dd><p><code>Unlink</code> removes a link at the location <var>pathname</var>.
- <code>Remove-directory</code> removes a directory at the location specified
- by <var>pathname</var>. The directory must be empty; an exception is
- signalled if it is not. <code>Rename</code> moves the file at the location
- <var>old-pathname</var> to the new location <var>new-pathname</var>.
- </p></dd></dl>
- <span id="index-file-access-probing"></span>
- <dl>
- <dt id="index-accessible_003f">procedure: <strong>accessible?</strong> <em>pathname access-mode more-modes … --> boolean</em></dt>
- <dt id="index-access_002dmode">syntax: <strong>access-mode</strong> <em>name --> access mode</em></dt>
- <dd><p><code>Accessible?</code> returns true if <var>pathname</var> is accessible by all
- of the given access modes. (There must be at least one access mode
- argument.) <code>Access-mode</code> evaluates to an access mode, suitable for
- passing to <code>accessible?</code>, from the given name. The allowed names
- are <code>read</code>, <code>write</code>, <code>execute</code>, & <code>exists</code>.
- </p></dd></dl>
- <span id="index-file-info"></span>
- <p>Information about files can be queried using the <em>file info</em>
- abstraction. Every file has a corresponding file info record, which
- contains various data about the file including its name, its type,
- its device & inode numbers, the number of links to it, its size in
- bytes, its owner, its group, its file mode, and its access times.
- </p>
- <dl>
- <dt id="index-get_002dfile_002dinfo">procedure: <strong>get-file-info</strong> <em>pathname --> file-info</em></dt>
- <dt id="index-get_002dfile_002flink_002dinfo">procedure: <strong>get-file/link-info</strong> <em>pathname --> file-info</em></dt>
- <dt id="index-get_002dport_002dinfo">procedure: <strong>get-port-info</strong> <em>fd-port --> file-info</em></dt>
- <dd><p><code>Get-file-info</code> & <code>get-file/link-info</code> return a file info
- record for the files named by <var>pathname</var>. <code>Get-file-info</code>
- follows symbolic links, however, while <code>get-file/link</code> info does
- not. <code>Get-port-info</code> returns a file info record for the file that
- <var>fd-port</var> is a port atop a file descriptor for. If <var>fd-port</var>
- does not read from or write to a file descriptor, an error is
- signalled.
- </p></dd></dl>
- <dl>
- <dt id="index-file_002dinfo_003f">procedure: <strong>file-info?</strong> <em>object --> boolean</em></dt>
- <dt id="index-file_002dinfo_002dname">procedure: <strong>file-info-name</strong> <em>file-info --> string</em></dt>
- <dt id="index-file_002dinfo_002ddevice">procedure: <strong>file-info-device</strong> <em>file-info --> integer</em></dt>
- <dt id="index-file_002dinfo_002dinode">procedure: <strong>file-info-inode</strong> <em>file-info --> integer</em></dt>
- <dt id="index-file_002dinfo_002dlink_002dcount">procedure: <strong>file-info-link-count</strong> <em>file-info --> integer</em></dt>
- <dt id="index-file_002dinfo_002dsize">procedure: <strong>file-info-size</strong> <em>file-info --> integer</em></dt>
- <dt id="index-file_002dinfo_002downer">procedure: <strong>file-info-owner</strong> <em>file-info --> user-id</em></dt>
- <dt id="index-file_002dinfo_002dgroup">procedure: <strong>file-info-group</strong> <em>file-info --> group-id</em></dt>
- <dt id="index-file_002dinfo_002dmode">procedure: <strong>file-info-mode</strong> <em>file-info --> file-mode</em></dt>
- <dt id="index-file_002dinfo_002dlast_002daccess">procedure: <strong>file-info-last-access</strong> <em>file-info --> time</em></dt>
- <dt id="index-file_002dinfo_002dlast_002dmodification">procedure: <strong>file-info-last-modification</strong> <em>file-info --> time</em></dt>
- <dt id="index-file_002dinfo_002dlast_002dchange">procedure: <strong>file-info-last-change</strong> <em>file-info --> time</em></dt>
- <dd><p>Accessors for various file info record fields. The name is the string
- passed to <code>get-file-info</code> or <code>get-file/link-info</code>, if the
- file info record was created with either of those two, or the name of
- the file that the file descriptor of the port queried was created on,
- if the file info record was obtained with <code>get-port-info</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-file_002dinfo_002dtype">procedure: <strong>file-info-type</strong> <em>file-info --> file-type</em></dt>
- <dt id="index-file_002dtype">syntax: <strong>file-type</strong> <em>name --> file-type</em></dt>
- <dt id="index-file_002dtype_003f">procedure: <strong>file-type?</strong> <em>object --> boolean</em></dt>
- <dt id="index-file_002dtype_002dname">procedure: <strong>file-type-name</strong> <em>file-type --> symbol</em></dt>
- <dd><p><code>File-info-type</code> returns the type of the file as a <em>file type</em>
- object. File types may be compared using <code>eq?</code>. <code>File-type</code>
- evaluates to a file type of the given name. The disjoint type predicate
- for file types is <code>file-type?</code>. <code>File-type-name</code> returns the
- symbolic name that represents <var>file-type</var>.
- </p>
- <p>The valid file type names are:
- </p>
- <ul class="no-bullet">
- <li><!-- /@w --> <code>regular</code>
- </li><li><!-- /@w --> <code>directory</code>
- </li><li><!-- /@w --> <code>character-device</code>
- </li><li><!-- /@w --> <code>block-device</code>
- </li><li><!-- /@w --> <code>fifo</code>
- </li><li><!-- /@w --> <code>symbolic-link</code> (not required by POSIX)
- </li><li><!-- /@w --> <code>socket</code> (not required by POSIX)
- </li><li><!-- /@w --> <code>other</code>
- </li></ul>
- </dd></dl>
- <span id="index-POSIX-file-permissions"></span>
- <span id="index-file-permissions"></span>
- <p><em>File modes</em> are boxed integers that represent POSIX file
- protection masks.
- </p>
- <dl>
- <dt id="index-file_002dmode">syntax: <strong>file-mode</strong> <em>permission-name … --> file-mode</em></dt>
- <dt id="index-file_002dmode_003f">procedure: <strong>file-mode?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>File-mode</code> evaluates to a file mode object that contains all of
- the specified permissions. <code>File-mode?</code> is the disjoint type
- predicate for file mode descriptor objects. These are all of the names,
- with their corresponding octal bit masks and meanings, allowed to be
- passed to <code>file-mode</code>:
- </p>
- <table>
- <tr><td>Permission name</td><td>Octal mask</td><td>Description</td></tr>
- <tr><td><code>set-uid</code></td><td><code>#o4000</code></td><td>set user id when executing</td></tr>
- <tr><td><code>set-gid</code></td><td><code>#o2000</code></td><td>set group id when executing</td></tr>
- <tr><td><code>owner-read</code></td><td><code>#o0400</code></td><td>read by owner</td></tr>
- <tr><td><code>owner-write</code></td><td><code>#o0200</code></td><td>write by owner</td></tr>
- <tr><td><code>owner-exec</code></td><td><code>#o0100</code></td><td>execute (or search) by owner</td></tr>
- <tr><td><code>group-read</code></td><td><code>#o0040</code></td><td>read by group</td></tr>
- <tr><td><code>group-write</code></td><td><code>#o0020</code></td><td>write by group</td></tr>
- <tr><td><code>group-exec</code></td><td><code>#o0010</code></td><td>execute (or search) by group</td></tr>
- <tr><td><code>other-read</code></td><td><code>#o0004</code></td><td>read by others</td></tr>
- <tr><td><code>other-write</code></td><td><code>#o0002</code></td><td>write by others</td></tr>
- <tr><td><code>other-exec</code></td><td><code>#o0001</code></td><td>execute (or search) by others</td></tr>
- </table>
- <p>Also, several compound masks are supported for convenience:
- </p>
- <table>
- <tr><td>Permission set name</td><td>Octal mask</td><td>Description</td></tr>
- <tr><td><code>owner</code></td><td><code>#o0700</code></td><td>read, write, & execute by owner</td></tr>
- <tr><td><code>group</code></td><td><code>#o0070</code></td><td>read, write, & execute by group</td></tr>
- <tr><td><code>other</code></td><td><code>#o0007</code></td><td>read, write, & execute by others</td></tr>
- <tr><td><code>read</code></td><td><code>#o0444</code></td><td>read by anyone</td></tr>
- <tr><td><code>write</code></td><td><code>#o0111</code></td><td>write by anyone</td></tr>
- <tr><td><code>exec</code></td><td><code>#o0777</code></td><td>read, write, & execute by anyone</td></tr>
- </table>
- </dd></dl>
- <dl>
- <dt id="index-file_002dmode_002b">procedure: <strong>file-mode+</strong> <em>file-mode … --> file-mode</em></dt>
- <dt id="index-file_002dmode_002d">procedure: <strong>file-mode-</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --> file-mode</em></dt>
- <dt id="index-file_002dmode_003d_003f">procedure: <strong>file-mode=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --> boolean</em></dt>
- <dt id="index-file_002dmode_003c_003d_003f">procedure: <strong>file-mode<=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --> boolean</em></dt>
- <dt id="index-file_002dmode_003e_003d_003f">procedure: <strong>file-mode>=?</strong> <em>file-mode<sub>a</sub> file-mode<sub>b</sub> --> boolean</em></dt>
- <dd><p><code>File-mode+</code> returns a file mode that contains all of the
- permissions specified in any of its arguments. <code>File-mode-</code>
- returns a file mode that contains all of <var>file-mode<sub>a</sub></var>’s
- permissions not in <var>file-mode<sub>b</sub></var>. <code>File-mode=?</code> tests
- whether two file modes are the same. <code>File-mode<=?</code> returns true
- if each successive file mode argument has the same or more permissions
- as the previous one. <code>File-mode>=?</code> returns true if each
- successive file mode argument has the same or fewer permissions as the
- previous one.
- </p></dd></dl>
- <dl>
- <dt id="index-file_002dmode_002d_003einteger">procedure: <strong>file-mode->integer</strong> <em>file-mode --> integer</em></dt>
- <dt id="index-integer_002d_003efile_002dmode">procedure: <strong>integer->file-mode</strong> <em>integer --> file-mode</em></dt>
- <dd><p>These convert between file mode objects and Unix file mode masks as
- integers. The integer representations may or may not be the masks used
- by the underlying operating system.
- </p></dd></dl>
- <hr>
- <span id="POSIX-time"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Time"></span><h3 class="section">8.7 Time</h3>
- <p>A <em>time</em> record contains an integer that represents a time as the
- number of seconds since the Unix epoch (00:00:00 GMT, January 1, 1970).
- These procedures for operating on time records are in the structures
- <code>posix-time</code> & <code>posix</code>.
- </p>
- <dl>
- <dt id="index-make_002dtime">procedure: <strong>make-time</strong> <em>seconds --> time</em></dt>
- <dt id="index-current_002dtime">procedure: <strong>current-time</strong> <em>--> time</em></dt>
- <dt id="index-time_003f">procedure: <strong>time?</strong> <em>object --> boolean</em></dt>
- <dt id="index-time_002dseconds">procedure: <strong>time-seconds</strong> <em>time --> integer</em></dt>
- <dd><p><code>Make-time</code> & <code>current-time</code> construct time records;
- <code>make-time</code> uses the number of seconds that is its argument, and
- <code>current-time</code> uses the current number of seconds since the epoch.
- <code>Time?</code> is the disjoint type predicate for time objects.
- <code>Time-seconds</code> returns the number of seconds recorded by
- <var>time</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-time_003d_003f">procedure: <strong>time=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --> boolean</em></dt>
- <dt id="index-time_003c_003f">procedure: <strong>time<?</strong> <em>time<sub>a</sub> time<sub>b</sub> --> boolean</em></dt>
- <dt id="index-time_003c_003d_003f">procedure: <strong>time<=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --> boolean</em></dt>
- <dt id="index-time_003e_003f">procedure: <strong>time>?</strong> <em>time<sub>a</sub> time<sub>b</sub> --> boolean</em></dt>
- <dt id="index-time_003e_003d_003f">procedure: <strong>time>=?</strong> <em>time<sub>a</sub> time<sub>b</sub> --> boolean</em></dt>
- <dd><p>Various time comparators. <code>Time=?</code> returns true if its two
- arguments represent the same number of seconds since the epoch.
- <code>Time<?</code>, <code>time<=?</code>, <code>time>?</code>, & <code>time>=</code> return
- true if their arguments are monotonically increasing, monotonically
- non-decreasing, monotonically decreasing, or monotonically
- non-increasing, respectively.
- </p></dd></dl>
- <dl>
- <dt id="index-time_002d_003estring">procedure: <strong>time->string</strong> <em>time --> string</em></dt>
- <dd><p>Returns a string representation of <var>time</var> in the format of
- <code>"<var>DDD</var> <var>MMM</var> <var>HH</var>:<var>MM</var>:<var>SS</var> <var>YYYY</var>"</code>.
- For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(time->string (make-time 1234567890))
- ⇒ "Fri Feb 13 18:31:30 2009"</pre></div>
- <p><strong>Note:</strong> The string has a newline suffix.
- </p></dd></dl>
- <hr>
- <span id="POSIX-I_002fO-utilities"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="I_002fO-utilities"></span><h3 class="section">8.8 I/O utilities</h3>
- <span id="index-posix_002di_002fo-1"></span>
- <p>These procedures for manipulating pipes and ports built on file
- descriptors are provided by the structures <code>posix-i/o</code> &
- <code>posix</code>.
- </p>
- <span id="index-POSIX-pipe-I_002fO"></span>
- <span id="index-pipe-I_002fO"></span>
- <dl>
- <dt id="index-open_002dpipe">procedure: <strong>open-pipe</strong> <em>--> [input-port output-port]</em></dt>
- <dd><p>Creates a pipe and returns the two ends of the pipe as an input port &
- an output port.
- </p></dd></dl>
- <span id="index-file-descriptor-ports"></span>
- <span id="index-fd_002dports"></span>
- <p>A <em>file descriptor port</em> (or <em>fd-port</em>) is a port or a
- <a href="#Channels">channel</a> that reads from or writes to an OS file
- descriptor. File descriptor ports are returned by the standard Scheme
- procedures <code>open-input-file</code> & <code>open-output-file</code> as well as
- the procedures <code>open-file</code> & <code>open-pipe</code> from this POSIX
- interface.
- </p>
- <dl>
- <dt id="index-fd_002dport_003f">procedure: <strong>fd-port?</strong> <em>port --> boolean</em></dt>
- <dt id="index-port_002d_003efd">procedure: <strong>port->fd</strong> <em>port --> integer or <code>#f</code></em></dt>
- <dd><p><code>Fd-port?</code> returns true if <var>port</var> is a port that reads from or
- writes to a file descriptor, or false if not. <code>Port->fd</code> returns
- the file descriptor that <var>port</var> reads from or writes to, if it is a
- file descriptor port, or <code>#f</code> if it is not. It is an error to
- pass a value that is not a port to either of these procedures.
- </p>
- <p><strong>Note:</strong> Channels may <em>not</em> be passed to these procedures.
- To access a channel’s file descriptor, use <code>channel-os-index</code>;
- see <a href="#Channels">Channels</a> for more details.
- </p></dd></dl>
- <span id="index-file-descriptor-reassignment"></span>
- <dl>
- <dt id="index-remap_002dfile_002ddescriptors_0021">procedure: <strong>remap-file-descriptors!</strong> <em>fd-spec … --> unspecified</em></dt>
- <dd><p>Reassigns file descriptors to ports. Each <var>fd-spec</var> specifies what
- port is to be mapped to what file descriptor: the first port gets file
- descriptor <code>0</code>; the second, <code>1</code>; and so on. An <var>fd-spec</var>
- is either a port that reads from or writes to a file descriptor or
- <code>#f</code>; in the latter case, the corresponding file descriptor is not
- used. Any open ports not listed are marked <em>close-on-exec</em>. The
- same port may be moved to multiple new file descriptors.
- </p>
- <p>For example,
- </p>
- <div class="lisp">
- <pre class="lisp">(remap-file-descriptors! (current-output-port)
- #f
- (current-input-port))</pre></div>
- <p>moves the current output port to file descriptor <code>0</code> (<i>i.e.</i>
- <code>stdin</code>) and the current input port to file descriptor <code>2</code>
- (<i>i.e.</i> <code>stderr</code>). File descriptor <code>1</code> (<code>stdout</code>) is not
- mapped to anything, and all other open ports (including anything that
- had the file descriptor <code>1</code>) are marked <em>close-on-exec</em>.
- </p></dd></dl>
- <span id="index-fd_002dport-dup_0027ing"></span>
- <dl>
- <dt id="index-dup">procedure: <strong>dup</strong> <em>fd-port --> fd-port</em></dt>
- <dt id="index-dup_002dswitching_002dmode">procedure: <strong>dup-switching-mode</strong> <em>fd-port --> fd-port</em></dt>
- <dt id="index-dup2">procedure: <strong>dup2</strong> <em>fd-port fdes --> fd-port</em></dt>
- <dd><p>These change <var>fd-port</var>’s file descriptor and return new ports that
- have the ports’ old file descriptors. <code>Dup</code> uses the lowest
- unused file descriptor; <code>dup2</code> uses the one provided.
- <code>Dup-switching-mode</code> is the same as <code>dup</code> except that the
- returned port is an input port if the argument was an output port and
- vice versa. If any existing port uses the file descriptor passed to
- <code>dup2</code>, that port is closed.
- </p></dd></dl>
- <dl>
- <dt id="index-close_002dall_002dport">procedure: <strong>close-all-port</strong> <em>port-or-channel … --> unspecified</em></dt>
- <dd><p>Closes all ports or channels not listed as arguments.
- </p></dd></dl>
- <dl>
- <dt id="index-close_002don_002dexec_003f">procedure: <strong>close-on-exec?</strong> <em>channel --> boolean</em></dt>
- <dt id="index-set_002dclose_002don_002dexec_003f_0021">procedure: <strong>set-close-on-exec?!</strong> <em>channel boolean --> unspecified</em></dt>
- <dd><p>These access the boolean flag that specifies whether <var>channel</var> will
- be closed when a new program is <code>exec</code>’d.
- </p></dd></dl>
- <span id="index-fcntl"></span>
- <span id="index-POSIX-fcntl"></span>
- <span id="index-fd_002dport-I_002fO-flags"></span>
- <span id="index-I_002fO-flags"></span>
- <dl>
- <dt id="index-i_002fo_002dflags">procedure: <strong>i/o-flags</strong> <em>fd-port --> file-options</em></dt>
- <dt id="index-set_002di_002fo_002dflags_0021">procedure: <strong>set-i/o-flags!</strong> <em>fd-port file-options --> unspecified</em></dt>
- <dd><p>These access various <a href="#POSIX-file-system-access">file options</a>
- for <var>fd-port</var>. The options that may be read are <code>append</code>,
- <code>nonblocking</code>, <code>read-only</code>, <code>read-write</code>, and
- <code>write-only</code>; only the <code>append</code> and <code>nonblocking</code>
- options can be written.
- </p></dd></dl>
- <span id="index-terminal-ports"></span>
- <span id="index-POSIX-terminal-ports"></span>
- <dl>
- <dt id="index-port_002dis_002da_002dterminal_003f">procedure: <strong>port-is-a-terminal?</strong> <em>port --> boolean</em></dt>
- <dt id="index-port_002dterminal_002dname">procedure: <strong>port-terminal-name</strong> <em>port --> string or <code>#f</code></em></dt>
- <dd><p><code>Port-is-a-terminal?</code> returns true of <var>port</var> is a port that
- has an underlying file descriptor associated with a terminal. For such
- ports, <code>port-terminal-name</code> returns the name of the terminal; for
- all others, it returns <code>#f</code>.
- </p>
- <p><strong>Note:</strong> These procedures accept only ports, not channels.
- </p></dd></dl>
- <hr>
- <span id="POSIX-regular-expressions"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Regular-expressions"></span><h3 class="section">8.9 Regular expressions</h3>
- <span id="index-string-matching"></span>
- <p>The procedures in this section provide access to POSIX regular
- expression matching. The regular expression syntax and semantics are
- far too complex to be described here.
- </p>
- <p><strong>Note:</strong> Because the C interface uses ASCII <code>NUL</code> bytes to
- mark the ends of strings, patterns & strings that contain <code>NUL</code>
- characters will not work correctly.
- </p>
- <span id="Direct-POSIX-regular-expression-interface"></span><h4 class="subsection">8.9.1 Direct POSIX regular expression interface</h4>
- <span id="index-posix_002dregexps-1"></span>
- <p>The first interface to regular expressions is a thin layer over the
- interface that POSIX provides. It is exported by the structures
- <code>posix-regexps</code> & <code>posix</code>.
- </p>
- <dl>
- <dt id="index-make_002dregexp">procedure: <strong>make-regexp</strong> <em>string option … --> regexp</em></dt>
- <dt id="index-regexp_003f">procedure: <strong>regexp?</strong> <em>object --> boolean</em></dt>
- <dd><p><code>Make-regexp</code> creates a regular expression with the given string
- pattern. The arguments after <var>string</var> specify various options for
- the regular expression; see <code>regexp-option</code> below. The regular
- expression is not compiled until it is matched against a string, so any
- errors in the pattern string will not be reported until that point.
- <code>Regexp?</code> is the disjoint type predicate for regular expression
- objects.
- </p></dd></dl>
- <dl>
- <dt id="index-regexp_002doption">syntax: <strong>regexp-option</strong> <em>name --> regexp-option</em></dt>
- <dd><p>Evaluates to a regular expression option, suitable to be passed to
- <code>make-regexp</code>, with the given name. The possible option names
- are:
- </p>
- <dl compact="compact">
- <dt><code>extended</code></dt>
- <dd><p>use the extended patterns
- </p></dd>
- <dt><code>ignore-case</code></dt>
- <dd><p>ignore case differences when matching
- </p></dd>
- <dt><code>submatches</code></dt>
- <dd><p>report submatches
- </p></dd>
- <dt><code>newline</code></dt>
- <dd><p>treat newlines specially
- </p></dd>
- </dl>
- </dd></dl>
- <dl>
- <dt id="index-regexp_002dmatch">procedure: <strong>regexp-match</strong> <em>regexp string start submatches? starts-line? ends-line? --> boolean or list of matches</em></dt>
- <dd><p><code>Regexp-match</code> matches <var>regexp</var> against the characters in
- <var>string</var>, starting at position <var>start</var>. If the string does not
- match the regular expression, <code>regexp-match</code> returns <code>#f</code>.
- If the string does match, then a list of match records is returned if
- <var>submatches?</var> is true or <code>#t</code> if <var>submatches?</var> is false.
- The first match record gives the location of the substring that matched
- <var>regexp</var>. If the pattern in <var>regexp</var> contained submatches,
- then the submatches are returned in order, with match records in the
- positions where submatches succeeded and <code>#f</code> in the positions
- where submatches failed.
- </p>
- <p><var>Starts-line?</var> should be true if <var>string</var> starts at the
- beginning of a line, and <var>ends-line?</var> should be true if it ends
- one.
- </p></dd></dl>
- <dl>
- <dt id="index-match_003f">procedure: <strong>match?</strong> <em>object --> boolean</em></dt>
- <dt id="index-match_002dstart">procedure: <strong>match-start</strong> <em>match --> integer</em></dt>
- <dt id="index-match_002dend">procedure: <strong>match-end</strong> <em>match --> integer</em></dt>
- <dt id="index-match_002dsubmatches">procedure: <strong>match-submatches</strong> <em>match --> alist</em></dt>
- <dd><p><code>Match?</code> is the disjoint type predicate for match records. Match
- records contain three values: the beginning & end of the substring that
- matched the pattern and an association list of submatch keys and
- corresponding match records for any named submatches that also matched.
- <code>Match-start</code> returns the index of the first character in the
- matching substring, and <code>match-end</code> gives the index of the
- first character after the matching substring. <code>Match-submatches</code>
- returns the alist of submatches.
- </p></dd></dl>
- <span id="High_002dlevel-regular-expression-construction"></span><h4 class="subsection">8.9.2 High-level regular expression construction</h4>
- <span id="index-regexp"></span>
- <p>This section describes a functional interface for building regular
- expressions and matching them against strings, higher-level than the
- direct POSIX interface. The matching is done using the POSIX regular
- expression package. Regular expressions constructed by procedures
- listed here are compatible with those in the previous section; that is,
- they satisfy the predicate <code>regexp?</code> from the <code>posix-regexps</code>
- structure. These names are exported by the structure <code>regexps</code>.
- </p>
- <span id="Character-sets"></span><h4 class="subsubsection">8.9.2.1 Character sets</h4>
- <p>Character sets may be defined using a list of characters and strings,
- using a range or ranges of characters, or by using set operations on
- existing character sets.
- </p>
- <dl>
- <dt id="index-set">procedure: <strong>set</strong> <em>char-or-string … --> char-set-regexp</em></dt>
- <dt id="index-range">procedure: <strong>range</strong> <em>low-char high-char --> char-set-regexp</em></dt>
- <dt id="index-ranges">procedure: <strong>ranges</strong> <em>low-char high-char … --> char-set-regexp</em></dt>
- <dt id="index-ascii_002drange">procedure: <strong>ascii-range</strong> <em>low-char high-char --> char-set-regexp</em></dt>
- <dt id="index-ascii_002dranges">procedure: <strong>ascii-ranges</strong> <em>low-char high-char … --> char-set-regexp</em></dt>
- <dd><p><code>Set</code> returns a character set that contains all of the character
- arguments and all of the characters in all of the string arguments.
- <code>Range</code> returns a character set that contains all characters
- between <var>low-char</var> and <var>high-char</var>, inclusive. <code>Ranges</code>
- returns a set that contains all of the characters in the given set of
- ranges. <code>Range</code> & <code>ranges</code> use the ordering imposed by
- <code>char->integer</code>. <code>Ascii-range</code> & <code>ascii-ranges</code> are
- like <code>range</code> & <code>ranges</code>, but they use the ASCII ordering.
- <code>Ranges</code> & <code>ascii-ranges</code> must be given an even number of
- arguments. It is an error for a <var>high-char</var> to be less than the
- preceding <var>low-char</var> in the appropriate ordering.
- </p></dd></dl>
- <dl>
- <dt id="index-negate">procedure: <strong>negate</strong> <em>char-set --> char-set-regexp</em></dt>
- <dt id="index-union">procedure: <strong>union</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --> char-set-regexp</em></dt>
- <dt id="index-intersection">procedure: <strong>intersection</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --> char-set-regexp</em></dt>
- <dt id="index-subtract">procedure: <strong>subtract</strong> <em>char-set<sub>a</sub> char-set<sub>b</sub> --> char-set-regexp</em></dt>
- <dd><p>Set operations on character sets. <code>Negate</code> returns a character
- set of all characters that are not in <var>char-set</var>. <code>Union</code>
- returns a character set that contains all of the characters in
- <var>char-set<sub>a</sub></var> and all of the characters in
- <var>char-set<sub>b</sub></var>. <code>Intersection</code> returns a character set of
- all of the characters that are in both <var>char-set<sub>a</sub></var> and
- <var>char-set<sub>b</sub></var>. <code>Subtract</code> returns a character set of all
- the characters in <var>char-set<sub>a</sub></var> that are not also in
- <var>char-set<sub>b</sub></var>.
- </p></dd></dl>
- <dl>
- <dt id="index-lower_002dcase">character set: <strong>lower-case</strong> <em>= <code>(set "abcdefghijklmnopqrstuvwxyz")</code></em></dt>
- <dt id="index-lower_002dcase-1">character set: <strong>lower-case</strong> <em>= <code>(set "abcdefghijklmnopqrstuvwxyz")</code></em></dt>
- <dt id="index-upper_002dcase">character set: <strong>upper-case</strong> <em>= <code>(set "ABCDEFGHIJKLMNOPQRSTUVWXYZ")</code></em></dt>
- <dt id="index-alphabetic">character set: <strong>alphabetic</strong> <em>= <code>(union lower-case upper-case)</code></em></dt>
- <dt id="index-numeric">character set: <strong>numeric</strong> <em>= <code>(set "0123456789")</code></em></dt>
- <dt id="index-alphanumeric">character set: <strong>alphanumeric</strong> <em>= <code>(union alphabetic numeric)</code></em></dt>
- <dt id="index-punctuation">character set: <strong>punctuation</strong> <em>= <code>(set "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")</code></em></dt>
- <dt id="index-graphic">character set: <strong>graphic</strong> <em>= <code>(union alphanumeric punctuation)</code></em></dt>
- <dt id="index-printing-1">character set: <strong>printing</strong> <em>= <code>(union graphic (set #\space))</code></em></dt>
- <dt id="index-control">character set: <strong>control</strong> <em>= <code>(negate printing)</code></em></dt>
- <dt id="index-blank">character set: <strong>blank</strong> <em>= <code>(set #\space (ascii->char 9)) ; ASCII 9 = TAB</code></em></dt>
- <dt id="index-whitespace">character set: <strong>whitespace</strong> <em>= <code>(union (set #\space) (ascii-range 9 13))</code></em></dt>
- <dt id="index-hexdigit">character set: <strong>hexdigit</strong> <em>= <code>(set "0123456789ABCDEF")</code></em></dt>
- <dd><p>Predefined character sets.
- </p></dd></dl>
- <span id="Anchoring"></span><h4 class="subsubsection">8.9.2.2 Anchoring</h4>
- <dl>
- <dt id="index-string_002dstart">procedure: <strong>string-start</strong> <em>--> regexp</em></dt>
- <dt id="index-string_002dend">procedure: <strong>string-end</strong> <em>--> regexp</em></dt>
- <dd><p><code>String-start</code> returns a regular expression that matches the
- beginning of the string being matched against; <code>string-end</code>
- returns one that matches the end.
- </p></dd></dl>
- <span id="Composite-expressions"></span><h4 class="subsubsection">8.9.2.3 Composite expressions</h4>
- <dl>
- <dt id="index-sequence">procedure: <strong>sequence</strong> <em>regexp … --> regexp</em></dt>
- <dt id="index-one_002dof">procedure: <strong>one-of</strong> <em>regexp … --> regexp</em></dt>
- <dd><p><code>Sequence</code> returns a regular expression that matches
- concatenation of all of its arguments; <code>one-of</code> returns a regular
- expression that matches any one of its arguments.
- </p></dd></dl>
- <dl>
- <dt id="index-text">procedure: <strong>text</strong> <em>string --> regexp</em></dt>
- <dd><p>Returns a regular expression that matches exactly the characters in
- <var>string</var>, in order.
- </p></dd></dl>
- <dl>
- <dt id="index-repeat">procedure: <strong>repeat</strong> <em>regexp --> regexp</em></dt>
- <dt id="index-repeat-1">procedure: <strong>repeat</strong> <em>count regexp --> regexp</em></dt>
- <dt id="index-repeat-2">procedure: <strong>repeat</strong> <em>min max regexp --> regexp</em></dt>
- <dd><p><code>Repeat</code> returns a regular expression that matches zero or more
- occurrences of its <var>regexp</var> argument. With only one argument, the
- result will match <var>regexp</var> any number of times. With two
- arguments, <i>i.e.</i> one <var>count</var> argument, the returned regular
- expression will match <var>regexp</var> exactly that number of times. The
- final case will match from <var>min</var> to <var>max</var> repetitions,
- inclusive. <var>Max</var> may be <code>#f</code>, in which case there is no
- maximum number of matches. <var>Count</var> & <var>min</var> must be exact,
- non-negative integers; <var>max</var> should be either <code>#f</code> or an
- exact, non-negative integer.
- </p></dd></dl>
- <span id="Case-sensitivity"></span><h4 class="subsubsection">8.9.2.4 Case sensitivity</h4>
- <p>Regular expressions are normally case-sensitive, but case sensitivity
- can be manipulated simply.
- </p>
- <dl>
- <dt id="index-ignore_002dcase">procedure: <strong>ignore-case</strong> <em>regexp --> regexp</em></dt>
- <dt id="index-use_002dcase">procedure: <strong>use-case</strong> <em>regexp --> regexp</em></dt>
- <dd><p>The regular expression returned by <code>ignore-case</code> is identical to
- its argument except that the case will be ignored when matching. The
- value returned by <code>use-case</code> is protected from future applications
- of <code>ignore-case</code>. The expressions returned by <code>use-case</code> and
- <code>ignore-case</code> are unaffected by any enclosing uses of these
- procedures.
- </p>
- <p>By way of example, the following matches <code>"ab"</code>, but not
- <code>"aB"</code>, <code>"Ab"</code>, or <code>"AB"</code>:
- </p>
- <div class="lisp">
- <pre class="lisp">(text "ab")</pre></div>
- <p>while
- </p>
- <div class="lisp">
- <pre class="lisp">(ignore-case (text "ab"))</pre></div>
- <p>matches all of those, and
- </p>
- <div class="lisp">
- <pre class="lisp">(ignore-case (sequence (text "a")
- (use-case (text "b"))))</pre></div>
- <p>matches <code>"ab"</code> or <code>"Ab"</code>, but not <code>"aB"</code> or <code>"AB"</code>.
- </p></dd></dl>
- <span id="Submatches-and-matching"></span><h4 class="subsubsection">8.9.2.5 Submatches and matching</h4>
- <p>A subexpression within a larger expression can be marked as a submatch.
- When an expression is matched against a string, the success or failure
- of each submatch within that expression is reported, as well as the
- location of the substring matched by each successful submatch.
- </p>
- <dl>
- <dt id="index-submatch">procedure: <strong>submatch</strong> <em>key regexp --> regexp</em></dt>
- <dt id="index-no_002dsubmatches">procedure: <strong>no-submatches</strong> <em>regexp --> regexp</em></dt>
- <dd><p><code>Submatch</code> returns a regular expression that is equivalent to
- <var>regexp</var> in every way except that the regular expression returned by
- <code>submatch</code> will produce a submatch record in the output for the
- part of the string matched by <var>regexp</var>. <code>No-submatches</code>
- returns a regular expression that is equivalent to <var>regexp</var> in every
- respect except that all submatches generated by <var>regexp</var> will be
- ignored & removed from the output.
- </p></dd></dl>
- <dl>
- <dt id="index-any_002dmatch_003f">procedure: <strong>any-match?</strong> <em>regexp string --> boolean</em></dt>
- <dt id="index-exact_002dmatch_003f">procedure: <strong>exact-match?</strong> <em>regexp string --> boolean</em></dt>
- <dt id="index-match">procedure: <strong>match</strong> <em>regexp string --> match or <code>#f</code></em></dt>
- <dd><p><code>Any-match?</code> returns <code>#t</code> if <var>string</var> matches
- <var>regexp</var> or contains a substring that does, or <code>#f</code> if
- otherwise. <code>Exact-match?</code> returns <code>#t</code> if <var>string</var>
- matches <var>regexp</var> exactly, or <code>#f</code> if it does not.
- </p>
- <p><code>Match</code> returns <code>#f</code> if <var>string</var> does not match
- <var>regexp</var>, or a match record if it does, as described in the
- previous section. Matching occurs according to POSIX. The match
- returned is the one with the lowest starting index in <var>string</var>. If
- there is more than one such match, the longest is returned. Within
- that match, the longest possible submatches are returned.
- </p>
- <p>All three matching procedures cache a compiled version of <var>regexp</var>.
- Subsequent calls with the same input regular expression will be more
- efficient.
- </p></dd></dl>
- <p>Here are some examples of the high-level regular expression interface:
- </p>
- <div class="lisp">
- <pre class="lisp">(define pattern (text "abc"))
- (any-match? pattern "abc") ⇒ #t
- (any-match? pattern "abx") ⇒ #f
- (any-match? pattern "xxabcxx") ⇒ #t
- (exact-match? pattern "abc") ⇒ #t
- (exact-match? pattern "abx") ⇒ #f
- (exact-match? pattern "xxabcxx") ⇒ #f
- (let ((m (match (sequence (text "ab")
- (submatch 'foo (text "cd"))
- (text "ef")))
- "xxabcdefxx"))
- (list m (match-submatches m)))
- ⇒ (#{Match 3 9} ((foo . #{Match 5 7})))
- (match-submatches
- (match (sequence (set "a")
- (one-of (submatch 'foo (text "bc"))
- (submatch 'bar (text "BC"))))
- "xxxaBCd"))
- ⇒ ((bar . #{Match 4 6}))</pre></div>
- <hr>
- <span id="POSIX-C-to-Scheme-correspondence"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="C-to-Scheme-correspondence"></span><h3 class="section">8.10 C to Scheme correspondence</h3>
- <dl compact="compact">
- <dt><code>access</code></dt>
- <dd><p><code>accessible?</code>
- </p></dd>
- <dt><code>chdir</code></dt>
- <dd><p><code>set-working-directory!</code>
- </p></dd>
- <dt><code>close</code></dt>
- <dd><p><code>close-input-port, close-output-port, close-channel, close-socket</code>
- </p></dd>
- <dt><code>closedir</code></dt>
- <dd><p><code>close-directory-stream</code>
- </p></dd>
- <dt><code>creat</code></dt>
- <dd><p><code>open-file</code>
- </p></dd>
- <dt><code>ctime</code></dt>
- <dd><p><code>time->string</code>
- </p></dd>
- <dt><code>dup</code></dt>
- <dd><p><code>dup, dup-switching-mode</code>
- </p></dd>
- <dt><code>dup2</code></dt>
- <dd><p><code>dup2</code>
- </p></dd>
- <dt><code>exec[l|v][e|p|eps]</code></dt>
- <dd><p><code>exec, exec-with-environment, exec-file, exec-file-with-environment, exec-with-alias</code>
- </p></dd>
- <dt><code>_exit</code></dt>
- <dd><p><code>exit</code>
- </p></dd>
- <dt><code>fcntl</code></dt>
- <dd><p><code>i/o-flags, set-i/o-flags!, close-on-exec?, set-close-on-exec?!</code>
- </p></dd>
- <dt><code>fork</code></dt>
- <dd><p><code>fork, fork-and-forget</code>
- </p></dd>
- <dt><code>fstat</code></dt>
- <dd><p><code>get-port-info</code>
- </p></dd>
- <dt><code>getcwd</code></dt>
- <dd><p><code>working-directory</code>
- </p></dd>
- <dt><code>getegid</code></dt>
- <dd><p><code>get-effective-group-id</code>
- </p></dd>
- <dt><code>getenv</code></dt>
- <dd><p><code>lookup-environment-variable, environment-alist</code>
- </p></dd>
- <dt><code>geteuid</code></dt>
- <dd><p><code>get-effective-user-id</code>
- </p></dd>
- <dt><code>getgid</code></dt>
- <dd><p><code>get-group-id</code>
- </p></dd>
- <dt><code>getgroups</code></dt>
- <dd><p><code>get-login-name</code>
- </p></dd>
- <dt><code>getpid</code></dt>
- <dd><p><code>get-process-id</code>
- </p></dd>
- <dt><code>getppid</code></dt>
- <dd><p><code>get-parent-process-id</code>
- </p></dd>
- <dt><code>getuid</code></dt>
- <dd><p><code>get-user-id</code>
- </p></dd>
- <dt><code>isatty</code></dt>
- <dd><p><code>port-is-a-terminal?</code>
- </p></dd>
- <dt><code>link</code></dt>
- <dd><p><code>link</code>
- </p></dd>
- <dt><code>lstat</code></dt>
- <dd><p><code>get-file/link-info</code>
- </p></dd>
- <dt><code>mkdir</code></dt>
- <dd><p><code>make-directory</code>
- </p></dd>
- <dt><code>mkfifo</code></dt>
- <dd><p><code>make-fifo</code>
- </p></dd>
- <dt><code>open</code></dt>
- <dd><p><code>open-file</code>
- </p></dd>
- <dt><code>opendir</code></dt>
- <dd><p><code>open-directory-stream</code>
- </p></dd>
- <dt><code>pipe</code></dt>
- <dd><p><code>open-pipe</code>
- </p></dd>
- <dt><code>read</code></dt>
- <dd><p><code>read-char, read-block</code>
- </p></dd>
- <dt><code>readdir</code></dt>
- <dd><p><code>read-directory-stream</code>
- </p></dd>
- <dt><code>rename</code></dt>
- <dd><p><code>rename</code>
- </p></dd>
- <dt><code>rmdir</code></dt>
- <dd><p><code>remove-directory</code>
- </p></dd>
- <dt><code>setgid</code></dt>
- <dd><p><code>set-group-id!</code>
- </p></dd>
- <dt><code>setuid</code></dt>
- <dd><p><code>set-user-id!</code>
- </p></dd>
- <dt><code>stat</code></dt>
- <dd><p><code>get-file-info</code>
- </p></dd>
- <dt><code>time</code></dt>
- <dd><p><code>current-time</code>
- </p></dd>
- <dt><code>ttyname</code></dt>
- <dd><p><code>port-terminal-name</code>
- </p></dd>
- <dt><code>umask</code></dt>
- <dd><p><code>set-file-creation-mask!</code>
- </p></dd>
- <dt><code>uname</code></dt>
- <dd><p><code>os-name, os-node-name, os-release-name, os-version-name, machine-name</code>
- </p></dd>
- <dt><code>unlink</code></dt>
- <dd><p><code>unlink</code>
- </p></dd>
- <dt><code>waitpid</code></dt>
- <dd><p><code>wait-for-child-process</code>
- </p></dd>
- <dt><code>write</code></dt>
- <dd><p><code>write-char, write-block</code>
- </p></dd>
- </dl>
- <hr>
- <span id="Pre_002dScheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <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>
- <p>Pre-Scheme [Kelsey 97] is a low-level dialect of Scheme, designed for
- systems programming with higher-level abstractions. For example, the
- Scheme48 virtual machine is written in Pre-Scheme. Pre-Scheme is a
- particularly interesting alternative to C for many systems programming
- tasks, because not only does it operate at about the same level as C,
- but it also may be run in a regular high-level Scheme development with
- no changes to the source, without resorting to low-level stack munging
- with tools such as gdb. Pre-Scheme also supports two <em>extremely</em>
- important high-level abstractions of Scheme: macros and higher-order,
- anonymous functions. Richard Kelsey’s Pre-Scheme compiler, based on
- his PhD research on transformational compilation [Kelsey 89], compiles
- Pre-Scheme to efficient C, applying numerous intermediate source
- transformations in the process.
- </p>
- <p>This chapter describes details of the differences between Scheme and
- Pre-Scheme, listings of the default environment and other packages
- available to Pre-Scheme, the operation of Richard Kelsey’s Pre-Scheme
- compiler, and how to run Pre-Scheme code as if it were Scheme in a
- regular Scheme environment.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"></th></tr><tr><td align="left" valign="top">• <a href="#Differences-between-Pre_002dScheme-_0026-Scheme" accesskey="1">Differences between Pre-Scheme & Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme-type-specifiers" accesskey="2">Pre-Scheme type specifiers</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Standard-Pre_002dScheme-environment" accesskey="3">Standard Pre-Scheme environment</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#More-Pre_002dScheme-packages" accesskey="4">More Pre-Scheme packages</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Invoking-the-Pre_002dScheme-compiler" accesskey="5">Invoking the Pre-Scheme compiler</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Example-Pre_002dScheme-compiler-usage" accesskey="6">Example Pre-Scheme compiler usage</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Running-Pre_002dScheme-as-Scheme" accesskey="7">Running Pre-Scheme as Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- </table>
- <hr>
- <span id="Differences-between-Pre_002dScheme-_0026-Scheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Differences-between-Pre_002dScheme-_0026-Scheme-1"></span><h3 class="section">9.1 Differences between Pre-Scheme & Scheme</h3>
- <p>Pre-Scheme is often considered either a dialect of Scheme or a subset
- of Scheme. However, there are several very important fundamental
- differences between the semantics of Pre-Scheme & Scheme to detail.
- </p>
- <dl compact="compact">
- <dd><span id="index-Pre_002dScheme-memory-management"></span>
- <span id="index-Pre_002dScheme-garbage-collection"></span>
- <span id="index-memory-management-in-Pre_002dScheme"></span>
- <span id="index-garbage-collection-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>There is no garbage collector in Pre-Scheme.</strong></dt>
- <dd><p>All memory management is manual, as in C, although there are two levels
- to memory management, for higher- and lower-level purposes: pointers &
- addresses. Pointers represent higher-level data that are statically
- checked for type coherency, such as vectors of a certain element type,
- or strings. Addresses represent direct, low-level memory indices.
- </p>
- <span id="index-closures-in-Pre_002dScheme"></span>
- <span id="index-Pre_002dScheme-closures"></span>
- </dd>
- <dt><strong>Pre-Scheme has no closures.</strong></dt>
- <dd><p><code>Lambda</code> expressions that would require full closures at run-time
- — <i>e.g.</i>, those whose values are stored in the heap — are not
- permitted in Pre-Scheme. However, the Pre-Scheme compiler can hoist
- many <code>lambda</code> expressions to the top level, removing the need of
- closures for them. (Closures would be much less useful in the absence
- of garbage collection, in any case.) If the Pre-Scheme compiler is
- unable to move a <code>lambda</code> to a place where it requires no closure,
- it signals an error to the user.
- </p>
- <span id="index-Pre_002dScheme-tail-call-optimization"></span>
- <span id="index-tail-call-optimization-in-Pre_002dScheme"></span>
- <span id="index-tail-recursion-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>Tail call optimization is not universal.</strong></dt>
- <dd><p>The Pre-Scheme compiler optimizes tail calls where it is possible —
- typically, just in local loops and top-level procedures that are not
- exported from the package, but there are other heuristics —, but it
- is not universal. Programmers may force tail call optimization with
- Pre-Scheme’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
- optimized the tail call, this can make the generated code have to jump
- through many hoops to be a tail call — often necessitating code bloat,
- because the code of the tail-called procedure is integrated into the
- caller’s driver loop —; and, where the compiler would have otherwise
- optimized the tail call, <code>goto</code> has no effect anyway.
- </p>
- <span id="index-Pre_002dScheme-type-inference"></span>
- <span id="index-static-types-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>Types are strictly verified with Hindley-Milner type inference.</strong></dt>
- <dd><p>The types of Pre-Scheme programs are statically verified based on
- Hindley-Milner type inference, with some modifications specific to
- Pre-Scheme. Type information is <em>not</em> retained at run-time; any
- tagging must be performed explicitly.
- </p>
- <span id="index-continuations-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>Pre-Scheme does not support first-class continuations.</strong></dt>
- <dd><p>There is no <code>call-with-current-continuation</code> or other continuation
- manipulation interface. It has been suggested that downward-only
- continuations, based on C’s <code>setjmp</code> & <code>longjmp</code>, might be
- implemented in the future, but this is not yet the case.<a id="DOCF27" href="#FOOT27"><sup>27</sup></a>
- </p>
- <span id="index-Pre_002dScheme-numbers"></span>
- <span id="index-numbers-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>The full numeric tower of R5RS is not supported by Pre-Scheme.</strong></dt>
- <dd><p>Pre-Scheme’s only numeric types are fixnums and flonums, with precision
- determined by the architecture on which the Pre-Scheme code runs.
- Fixnums are translated to C as the <code>long</code> type; flonums are
- translated as the <code>float</code> type.
- </p>
- <span id="index-top_002dlevel-evaluation-in-Pre_002dScheme"></span>
- <span id="index-evaluation-of-top_002dlevel-code-in-Pre_002dScheme"></span>
- <span id="index-Pre_002dScheme-top_002dlevel-evaluation"></span>
- <span id="index-compile_002dtime-evaluation-in-Pre_002dScheme"></span>
- </dd>
- <dt><strong>Top-level Pre-Scheme code is evaluated at compile-time.</strong></dt>
- <dd><p>Closures actually <em>are</em> available, as long as they may be
- eliminated before run-time. Code evaluated at compile-time also does
- not require satisfaction of strict static typing. Moreover, certain
- procedures, such as <code>vector-length</code>, are available only at
- compile-time.
- </p></dd>
- </dl>
- <hr>
- <span id="Pre_002dScheme-type-specifiers"></span><div class="header">
- <p>
- 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 & Scheme</a>, Up: <a href="#Pre_002dScheme" accesskey="u" rel="up">Pre-Scheme</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Type-specifiers"></span><h3 class="section">9.2 Type specifiers</h3>
- <span id="index-Pre_002dScheme-type-inference-1"></span>
- <span id="index-static-types-in-Pre_002dScheme-1"></span>
- <p>Although Pre-Scheme’s static type system is based mostly on
- Hindley-Milner type inference, with as little explicit type information
- as possible, there are still places where it is necessary to specify
- 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
- syntax:
- </p>
- <dl compact="compact">
- <dt><code><var>type-name</var></code></dt>
- <dd><p>Symbols denote either record type or base types. Record types are
- defined with the <code>define-record-type</code> special form described
- later; the following base types are defined:
- </p>
- <dl compact="compact">
- <dt><code>integer</code></dt>
- <dd><p>Fixed-size integers (fixnums). This type is translated into C as
- <code>long</code>. The actual size depends on the size of C’s <code>long</code>,
- which on most architectures is 32 bits.
- </p>
- </dd>
- <dt><code>float</code></dt>
- <dd><p>Floating-point data. This type translates to C as <code>double</code>.
- </p>
- </dd>
- <dt><code>null</code></dt>
- <dd><p>Type which has no value. The <code>null</code> type translates to the C
- <code>void</code> type.
- </p>
- </dd>
- <dt><code>unit</code></dt>
- <dd><p>Type which has one value. Actually, this, too, translates to C’s
- <code>void</code>, so that it has one value is not strictly true.
- </p>
- </dd>
- <dt><code>boolean</code></dt>
- <dd><p>Booleans translate to the C <code>char</code> type. <code>#t</code> is emitted as
- <code>TRUE</code>, and <code>#f</code>, as <code>FALSE</code>; these are usually the same
- as <code>1</code> & <code>0</code>, respectively.
- </p>
- </dd>
- <dt><code>input-port</code></dt>
- <dt><code>output-port</code></dt>
- <dd><p>I/O ports. On Unix, since Pre-Scheme uses <code>stdio</code>, these are
- translated to <code>FILE *</code>s, <code>stdio</code> file streams.
- </p>
- </dd>
- <dt><code>char</code></dt>
- <dd><p>Characters. The size of characters is dependent on the underlying C
- compiler’s implementation of the <code>char</code> type.
- </p>
- </dd>
- <dt><code>address</code></dt>
- <dd><p>Simple addresses for use in <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Pre-Scheme’s low-level memory manipulation primitives</a>;
- see that section for more details.
- </p></dd>
- </dl>
- </dd>
- <dt><code>(=> (<var>argument-type</var> …) <var>return-type</var> …)</code></dt>
- <dd><p>The types of procedures, known as ‘arrow’ types.
- </p>
- </dd>
- <dt><code>(^ <var>type</var>)</code></dt>
- <dd><p>The type of pointers that point to <var>type</var>. Note that these are
- distinct from the address type. Pointer types are statically verified
- to be coherent data, with no defined operations except for accessing
- offsets in memory from the pointer — <i>i.e.</i> operations such as
- <code>vector-ref</code> —; addresses simply index bytes, on which only
- direct dereferencing, but also arbitrary address arithmetic, is
- available. Pointers and addresses are <em>not</em> interchangeable, and
- and there is no way to convert between them, as that would break the
- type safety of Pre-Scheme pointers.
- </p>
- </dd>
- <dt><code>(tuple <var>type</var> …)</code></dt>
- <dd><p>Multiple value types, internally used for argument & return types.
- </p></dd>
- </dl>
- <hr>
- <span id="Standard-Pre_002dScheme-environment"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Standard-environment"></span><h3 class="section">9.3 Standard environment</h3>
- <span id="index-prescheme-1"></span>
- <p>Pre-Scheme programs usually open the <code>prescheme</code> structure. There
- are several other structures built-in to Pre-Scheme as well, described
- in the next section. This section describes the <code>prescheme</code>
- structure.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Scheme-bindings-in-Pre_002dScheme" accesskey="1">Scheme bindings in Pre-Scheme</a></td><td> </td><td align="left" valign="top">Bindings from R5RS
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Tail-call-optimization-in-Pre_002dScheme" accesskey="2">Tail call optimization in Pre-Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme-bitwise-manipulation" accesskey="3">Pre-Scheme bitwise manipulation</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Compound-Pre_002dScheme-data-manipulation" accesskey="4">Compound Pre-Scheme data manipulation</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme-error-handling" accesskey="5">Pre-Scheme error handling</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="6">Input & output in Pre-Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme-access-to-C-functions-and-macros" accesskey="7">Pre-Scheme access to C functions and macros</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Scheme-bindings-in-Pre_002dScheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Scheme-bindings"></span><h4 class="subsection">9.3.1 Scheme bindings</h4>
- <p>Bindings for all the names specified here from R5RS Scheme are
- available in Pre-Scheme. The remainder of the sections after this one
- detail Pre-Scheme specifics that are not a part of Scheme.
- </p>
- <dl>
- <dt id="index-define">syntax: <strong>define</strong> <em>name value</em></dt>
- <dt id="index-define-1">syntax: <strong>define</strong> <em>(name . argument-list) value</em></dt>
- <dt id="index-if">syntax: <strong>if</strong> <em>condition consequent [alternate]</em></dt>
- <dt id="index-let-1">syntax: <strong>let</strong> <em>((name expression) …) body</em></dt>
- <dt id="index-let_002a">syntax: <strong>let*</strong> <em>((name expression) …) body</em></dt>
- <dt id="index-and">syntax: <strong>and</strong> <em>conjunct …</em></dt>
- <dt id="index-or">syntax: <strong>or</strong> <em>disjunct …</em></dt>
- <dt id="index-cond">syntax: <strong>cond</strong> <em>cond-clause …</em></dt>
- <dt id="index-do">syntax: <strong>do</strong> <em>((name init-exp [step-exp]) …) (test-exp [return-exp]) body</em></dt>
- <dd><p>These special forms & macros are all unchanged from their R5RS
- specifications.
- </p></dd></dl>
- <dl>
- <dt id="index-define_002dsyntax-2">syntax: <strong>define-syntax</strong> <em>name transformer-expression [aux-names]</em></dt>
- <dt id="index-let_002dsyntax">syntax: <strong>let-syntax</strong> <em>((name transformer-expression) …) body</em></dt>
- <dt id="index-letrec_002dsyntax">syntax: <strong>letrec-syntax</strong> <em>((name transformer-expression) …) body</em></dt>
- <dd><p>Pre-Scheme’s macro facility is exactly the same as Scheme48’s.
- <var>Transformer-expression</var> may be either a <code>syntax-rules</code> or an
- explicit renaming transformer, just as in Scheme48; in the latter case,
- it is evaluated either in a standard Scheme environment or however the
- <code>for-syntax</code> clause specified of the package in whose code the
- transformer appeared. For details on the extra <var>aux-names</var> operand
- to <code>define-syntax</code>, see <a href="#Explicit-renaming-macros">Explicit renaming macros</a>.
- </p></dd></dl>
- <dl>
- <dt id="index-not">procedure: <strong>not</strong> <em>boolean --> boolean</em></dt>
- <dt id="index-eq_003f">procedure: <strong>eq?</strong> <em>value<sub>a</sub> value<sub>b</sub> --> boolean</em></dt>
- <dt id="index-char_003d_003f">procedure: <strong>char=?</strong> <em>char<sub>a</sub> char<sub>b</sub> --> boolean</em></dt>
- <dt id="index-char_003c_003f">procedure: <strong>char<?</strong> <em>char<sub>a</sub> char<sub>b</sub> --> boolean</em></dt>
- <dt id="index-values-1">procedure: <strong>values</strong> <em>value … --> values</em></dt>
- <dt id="index-call_002dwith_002dvalues">procedure: <strong>call-with-values</strong> <em>producer consumer --> values</em></dt>
- <dt id="index-current_002dinput_002dport-1">procedure: <strong>current-input-port</strong> <em>--> input-port</em></dt>
- <dt id="index-current_002doutput_002dport-1">procedure: <strong>current-output-port</strong> <em>--> output-port</em></dt>
- <dd><p>These procedures are all unchanged from their R5RS specifications.
- </p></dd></dl>
- <dl>
- <dt id="index-_002b">procedure: <strong>+</strong> <em>addend … --> integer</em></dt>
- <dt id="index-_002d">procedure: <strong>-</strong> <em>integer --> integer</em></dt>
- <dt id="index-_002d-1">procedure: <strong>-</strong> <em>minuend subtrahend --> integer</em></dt>
- <dt id="index-_002a">procedure: <strong>*</strong> <em>multiplicand … --> integer</em></dt>
- <dt id="index-_003d">procedure: <strong>=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> boolean</em></dt>
- <dt id="index-_003c">procedure: <strong><</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> boolean</em></dt>
- <dt id="index-_003e">procedure: <strong>></strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> boolean</em></dt>
- <dt id="index-_003c_003d">procedure: <strong><=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> boolean</em></dt>
- <dt id="index-_003e_003d">procedure: <strong>>=</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> boolean</em></dt>
- <dt id="index-min">procedure: <strong>min</strong> <em>integer<sub>1</sub> integer<sub>2</sub> … --> integer</em></dt>
- <dt id="index-max">procedure: <strong>max</strong> <em>integer<sub>1</sub> integer<sub>2</sub> … --> integer</em></dt>
- <dt id="index-abs">procedure: <strong>abs</strong> <em>integer --> integer</em></dt>
- <dt id="index-quotient">procedure: <strong>quotient</strong> <em>divisor dividend --> integer</em></dt>
- <dt id="index-remainder">procedure: <strong>remainder</strong> <em>divisor dividend --> integer</em></dt>
- <dt id="index-expt">procedure: <strong>expt</strong> <em>base exponent --> integer</em></dt>
- <dd><p>These numerical operations are all unchanged from their R5RS
- counterparts, except that they are applicable only to fixnums, not to
- flonums, and they always return fixnums.
- </p></dd></dl>
- <hr>
- <span id="Tail-call-optimization-in-Pre_002dScheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Tail-call-optimization"></span><h4 class="subsection">9.3.2 Tail call optimization</h4>
- <span id="index-Pre_002dScheme-tail-call-optimization-1"></span>
- <span id="index-tail-call-optimization-in-Pre_002dScheme-1"></span>
- <span id="index-tail-recursion-in-Pre_002dScheme-1"></span>
- <dl>
- <dt id="index-goto">syntax: <strong>goto</strong> <em>procedure argument …</em></dt>
- <dd><p>The Pre-Scheme compiler can be forced to optimize tail calls, even
- those it would not have otherwise optimized, by use of the <code>goto</code>
- special form, rather than simple procedure calls. In every respect
- other than tail call optimization, this is equivalent to calling
- <var>procedure</var> with the given arguments. Note, however, that uses of
- <code>goto</code> may cause code to blow up if the Pre-Scheme compiler had
- reason not to optimize the tail call were it not for the <code>goto</code>:
- it may need to merge the tail-called procedure into the caller’s code.
- </p></dd></dl>
- <hr>
- <span id="Pre_002dScheme-bitwise-manipulation"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Bitwise-manipulation-2"></span><h4 class="subsection">9.3.3 Bitwise manipulation</h4>
- <p>Pre-Scheme provides basic bitwise manipulation operators.
- </p>
- <dl>
- <dt id="index-bitwise_002dand-1">procedure: <strong>bitwise-and</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> integer</em></dt>
- <dt id="index-bitwise_002dior-1">procedure: <strong>bitwise-ior</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> integer</em></dt>
- <dt id="index-bitwise_002dxor-1">procedure: <strong>bitwise-xor</strong> <em>integer<sub>a</sub> integer<sub>b</sub> --> integer</em></dt>
- <dt id="index-bitwise_002dnot-1">procedure: <strong>bitwise-not</strong> <em>integer --> integer</em></dt>
- <dd><p>Bitwise boolean logical operations.
- </p></dd></dl>
- <dl>
- <dt id="index-shift_002dleft">procedure: <strong>shift-left</strong> <em>integer count --> integer</em></dt>
- <dt id="index-arithmetic_002dshift_002dright">procedure: <strong>arithmetic-shift-right</strong> <em>integer count --> integer</em></dt>
- <dt id="index-logical_002dshift_002dright">procedure: <strong>logical-shift-right</strong> <em>integer count --> integer</em></dt>
- <dd><p>Three ways to shift bit strings: <code>shift-left</code> shifts <var>integer</var>
- left by <var>count</var>, <code>arithmetic-shift-right</code> shifts <var>integer</var>
- right by <var>count</var> arithmetically, and <code>logical-shift-right</code>
- shifts <var>integer</var> right by <var>count</var> logically.
- </p></dd></dl>
- <hr>
- <span id="Compound-Pre_002dScheme-data-manipulation"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Compound-data-manipulation"></span><h4 class="subsection">9.3.4 Compound data manipulation</h4>
- <span id="index-vectors-in-Pre_002dScheme"></span>
- <span id="index-Pre_002dScheme-vectors"></span>
- <span id="index-strings-in-Pre_002dScheme"></span>
- <span id="index-Pre_002dScheme-strings"></span>
- <span id="index-Pre_002dScheme-memory-management-1"></span>
- <span id="index-memory-management-in-Pre_002dScheme-1"></span>
- <p>Pre-Scheme has somewhat lower-level vector & string facilities than
- Scheme, with more orientation towards static typing. It also provides
- a statically typed record facility, which translates to C structs,
- though not described here, as it is not in the <code>prescheme</code>
- structure; see <a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a>.
- </p>
- <dl>
- <dt id="index-make_002dvector">procedure: <strong>make-vector</strong> <em>length init --> vector</em></dt>
- <dt id="index-vector_002dlength">procedure: <strong>vector-length</strong> <em>vector --> integer</em></dt>
- <dt id="index-vector_002dref">procedure: <strong>vector-ref</strong> <em>vector index --> value</em></dt>
- <dt id="index-vector_002dset_0021">procedure: <strong>vector-set!</strong> <em>vector index value --> unit</em></dt>
- <dd><p>Vectors in Pre-Scheme are almost the same as vectors in regular Scheme,
- but with a few differences. <code>Make-vector</code> initializes what it
- returns with null pointers (see below); it uses the <em>required</em>
- (unlike Scheme) <var>init</var> argument only to determine the type of the
- vector: vectors are statically typed; they can contain only values that
- have the same static type as <var>init</var>. <code>Vector-length</code> is
- available only at the top level, where calls to it can be evaluated at
- compile-time; vectors do not at run-time store their lengths. Vectors
- must also be explicitly deallocated.
- </p>
- <p><strong>Warning:</strong> As in C, there is <em>no</em> vector bounds checking at
- run-time.
- </p></dd></dl>
- <dl>
- <dt id="index-make_002dstring">procedure: <strong>make-string</strong> <em>length --> string</em></dt>
- <dt id="index-string_002dlength">procedure: <strong>string-length</strong> <em>string --> integer</em></dt>
- <dt id="index-string_002dref">procedure: <strong>string-ref</strong> <em>string index --> char</em></dt>
- <dt id="index-string_002dset_0021">procedure: <strong>string-set!</strong> <em>string index char --> unit</em></dt>
- <dd><p>Strings in Pre-Scheme are the nearly same as strings in R5RS Scheme.
- The only three differences here are that <code>make-string</code> accepts
- exactly one argument, strings must be explicitly deallocated, and
- strings are <code>nul</code>-terminated: <code>string-length</code> operates by
- scanning for the first ASCII <code>nul</code> character in a string.
- </p>
- <p><strong>Warning:</strong> As in C, there is <em>no</em> string bounds checking at
- run-time.
- </p></dd></dl>
- <dl>
- <dt id="index-deallocate">procedure: <strong>deallocate</strong> <em>pointer --> unit</em></dt>
- <dd><p>Deallocates the memory pointed to by <code>pointer</code>. This is necessary
- at the end of a string, vector, or record’s life, as Pre-Scheme data
- are not automatically garbage-collected.
- </p></dd></dl>
- <dl>
- <dt id="index-null_002dpointer">procedure: <strong>null-pointer</strong> <em>--> null-pointer</em></dt>
- <dt id="index-null_002dpointer_003f">procedure: <strong>null-pointer?</strong> <em>pointer --> boolean</em></dt>
- <dd><p><code>Null-pointer</code> returns the distinguished null pointer object. It
- corresponds with <code>0</code> in a pointer context or <code>NULL</code> in C.
- <code>Null-pointer?</code> returns true if <var>pointer</var> is a null pointer,
- or false if not.
- </p></dd></dl>
- <hr>
- <span id="Pre_002dScheme-error-handling"></span><div class="header">
- <p>
- Next: <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="n" rel="next">Input & 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Error-handling"></span><h4 class="subsection">9.3.5 Error handling</h4>
- <p>Pre-Scheme’s method of error handling is similar to the most common one
- in C: error codes. There is an enumeration <code>errors</code> of some error
- codes commonly and portably encountered in Pre-Scheme.
- </p>
- <dl>
- <dt id="index-errors-1">enumeration: <strong>errors</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-enumeration errors
- (no-errors
- parse-error
- file-not-found
- out-of-memory
- invalid-port))</pre></div>
- <p>Each enumerand has the following meaning:
- </p>
- <dl compact="compact">
- <dt><code>(enum errors no-errors)</code></dt>
- <dd><p>Absence of error: success.
- </p>
- </dd>
- <dt><code>(enum errors parse-error)</code></dt>
- <dd><p>Any kind of parsing error. The Scheme48 VM uses this when someone
- attempts to resume a malformed suspended heap image.
- </p>
- </dd>
- <dt><code>(enum errors file-not-found)</code></dt>
- <dd><p>Used when an operation that operates on a file given a string filename
- found that the file for that filename was absent.
- </p>
- </dd>
- <dt><code>(enum errors out-of-memory)</code></dt>
- <dd><p>When there is no more memory to allocate.
- </p>
- </dd>
- <dt><code>(enum errors invalid-port)</code></dt>
- <dd><p>Unused.
- </p></dd>
- </dl>
- </dd></dl>
- <dl>
- <dt id="index-error_002dstring">procedure: <strong>error-string</strong> <em>error-status --> string</em></dt>
- <dd><p>Returns a string describing the meaning of the <code>errors</code> enumerand
- <var>error-status</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-error-2">procedure: <strong>error</strong> <em>message irritant …</em></dt>
- <dd><p>Signals a fatal error with the given message & related irritants and
- halts the program. On Unix, the program’s exit code is -1.
- </p></dd></dl>
- <hr>
- <span id="Input-_0026-output-in-Pre_002dScheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Input-_0026-output"></span><h4 class="subsection">9.3.6 Input & output</h4>
- <p>Pre-Scheme’s I/O facilities are somewhat different from Scheme’s, given
- the low level and the static type strictness. There is no exception
- mechanism in Pre-Scheme; everything is maintained by returning a status
- token, as in C. Pre-Scheme’s built-in I/O facilities are buffered.
- <a id="DOCF28" href="#FOOT28"><sup>28</sup></a>
- (see <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a>, for two other I/O
- primitives, <code>read-block</code> & <code>write-block</code>, for reading &
- writing blocks of direct memory.)
- </p>
- <dl>
- <dt id="index-open_002dinput_002dfile-1">procedure: <strong>open-input-file</strong> <em>filename --> [port status]</em></dt>
- <dt id="index-open_002doutput_002dfile-1">procedure: <strong>open-output-file</strong> <em>filename --> [port status]</em></dt>
- <dt id="index-close_002dinput_002dport-1">procedure: <strong>close-input-port</strong> <em>input-port --> status</em></dt>
- <dt id="index-close_002doutput_002dport-1">procedure: <strong>close-output-port</strong> <em>output-port --> status</em></dt>
- <dd><p><code>Open-input-file</code> & <code>open-output-file</code> open ports for the
- given filenames. They each return two values: the newly open port and
- an <code>errors</code> enumerand status. Users of these procedures should
- always check the error status before proceeding to operate with the
- port. <code>Close-input-port</code> & <code>close-output-port</code> close their
- port arguments and return the <code>errors</code> enumerand status of the
- closing.
- </p></dd></dl>
- <dl>
- <dt id="index-read_002dchar">procedure: <strong>read-char</strong> <em>input-port --> [char eof? status]</em></dt>
- <dt id="index-peek_002dchar">procedure: <strong>peek-char</strong> <em>input-port --> [char eof? status]</em></dt>
- <dt id="index-read_002dinteger">procedure: <strong>read-integer</strong> <em>input-port --> [integer eof? status]</em></dt>
- <dd><p><code>Read-char</code> reads & consumes a single character from its
- <var>input-port</var> argument. <code>Peek-char</code> reads, but does not
- consume, a single character from <var>input-port</var>. <code>Read-integer</code>
- parses an integer literal, including sign. All of these also return
- two other values: whether or not the file is at the end and any
- <code>errors</code> enumerand status. If any error occurred, the first two
- values returned should be ignored. If <var>status</var> is <code>(enum
- errors no-errors)</code>, users of these three procedures should then check
- <var>eof?</var>; it is true if <var>input-port</var> was at the end of the file
- with nothing more left to read and false otherwise. Finally, if both
- <var>status</var> is <code>(enum errors no-errors)</code> and <var>eof?</var> is false,
- the first value returned may be safely used.
- </p></dd></dl>
- <dl>
- <dt id="index-write_002dchar">procedure: <strong>write-char</strong> <em>char output-port --> status</em></dt>
- <dt id="index-newline-1">procedure: <strong>newline</strong> <em>output-port --> status</em></dt>
- <dt id="index-write_002dstring-1">procedure: <strong>write-string</strong> <em>string output-port --> status</em></dt>
- <dt id="index-write_002dinteger">procedure: <strong>write-integer</strong> <em>integer output-port --> status</em></dt>
- <dd><p>These all write particular elements to their <var>output-port</var>
- arguments. <code>Write-char</code> writes individual characters.
- <code>Newline</code> writes newlines (line-feed, or ASCII codepoint 10, on
- Unix). <code>Write-string</code> writes the contents of <var>string</var>.
- <code>Write-integer</code> writes an ASCII representation of <var>integer</var> to
- port, suitable to be read by <code>read-integer</code>. These all return an
- <code>errors</code> enumerand status. If it is <code>no-errors</code>, the write
- succeeded.
- </p></dd></dl>
- <dl>
- <dt id="index-force_002doutput-2">procedure: <strong>force-output</strong> <em>output-port --> status</em></dt>
- <dd><p>Forces all buffered output in <var>output-port</var>. <var>Status</var> tells
- whether or not the operation was successful.
- </p></dd></dl>
- <hr>
- <span id="Pre_002dScheme-access-to-C-functions-and-macros"></span><div class="header">
- <p>
- Previous: <a href="#Input-_0026-output-in-Pre_002dScheme" accesskey="p" rel="prev">Input & output in Pre-Scheme</a>, Up: <a href="#Standard-Pre_002dScheme-environment" accesskey="u" rel="up">Standard Pre-Scheme environment</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Access-to-C-functions-and-macros"></span><h4 class="subsection">9.3.7 Access to C functions and macros</h4>
- <dl>
- <dt id="index-external">syntax: <strong>external</strong> <em>c-name ps-type --> procedure</em></dt>
- <dd><p>Special form for accessing C functions & macros. Calls in Pre-Scheme to
- the resulting procedure are compiled to calls in C to the function or
- macro named by <var>c-name</var>, which should be a string. <var>PS-type</var> is
- the <a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type</a> that the
- procedure should have, which is necessary for type inference.
- </p></dd></dl>
- <hr>
- <span id="More-Pre_002dScheme-packages"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="More-Pre_002dScheme-packages-1"></span><h3 class="section">9.4 More Pre-Scheme packages</h3>
- <p>Along with the <code>prescheme</code> structure, there are several other
- structures built-in to Pre-Scheme.
- </p>
- <table class="menu" border="0" cellspacing="0">
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr><tr><td align="left" valign="top">• <a href="#Pre_002dScheme-floating-point-operation" accesskey="1">Pre-Scheme floating point operation</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Pre_002dScheme-record-types" accesskey="2">Pre-Scheme record types</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Multiple-return-values-in-Pre_002dScheme" accesskey="3">Multiple return values in Pre-Scheme</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><td align="left" valign="top">• <a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation" accesskey="4">Low-level Pre-Scheme memory manipulation</a></td><td> </td><td align="left" valign="top">
- </td></tr>
- <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
- </pre></th></tr></table>
- <hr>
- <span id="Pre_002dScheme-floating-point-operation"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Floating-point-operation"></span><h4 class="subsection">9.4.1 Floating point operation</h4>
- <span id="index-ps_002dflonums"></span>
- <p>Since Pre-Scheme’s strict static type system would not permit
- overloading of the arithmetic operators for integers & floats, it
- provides a different set of operators for floats. These names are all
- exported by the <code>ps-flonums</code> structure.
- </p>
- <dl>
- <dt id="index-fl_002b">procedure: <strong>fl+</strong> <em>augend addend … --> float</em></dt>
- <dt id="index-fl_002d">procedure: <strong>fl-</strong> <em>float --> float</em></dt>
- <dt id="index-fl_002d-1">procedure: <strong>fl-</strong> <em>minuend subtrahend --> float</em></dt>
- <dt id="index-fl_002a">procedure: <strong>fl*</strong> <em>multiplier multiplicand … --> float</em></dt>
- <dt id="index-fl_002f">procedure: <strong>fl/</strong> <em>divisor dividend --> float</em></dt>
- <dt id="index-fl_003d">procedure: <strong>fl=</strong> <em>float<sub>a</sub> float<sub>b</sub> --> boolean</em></dt>
- <dt id="index-fl_003c">procedure: <strong>fl<</strong> <em>float<sub>a</sub> float<sub>b</sub> --> boolean</em></dt>
- <dt id="index-fl_003e">procedure: <strong>fl></strong> <em>float<sub>a</sub> float<sub>b</sub> --> boolean</em></dt>
- <dt id="index-fl_003c_003d">procedure: <strong>fl<=</strong> <em>float<sub>a</sub> float<sub>b</sub> --> boolean</em></dt>
- <dt id="index-fl_003e_003d">procedure: <strong>fl>=</strong> <em>float<sub>a</sub> float<sub>b</sub> --> boolean</em></dt>
- <dd><p>All of these operations <code>fl<var>op</var></code> correspond as floating point
- variations of their <var>op</var> integer equivalents.
- </p></dd></dl>
- <hr>
- <span id="Pre_002dScheme-record-types"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Record-types-1"></span><h4 class="subsection">9.4.2 Record types</h4>
- <span id="index-ps_002drecord_002dtypes"></span>
- <p>The <code>ps-record-types</code> structure defines the following special form
- for introducing record types. Pre-Scheme record types are translated
- to C as structs.
- </p>
- <dl>
- <dt id="index-define_002drecord_002dtype-2">syntax: <strong>define-record-type</strong></dt>
- <dd><div class="lisp">
- <pre class="lisp">(define-record-type <var>type</var> <var>type-descriptor</var>
- (<var>constructor</var> <var>argument-field-tag</var> …)
- (<var>field-tag<sub>1</sub></var> <var>field-type-spec<sub>1</sub></var>
- <var>field-accessor<sub>1</sub></var> [<var>field-modifier<sub>1</sub></var>])
- (<var>field-tag<sub>2</sub></var> <var>field-type-spec<sub>2</sub></var>
- <var>field-accessor<sub>2</sub></var> [<var>field-modifier<sub>2</sub></var>])
- …
- (<var>field-tag<sub>n</sub></var> <var>field-type-spec<sub>n</sub></var>
- <var>field-accessor<sub>n</sub></var> [<var>field-modifier<sub>n</sub></var>])</pre></div>
- <p>Defines a record type. <var>Type</var> is mangled to the C struct type name
- (<var>type-descriptor-name</var> is unused unless running Pre-Scheme as
- Scheme). <var>Constructor</var> is defined to construct a record of the new
- type and initialize the fields <var>argument-type-field</var> … with
- its arguments, respectively. If it cannot allocate a sufficient
- quantity of memory, <var>constructor</var> returns a null pointer. The
- initial values of fields that are not passed to the constructor are
- undefined. For each field <var>field<sub>i</sub></var> specified,
- </p>
- <ul>
- <li> <var>field<sub>i</sub></var> is specified to have the type
- <var>field-type-spec<sub>i</sub></var>;
- </li><li> <var>field-accessor<sub>i</sub></var> is defined to be a procedure of one
- argument, a record of type <var>type-name</var>, that returns the value of
- the field <var>field<sub>i</sub></var> of that record — its type is defined to
- be <code>(=> (<var>type-name</var>) <var>field-type-spec<sub>i</sub></var>)</code>; and
- </li><li> if present, <var>field-modifier<sub>i</sub></var> is defined to be a
- procedure of two arguments, a record of type <var>type-name</var> and a
- value of type <var>field-type-spec</var>, that assigns the value of the
- field <var>field<sub>i</sub></var> in its first argument to be the value of its
- second argument; its type is <code>(=> (<var>type-name</var>
- <var>field-type-spec</var>) unit)</code>.
- </li></ul>
- <p>Records must be deallocated explicitly when their lifetime has expired
- with <code>deallocate</code>.
- </p></dd></dl>
- <hr>
- <span id="Multiple-return-values-in-Pre_002dScheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Multiple-return-values"></span><h4 class="subsection">9.4.3 Multiple return values</h4>
- <span id="index-ps_002dreceive"></span>
- <p>Pre-Scheme support multiple return values, like in Scheme. The only
- difference is that one cannot operate on multiple return values as
- lists, since Pre-Scheme does not have lists. Multiple return values
- are implemented in C as returning in C the first value and passing
- pointers to the remaining values, which the function returning multiple
- values assigns. The <code>prescheme</code> structure exports the two
- multiple return value primitives, <code>call-with-values</code> and
- <code>values</code>, but the <code>ps-receive</code> structure exports this macro
- for more conveniently binding multiple return values.
- </p>
- <dl>
- <dt id="index-receive-3">syntax: <strong>receive</strong> <em>formals producer body</em></dt>
- <dd><p>Binds the <code>lambda</code> parameter list <var>formals</var> to the multiple
- values that <var>producer</var> returns, and evaluates <var>body</var> with the
- new variables bound.
- </p>
- <div class="lisp">
- <pre class="lisp">(receive <var>formals</var>
- <var>producer</var>
- <var>body</var>)
- ≡
- (call-with-values
- (lambda () <var>producer</var>)
- (lambda <var>formals</var>
- <var>body</var>))</pre></div>
- </dd></dl>
- <hr>
- <span id="Low_002dlevel-Pre_002dScheme-memory-manipulation"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Low_002dlevel-memory-manipulation"></span><h4 class="subsection">9.4.4 Low-level memory manipulation</h4>
- <span id="index-Pre_002dScheme-memory-management-2"></span>
- <span id="index-memory-management-in-Pre_002dScheme-2"></span>
- <span id="index-ps_002dmemory"></span>
- <p>Pre-Scheme is a low-level language. It provides very low-level, direct
- memory manipulation. ‘Addresses’ index a flat store of sequences of
- bytes. While Pre-Scheme ‘pointers’ are statically checked for data
- coherency, allow no arbitrary arithmetic, and in general are high-level
- abstract data to some extent, addresses are much lower-level, have no
- statically checked coherency — the values an address represents are
- selected by what operation used to read or write from it —, permit
- arbitrary address arithmetic, and are a much more concrete interface
- into direct memory. The <code>ps-memory</code> structure exports these
- direct memory manipulation primitives.
- </p>
- <dl>
- <dt id="index-allocate_002dmemory">procedure: <strong>allocate-memory</strong> <em>size --> address</em></dt>
- <dt id="index-deallocate_002dmemory">procedure: <strong>deallocate-memory</strong> <em>address --> unit</em></dt>
- <dd><p><code>Allocate-memory</code> reserves a sequence of <var>size</var> bytes in the
- store and returns an address to the first byte in the sequence.
- <code>Deallocate-memory</code> releases the memory at <var>address</var>, which
- should have been the initial address of a contiguous byte sequence, as
- <code>allocate-memory</code> would return, not an offset address from such an
- initial address.
- </p></dd></dl>
- <dl>
- <dt id="index-unsigned_002dbyte_002dref">procedure: <strong>unsigned-byte-ref</strong> <em>address --> unsigned-byte</em></dt>
- <dt id="index-unsigned_002dbyte_002dset_0021">procedure: <strong>unsigned-byte-set!</strong> <em>address unsigned-byte --> unit</em></dt>
- <dt id="index-word_002dref">procedure: <strong>word-ref</strong> <em>address --> word</em></dt>
- <dt id="index-word_002dset_0021">procedure: <strong>word-set!</strong> <em>address word --> unit</em></dt>
- <dt id="index-flonum_002dref">procedure: <strong>flonum-ref</strong> <em>address --> float</em></dt>
- <dt id="index-flonum_002dset_0021">procedure: <strong>flonum-set!</strong> <em>address float --> unit</em></dt>
- <dd><p>Procedures for reading from & storing to memory.
- <code>Unsigned-byte-ref</code> & <code>unsigned-byte-set!</code> access & store the
- first unsigned byte at <var>address</var>. <code>Word-ref</code> &
- <code>word-set!</code> access & store the first word — Pre-Scheme integer
- — beginning at <var>address</var>. <code>Flonum-ref</code> & <code>flonum-set!</code>
- access & store 64-bit floats beginning at <var>address</var>..
- </p>
- <p><strong>Bug:</strong> <code>Flonum-ref</code> & <code>flonum-set!</code> are unimplemented
- in the Pre-Scheme-as-Scheme layer (see <a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a>).
- </p></dd></dl>
- <dl>
- <dt id="index-address_003f">procedure: <strong>address?</strong> <em>value --> boolean</em></dt>
- <dd><p>Disjoint type predicate for addresses.
- </p>
- <p><strong>Note:</strong> <code>Address?</code> is available <em>only</em> at the top
- level, where code is evaluated at compile-time. Do not use this in any
- place where it may be called at run-time.
- </p></dd></dl>
- <dl>
- <dt id="index-null_002daddress">constant: <strong>null-address</strong> <em>--> address</em></dt>
- <dd><p>The null address. This is somewhat similar to the null pointer, except
- that it is an address.
- </p>
- <p><strong>Note:</strong> One acquires the null <em>pointer</em> by calling the
- <em>procedure</em> <code>null-pointer</code>, whereas the constant value of the
- <em>binding</em> named <code>null-address</code> is the null <em>address</em>.
- </p></dd></dl>
- <dl>
- <dt id="index-null_002daddress_003f">procedure: <strong>null-address?</strong> <em>address --> boolean</em></dt>
- <dd><p><code>Null-address?</code> returns true if <var>address</var> is the null
- address and false if not.
- </p></dd></dl>
- <dl>
- <dt id="index-address_002b">procedure: <strong>address+</strong> <em>address increment --> address</em></dt>
- <dt id="index-address_002d">procedure: <strong>address-</strong> <em>address decrement --> address</em></dt>
- <dt id="index-address_002ddifference">procedure: <strong>address-difference</strong> <em>address<sub>a</sub> address<sub>b</sub> --> integer</em></dt>
- <dd><p>Address arithmetic operators. <code>Address+</code> adds <var>increment</var> to
- <var>address</var>; <code>address-</code> subtracts <var>decrement</var> from
- <var>address</var>; and <code>address-difference</code> returns the integer
- difference between <var>address<sub>a</sub></var> and <var>address<sub>b</sub></var>.
- For any <var>address<sub>p</sub></var> & <var>address<sub>q</sub></var>, <code>(address+
- <var>address<sub>p</sub></var> (address-difference <var>address<sub>p</sub></var>
- <var>address<sub>q</sub></var>))</code> is equal to <var>address<sub>q</sub></var>.
- </p></dd></dl>
- <dl>
- <dt id="index-address_003d">procedure: <strong>address=</strong> <em>address<sub>a</sub> address<sub>b</sub> --> boolean</em></dt>
- <dt id="index-address_003c">procedure: <strong>address<</strong> <em>address<sub>a</sub> address<sub>b</sub> --> boolean</em></dt>
- <dt id="index-address_003e">procedure: <strong>address></strong> <em>address<sub>a</sub> address<sub>b</sub> --> boolean</em></dt>
- <dt id="index-address_003c_003d">procedure: <strong>address<=</strong> <em>address<sub>a</sub> address<sub>b</sub> --> boolean</em></dt>
- <dt id="index-address_003e_003d">procedure: <strong>address>=</strong> <em>address<sub>a</sub> address<sub>b</sub> --> boolean</em></dt>
- <dd><p>Address comparators.
- </p></dd></dl>
- <dl>
- <dt id="index-integer_002d_003eaddress">procedure: <strong>integer->address</strong> <em>integer --> address</em></dt>
- <dt id="index-address_002d_003einteger">procedure: <strong>address->integer</strong> <em>address --> integer</em></dt>
- <dd><p>Integers and addresses, although not the same type, may be converted to
- and from each other; <code>integer->address</code> & <code>address->integer</code>
- perform this conversion. Note that Pre-Scheme <em>pointers</em> may not
- be converted to addresses or integers, and the converse is also true.
- </p></dd></dl>
- <dl>
- <dt id="index-copy_002dmemory_0021">procedure: <strong>copy-memory!</strong> <em>source-address target-address count --> unit</em></dt>
- <dd><p>Copies <var>count</var> bytes starting at <var>source-address</var> to
- <var>target-address</var>. This is similar to C’s <code>memcpy</code>.
- </p></dd></dl>
- <dl>
- <dt id="index-memory_002dequal_003f">procedure: <strong>memory-equal?</strong> <em>address<sub>a</sub> address<sub>b</sub> count --> boolean</em></dt>
- <dd><p>Compares the two sequences of <var>count</var> bytes starting at addresses
- <var>address<sub>a</sub></var> & <var>address<sub>b</sub></var>. It returns true if every
- byte is equal and false if not.
- </p></dd></dl>
- <dl>
- <dt id="index-char_002dpointer_002d_003estring">procedure: <strong>char-pointer->string</strong> <em>address size --> string</em></dt>
- <dt id="index-char_002dpointer_002d_003enul_002dterminated_002dstring">procedure: <strong>char-pointer->nul-terminated-string</strong> <em>address --> string</em></dt>
- <dd><p><code>Char-pointer->string</code> returns a string with <var>size</var> bytes from
- the contiguous sequence of bytes starting at <var>address</var>.
- <code>Char-pointer->nul-terminated-string</code> does similarly, but it
- returns a string whose contents include every byte starting at
- <var>address</var> until, but not including, the first 0 byte, <i>i.e.</i> ASCII
- nul character, following <var>address</var>.
- </p></dd></dl>
- <dl>
- <dt id="index-read_002dblock-1">procedure: <strong>read-block</strong> <em>port address count --> [count-read eof? status]</em></dt>
- <dt id="index-write_002dblock-1">procedure: <strong>write-block</strong> <em>port address count --> status</em></dt>
- <dd><p><code>Read-block</code> attempts to read <var>count</var> bytes from <var>port</var>
- into memory starting at <var>address</var>. <code>Write-block</code> attempts to
- write <var>count</var> bytes to <var>port</var> from the contiguous sequence in
- memory starting at <var>address</var>. <code>Read-block</code> returns three
- values: the number of bytes read, whether or not the read went to the
- 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.
- </p></dd></dl>
- <hr>
- <span id="Invoking-the-Pre_002dScheme-compiler"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Invoking-the-Pre_002dScheme-compiler-1"></span><h3 class="section">9.5 Invoking the Pre-Scheme compiler</h3>
- <p>Richard Kelsey’s Pre-Scheme compiler is a whole-program compiler based
- on techniques from his research in transformational compilation
- [Kelsey 89]. It compiles the restricted dialect of Scheme to efficient
- C, and provides facilities for programmer direction in several
- optimizations.
- </p>
- <span id="Loading-the-compiler"></span><h4 class="subsection">9.5.1 Loading the compiler</h4>
- <p>There is a script, a Scheme48 <a href="#Command-programs">command
- program</a>, that comes with Scheme48 to load the Pre-Scheme compiler,
- which is in the file <samp>ps-compiler/load-ps-compiler.scm</samp>. It must
- be loaded from the <samp>ps-compiler/</samp> directory, from Scheme48’s main
- distribution, into the <code>exec</code> package, after having loaded
- <samp>../scheme/prescheme/interface.scm</samp> &
- <samp>../scheme/prescheme/package-defs.scm</samp> into the <code>config</code>
- package. The Pre-Scheme compiler takes some time to load, so it may be
- easier to load it once and dump a heap image of the suspended command
- processor after having loaded everything; see <a href="#Image_002dbuilding-commands">Image-building commands</a>.
- </p>
- <p>To load the Pre-Scheme compiler and dump an image to the file
- <samp>ps-compiler.image</samp> that contains <code>prescheme-compiler</code> in the
- user package, send this sequence of commands to the command processor
- while in the <samp>ps-compiler/</samp> directory of Scheme48’s distribution:
- </p>
- <div class="lisp">
- <pre class="lisp">,config ,load ../scheme/prescheme/interface.scm
- ,config ,load ../scheme/prescheme/package-defs.scm
- ,exec ,load load-ps-compiler.scm
- ,in prescheme-compiler prescheme-compiler
- ,user (define prescheme-compiler ##)
- ,dump ps-compiler.image "(Pre-Scheme)"</pre></div>
- <span id="Calling-the-compiler"></span><h4 class="subsection">9.5.2 Calling the compiler</h4>
- <span id="index-prescheme_002dcompiler-1"></span>
- <p>After having loaded the Pre-Scheme compiler, the
- <code>prescheme-compiler</code> structure is the front end to the compiler
- that exports the <code>prescheme-compiler</code> procedure.
- </p>
- <dl>
- <dt id="index-prescheme_002dcompiler">procedure: <strong>prescheme-compiler</strong> <em>structure-spec config-filenames init-name c-filename command …</em></dt>
- <dd><p>Invokes the Pre-Scheme compiler. <var>Config-filenames</var> contain module
- descriptions (see <a href="#Module-system">Module system</a>) for the components of the program.
- <var>Structure-spec</var> may be a symbol or a list of symbols, naming the
- important structure or structures. All structures that it relies/they
- rely on are traced in the packages’ <code>open</code> clauses. Modules that
- are not traced in the dependency graph with root vertices of the given
- structure[s] are omitted from the output. <var>C-filename</var> is a string
- naming the file to which the C code generated by the Pre-Scheme
- compiler should be emitted. <var>Init-name</var> is the name for an
- initialization routine, generated automatically by the Pre-Scheme
- compiler to initialize some top-level variables. The <var>command</var>
- arguments are used to control certain aspects of the compilation. The
- following commands are defined:
- </p>
- <dl compact="compact">
- <dt><code>(copy (<var>structure</var> <var>copyable-procedure</var>) …)</code></dt>
- <dd><p>Specifies that each the body of each <var>copyable-procedure</var> from the
- respective <var>structure</var> (from one of <var>config-filenames</var>) may be
- integrated & duplicated.
- </p>
- </dd>
- <dt><code>(no-copy (<var>structure</var> <var>uncopyable-procedure</var>) …)</code></dt>
- <dd><p>Specifies that the given procedures may not be integrated.
- </p>
- </dd>
- <dt><code>(shadow ((<var>proc-structure</var> <var>procedure</var>) (<var>var-structure</var> <var>variable-to-shadow</var>) …) …)</code></dt>
- <dd><p>Specifies that, in <var>procedure</var> from <var>proc-structure</var>, the
- global variables <var>variable-to-shadow</var> from their respective
- <var>var-structure</var>s should be shadowed with local variables, which
- are more likely to be kept in registers for faster operation on them.
- </p>
- </dd>
- <dt><code>(integrate (<var>client-procedure</var> <var>integrable-procedure</var>) …)</code></dt>
- <dd><p>Forces <var>integrable-procedure</var> to be integrated in
- <var>client-procedure</var>.
- </p>
- <p><strong>Note:</strong> The <code>integrate</code> command operates on the global
- program, not on one particular module; each <var>client-procedure</var> and
- <var>integrable-procedure</var> is chosen from all variables defined in the
- entirety of the program, across all modules. It is advised that there
- be only one of each.
- </p>
- </dd>
- <dt><code>(header <var>header-line</var> …)</code></dt>
- <dd><p>Each <var>header-line</var> is added to the top of the generated C file,
- after a cpp inclusion of <code><stdio.h></code> and <code>"prescheme.h"</code>.
- </p></dd>
- </dl>
- <p>The command arguments to <code>prescheme-compiler</code> are optional; they
- are used only to optimize the compiled program at the programmer’s
- request.
- </p></dd></dl>
- <hr>
- <span id="Example-Pre_002dScheme-compiler-usage"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Example-Pre_002dScheme-compiler-usage-1"></span><h3 class="section">9.6 Example Pre-Scheme compiler usage</h3>
- <p>The <samp>ps-compiler/compile-vm.scm</samp>,
- <samp>ps-compiler/compile-gc.scm</samp>, and
- <samp>ps-compiler/compile-vm-no-gc.scm</samp> files give examples of running
- the Pre-Scheme compiler. They are Scheme48 <a href="#Command-programs">command programs</a>, to be loaded into the <code>exec</code> package after
- having already loaded the Pre-Scheme compiler. <samp>compile-vm.scm</samp> &
- <samp>compile-vm-no-gc.scm</samp> generate a new <samp>scheme48vm.c</samp> in the
- <samp>scheme/vm/</samp> directory — <samp>compile-vm.scm</samp> includes the
- garbage collector, while <samp>compile-vm-no-gc.scm</samp> does not
- <a id="DOCF29" href="#FOOT29"><sup>29</sup></a> —, and <samp>compile-gc.scm</samp>
- generates a new <samp>scheme48heap.c</samp>, <samp>scheme48read-image.c</samp>, &
- <samp>scheme48write-image.c</samp> in the <samp>scheme/vm/</samp> directory.
- </p>
- <p>Here is a somewhat simpler example. It assumes a pre-built image with
- the Pre-Scheme compiler loaded is in the <samp>ps-compiler.image</samp> file
- in the current directory (see <a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a>,
- where there is a description of how to dump an image with the
- Pre-Scheme compiler loaded).
- </p>
- <div class="example">
- <pre class="example">% ls
- hello.scm packages.scm ps-compiler.image
- % cat hello.scm
- (define (main argc argv)
- (if (= argc 2)
- (let ((out (current-output-port)))
- (write-string "Hello, world, " out)
- (write-string (vector-ref argv 1) out)
- (write-char #\! out)
- (newline out)
- 0)
- (let ((out (current-error-port)))
- (write-string "Usage: " out)
- (write-string (vector-ref argv 0) out)
- (write-string " <user>" out)
- (newline out)
- (write-string " Greets the world & <user>." out)
- (newline out)
- -1)))
- % cat packages.scm
- (define-structure hello (export main)
- (open prescheme)
- (files hello))
- % scheme48 -i ps-compiler.image
- heap size 3000000 is too small, using 4770088
- Welcome to Scheme 48 1.3 (Pre-Scheme)
- Copyright (c) 1993-2005 by Richard Kelsey and Jonathan Rees.
- Please report bugs to scheme-48-bugs@s48.org.
- Get more information at http://www.s48.org/.
- Type ,? (comma question-mark) for help.
- > (prescheme-compiler 'hello '("packages.scm") 'hello-init "hello.c")
- packages.scm
- hello.scmChecking types
- main : ((integer **char) -> integer)
- In-lining single-use procedures
- Call Graph:
- <procedure name>
- <called non-tail-recursively>
- <called tail-recursively>
- main (exported)
- Merging forms
- Translating
- main
- #{Unspecific}
- > ,exit
- % cat hello.c
- #include <stdio.h>
- #include "prescheme.h"
- long main(long, char**);
- long main(long argc_0X, char **argv_1X)
- {
- FILE * out_3X;
- FILE * out_2X;
- { if ((1 == argc_0X)) {
- out_2X = stdout;
- ps_write_string("Hello, world, ", out_2X);
- ps_write_string((*(argv_1X + 1)), out_2X);
- { long ignoreXX;
- PS_WRITE_CHAR(33, out_2X, ignoreXX) }
- { long ignoreXX;
- PS_WRITE_CHAR(10, out_2X, ignoreXX) }
- return 0;}
- else {
- out_3X = stderr;
- ps_write_string("Usage: ", out_3X);
- ps_write_string((*(argv_1X + 0)), out_3X);
- ps_write_string(" <user>", out_3X);
- { long ignoreXX;
- PS_WRITE_CHAR(10, out_3X, ignoreXX) }
- ps_write_string(" Greets the world & <user>.", out_3X);
- { long ignoreXX;
- PS_WRITE_CHAR(10, out_3X, ignoreXX) }
- return -1;}}
- }
- % </pre></div>
- <hr>
- <span id="Running-Pre_002dScheme-as-Scheme"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Running-Pre_002dScheme-as-Scheme-1"></span><h3 class="section">9.7 Running Pre-Scheme as Scheme</h3>
- <span id="index-prescheme-2"></span>
- <span id="index-ps_002dmemory-1"></span>
- <span id="index-ps_002dreceive-1"></span>
- <span id="index-ps_002drecord_002dtypes-1"></span>
- <span id="index-ps_002dflonums-1"></span>
- <p>To facilitate the operation of Pre-Scheme systems within a high-level
- Scheme development environment, Scheme48 simply defines the
- <code>prescheme</code>, <code>ps-memory</code>, <code>ps-record-types</code>,
- <code>ps-flonums</code>, and <code>ps-receive</code> structures in terms of Scheme;
- Pre-Scheme structures can be loaded as regular Scheme structures
- because of this. Those structures and the interfaces they implement
- are defined in the files <samp>scheme/prescheme/interface.scm</samp> and
- <samp>scheme/prescheme/package-defs.scm</samp> from the main Scheme48
- distribution; simply load these files into the <a href="#Module-commands">config package</a> before loading any Pre-Scheme configuration
- files.
- </p>
- <p>The Pre-Scheme emulation layer in Scheme has some shortcomings:
- </p>
- <ul>
- <li> No more than sixteen megabytes can be allocated at once.
- </li><li> More than thirty-two or sixty-four or so allocations result in
- addresses overflowing bignums, which deallocations does not affect.
- </li><li> Flonum memory access is unimplemented. (Flonum arithmetic works,
- though.)
- </li><li> The layer is very slow.
- </li></ul>
- <hr>
- <span id="References"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="References-1"></span><h2 class="unnumbered">References</h2>
- <dl compact="compact">
- <dt>[Cejtin <i>et al.</i> 95]</dt>
- <dd><p>Henry Cejtin, Suresh Jagannathan, and Richard Kelsey.
- Higher-Order Distributed Objects.
- In <cite>ACM Transactions on Programming Languages and Systems</cite>, vol.
- 17, pp. 704–739, ACM Press, September 1995.
- </p>
- </dd>
- <dt>[Clinger 91]</dt>
- <dd><p>William D. Clinger.
- Hygienic Macros through Explicit Renaming.
- In <cite>Lisp Pointers</cite>, IV(4): 25-28, December 1991.
- </p>
- </dd>
- <dt>[Donald 92]</dt>
- <dd><p>Bruce Donald and Jonathan A. Rees.
- Program Mobile Robots in Scheme!
- In <cite>Proceedings of the 1992 IEEE International Conference on
- Robotics and Automation</cite>, 2681-2688.
- </p>
- </dd>
- <dt>[Friedman 00]</dt>
- <dd><p>Daniel Friedman and Erik Hilsdale.
- <cite>Writing Macros in Continuation-Passing Style</cite>.
- Worksop on Scheme and Functional Programming, September 2000.
- </p>
- </dd>
- <dt>[Kelsey 89]</dt>
- <dd><p>Richard Kelsey.
- <cite>Compilation by Program Transformation</cite>.
- PhD thesis, Yale University, 1989.
- </p>
- </dd>
- <dt>[Kelsey 97]</dt>
- <dd><p>Richard Kelsey.
- <cite>Pre-Scheme: A Scheme Dialect for Systems Programming</cite>.
- June 1997.
- </p>
- </dd>
- <dt>[Museme]</dt>
- <dd><p>Franklyn Turbak and Dan Winship.
- <cite>Museme: a multi-user simulation environment for Scheme</cite>.
- <br><a href="http://www.bloodandcoffee.net/campbell/code/museme.tar.gz">http://www.bloodandcoffee.net/campbell/code/museme.tar.gz</a>
- </p>
- </dd>
- <dt>[Rees 96]</dt>
- <dd><p>Jonathan A. Rees.
- <cite>A Security Kernel based on the Lambda-Calculus</cite>.
- PhD thesis, AI Memo 1564, Massachusetts Institute of Technology,
- Artificial Intelligence Laboratory, 1996.
- </p>
- </dd>
- <dt>[Reppy 99]</dt>
- <dd><p>John Reppy.
- <cite>Concurrent Programming in ML</cite>.
- Cambridge University Press, 1999.
- </p>
- </dd>
- <dt>[Shivers 94]</dt>
- <dd><p>Olin Shivers.
- <cite>A Scheme Shell</cite>.
- Tech Report 635, Massachusetts Institute of Technology, Laboratory for
- Computer Science, 1994.
- </p>
- </dd>
- <dt>[Shivers 96]</dt>
- <dd><p>Olin Shivers.
- <cite>A Universal Scripting Framework, or Lambda: the Ultimate “Little
- Language”</cite>.
- <cite>Concurrency and Parallelism, Programming, Networking, and
- Security</cite>, pp. 254-265, 1996, Joxan Jaffar and Roland H. C. Yap (eds).
- </p>
- </dd>
- <dt>[Shivers <i>et al.</i> 04]</dt>
- <dd><p>Olin Shivers, Brian D. Carlstrom, Martin Gasbichler, and Michael
- Sperber.
- <cite>Scsh Reference Manual</cite>, for scsh release 0.6.6
- <br><a href="http://www.scsh.net/docu/docu.html">http://www.scsh.net/docu/docu.html</a>
- </p>
- </dd>
- <dt>[SRFI 1]</dt>
- <dd><p>Olin Shivers.
- <cite>SRFI 1: List Library</cite>
- Scheme Requests for Implementation, 1999.
- <br><a href="http://srfi.schemers.org/srfi-1/">http://srfi.schemers.org/srfi-1/</a>
- </p>
- </dd>
- <dt>[SRFI 7]</dt>
- <dd><p>Richard Kelsey.
- <cite>SRFI 7: Feature-Based Program Configuration Language</cite>
- Scheme Requests for Implementation, 1999.
- <br><a href="http://srfi.schemers.org/srfi-7/">http://srfi.schemers.org/srfi-7/</a>
- </p>
- </dd>
- <dt>[SRFI 9]</dt>
- <dd><p>Richard Kelsey.
- <cite>SRFI 9: Defining Record Types</cite>
- Scheme Requests for Implementation, 1999.
- <br><a href="http://srfi.schemers.org/srfi-9/">http://srfi.schemers.org/srfi-9/</a>
- </p>
- </dd>
- <dt>[SRFI 22]</dt>
- <dd><p>Martin Gasbichler and Michael Sperber
- <cite>SRFI 22: Running Scheme Scripts on Unix</cite>
- Scheme Requests for Implementation, 2002.
- <br><a href="http://srfi.schemers.org/srfi-22/">http://srfi.schemers.org/srfi-22/</a>
- </p>
- </dd>
- <dt>[SRFI 34]</dt>
- <dd><p>Richard Kelsey and Michael Sperber.
- <cite>SRFI 34: Exception Handling for Programs</cite>.
- Scheme Requests for Implementation, 2002.
- <br><a href="http://srfi.schemers.org/srfi-34/">http://srfi.schemers.org/srfi-34/</a>
- </p>
- </dd>
- <dt>[SRFI 35]</dt>
- <dd><p>Richard Kelsey and Michael Sperber.
- <cite>SRFI 35: Conditions</cite>.
- Scheme Requests for Implementation, 2002.
- <br><a href="http://srfi.schemers.org/srfi-35/">http://srfi.schemers.org/srfi-35/</a>
- </p>
- </dd>
- </dl>
- <hr>
- <span id="Concept-index"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Concept-index-1"></span><h2 class="unnumbered">Concept index</h2>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-index_cp_symbol-1"><b>=</b></a>
-
- <br>
- <a class="summary-letter" href="#Concept-index_cp_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-G"><b>G</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-J"><b>J</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-O"><b>O</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-V"><b>V</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-W"><b>W</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-Y"><b>Y</b></a>
-
- </td></tr></table>
- <table class="index-cp" border="0">
- <tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_symbol-1">=</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003dscheme48_002f"><code>=scheme48/</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-A">A</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-abstract-data-types">abstract data types</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-accessing-file-ports_0027-channels">accessing file ports’ channels</a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-accessing-structures">accessing structures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-amb-operator"><code>amb</code> operator</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-anonymous-structures">anonymous structures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-arrays">arrays</a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-asynchronous-channels">asynchronous channels</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-asynchronous-thread-communication-channels">asynchronous thread communication channels</a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-atomic-regions">atomic regions</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-auto_002dintegrate-optimizer"><code>auto-integrate</code> optimizer</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-B">B</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-backtrace">backtrace</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-backtracking">backtracking</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-batch-mode">batch mode</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-batch-mode-1">batch mode</a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-binary-data-operation">binary data operation</a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-binary-search-trees">binary search trees</a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-binding-multiple-values">binding multiple values</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise-integer-operations">bitwise integer operations</a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-block-input-and-output">block input and output</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-blocking-I_002fO">blocking I/O</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-buffered-input-and-output">buffered input and output</a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-buffered-output-forcing">buffered output forcing</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-buffered-output-forcing-1">buffered output forcing</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte-manipulation">byte manipulation</a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-C">C</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-byte-vectors">C access to Scheme byte vectors</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-fixnums">C access to Scheme fixnums</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-pairs">C access to Scheme pairs</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-strings">C access to Scheme strings</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-access-to-Scheme-vectors">C access to Scheme vectors</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-and-Scheme-data-conversion">C and Scheme data conversion</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-dynamic-loading">C dynamic loading</a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-macros-for-Scheme-constants">C macros for Scheme constants</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-macros-on-Scheme-booleans">C macros on Scheme booleans</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-naming-conventions">C naming conventions</a>:</td><td> </td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-predicates-for-Scheme-data">C predicates for Scheme data</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-C-shared-objects">C shared objects</a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-callbacks-from-C-and-continuations">callbacks from C and continuations</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-callbacks-from-C-and-threads">callbacks from C and threads</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel-utilities_002c-higher_002dlevel">channel utilities, higher-level</a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channels">channels</a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channels-1">channels</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channels-2">channels</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-character-sink-output-ports">character sink output ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-character-source-input-ports">character source input ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-closing-channels">closing channels</a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-closure-flattening">closure flattening</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-closures-in-Pre_002dScheme">closures in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-code-reloading">code reloading</a>:</td><td> </td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-code-reloading-1">code reloading</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-command-levels">command levels</a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-command-levels-1">command levels</a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-command-processor-help">command processor help</a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-command-processor-settings">command processor settings</a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-committing-proposals">committing proposals</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-compile_002dtime-evaluation-in-Pre_002dScheme">compile-time evaluation in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-compiler-optimization">compiler optimization</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-compound-interfaces">compound interfaces</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-compound-interfaces-1">compound interfaces</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition-handlers">condition handlers</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition-messages">condition messages</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition-restarting">condition restarting</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition-types">condition types</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition-types-1">condition types</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-conditions">conditions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-conditions-1">conditions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-config-package">config package</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-configuration-language">configuration language</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-configuration-language-1">configuration language</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-configuration-language-macros">configuration language macros</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-configuring-the-command-processor">configuring the command processor</a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-continuation-previews">continuation previews</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-continuations-and-callbacks-from-C">continuations and callbacks from C</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-continuations-in-Pre_002dScheme">continuations in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-creating-directories">creating directories</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-creating-POSIX-FIFOs">creating POSIX FIFOs</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-creating-POSIX-links">creating POSIX links</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-customized-writer">customized writer</a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-customized-writer-1">customized writer</a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-D">D</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-debug-data-storage-control">debug data storage control</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-defining-record-types">defining record types</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-deleting-directories">deleting directories</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-deleting-files">deleting files</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-destructuring-S_002dexpressions">destructuring S-expressions</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-directory-creation">directory creation</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-directory-deletion">directory deletion</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-directory-listing">directory listing</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-directory-streams">directory streams</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-disabling-command-levels">disabling command levels</a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-disabling-command-levels-1">disabling command levels</a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-disassembly">disassembly</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-displaying-conditions">displaying conditions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-displaying-heap-usage">displaying heap usage</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dumping-heap-images">dumping heap images</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dumping-heap-images-1">dumping heap images</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <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> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dynamic-bindings">dynamic bindings</a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-E">E</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-environment-flattening">environment flattening</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-environment-variables">environment variables</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error-messages">error messages</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-errors">errors</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <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> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-event">event</a>:</td><td> </td><td valign="top"><a href="#Concurrent-ML">Concurrent ML</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exceptions">exceptions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec-language">exec language</a>:</td><td> </td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec-package">exec package</a>:</td><td> </td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-executing-processes">executing processes</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-execution-timing">execution timing</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exiting-processes">exiting processes</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exiting-Scheme">exiting Scheme</a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-expanding-macros">expanding macros</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exporting-bindings-from-C-to-Scheme">exporting bindings from C to Scheme</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exporting-bindings-from-Scheme-to-C">exporting bindings from Scheme to C</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exporting-C-functions-to-Scheme">exporting C functions to Scheme</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-F">F</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fcntl"><code>fcntl</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fd_002dport-dup_0027ing">fd-port dup’ing</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fd_002dport-I_002fO-flags">fd-port I/O flags</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fd_002dports">fd-ports</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-FIFOs">FIFOs</a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-access-probing">file access probing</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-channels">file channels</a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-deletion">file deletion</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-descriptor-ports">file descriptor ports</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-descriptor-reassignment">file descriptor reassignment</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-info">file info</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file-permissions">file permissions</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filename-translations">filename translations</a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flat-closures">flat closures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flat-environments">flat environments</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flat_002denvironments-optimizer"><code>flat-environments</code> optimizer</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fluid-bindings">fluid bindings</a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flushing-output-buffers">flushing output buffers</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flushing-output-buffers-1">flushing output buffers</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-for_002dsyntax"><code>for-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-for_002dsyntax-1"><code>for-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-forcing-buffered-output">forcing buffered output</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-forcing-buffered-output-1">forcing buffered output</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-forcing-garbage-collection">forcing garbage collection</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-forking">forking</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-functors">functors</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-G">G</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-garbage-collection-in-Pre_002dScheme">garbage collection in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-garbage-collection_002c-forcing">garbage collection, forcing</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-GC-protection-in-C">GC protection in C</a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-generic-functions">generic functions</a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-generic-modules">generic modules</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-generic-predicate-dispatch">generic predicate dispatch</a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-graph-algorithms">graph algorithms</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group-ids">group ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group-ids-1">group ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-growing-vectors">growing vectors</a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-H">H</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-dumping">heap image dumping</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-dumping-1">heap image dumping</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-resumption">heap image resumption</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-resumption-1">heap image resumption</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-writing">heap image writing</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-image-writing-1">heap image writing</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-size">heap size</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-space-analysis">heap space analysis</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-heap-traversal">heap traversal</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-help">help</a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-higher_002dlevel-channel-utilities">higher-level channel utilities</a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-higher_002dorder-modules">higher-order modules</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-hygiene-of-macros-in-modules">hygiene of macros in modules</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-I">I</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-I_002fO-flags">I/O flags</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-image-dumping">image dumping</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-image-dumping-1">image dumping</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-image-writing">image writing</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-image-writing-1">image writing</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-immutability">immutability</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-importing-bindings-into-C-from-Scheme">importing bindings into C from Scheme</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-importing-bindings-into-Scheme-from-C">importing bindings into Scheme from C</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-importing-C-functions-to-Scheme">importing C functions to Scheme</a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-importing-C-functions-to-Scheme-1">importing C functions to Scheme</a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-in_002dline-procedures">in-line procedures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input-and-output-of-blocks">input and output of blocks</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input-ports-from-strings">input ports from strings</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-installing-condition-handlers">installing condition handlers</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-installing-proposals">installing proposals</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integrated-procedures">integrated procedures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interaction-between-continuations-and-C">interaction between continuations and C</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interface-abstraction">interface abstraction</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interface-definition-forms">interface definition forms</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interface-reuse">interface reüse</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interfaces">interfaces</a>:</td><td> </td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interfaces-1">interfaces</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-J">J</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-join-types">join types</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-L">L</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-limiting-output">limiting output</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-line_002d-_0026-column_002dtracking-ports">line- & column-tracking ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-listing-directories">listing directories</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-locks-for-mutual-exclusion">locks for mutual exclusion</a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-logging-operations">logging operations</a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-logging-operations-1">logging operations</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-logs">logs</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-loopholes-in-the-type-system">loopholes in the type system</a>:</td><td> </td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-low_002dlevel-access-to-records">low-level access to records</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-low_002dlevel-macros">low-level macros</a>:</td><td> </td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-M">M</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macro-expansion">macro expansion</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macro-hygiene-in-modules">macro hygiene in modules</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macro-referential-transparency-in-modules">macro referential transparency in modules</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macros-in-the-module-configuration-language">macros in the module configuration language</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macros_002c-low_002dlevel">macros, low-level</a>:</td><td> </td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-macros_002c-unhygienic">macros, unhygienic</a>:</td><td> </td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-making-directories">making directories</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-marshalling">marshalling</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-meet-types">meet types</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme">memory management in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme-1">memory management in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memory-management-in-Pre_002dScheme-2">memory management in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memory-size">memory size</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-message_002dpassing">message-passing</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-message_002dpassing-1">message-passing</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-modified-interfaces">modified interfaces</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-modified-structures">modified structures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-module-language">module language</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-module-language-1">module language</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-module-language-macros">module language macros</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-modules">modules</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-multimethod-dispatch">multimethod dispatch</a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-multiple-value-binding">multiple value binding</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mutability">mutability</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mutex-locks">mutex locks</a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mutual-exclusion">mutual exclusion</a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-N">N</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-namelists">namelists</a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-networking">networking</a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-noise-output">noise output</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-noise-output-1">noise output</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-nonblocking-I_002fO">nonblocking I/O</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-nondeterminism">nondeterminism</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-numbers-in-Pre_002dScheme">numbers in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-O">O</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-object-dumping">object dumping</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-object-reference-analysis">object reference analysis</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-opaque-data-types">opaque data types</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-opening-structures">opening structures</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-opening-structures-1">opening structures</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-opening-structures-2">opening structures</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logging-operations">optimistic concurrency logging operations</a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logging-operations-1">optimistic concurrency logging operations</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-logs">optimistic concurrency logs</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimistic-concurrency-proposals">optimistic concurrency proposals</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimistically-concurrent-record-types">optimistically concurrent record types</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimizer">optimizer</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output-port-buffer-forcing">output port buffer forcing</a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output-port-buffer-forcing-1">output port buffer forcing</a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output-ports-to-strings">output ports to strings</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-P">P</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-package-clauses">package clauses</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-packages">packages</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-parameterized-modules">parameterized modules</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-parametric-polymorphism">parametric polymorphism</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-phase-separation">phase separation</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe-I_002fO">pipe I/O</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port-to-channel-conversion">port to channel conversion</a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ports-that-track-line-_0026-column-numbers">ports that track line & column numbers</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ports-with-line-_0026-column-numbers">ports with line & column numbers</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-directory-access">POSIX directory access</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-environment-variables">POSIX environment variables</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-exec">POSIX <code>exec</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-fcntl">POSIX <code>fcntl</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-FIFOs">POSIX FIFOs</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-file-creation-masks">POSIX file creation masks</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-file-opening">POSIX file opening</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-file-permissions">POSIX file permissions</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-fork">POSIX <code>fork</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-group-ids">POSIX group ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-group-info">POSIX group info</a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-links">POSIX links</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-pipe-I_002fO">POSIX pipe I/O</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-process-exiting">POSIX process exiting</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-process-ids">POSIX process ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-process-ids-1">POSIX process ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-process-termination">POSIX process termination</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-terminal-ports">POSIX terminal ports</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-user-ids">POSIX user ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-user-info">POSIX user info</a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-POSIX-working-directory">POSIX working directory</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-closures">Pre-Scheme closures</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-garbage-collection">Pre-Scheme garbage collection</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management">Pre-Scheme memory management</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management-1">Pre-Scheme memory management</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-memory-management-2">Pre-Scheme memory management</a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-numbers">Pre-Scheme numbers</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-strings">Pre-Scheme strings</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-tail-call-optimization">Pre-Scheme tail call optimization</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-tail-call-optimization-1">Pre-Scheme tail call optimization</a>:</td><td> </td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-top_002dlevel-evaluation">Pre-Scheme top-level evaluation</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-type-inference">Pre-Scheme type inference</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-type-inference-1">Pre-Scheme type inference</a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type specifiers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Pre_002dScheme-vectors">Pre-Scheme vectors</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pretty_002dprinting">pretty-printing</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-previewing-continuations">previewing continuations</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-printing">printing</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-printing-conditions">printing conditions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-procedure-integration">procedure integration</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-procedures_002c-tracing">procedures, tracing</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proceeding-from-errors">proceeding from errors</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process-forking">process forking</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process-ids">process ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process-ids-1">process ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process-termination">process termination</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-programmatic-record-types">programmatic record types</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proposals">proposals</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proposals-1">proposals</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proposals_002c-committing">proposals, committing</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proposals_002c-installing">proposals, installing</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-Q">Q</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-quitting-Scheme">quitting Scheme</a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-R">R</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-real-time">real time</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record-resumers">record resumers</a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record-types_002c-defining">record types, defining</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record-types_002c-programmatic">record types, programmatic</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-records_002c-low_002dlevel-access-to">records, low-level access to</a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-referential-transparency-of-macros-in-modules">referential transparency of macros in modules</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reflective-tower">reflective tower</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reloading-code">reloading code</a>:</td><td> </td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reloading-code-1">reloading code</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-removing-directories">removing directories</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-removing-files">removing files</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-renaming-files">renaming files</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous">rendezvous</a>:</td><td> </td><td valign="top"><a href="#Concurrent-ML">Concurrent ML</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-resizable-vectors">resizable vectors</a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-restoring-C-data-after-resuming-images">restoring C data after resuming images</a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-resuming-heap-images">resuming heap images</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-resuming-heap-images-1">resuming heap images</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-resuming-suspended-threads">resuming suspended threads</a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-returning-from-errors">returning from errors</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-run-time">run time</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-S">S</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S_002dexpression-destructuring">S-expression destructuring</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-and-C-data-conversion">Scheme and C data conversion</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-boolean-testing-in-C">Scheme boolean testing in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-byte-vector-operations-in-C">Scheme byte vector operations in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-callbacks-in-C">Scheme callbacks in C</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-constants-in-C">Scheme constants in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-data-predicates-in-C">Scheme data predicates in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-fixnums-from-C">Scheme fixnums from C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-pair-operations-in-C">Scheme pair operations in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-string-operations-in-C">Scheme string operations in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-Scheme-vector-operations-in-C">Scheme vector operations in C</a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-scheme48_002eh"><samp>scheme48.h</samp></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-separate-compilation">separate compilation</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-serialization">serialization</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sharing-data-between-Scheme-and-C">sharing data between Scheme and C</a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal-queues">signal queues</a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signalling-conditions">signalling conditions</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-simple-character-sink-output-ports">simple character sink output ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-simple-character-source-input-ports">simple character source input ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-simple-interfaces">simple interfaces</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sleeping-threads">sleeping threads</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-space-usage-analysis">space usage analysis</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-spawning-threads">spawning threads</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-stack-size">stack size</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-static-type-analysis">static type analysis</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-static-types-in-Pre_002dScheme">static types in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-static-types-in-Pre_002dScheme-1">static types in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-type-specifiers">Pre-Scheme type specifiers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-storage-control-of-debug-data">storage control of debug data</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-storage-leak-analysis">storage leak analysis</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <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> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string-input-ports">string input ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string-matching">string matching</a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string-output-ports">string output ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string-ports">string ports</a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-strings-in-Pre_002dScheme">strings in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-strongly_002dconnected-graph-components">strongly-connected graph components</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structure-definition-forms">structure definition forms</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures">structures</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures_002c-accessing">structures, accessing</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures_002c-opening">structures, opening</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures_002c-opening-1">structures, opening</a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures_002c-opening-2">structures, opening</a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-suspending-threads">suspending threads</a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-synchronous-channels">synchronous channels</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-syntactic-tower">syntactic tower</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-syntax-expansion">syntax expansion</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-T">T</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-tail-call-optimization-in-Pre_002dScheme">tail call optimization in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <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> </td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-tail-recursion-in-Pre_002dScheme">tail recursion in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-tail-recursion-in-Pre_002dScheme-1">tail recursion in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-terminal-ports">terminal ports</a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-terminating-threads">terminating threads</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-cells">thread cells</a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-communication-channels_002c-asynchronous">thread communication channels, asynchronous</a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-descriptors">thread descriptors</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-queues">thread queues</a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-sleeping">thread sleeping</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-termination">thread termination</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread-yielding">thread yielding</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-threads-and-callbacks-from-C">threads and callbacks from C</a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-threads_002c-spawning">threads, spawning</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time">time</a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time-1">time</a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-timing-execution">timing execution</a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-top_002dlevel-evaluation-in-Pre_002dScheme">top-level evaluation in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Differences-between-Pre_002dScheme-_0026-Scheme">Differences between Pre-Scheme & Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-towers-of-evaluation-phases">towers of evaluation phases</a>:</td><td> </td><td valign="top"><a href="#Macros-in-concert-with-modules">Macros in concert with modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-tracing">tracing</a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-transaction-logs">transaction logs</a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-type-dispatch">type dispatch</a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-type-inference">type inference</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-type-lattice">type lattice</a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-type-system-loopholes">type system loopholes</a>:</td><td> </td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-U">U</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-undefined-imported-bindings">undefined imported bindings</a>:</td><td> </td><td valign="top"><a href="#Running-Scheme48">Running Scheme48</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unhygienic-macros">unhygienic macros</a>:</td><td> </td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unspecific">unspecific</a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unspecified">unspecified</a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user-ids">user ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user-ids-1">user ids</a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user-package">user package</a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-usual-resumer">usual resumer</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-V">V</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vectors-in-Pre_002dScheme">vectors in Pre-Scheme</a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-W">W</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-waiting-for-POSIX-processes">waiting for POSIX processes</a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-warnings">warnings</a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-working-directory">working directory</a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-writer_002c-customized">writer, customized</a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-writer_002c-customized-1">writer, customized</a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-writing-heap-images">writing heap images</a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-writing-heap-images-1">writing heap images</a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Concept-index_cp_letter-Y">Y</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-yielding-threads">yielding threads</a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- </table>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-index_cp_symbol-1"><b>=</b></a>
-
- <br>
- <a class="summary-letter" href="#Concept-index_cp_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-G"><b>G</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-J"><b>J</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-O"><b>O</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-V"><b>V</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-W"><b>W</b></a>
-
- <a class="summary-letter" href="#Concept-index_cp_letter-Y"><b>Y</b></a>
-
- </td></tr></table>
- <hr>
- <span id="Binding-index"></span><div class="header">
- <p>
- 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> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Binding-index-1"></span><h2 class="unnumbered">Binding index</h2>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Binding-index_bn_symbol-1"><b>&</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-2"><b>*</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-3"><b>+</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-4"><b>,</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-5"><b>-</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-6"><b>:</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-7"><b><</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-8"><b>=</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-9"><b>></b></a>
-
- <br>
- <a class="summary-letter" href="#Binding-index_bn_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-G"><b>G</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-J"><b>J</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-O"><b>O</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-V"><b>V</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-W"><b>W</b></a>
-
- </td></tr></table>
- <table class="index-bn" border="0">
- <tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-1">&</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_0026disclose_002dcondition"><code>&disclose-condition</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-2">*</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002a"><code>*</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002aload_002dfile_002dtype_002a"><code>*load-file-type*</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ascheme_002dfile_002dtype_002a"><code>*scheme-file-type*</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-3">+</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002b"><code>+</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-4">,</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002c_003f"><code>,?</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002c_003f-1"><code>,?</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cbound_003f"><code>,bound?</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cbuild"><code>,build</code></a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ccollect"><code>,collect</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ccondition"><code>,condition</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ccondition-1"><code>,condition</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cconfig"><code>,config</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cconfig-1"><code>,config</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cconfig_002dpackage_002dis"><code>,config-package-is</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cdebug"><code>,debug</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cdis"><code>,dis</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cdis-1"><code>,dis</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cdump"><code>,dump</code></a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cdump-1"><code>,dump</code></a>:</td><td> </td><td valign="top"><a href="#Image_002dbuilding-commands">Image-building commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cend"><code>,end</code></a>:</td><td> </td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexec"><code>,exec</code></a>:</td><td> </td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexec-1"><code>,exec</code></a>:</td><td> </td><td valign="top"><a href="#Command-programs">Command programs</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexit"><code>,exit</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexit-1"><code>,exit</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexit_002dwhen_002ddone"><code>,exit-when-done</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexit_002dwhen_002ddone-1"><code>,exit-when-done</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexpand"><code>,expand</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cexpand-1"><code>,expand</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cflush"><code>,flush</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cflush-1"><code>,flush</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cfor_002dsyntax"><code>,for-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cfor_002dsyntax-1"><code>,for-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cforget"><code>,forget</code></a>:</td><td> </td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cfrom_002dfile"><code>,from-file</code></a>:</td><td> </td><td valign="top"><a href="#Emacs-integration-commands">Emacs integration commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cgo"><code>,go</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002chelp"><code>,help</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002chelp-1"><code>,help</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cin"><code>,in</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cin-1"><code>,in</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cinspect"><code>,inspect</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cinspect-1"><code>,inspect</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ckeep"><code>,keep</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ckeep-1"><code>,keep</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cload"><code>,load</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cload_002dpackage"><code>,load-package</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cload_002dsrfi_002d7_002dprogram"><code>,load-srfi-7-program</code></a>:</td><td> </td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cload_002dsrfi_002d7_002dscript"><code>,load-srfi-7-script</code></a>:</td><td> </td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cnew_002dpackage"><code>,new-package</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002copen"><code>,open</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cpop"><code>,pop</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cpreview"><code>,preview</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cproceed"><code>,proceed</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cproceed-1"><code>,proceed</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cpush"><code>,push</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002creload_002dpackage"><code>,reload-package</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002creset"><code>,reset</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002creset-1"><code>,reset</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cresume"><code>,resume</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cresume-1"><code>,resume</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002crun"><code>,run</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cset"><code>,set</code></a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cset-1"><code>,set</code></a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cset-2"><code>,set</code></a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cstructure"><code>,structure</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cthreads"><code>,threads</code></a>:</td><td> </td><td valign="top"><a href="#Command-levels">Command levels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cthreads-1"><code>,threads</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ctime"><code>,time</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ctrace"><code>,trace</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ctrace-1"><code>,trace</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002ctranslate"><code>,translate</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cundefine"><code>,undefine</code></a>:</td><td> </td><td valign="top"><a href="#Basic-commands">Basic commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cunset"><code>,unset</code></a>:</td><td> </td><td valign="top"><a href="#Command-processor-switches">Command processor switches</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cuntrace"><code>,untrace</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cuntrace-1"><code>,untrace</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cuser"><code>,user</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cuser-1"><code>,user</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cuser_002dpackage_002dis"><code>,user-package-is</code></a>:</td><td> </td><td valign="top"><a href="#Module-commands">Module commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cwhere"><code>,where</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002cwhere-1"><code>,where</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-commands">Debugging commands</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-5">-</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002d"><code>-</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_002d-1"><code>-</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-6">:</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003arecord_002dtype"><code>:record-type</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-7"><</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003c"><code><</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003c_003d"><code><=</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-8">=</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003d"><code>=</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_symbol-9">></th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003e"><code>></code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-_003e_003d"><code>>=</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-A">A</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-abs"><code>abs</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-access"><code>access</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-access_002dmode"><code>access-mode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-accessible_003f"><code>accessible?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-add_002dfinalizer_0021"><code>add-finalizer!</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-add_002dsignal_002dqueue_002dsignal_0021"><code>add-signal-queue-signal!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-add_002dto_002dpopulation_0021"><code>add-to-population!</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_002b"><code>address+</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_002d"><code>address-</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_002d_003einteger"><code>address->integer</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_002ddifference"><code>address-difference</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003c"><code>address<</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003c_003d"><code>address<=</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003d"><code>address=</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003e"><code>address></code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003e_003d"><code>address>=</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-address_003f"><code>address?</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-after_002dtime_002drv"><code>after-time-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-alias"><code>alias</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-all_002dvalues"><code>all-values</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-allocate_002dmemory"><code>allocate-memory</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-alphabetic"><code>alphabetic</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-alphanumeric"><code>alphanumeric</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-always_002drv"><code>always-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-and"><code>and</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-any"><code>any</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-any-1"><code>any</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-any_002dmatch_003f"><code>any-match?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-any_003f"><code>any?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-arithmetic_002dshift"><code>arithmetic-shift</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-arithmetic_002dshift_002dright"><code>arithmetic-shift-right</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array"><code>array</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array_002d_003evector"><code>array->vector</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array_002dref"><code>array-ref</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array_002dset_0021"><code>array-set!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array_002dshape"><code>array-shape</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-array_003f"><code>array?</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii_002d_003echar"><code>ascii->char</code></a>:</td><td> </td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii_002dlimit"><code>ascii-limit</code></a>:</td><td> </td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii_002drange"><code>ascii-range</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii_002dranges"><code>ascii-ranges</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii_002dwhitespaces"><code>ascii-whitespaces</code></a>:</td><td> </td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-async_002dchannel_003f"><code>async-channel?</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-at_002dreal_002dtime_002drv"><code>at-real-time-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-atom_003f"><code>atom?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-atomically"><code>atomically</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-atomically_0021"><code>atomically!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-attempt_002dcopy_002dbytes_0021"><code>attempt-copy-bytes!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-B">B</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-begin"><code>begin</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-begin-1"><code>begin</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bit_002dcount"><code>bit-count</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dand"><code>bitwise-and</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dand-1"><code>bitwise-and</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dior"><code>bitwise-ior</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dior-1"><code>bitwise-ior</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dnot"><code>bitwise-not</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dnot-1"><code>bitwise-not</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dxor"><code>bitwise-xor</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise_002dxor-1"><code>bitwise-xor</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-blank"><code>blank</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-breakpoint"><code>breakpoint</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvector"><code>byte-vector</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dlength"><code>byte-vector-length</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dref"><code>byte-vector-ref</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvector_002dset_0021"><code>byte-vector-set!</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvector_003f"><code>byte-vector?</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-C">C</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002datomically"><code>call-atomically</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002datomically_0021"><code>call-atomically!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002densuring_002datomicity"><code>call-ensuring-atomicity</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002densuring_002datomicity_0021"><code>call-ensuring-atomicity!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002derror"><code>call-error</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002derror_003f"><code>call-error?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dexternal"><code>call-external</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dexternal_002dvalue"><code>call-external-value</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dimported_002dbinding"><code>call-imported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002dinput_002dport"><code>call-with-current-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002dnoise_002dport"><code>call-with-current-noise-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dcurrent_002doutput_002dport"><code>call-with-current-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dinput_002dfile"><code>call-with-input-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002doutput_002dfile"><code>call-with-output-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dstring_002doutput_002dport"><code>call-with-string-output-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-call_002dwith_002dvalues"><code>call-with-values</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-cell_002dref"><code>cell-ref</code></a>:</td><td> </td><td valign="top"><a href="#Cells">Cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-cell_002dset_0021"><code>cell-set!</code></a>:</td><td> </td><td valign="top"><a href="#Cells">Cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-cell_003f"><code>cell?</code></a>:</td><td> </td><td valign="top"><a href="#Cells">Cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dabort"><code>channel-abort</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002did"><code>channel-id</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dclose"><code>channel-maybe-commit-and-close</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dread"><code>channel-maybe-commit-and-read</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dcommit_002dand_002dwrite"><code>channel-maybe-commit-and-write</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dread"><code>channel-maybe-read</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dmaybe_002dwrite"><code>channel-maybe-write</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dos_002dindex"><code>channel-os-index</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dready_003f"><code>channel-ready?</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dstatus"><code>channel-status</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dstatus_002doption"><code>channel-status-option</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dwrite"><code>channel-write</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_003f"><code>channel?</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_003f-1"><code>channel?</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002d_003eascii"><code>char->ascii</code></a>:</td><td> </td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002dpointer_002d_003enul_002dterminated_002dstring"><code>char-pointer->nul-terminated-string</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002dpointer_002d_003estring"><code>char-pointer->string</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002dready_003f"><code>char-ready?</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002dsink_002d_003eoutput_002dport"><code>char-sink->output-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_002dsource_002d_003einput_002dport"><code>char-source->input-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_003c_003f"><code>char<?</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-char_003d_003f"><code>char=?</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-check_002dbuffer_002dtimestamp_0021"><code>check-buffer-timestamp!</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-choose"><code>choose</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002dall_002dport"><code>close-all-port</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002dchannel"><code>close-channel</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002ddirectory_002dstream"><code>close-directory-stream</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002dinput_002dport"><code>close-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002dinput_002dport-1"><code>close-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002don_002dexec_003f"><code>close-on-exec?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002doutput_002dport"><code>close-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002doutput_002dport-1"><code>close-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-close_002dsocket"><code>close-socket</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-code_002dquote"><code>code-quote</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-components"><code>components</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-compound_002dinterface"><code>compound-interface</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-concatenate_002dsymbol"><code>concatenate-symbol</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-cond"><code>cond</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition_002dpredicate"><code>condition-predicate</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition_002dstuff"><code>condition-stuff</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condition_002dtype"><code>condition-type</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condvar_002dhas_002dvalue_003f"><code>condvar-has-value?</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condvar_002dvalue"><code>condvar-value</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condvar_003f"><code>condvar?</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-control"><code>control</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-copy_002darray"><code>copy-array</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-copy_002dmemory_0021"><code>copy-memory!</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-count_0025"><code>count%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-count_002a"><code>count*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dcolumn"><code>current-column</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002derror_002dport"><code>current-error-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dinput_002dport"><code>current-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dinput_002dport-1"><code>current-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dnoise_002dport"><code>current-noise-port</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dnoise_002dport-1"><code>current-noise-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002doutput_002dport"><code>current-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002doutput_002dport-1"><code>current-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dproposal"><code>current-proposal</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002drow"><code>current-row</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dthread"><code>current-thread</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-current_002dtime"><code>current-time</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-D">D</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-d"><code>d</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-deallocate"><code>deallocate</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-deallocate_002dmemory"><code>deallocate-memory</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-debug_002dmessage"><code>debug-message</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-def"><code>def</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-default_002dbuffer_002dsize"><code>default-buffer-size</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-default_002dhash_002dfunction"><code>default-hash-function</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define"><code>define</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define-1"><code>define</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dcondition_002dtype"><code>define-condition-type</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002denum_002dset_002dtype"><code>define-enum-set-type</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002denumerated_002dtype"><code>define-enumerated-type</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002denumeration"><code>define-enumeration</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dexported_002dbinding"><code>define-exported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dexported_002dbinding-1"><code>define-exported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dfinite_002dtype"><code>define-finite-type</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dgeneric"><code>define-generic</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dimported_002dbinding"><code>define-imported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dindentation"><code>define-indentation</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dinterface"><code>define-interface</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dmethod"><code>define-method</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dmodule"><code>define-module</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002ddiscloser"><code>define-record-discloser</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dresumer"><code>define-record-resumer</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dresumer-1"><code>define-record-resumer</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype"><code>define-record-type</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype-1"><code>define-record-type</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtype-2"><code>define-record-type</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsharp_002dmacro"><code>define-sharp-macro</code></a>:</td><td> </td><td valign="top"><a href="#Reader">Reader</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsimple_002dtype"><code>define-simple-type</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dstructure"><code>define-structure</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dstructures"><code>define-structures</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsynchronized_002drecord_002dtype"><code>define-synchronized-record-type</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsyntax"><code>define-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsyntax-1"><code>define-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Explicit-renaming-macros">Explicit renaming macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsyntax-2"><code>define-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-delete"><code>delete</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-delete_002dfrom_002dqueue_0021"><code>delete-from-queue!</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-delq"><code>delq</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-delq_0021"><code>delq!</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dequeue_0021"><code>dequeue!</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dequeue_002dsignal_0021"><code>dequeue-signal!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-destructure"><code>destructure</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-directory_002dstream_003f"><code>directory-stream?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-disclose_002dport"><code>disclose-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-disclose_002drecord"><code>disclose-record</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-display"><code>display</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-display_002dcondition"><code>display-condition</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-display_002dtype_002dname"><code>display-type-name</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-do"><code>do</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dump"><code>dump</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dup"><code>dup</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dup_002dswitching_002dmode"><code>dup-switching-mode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dup2"><code>dup2</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dynamic_002dload"><code>dynamic-load</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-E">E</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-either"><code>either</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-empty_002dpipe_0021"><code>empty-pipe!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-empty_002dpipe_003f"><code>empty-pipe?</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-empty_002dqueue_0021"><code>empty-queue!</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enqueue_0021"><code>enqueue!</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ensure_002datomicity"><code>ensure-atomicity</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ensure_002datomicity_0021"><code>ensure-atomicity!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum"><code>enum</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dcase"><code>enum-case</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_002d_003elist"><code>enum-set->list</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dintersection"><code>enum-set-intersection</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dmember_003f"><code>enum-set-member?</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dnegation"><code>enum-set-negation</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_002dunion"><code>enum-set-union</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dset_003d_003f"><code>enum-set=?</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enumerand_002d_003ename"><code>enumerand->name</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-environment_002dalist"><code>environment-alist</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-eof_002dobject"><code>eof-object</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-eq_003f"><code>eq?</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error"><code>error</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error-1"><code>error</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error-2"><code>error</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error_002dstring"><code>error-string</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-error_003f"><code>error?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-errors-1"><code>errors</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-error-handling">Pre-Scheme error handling</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-every"><code>every</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-every_003f"><code>every?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exact_002dmatch_003f"><code>exact-match?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exception_002darguments"><code>exception-arguments</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exception_002dopcode"><code>exception-opcode</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exception_002dreason"><code>exception-reason</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exception_003f"><code>exception?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec"><code>exec</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec_002dfile"><code>exec-file</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec_002dfile_002dwith_002denvironment"><code>exec-file-with-environment</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec_002dwith_002dalias"><code>exec-with-alias</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exec_002dwith_002denvironment"><code>exec-with-environment</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exit"><code>exit</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-export"><code>export</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-expose"><code>expose</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-expt"><code>expt</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-external"><code>external</code></a>:</td><td> </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>
- <tr><td></td><td valign="top"><a href="#index-external_002dname"><code>external-name</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-external_002dvalue"><code>external-value</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-external_003f"><code>external?</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-F">F</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fail"><code>fail</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fd_002dport_003f"><code>fd-port?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002ddevice"><code>file-info-device</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dgroup"><code>file-info-group</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dinode"><code>file-info-inode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002daccess"><code>file-info-last-access</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002dchange"><code>file-info-last-change</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlast_002dmodification"><code>file-info-last-modification</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dlink_002dcount"><code>file-info-link-count</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dmode"><code>file-info-mode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dname"><code>file-info-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002downer"><code>file-info-owner</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dsize"><code>file-info-size</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_002dtype"><code>file-info-type</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dinfo_003f"><code>file-info?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode"><code>file-mode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_002b"><code>file-mode+</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_002d"><code>file-mode-</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_002d_003einteger"><code>file-mode->integer</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_003c_003d_003f"><code>file-mode<=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_003d_003f"><code>file-mode=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_003e_003d_003f"><code>file-mode>=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dmode_003f"><code>file-mode?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dname_002ddirectory"><code>file-name-directory</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dname_002dnondirectory"><code>file-name-nondirectory</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002doptions"><code>file-options</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002doptions_002don_003f"><code>file-options-on?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dtype"><code>file-type</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dtype_002dname"><code>file-type-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-file_002dtype_003f"><code>file-type?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-files"><code>files</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filter"><code>filter</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filter-1"><code>filter</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filter_0021"><code>filter!</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filter_002dmap"><code>filter-map</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-find_002dundefined_002dimported_002dbindings"><code>find-undefined-imported-bindings</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-first"><code>first</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_002a"><code>fl*</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_002b"><code>fl+</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_002d"><code>fl-</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_002d-1"><code>fl-</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_002f"><code>fl/</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_003c"><code>fl<</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_003c_003d"><code>fl<=</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_003d"><code>fl=</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_003e"><code>fl></code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fl_003e_003d"><code>fl>=</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flonum_002dref"><code>flonum-ref</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-flonum_002dset_0021"><code>flonum-set!</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fluid"><code>fluid</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fluid_002dcell_002dref"><code>fluid-cell-ref</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fluid_002dcell_002dset_0021"><code>fluid-cell-set!</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fold"><code>fold</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fold_002d_003e2"><code>fold->2</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fold_002d_003e3"><code>fold->3</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-for_002dsyntax-2"><code>for-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-force_002dchannel_002doutput_002dports_0021"><code>force-channel-output-ports!</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-force_002doutput"><code>force-output</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-force_002doutput-1"><code>force-output</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-force_002doutput-2"><code>force-output</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-force_002doutput_002dif_002dopen"><code>force-output-if-open</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fork"><code>fork</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fork_002dand_002dforget"><code>fork-and-forget</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-format"><code>format</code></a>:</td><td> </td><td valign="top"><a href="#Common_002dLisp_002dstyle-formatting">Common-Lisp-style formatting</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fresh_002dline"><code>fresh-line</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-G">G</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002deffective_002dgroup_002did"><code>get-effective-group-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002deffective_002duser_002did"><code>get-effective-user-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dexternal"><code>get-external</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dfile_002dinfo"><code>get-file-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dfile_002flink_002dinfo"><code>get-file/link-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dgroup_002did"><code>get-group-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dgroups"><code>get-groups</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dhost_002dname"><code>get-host-name</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dlogin_002dname"><code>get-login-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dparent_002dprocess_002did"><code>get-parent-process-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dport_002dinfo"><code>get-port-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002dprocess_002did"><code>get-process-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-get_002duser_002did"><code>get-user-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-gobble_002dline"><code>gobble-line</code></a>:</td><td> </td><td valign="top"><a href="#Reader">Reader</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-goto"><code>goto</code></a>:</td><td> </td><td valign="top"><a href="#Tail-call-optimization-in-Pre_002dScheme">Tail call optimization in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-graphic"><code>graphic</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002did_002d_003egroup_002dinfo"><code>group-id->group-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002did_002d_003einteger"><code>group-id->integer</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002did_003d_003f"><code>group-id=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002did_003f"><code>group-id?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002did"><code>group-info-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002dmembers"><code>group-info-members</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002dinfo_002dname"><code>group-info-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-group_002dinfo_003f"><code>group-info?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-guard"><code>guard</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-H">H</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-hexdigit"><code>hexdigit</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-hide"><code>hide</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-host_002dname"><code>host-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-I">I</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo_002dflags"><code>i/o-flags</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-identity"><code>identity</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-if"><code>if</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ignore_002dcase"><code>ignore-case</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ignore_002derrors"><code>ignore-errors</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-immutable_003f"><code>immutable?</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-import_002ddefinition"><code>import-definition</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-import_002ddynamic_002dexternals"><code>import-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-import_002dlambda_002ddefinition"><code>import-lambda-definition</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_0025"><code>input%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_002a"><code>input*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_002dchannel_002bcloser_002d_003eport"><code>input-channel+closer->port</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_002dchannel_002d_003eport"><code>input-channel->port</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_002dport_002doption"><code>input-port-option</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-input_002dport_003f"><code>input-port?</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-insert"><code>insert</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003eaddress"><code>integer->address</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003efile_002dmode"><code>integer->file-mode</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003egroup_002did"><code>integer->group-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003emask"><code>integer->mask</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003eprocess_002did"><code>integer->process-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003esignal"><code>integer->signal</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integer_002d_003euser_002did"><code>integer->user-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-integrate"><code>integrate</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-interrupt_003f"><code>interrupt?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-intersection"><code>intersection</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-invalidate_002dcurrent_002dproposal_0021"><code>invalidate-current-proposal!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-iterate"><code>iterate</code></a>:</td><td> </td><td valign="top"><a href="#Main-looping-macros">Main looping macros</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-J">J</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-jar_002dput_0021"><code>jar-put!</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-jar_002dtake"><code>jar-take</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-jar_002dtake_002drv"><code>jar-take-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-jar_003f"><code>jar?</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-join"><code>join</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-L">L</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-last"><code>last</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let"><code>let</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let-1"><code>let</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let_002a"><code>let*</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let_002dfluid"><code>let-fluid</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let_002dfluids"><code>let-fluids</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-let_002dsyntax"><code>let-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-letrec_002dsyntax"><code>letrec-syntax</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-limit_002doutput"><code>limit-output</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-limited_002dwrite"><code>limited-write</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-link"><code>link</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_0025"><code>list%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002a"><code>list*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002d_003emask"><code>list->mask</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002d_003equeue"><code>list->queue</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002ddirectory"><code>list-directory</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002dinterface"><code>list-interface</code></a>:</td><td> </td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals"><code>load-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lock_003f"><code>lock?</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-logical_002dshift_002dright"><code>logical-shift-right</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dall_002dexternals"><code>lookup-all-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002denvironment_002dvariable"><code>lookup-environment-variable</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dexported_002dbinding"><code>lookup-exported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dexternal"><code>lookup-external</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dimported_002dbinding"><code>lookup-imported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dimported_002dbinding-1"><code>lookup-imported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lookup_002dudp_002daddress"><code>lookup-udp-address</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-loophole"><code>loophole</code></a>:</td><td> </td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lower_002dcase"><code>lower-case</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-lower_002dcase-1"><code>lower-case</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-M">M</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-m"><code>m</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-machine_002dname"><code>machine-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002darray"><code>make-array</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dasync_002dchannel"><code>make-async-channel</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002dinput_002dport"><code>make-buffered-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002dinput_002dport_002dhandler"><code>make-buffered-input-port-handler</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002doutput_002dport"><code>make-buffered-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dbuffered_002doutput_002dport_002dhandler"><code>make-buffered-output-port-handler</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dbyte_002dvector"><code>make-byte-vector</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dcell"><code>make-cell</code></a>:</td><td> </td><td valign="top"><a href="#Cells">Cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dchannel"><code>make-channel</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dcondition"><code>make-condition</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dcondvar"><code>make-condvar</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002ddirectory"><code>make-directory</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dexception"><code>make-exception</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dfifo"><code>make-fifo</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dfluid"><code>make-fluid</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dimmutable_0021"><code>make-immutable!</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dinput_002dport_002dclosed_0021"><code>make-input-port-closed!</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dinteger_002dtable"><code>make-integer-table</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002djar"><code>make-jar</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dlock"><code>make-lock</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dmask_002dtype"><code>make-mask-type</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dnull_002doutput_002dport"><code>make-null-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002doutput_002dport_002dclosed_0021"><code>make-output-port-closed!</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dpipe"><code>make-pipe</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dplaceholder"><code>make-placeholder</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dplaceholder-1"><code>make-placeholder</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dpopulation"><code>make-population</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dport"><code>make-port</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dport_002dhandler"><code>make-port-handler</code></a>:</td><td> </td><td valign="top"><a href="#Port-handlers">Port handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dproposal"><code>make-proposal</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dqueue"><code>make-queue</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002drecord"><code>make-record</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002drecord_002dtype"><code>make-record-type</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dregexp"><code>make-regexp</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dsearch_002dtree"><code>make-search-tree</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dshared_002darray"><code>make-shared-array</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dsignal_002dqueue"><code>make-signal-queue</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dsparse_002dvector"><code>make-sparse-vector</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dstring"><code>make-string</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dstring_002dinput_002dport"><code>make-string-input-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dstring_002doutput_002dport"><code>make-string-output-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dstring_002dtable"><code>make-string-table</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dsymbol_002dtable"><code>make-symbol-table</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtable"><code>make-table</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtable_002dimmutable_0021"><code>make-table-immutable!</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtable_002dmaker"><code>make-table-maker</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtime"><code>make-time</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtracking_002dinput_002dport"><code>make-tracking-input-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dtracking_002doutput_002dport"><code>make-tracking-output-port</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dunbuffered_002dinput_002dport"><code>make-unbuffered-input-port</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dunbuffered_002doutput_002dport"><code>make-unbuffered-output-port</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dvector"><code>make-vector</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-make_002dweak_002dpointer"><code>make-weak-pointer</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002d_003einteger"><code>mask->integer</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002d_003elist"><code>mask->list</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dclear"><code>mask-clear</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dhas_002dtype_003f"><code>mask-has-type?</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dintersection"><code>mask-intersection</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dmember_003f"><code>mask-member?</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dnegate"><code>mask-negate</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dset"><code>mask-set</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dsubtract"><code>mask-subtract</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dtype"><code>mask-type</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dtype_003f"><code>mask-type?</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dunion"><code>mask-union</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_003f"><code>mask?</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-match"><code>match</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-match_002dend"><code>match-end</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-match_002dstart"><code>match-start</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-match_002dsubmatches"><code>match-submatches</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-match_003f"><code>match?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-max"><code>max</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit"><code>maybe-commit</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dblock"><code>maybe-commit-and-block</code></a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <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> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002dcommit_002dand_002dmake_002dready"><code>maybe-commit-and-make-ready</code></a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <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> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <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> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_0021"><code>maybe-dequeue!</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_002dsignal_0021"><code>maybe-dequeue-signal!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002ddequeue_002dthread_0021"><code>maybe-dequeue-thread!</code></a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-maybe_002dobtain_002dlock"><code>maybe-obtain-lock</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-meet"><code>meet</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memory_002dequal_003f"><code>memory-equal?</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-memq_003f"><code>memq?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-menu"><code>menu</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-min"><code>min</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-modify"><code>modify</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mvlet"><code>mvlet</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mvlet_002a"><code>mvlet*</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-N">N</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-n_003d"><code>n=</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-name_002d_003eenumerand"><code>name->enumerand</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-name_002d_003egroup_002dinfo"><code>name->group-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-name_002d_003esignal"><code>name->signal</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-name_002d_003euser_002dinfo"><code>name->user-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-namestring"><code>namestring</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-negate"><code>negate</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-neq_003f"><code>neq?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-never_002drv"><code>never-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-newline"><code>newline</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-newline-1"><code>newline</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-no_002dop"><code>no-op</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-no_002dsubmatches"><code>no-submatches</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-not"><code>not</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-note"><code>note</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-note_002dbuffer_002dreuse_0021"><code>note-buffer-reuse!</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-note_003f"><code>note?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-null_002daddress"><code>null-address</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-null_002daddress_003f"><code>null-address?</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-null_002dlist_003f"><code>null-list?</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-null_002dpointer"><code>null-pointer</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-null_002dpointer_003f"><code>null-pointer?</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-numeric"><code>numeric</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-O">O</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-obtain_002dlock"><code>obtain-lock</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-on_002dqueue_003f"><code>on-queue?</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-one_002dof"><code>one-of</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-one_002dvalue"><code>one-value</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open"><code>open</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dchannel"><code>open-channel</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dchannels_002dlist"><code>open-channels-list</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002ddirectory_002dstream"><code>open-directory-stream</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dfile"><code>open-file</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dfile"><code>open-input-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dfile-1"><code>open-input-file</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dport_002dstatus"><code>open-input-port-status</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dinput_002dport_003f"><code>open-input-port?</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dfile"><code>open-output-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dfile-1"><code>open-output-file</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dport_002dstatus"><code>open-output-port-status</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002doutput_002dport_003f"><code>open-output-port?</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dpipe"><code>open-pipe</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dsocket"><code>open-socket</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-open_002dudp_002dsocket"><code>open-udp-socket</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-optimize"><code>optimize</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-or"><code>or</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-os_002dnode_002dname"><code>os-node-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-os_002drelease_002dname"><code>os-release-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-os_002dversion_002dname"><code>os-version-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output_002dchannel_002bcloser_002d_003eport"><code>output-channel+closer->port</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output_002dchannel_002d_003eport"><code>output-channel->port</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output_002dport_002doption"><code>output-port-option</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output_002dport_002dready_003f"><code>output-port-ready?</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-output_002dport_003f"><code>output-port?</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-P">P</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-p"><code>p</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-partition_002dlist"><code>partition-list</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-partition_002dlist_0021"><code>partition-list!</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-peek_002dchar"><code>peek-char</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-periodically_002dflushed_002dports"><code>periodically-flushed-ports</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-periodically_002dforce_002doutput_0021"><code>periodically-force-output!</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dread_0021"><code>pipe-maybe-read!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dread_003f_0021"><code>pipe-maybe-read?!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dmaybe_002dwrite_0021"><code>pipe-maybe-write!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dpush_0021"><code>pipe-push!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dread_0021"><code>pipe-read!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_002dwrite_0021"><code>pipe-write!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pipe_003f"><code>pipe?</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_002dset_0021"><code>placeholder-set!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_002dset_0021-1"><code>placeholder-set!</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue"><code>placeholder-value</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue-1"><code>placeholder-value</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_002dvalue_002drv"><code>placeholder-value-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_003f"><code>placeholder?</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholder_003f-1"><code>placeholder?</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pop_002dsearch_002dtree_002dmax_0021"><code>pop-search-tree-max!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pop_002dsearch_002dtree_002dmin_0021"><code>pop-search-tree-min!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-population_002d_003elist"><code>population->list</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002d_003echannel"><code>port->channel</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002d_003efd"><code>port->fd</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dbuffer"><code>port-buffer</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002ddata"><code>port-data</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dhandler"><code>port-handler</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dindex"><code>port-index</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dis_002da_002dterminal_003f"><code>port-is-a-terminal?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dlimit"><code>port-limit</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dlock"><code>port-lock</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dpending_002deof_003f"><code>port-pending-eof?</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dstatus"><code>port-status</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dstatus_002doptions"><code>port-status-options</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-port_002dterminal_002dname"><code>port-terminal-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-position"><code>position</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posq"><code>posq</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posv"><code>posv</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prefix"><code>prefix</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prescheme_002dcompiler"><code>prescheme-compiler</code></a>:</td><td> </td><td valign="top"><a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pretty_002dprint"><code>pretty-print</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-printing-1"><code>printing</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proc"><code>proc</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proc-1"><code>proc</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-procedure"><code>procedure</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-procedure-1"><code>procedure</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process_002did_002d_003einteger"><code>process-id->integer</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process_002did_002dexit_002dstatus"><code>process-id-exit-status</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process_002did_002dterminating_002dsignal"><code>process-id-terminating-signal</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process_002did_003d_003f"><code>process-id=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-process_002did_003f"><code>process-id?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dbyte_002dvector_002dref"><code>provisional-byte-vector-ref</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dbyte_002dvector_002dset_0021"><code>provisional-byte-vector-set!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dcar"><code>provisional-car</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dcdr"><code>provisional-cdr</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dcell_002dref"><code>provisional-cell-ref</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dcell_002dset_0021"><code>provisional-cell-set!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002ddata"><code>provisional-port-data</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dhandler"><code>provisional-port-handler</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dindex"><code>provisional-port-index</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dlimit"><code>provisional-port-limit</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dlock"><code>provisional-port-lock</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dpending_002deof_003f"><code>provisional-port-pending-eof?</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dport_002dstatus"><code>provisional-port-status</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dcar_0021"><code>provisional-set-car!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dcdr_0021"><code>provisional-set-cdr!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002ddata_0021"><code>provisional-set-port-data!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dindex_0021"><code>provisional-set-port-index!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dlimit_0021"><code>provisional-set-port-limit!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dlock_0021"><code>provisional-set-port-lock!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <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> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dset_002dport_002dstatus_0021"><code>provisional-set-port-status!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dstring_002dref"><code>provisional-string-ref</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dstring_002dset_0021"><code>provisional-string-set!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dvector_002dref"><code>provisional-vector-ref</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-provisional_002dvector_002dset_0021"><code>provisional-vector-set!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-punctuation"><code>punctuation</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-Q">Q</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-q"><code>q</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queue_002d_003elist"><code>queue->list</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queue_002dempty_003f"><code>queue-empty?</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queue_002dhead"><code>queue-head</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queue_002dlength"><code>queue-length</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queue_003f"><code>queue?</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-quotient"><code>quotient</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-R">R</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-range"><code>range</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ranges"><code>ranges</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read"><code>read</code></a>:</td><td> </td><td valign="top"><a href="#Reader">Reader</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002dblock"><code>read-block</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002dblock-1"><code>read-block</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002dchar"><code>read-char</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002ddirectory_002dstream"><code>read-directory-stream</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002derror_003f"><code>read-error?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-read_002dinteger"><code>read-integer</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reading_002derror"><code>reading-error</code></a>:</td><td> </td><td valign="top"><a href="#Reader">Reader</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-real_002dtime"><code>real-time</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive"><code>receive</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive-1"><code>receive</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive-2"><code>receive</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive-3"><code>receive</code></a>:</td><td> </td><td valign="top"><a href="#Multiple-return-values-in-Pre_002dScheme">Multiple return values in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive_002dasync"><code>receive-async</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive_002dasync_002drv"><code>receive-async-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receive_002drv"><code>receive-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record"><code>record</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002daccessor"><code>record-accessor</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dconstructor"><code>record-constructor</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dlength"><code>record-length</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dmodifier"><code>record-modifier</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dpredicate"><code>record-predicate</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dref"><code>record-ref</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dset_0021"><code>record-set!</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dspace"><code>record-space</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dtype"><code>record-type</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dtype_002dfield_002dnames"><code>record-type-field-names</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dtype_002dname"><code>record-type-name</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dtype_003f"><code>record-type?</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_003f"><code>record?</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-recurring_002dwrite"><code>recurring-write</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reduce"><code>reduce</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reduce-1"><code>reduce</code></a>:</td><td> </td><td valign="top"><a href="#Main-looping-macros">Main looping macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-regexp_002dmatch"><code>regexp-match</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-regexp_002doption"><code>regexp-option</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-regexp_003f"><code>regexp?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-release_002dlock"><code>release-lock</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-relinquish_002dtimeslice"><code>relinquish-timeslice</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reload_002ddynamic_002dexternals"><code>reload-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remainder"><code>remainder</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remap_002dfile_002ddescriptors_0021"><code>remap-file-descriptors!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remove_002dcurrent_002dproposal_0021"><code>remove-current-proposal!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remove_002ddirectory"><code>remove-directory</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remove_002dduplicates"><code>remove-duplicates</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-remove_002dsignal_002dqueue_002dsignal_0021"><code>remove-signal-queue-signal!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rename"><code>rename</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rename-1"><code>rename</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-repeat"><code>repeat</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-repeat-1"><code>repeat</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-repeat-2"><code>repeat</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-report_002derrors_002das_002dwarnings"><code>report-errors-as-warnings</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-restore"><code>restore</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reverse_0021"><code>reverse!</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reverse_002dlist_002d_003estring"><code>reverse-list->string</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-run_002dscheme"><code>run-scheme</code></a>:</td><td> </td><td valign="top"><a href="#Emacs-integration">Emacs integration</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-run_002dtime"><code>run-time</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-S">S</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fLENGTH"><code>S48_BYTE_VECTOR_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fP"><code>S48_BYTE_VECTOR_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fREF"><code>S48_BYTE_VECTOR_REF</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fBYTE_005fVECTOR_005fSET"><code>S48_BYTE_VECTOR_SET</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fcall_005fscheme"><code>s48_call_scheme</code></a>:</td><td> </td><td valign="top"><a href="#Calling-Scheme-procedures-from-C">Calling Scheme procedures from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCAR"><code>S48_CAR</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCDR"><code>S48_CDR</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHAR_005fP"><code>S48_CHAR_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fBOOLEAN"><code>S48_CHECK_BOOLEAN</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fBYTE_005fVECTOR"><code>S48_CHECK_BYTE_VECTOR</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fCHANNEL"><code>S48_CHECK_CHANNEL</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fINTEGER"><code>S48_CHECK_INTEGER</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fPAIR"><code>S48_CHECK_PAIR</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fRECORD"><code>S48_CHECK_RECORD</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fcheck_005frecord_005ftype"><code>s48_check_record_type</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSHARED_005fBINDING"><code>S48_CHECK_SHARED_BINDING</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSTRING"><code>S48_CHECK_STRING</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fCHECK_005fSYMBOL"><code>S48_CHECK_SYMBOL</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fcons"><code>s48_cons</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fDECLARE_005fGC_005fPROTECT"><code>S48_DECLARE_GC_PROTECT</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fdefine_005fexported_005fbinding"><code>s48_define_exported_binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fENTER_005fBOOLEAN"><code>S48_ENTER_BOOLEAN</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fbyte_005fvector"><code>s48_enter_byte_vector</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fchar"><code>s48_enter_char</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fdouble"><code>s48_enter_double</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005ffixnum"><code>s48_enter_fixnum</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005finteger"><code>s48_enter_integer</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fenter_005fstring"><code>s48_enter_string</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEOF"><code>S48_EOF</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEQ_005fP"><code>S48_EQ_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEXPORT_005fFUNCTION"><code>S48_EXPORT_FUNCTION</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fBOOLEAN"><code>S48_EXTRACT_BOOLEAN</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fbyte_005fvector"><code>s48_extract_byte_vector</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fchar"><code>s48_extract_char</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fdouble"><code>s48_extract_double</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005ffixnum"><code>s48_extract_fixnum</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005finteger"><code>s48_extract_integer</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fextract_005fstring"><code>s48_extract_string</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fVALUE"><code>S48_EXTRACT_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fEXTRACT_005fVALUE_005fPOINTER"><code>S48_EXTRACT_VALUE_POINTER</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fFALSE"><code>S48_FALSE</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fFALSE_005fP"><code>S48_FALSE_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fFIXNUM_005fP"><code>S48_FIXNUM_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fPROTECT_005fGLOBAL"><code>S48_GC_PROTECT_GLOBAL</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fPROTECT_005fn"><code>S48_GC_PROTECT_<var>n</var></code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fUNPROTECT"><code>S48_GC_UNPROTECT</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fGC_005fUNPROTECT_005fGLOBAL"><code>S48_GC_UNPROTECT_GLOBAL</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fget_005fimported_005fbinding"><code>s48_get_imported_binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005flength"><code>s48_length</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fbyte_005fvector"><code>s48_make_byte_vector</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005frecord"><code>s48_make_record</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fstring"><code>s48_make_string</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fMAKE_005fVALUE"><code>S48_MAKE_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fmake_005fvector"><code>s48_make_vector</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fMAX_005fFIXNUM_005fVALUE"><code>S48_MAX_FIXNUM_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fMIN_005fFIXNUM_005fVALUE"><code>S48_MIN_FIXNUM_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fNULL"><code>S48_NULL</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fon_005fload"><code>s48_on_load</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fon_005freload"><code>s48_on_reload</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fPAIR_005fP"><code>S48_PAIR_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fargument_005fnumber_005ferror"><code>s48_raise_argument_number_error</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fargument_005ftype_005ferror"><code>s48_raise_argument_type_error</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fclosed_005fchannel_005ferror"><code>s48_raise_closed_channel_error</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fos_005ferror"><code>s48_raise_os_error</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <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> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005frange_005ferror"><code>s48_raise_range_error</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fraise_005fscheme_005fexception"><code>s48_raise_scheme_exception</code></a>:</td><td> </td><td valign="top"><a href="#Raising-exceptions-from-C">Raising exceptions from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fP"><code>S48_RECORD_P</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fREF"><code>S48_RECORD_REF</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fSET"><code>S48_RECORD_SET</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fRECORD_005fTYPE"><code>S48_RECORD_TYPE</code></a>:</td><td> </td><td valign="top"><a href="#Using-Scheme-records-in-C">Using Scheme records in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fCAR"><code>S48_SET_CAR</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fCDR"><code>S48_SET_CDR</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSET_005fVALUE"><code>S48_SET_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Interacting-with-the-Scheme-heap-in-C">Interacting with the Scheme heap in C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fCHECK"><code>S48_SHARED_BINDING_CHECK</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fIS_005fIMPORTP"><code>S48_SHARED_BINDING_IS_IMPORTP</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fNAME"><code>S48_SHARED_BINDING_NAME</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fP"><code>S48_SHARED_BINDING_P</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fREF"><code>S48_SHARED_BINDING_REF</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSHARED_005fBINDING_005fSET"><code>S48_SHARED_BINDING_SET</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fLENGTH"><code>S48_STRING_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fP"><code>S48_STRING_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fREF"><code>S48_STRING_REF</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSTRING_005fSET"><code>S48_STRING_SET</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSYMBOL_005fP"><code>S48_SYMBOL_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fSYMBOL_005fTO_005fSTRING"><code>S48_SYMBOL_TO_STRING</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fTRUE"><code>S48_TRUE</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fTRUE_005fP"><code>S48_TRUE_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fLENGTH"><code>S48_UNSAFE_BYTE_VECTOR_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fREF"><code>S48_UNSAFE_BYTE_VECTOR_REF</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fBYTE_005fVECTOR_005fSET"><code>S48_UNSAFE_BYTE_VECTOR_SET</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fCAR"><code>S48_UNSAFE_CAR</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fCDR"><code>S48_UNSAFE_CDR</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fENTER_005fFIXNUM"><code>S48_UNSAFE_ENTER_FIXNUM</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fCHAR"><code>S48_UNSAFE_EXTRACT_CHAR</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fDOUBLE"><code>S48_UNSAFE_EXTRACT_DOUBLE</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fFIXNUM"><code>S48_UNSAFE_EXTRACT_FIXNUM</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fINTEGER"><code>S48_UNSAFE_EXTRACT_INTEGER</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fSTRING"><code>S48_UNSAFE_EXTRACT_STRING</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fVALUE"><code>S48_UNSAFE_EXTRACT_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fEXTRACT_005fVALUE_005fPOINTER"><code>S48_UNSAFE_EXTRACT_VALUE_POINTER</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fCAR"><code>S48_UNSAFE_SET_CAR</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fCDR"><code>S48_UNSAFE_SET_CDR</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSET_005fVALUE"><code>S48_UNSAFE_SET_VALUE</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <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> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fNAME"><code>S48_UNSAFE_SHARED_BINDING_NAME</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fREF"><code>S48_UNSAFE_SHARED_BINDING_REF</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSHARED_005fBINDING_005fSET"><code>S48_UNSAFE_SHARED_BINDING_SET</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fLENGTH"><code>S48_UNSAFE_STRING_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fREF"><code>S48_UNSAFE_STRING_REF</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSTRING_005fSET"><code>S48_UNSAFE_STRING_SET</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fSYMBOL_005fTO_005fSTRING"><code>S48_UNSAFE_SYMBOL_TO_STRING</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fLENGTH"><code>S48_UNSAFE_VECTOR_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fREF"><code>S48_UNSAFE_VECTOR_REF</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSAFE_005fVECTOR_005fSET"><code>S48_UNSAFE_VECTOR_SET</code></a>:</td><td> </td><td valign="top"><a href="#Unsafe-C-macros">Unsafe C macros</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fUNSPECIFIC"><code>S48_UNSPECIFIC</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-s48_005fvalue"><code>s48_value</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fLENGTH"><code>S48_VECTOR_LENGTH</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fP"><code>S48_VECTOR_P</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fREF"><code>S48_VECTOR_REF</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-S48_005fVECTOR_005fSET"><code>S48_VECTOR_SET</code></a>:</td><td> </td><td valign="top"><a href="#Accessing-Scheme-data-from-C">Accessing Scheme data from C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-scheme_002dprogram_002dname"><code>scheme-program-name</code></a>:</td><td> </td><td valign="top"><a href="#Emacs-integration">Emacs integration</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmax"><code>search-tree-max</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmin"><code>search-tree-min</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dmodify_0021"><code>search-tree-modify!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dref"><code>search-tree-ref</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_002dset_0021"><code>search-tree-set!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtree_003f"><code>search-tree?</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-select"><code>select</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-send"><code>send</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-send_002dasync"><code>send-async</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-send_002drv"><code>send-rv</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sequence"><code>sequence</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set"><code>set</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dclose_002don_002dexec_003f_0021"><code>set-close-on-exec?!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dcondvar_002dhas_002dvalue_003f_0021"><code>set-condvar-has-value?!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dcondvar_002dvalue_0021"><code>set-condvar-value!</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dcurrent_002dproposal_0021"><code>set-current-proposal!</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dfile_002dcreation_002dmask_0021"><code>set-file-creation-mask!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dfluid_0021"><code>set-fluid!</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dgroup_002did_0021"><code>set-group-id!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002di_002fo_002dflags_0021"><code>set-i/o-flags!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dleaf_002dpredicate_0021"><code>set-leaf-predicate!</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002ddata_0021"><code>set-port-data!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002dindex_0021"><code>set-port-index!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002dlimit_0021"><code>set-port-limit!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002dlock_0021"><code>set-port-lock!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002dpending_002deof_003f_0021"><code>set-port-pending-eof?!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dport_002dstatus_0021"><code>set-port-status!</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dtranslation_0021"><code>set-translation!</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002duser_002did_0021"><code>set-user-id!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-set_002dworking_002ddirectory_0021"><code>set-working-directory!</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dis_002dimport_003f"><code>shared-binding-is-import?</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dref"><code>shared-binding-ref</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dref-1"><code>shared-binding-ref</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_002dset_0021"><code>shared-binding-set!</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbinding_003f"><code>shared-binding?</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shift_002dleft"><code>shift-left</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-bitwise-manipulation">Pre-Scheme bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal"><code>signal</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal-1"><code>signal</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dcondition"><code>signal-condition</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dname"><code>signal-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dos_002dnumber"><code>signal-os-number</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dprocess"><code>signal-process</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dqueue_002dmonitored_002dsignals"><code>signal-queue-monitored-signals</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_002dqueue_003f"><code>signal-queue?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_003d_003f"><code>signal=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-signal_003f"><code>signal?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-silently"><code>silently</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-singleton"><code>singleton</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sleep"><code>sleep</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-socket_002daccept"><code>socket-accept</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-socket_002dclient"><code>socket-client</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-socket_002dport_002dnumber"><code>socket-port-number</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-some_002dvalues"><code>some-values</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-space"><code>space</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002d_003elist"><code>sparse-vector->list</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002dref"><code>sparse-vector-ref</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sparse_002dvector_002dset_0021"><code>sparse-vector-set!</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-spawn"><code>spawn</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-stream_0025"><code>stream%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-stream_002a"><code>stream*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_0025"><code>string%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002a"><code>string*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002d_003eimmutable_002dstring"><code>string->immutable-string</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dend"><code>string-end</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dhash"><code>string-hash</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dhash-1"><code>string-hash</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dlength"><code>string-length</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002doutput_002dport_002doutput"><code>string-output-port-output</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dref"><code>string-ref</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dset_0021"><code>string-set!</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-string_002dstart"><code>string-start</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-strongly_002dconnected_002dcomponents"><code>strongly-connected-components</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structure"><code>structure</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structure_002dref"><code>structure-ref</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structures-1"><code>structures</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sublist"><code>sublist</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-submatch"><code>submatch</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-subset"><code>subset</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-subtract"><code>subtract</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sync"><code>sync</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-syntax_002derror"><code>syntax-error</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-syntax_002derror_003f"><code>syntax-error?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-T">T</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-table_002dref"><code>table-ref</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-table_002dset_0021"><code>table-set!</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-table_002dwalk"><code>table-walk</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-table_003f"><code>table?</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-template"><code>template</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-terminate_002dcurrent_002dthread"><code>terminate-current-thread</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-text"><code>text</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread_002dname"><code>thread-name</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread_002dqueue_002dempty_003f"><code>thread-queue-empty?</code></a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread_002duid"><code>thread-uid</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-thread_003f"><code>thread?</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_002d_003estring"><code>time->string</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_002dseconds"><code>time-seconds</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003c_003d_003f"><code>time<=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003c_003f"><code>time<?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003d_003f"><code>time=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003e_003d_003f"><code>time>=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003e_003f"><code>time>?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time_003f"><code>time?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-time">POSIX time</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-trail"><code>trail</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-translate"><code>translate</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-translations"><code>translations</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-traverse_002dbreadth_002dfirst"><code>traverse-breadth-first</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-traverse_002ddepth_002dfirst"><code>traverse-depth-first</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-U">U</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-u"><code>u</code></a>:</td><td> </td><td valign="top"><a href="#Inspector">Inspector</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002daddress"><code>udp-address-address</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002dhostname"><code>udp-address-hostname</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002daddress_002dport"><code>udp-address-port</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002daddress_003f"><code>udp-address?</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002dreceive"><code>udp-receive</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002dsend"><code>udp-send</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-undefine_002dexported_002dbinding"><code>undefine-exported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-undefine_002dimported_002dbinding"><code>undefine-imported-binding</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-union"><code>union</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unlink"><code>unlink</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unload_002ddynamic_002dexternals"><code>unload-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unsigned_002dbyte_002dref"><code>unsigned-byte-ref</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unsigned_002dbyte_002dset_0021"><code>unsigned-byte-set!</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-unspecific-1"><code>unspecific</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-upper_002dcase"><code>upper-case</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-use_002dcase"><code>use-case</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002did_002d_003einteger"><code>user-id->integer</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002did_002d_003euser_002dinfo"><code>user-id->user-info</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002did_003d_003f"><code>user-id=?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002did_003f"><code>user-id?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dgroup"><code>user-info-group</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dhome_002ddirectory"><code>user-info-home-directory</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002did"><code>user-info-id</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dname"><code>user-info-name</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_002dshell"><code>user-info-shell</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-user_002dinfo_003f"><code>user-info?</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-usual_002dleaf_002dpredicate"><code>usual-leaf-predicate</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-usual_002dresumer"><code>usual-resumer</code></a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-V">V</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-values"><code>values</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-values-1"><code>values</code></a>:</td><td> </td><td valign="top"><a href="#Scheme-bindings-in-Pre_002dScheme">Scheme bindings in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-variable"><code>variable</code></a>:</td><td> </td><td valign="top"><a href="#Static-type-system">Static type system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_0025"><code>vector%</code></a>:</td><td> </td><td valign="top"><a href="#Synchronous-sequences">Synchronous sequences</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_002a"><code>vector*</code></a>:</td><td> </td><td valign="top"><a href="#Sequence-types">Sequence types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_002dlength"><code>vector-length</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_002dref"><code>vector-ref</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_002dset_0021"><code>vector-set!</code></a>:</td><td> </td><td valign="top"><a href="#Compound-Pre_002dScheme-data-manipulation">Compound Pre-Scheme data manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-vector_002dspace"><code>vector-space</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Binding-index_bn_letter-W">W</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-wait_002dfor_002dchannel"><code>wait-for-channel</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-wait_002dfor_002dchild_002dprocess"><code>wait-for-child-process</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-walk_002dpopulation"><code>walk-population</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-walk_002dsearch_002dtree"><code>walk-search-tree</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-warn"><code>warn</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-warning_003f"><code>warning?</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-weak_002dpointer_002dref"><code>weak-pointer-ref</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-weak_002dpointer_003f"><code>weak-pointer?</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-whitespace"><code>whitespace</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dcurrent_002dports"><code>with-current-ports</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dhandler"><code>with-handler</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dinput_002dfrom_002dfile"><code>with-input-from-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dnack"><code>with-nack</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dnew_002dproposal"><code>with-new-proposal</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dnondeterminism"><code>with-nondeterminism</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002doutput_002dto_002dfile"><code>with-output-to-file</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-with_002dprefix"><code>with-prefix</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-word_002dref"><code>word-ref</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-word_002dset_0021"><code>word-set!</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-working_002ddirectory"><code>working-directory</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-wrap"><code>wrap</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write"><code>write</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dblock"><code>write-block</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dblock-1"><code>write-block</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dchar"><code>write-char</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dimage"><code>write-image</code></a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dinteger"><code>write-integer</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dstring"><code>write-string</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dstring-1"><code>write-string</code></a>:</td><td> </td><td valign="top"><a href="#Input-_0026-output-in-Pre_002dScheme">Input & output in Pre-Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- </table>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Binding-index_bn_symbol-1"><b>&</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-2"><b>*</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-3"><b>+</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-4"><b>,</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-5"><b>-</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-6"><b>:</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-7"><b><</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-8"><b>=</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_symbol-9"><b>></b></a>
-
- <br>
- <a class="summary-letter" href="#Binding-index_bn_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-G"><b>G</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-J"><b>J</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-O"><b>O</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-V"><b>V</b></a>
-
- <a class="summary-letter" href="#Binding-index_bn_letter-W"><b>W</b></a>
-
- </td></tr></table>
- <hr>
- <span id="Structure-index"></span><div class="header">
- <p>
- Previous: <a href="#Binding-index" accesskey="p" rel="prev">Binding index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-index" title="Index" rel="index">Index</a>]</p>
- </div>
- <span id="Structure-index-1"></span><h2 class="unnumbered">Structure index</h2>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Structure-index_st_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-W"><b>W</b></a>
-
- </td></tr></table>
- <table class="index-st" border="0">
- <tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-A">A</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-architecture"><code>architecture</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-arrays-1"><code>arrays</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ascii"><code>ascii</code></a>:</td><td> </td><td valign="top"><a href="#ASCII-character-encoding">ASCII character encoding</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-B">B</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-big_002dutil"><code>big-util</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-bitwise"><code>bitwise</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-byte_002dvectors"><code>byte-vectors</code></a>:</td><td> </td><td valign="top"><a href="#Bitwise-manipulation">Bitwise manipulation</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-C">C</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-cells"><code>cells</code></a>:</td><td> </td><td valign="top"><a href="#Cells">Cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002di_002fo"><code>channel-i/o</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channel_002dports"><code>channel-ports</code></a>:</td><td> </td><td valign="top"><a href="#Channel-ports">Channel ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-channels-3"><code>channels</code></a>:</td><td> </td><td valign="top"><a href="#Channels">Channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-code_002dquote-1"><code>code-quote</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-conditions-2"><code>conditions</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-condvars"><code>condvars</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-D">D</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-debug_002dmessages"><code>debug-messages</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002drecord_002dtypes"><code>define-record-types</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-define_002dsync_002drecord_002dtypes"><code>define-sync-record-types</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-defrecord"><code>defrecord</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-destructuring"><code>destructuring</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dump_002frestore"><code>dump/restore</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dynamic_002dexternals"><code>dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-dynamic_002dexternals-1"><code>dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-E">E</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dcase-1"><code>enum-case</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enum_002dsets"><code>enum-sets</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-enumerated"><code>enumerated</code></a>:</td><td> </td><td valign="top"><a href="#Integer-enumerations">Integer enumerations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-exceptions-1"><code>exceptions</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-extended_002dports"><code>extended-ports</code></a>:</td><td> </td><td valign="top"><a href="#I_002fO-extensions">I/O extensions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-external_002dcalls"><code>external-calls</code></a>:</td><td> </td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-external_002dcalls-1"><code>external-calls</code></a>:</td><td> </td><td valign="top"><a href="#Calling-C-functions-from-Scheme">Calling C functions from Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-F">F</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-features"><code>features</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-filenames"><code>filenames</code></a>:</td><td> </td><td valign="top"><a href="#Filenames">Filenames</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-finite_002dtypes"><code>finite-types</code></a>:</td><td> </td><td valign="top"><a href="#Enumerated_002ffinite-types-and-sets">Enumerated/finite types and sets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-fluids"><code>fluids</code></a>:</td><td> </td><td valign="top"><a href="#Fluid_002fdynamic-bindings">Fluid/dynamic bindings</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-formats"><code>formats</code></a>:</td><td> </td><td valign="top"><a href="#Common_002dLisp_002dstyle-formatting">Common-Lisp-style formatting</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-H">H</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-handle"><code>handle</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-I">I</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo"><code>i/o</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal"><code>i/o-internal</code></a>:</td><td> </td><td valign="top"><a href="#Ports">Ports</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-1"><code>i/o-internal</code></a>:</td><td> </td><td valign="top"><a href="#Port-handlers">Port handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-2"><code>i/o-internal</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-ports-_0026-handlers">Buffered ports & handlers</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-i_002fo_002dinternal-3"><code>i/o-internal</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-I_002fO-internals">Miscellaneous I/O internals</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-L">L</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-list_002dinterfaces"><code>list-interfaces</code></a>:</td><td> </td><td valign="top"><a href="#Using-the-module-system">Using the module system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals-1"><code>load-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-load_002ddynamic_002dexternals-2"><code>load-dynamic-externals</code></a>:</td><td> </td><td valign="top"><a href="#Dynamic-loading-of-C-modules">Dynamic loading of C modules</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-locks"><code>locks</code></a>:</td><td> </td><td valign="top"><a href="#Pessimistic-concurrency">Pessimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-loopholes"><code>loopholes</code></a>:</td><td> </td><td valign="top"><a href="#Type-annotations">Type annotations</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-M">M</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mask_002dtypes"><code>mask-types</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-masks"><code>masks</code></a>:</td><td> </td><td valign="top"><a href="#Boxed-bitwise_002dinteger-masks">Boxed bitwise-integer masks</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-meta_002dmethods"><code>meta-methods</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-methods"><code>methods</code></a>:</td><td> </td><td valign="top"><a href="#Generic-dispatch-system">Generic dispatch system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-methods-1"><code>methods</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-mvlet-1"><code>mvlet</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-N">N</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-nondeterminism-1"><code>nondeterminism</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-P">P</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-placeholders"><code>placeholders</code></a>:</td><td> </td><td valign="top"><a href="#Higher_002dlevel-synchronization">Higher-level synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ports"><code>ports</code></a>:</td><td> </td><td valign="top"><a href="#Port-data-type">Port data type</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix"><code>posix</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dfiles"><code>posix-files</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dfiles-1"><code>posix-files</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-file-system-access">POSIX file system access</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002di_002fo"><code>posix-i/o</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002di_002fo-1"><code>posix-i/o</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-I_002fO-utilities">POSIX I/O utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dplatform_002dnames"><code>posix-platform-names</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-host-OS-and-machine-identification">POSIX host OS and machine identification</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dprocess_002ddata"><code>posix-process-data</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dprocess_002ddata-1"><code>posix-process-data</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-process-environment">POSIX process environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dprocesses"><code>posix-processes</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dprocesses-1"><code>posix-processes</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-processes">POSIX processes</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dregexps"><code>posix-regexps</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dregexps-1"><code>posix-regexps</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dsignals"><code>posix-signals</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-signals">POSIX signals</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dtime"><code>posix-time</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dusers"><code>posix-users</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-interface">POSIX interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-posix_002dusers-1"><code>posix-users</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-users-and-groups">POSIX users and groups</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-pp"><code>pp</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prescheme"><code>prescheme</code></a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prescheme-1"><code>prescheme</code></a>:</td><td> </td><td valign="top"><a href="#Standard-Pre_002dScheme-environment">Standard Pre-Scheme environment</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prescheme-2"><code>prescheme</code></a>:</td><td> </td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-prescheme_002dcompiler-1"><code>prescheme-compiler</code></a>:</td><td> </td><td valign="top"><a href="#Invoking-the-Pre_002dScheme-compiler">Invoking the Pre-Scheme compiler</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-proposals-2"><code>proposals</code></a>:</td><td> </td><td valign="top"><a href="#Optimistic-concurrency">Optimistic concurrency</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dflonums"><code>ps-flonums</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-floating-point-operation">Pre-Scheme floating point operation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dflonums-1"><code>ps-flonums</code></a>:</td><td> </td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dmemory"><code>ps-memory</code></a>:</td><td> </td><td valign="top"><a href="#Low_002dlevel-Pre_002dScheme-memory-manipulation">Low-level Pre-Scheme memory manipulation</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dmemory-1"><code>ps-memory</code></a>:</td><td> </td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dreceive"><code>ps-receive</code></a>:</td><td> </td><td valign="top"><a href="#Multiple-return-values-in-Pre_002dScheme">Multiple return values in Pre-Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002dreceive-1"><code>ps-receive</code></a>:</td><td> </td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002drecord_002dtypes"><code>ps-record-types</code></a>:</td><td> </td><td valign="top"><a href="#Pre_002dScheme-record-types">Pre-Scheme record types</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-ps_002drecord_002dtypes-1"><code>ps-record-types</code></a>:</td><td> </td><td valign="top"><a href="#Running-Pre_002dScheme-as-Scheme">Running Pre-Scheme as Scheme</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-Q">Q</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-queues"><code>queues</code></a>:</td><td> </td><td valign="top"><a href="#Queues">Queues</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-R">R</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reading"><code>reading</code></a>:</td><td> </td><td valign="top"><a href="#Reader">Reader</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-receiving"><code>receiving</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-record_002dtypes"><code>record-types</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-records"><code>records</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-records_002dinternal"><code>records-internal</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-reduce-2"><code>reduce</code></a>:</td><td> </td><td valign="top"><a href="#Macros-for-writing-loops">Macros for writing loops</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-regexp"><code>regexp</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-regular-expressions">POSIX regular expressions</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous-1"><code>rendezvous</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous_002dasync_002dchannels"><code>rendezvous-async-channels</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous_002dchannels"><code>rendezvous-channels</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-communication-channels">Rendezvous communication channels</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous_002djars"><code>rendezvous-jars</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous_002dplaceholders"><code>rendezvous-placeholders</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous_002dsynchronized-cells">Rendezvous-synchronized cells</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-rendezvous_002dtime"><code>rendezvous-time</code></a>:</td><td> </td><td valign="top"><a href="#Rendezvous-base-combinators">Rendezvous base combinators</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-S">S</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-scheme"><code>scheme</code></a>:</td><td> </td><td valign="top"><a href="#Module-system-architecture">Module system architecture</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-search_002dtrees"><code>search-trees</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbindings"><code>shared-bindings</code></a>:</td><td> </td><td valign="top"><a href="#C-interface">C interface</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-shared_002dbindings-1"><code>shared-bindings</code></a>:</td><td> </td><td valign="top"><a href="#Shared-bindings-between-Scheme-and-C">Shared bindings between Scheme and C</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-silly"><code>silly</code></a>:</td><td> </td><td valign="top"><a href="#Miscellaneous-features">Miscellaneous features</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-simple_002dconditions"><code>simple-conditions</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-simple_002dsignals"><code>simple-signals</code></a>:</td><td> </td><td valign="top"><a href="#Condition-system">Condition system</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sockets"><code>sockets</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sockets-1"><code>sockets</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-sparse_002dvectors"><code>sparse-vectors</code></a>:</td><td> </td><td valign="top"><a href="#Library-data-structures">Library data structures</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-spatial"><code>spatial</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-srfi_002d7"><code>srfi-7</code></a>:</td><td> </td><td valign="top"><a href="#SRFI-7">SRFI 7</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-srfi_002d9"><code>srfi-9</code></a>:</td><td> </td><td valign="top"><a href="#Records">Records</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-strong"><code>strong</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-structure_002drefs"><code>structure-refs</code></a>:</td><td> </td><td valign="top"><a href="#Module-configuration-language">Module configuration language</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-T">T</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-tables"><code>tables</code></a>:</td><td> </td><td valign="top"><a href="#Hash-tables">Hash tables</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-threads"><code>threads</code></a>:</td><td> </td><td valign="top"><a href="#Basic-thread-operations">Basic thread operations</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-threads_002dinternal"><code>threads-internal</code></a>:</td><td> </td><td valign="top"><a href="#Custom-thread-synchronization">Custom thread synchronization</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-time-2"><code>time</code></a>:</td><td> </td><td valign="top"><a href="#Library-utilities">Library utilities</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-traverse"><code>traverse</code></a>:</td><td> </td><td valign="top"><a href="#Resource-statistics-and-control">Resource statistics and control</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-U">U</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002dsockets"><code>udp-sockets</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-udp_002dsockets-1"><code>udp-sockets</code></a>:</td><td> </td><td valign="top"><a href="#TCP-_0026-UDP-sockets">TCP & UDP sockets</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-usual_002dresumer-1"><code>usual-resumer</code></a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-util"><code>util</code></a>:</td><td> </td><td valign="top"><a href="#Various-utilities">Various utilities</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- <tr><th id="Structure-index_st_letter-W">W</th><td></td><td></td></tr>
- <tr><td></td><td valign="top"><a href="#index-weak"><code>weak</code></a>:</td><td> </td><td valign="top"><a href="#Weak-references">Weak references</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-write_002dimages"><code>write-images</code></a>:</td><td> </td><td valign="top"><a href="#Suspending-and-resuming-heap-images">Suspending and resuming heap images</a></td></tr>
- <tr><td></td><td valign="top"><a href="#index-writing"><code>writing</code></a>:</td><td> </td><td valign="top"><a href="#Writer">Writer</a></td></tr>
- <tr><td colspan="4"> <hr></td></tr>
- </table>
- <table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Structure-index_st_letter-A"><b>A</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-B"><b>B</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-C"><b>C</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-D"><b>D</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-E"><b>E</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-F"><b>F</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-H"><b>H</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-I"><b>I</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-L"><b>L</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-M"><b>M</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-N"><b>N</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-P"><b>P</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-Q"><b>Q</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-R"><b>R</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-S"><b>S</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-T"><b>T</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-U"><b>U</b></a>
-
- <a class="summary-letter" href="#Structure-index_st_letter-W"><b>W</b></a>
-
- </td></tr></table>
- <div class="footnote">
- <hr>
- <h4 class="footnotes-heading">Footnotes</h4>
- <h5><a id="FOOT1" href="#DOCF1">(1)</a></h3>
- <p>The
- Scheme48 team is also working on a new, generational garbage collector,
- but it is not in the standard distribution of Scheme48 yet.</p>
- <h5><a id="FOOT2" href="#DOCF2">(2)</a></h3>
- <p><samp>scheme48.el</samp> is based on the older
- <samp>cmuscheme48.el</samp>, which is bundled with Scheme48 in the
- <samp>emacs/</samp> directory. Since <samp>cmuscheme48.el</samp> is older and less
- developed, it is not documented here.</p>
- <h5><a id="FOOT3" href="#DOCF3">(3)</a></h3>
- <p>Darcs is a revision control
- system; see
- </p>
- <div class="display">
- <pre class="display"><a href="http://www.darcs.net/">http://www.darcs.net/</a></pre></div>
- <p>for more details.</p>
- <h5><a id="FOOT4" href="#DOCF4">(4)</a></h3>
- <p>A description of the byte code is forthcoming, although
- it does not have much priority to this manual’s author. For now, users
- can read the rudimentary descriptions of the Scheme48 virtual machine’s
- byte code instruction set in <samp>vm/interp/arch.scm</samp> of Scheme48’s
- Scheme source.</p>
- <h5><a id="FOOT5" href="#DOCF5">(5)</a></h3>
- <p>This is in contrast to, for example, Common Lisp’s
- package system, which controls the mapping from strings to names.</p>
- <h5><a id="FOOT6" href="#DOCF6">(6)</a></h3>
- <p>The current implementation,
- however, does not detect this. Instead it uses the left-most structure
- in the list of a package’s <code>open</code> clause; see the next section for
- details on this.</p>
- <h5><a id="FOOT7" href="#DOCF7">(7)</a></h3>
- <p>While such facilities are
- not built-in to Scheme48, there is a package to do this, which will
- probably be integrated at some point soon into Scheme48.</p>
- <h5><a id="FOOT8" href="#DOCF8">(8)</a></h3>
- <p>This would be more
- accurately named ‘syntactic tower,’ as it has nothing to do with
- reflection.</p>
- <h5><a id="FOOT9" href="#DOCF9">(9)</a></h3>
- <p>This is actually only
- in the default config package of the default development environment.
- The full mechanism is very general.</p>
- <h5><a id="FOOT10" href="#DOCF10">(10)</a></h3>
- <p>The author of this manual is not at fault for
- this nomenclature.</p>
- <h5><a id="FOOT11" href="#DOCF11">(11)</a></h3>
- <p>On Unix,
- this is <code>stderr</code>, the standard I/O error output file.</p>
- <h5><a id="FOOT12" href="#DOCF12">(12)</a></h3>
- <p>Continuations here are in the
- sense of VM stack frames, not escape procedures as obtained using
- <code>call-with-current-continuation</code>.</p>
- <h5><a id="FOOT13" href="#DOCF13">(13)</a></h3>
- <p>The facilities Scheme48 provides
- are very rudimentary, and they are not intended to act as a coherent
- and comprehensive pathname or logical name facility such as that of
- Common Lisp. However, they served the basic needs of Scheme48’s build
- process when they were originally created.</p>
- <h5><a id="FOOT14" href="#DOCF14">(14)</a></h3>
- <p>However, the current standard distribution
- of Scheme48 is specific to Unix: the current code implements only Unix
- filename facilities.</p>
- <h5><a id="FOOT15" href="#DOCF15">(15)</a></h3>
- <p>For the
- sake of avoiding any potential copyright issues, the paper is not
- duplicated here, and instead the author of this manual has written the
- entirety of this section.</p>
- <h5><a id="FOOT16" href="#DOCF16">(16)</a></h3>
- <p>However, the current compiler in Scheme48
- does not require this, though the static linker does.</p>
- <h5><a id="FOOT17" href="#DOCF17">(17)</a></h3>
- <p>Note, however,
- that Scheme48’s condition system is likely to be superseded in the near
- future by [SRFI 34, SRFI 35].</p>
- <h5><a id="FOOT18" href="#DOCF18">(18)</a></h3>
- <p>There is an internal interface, a
- sort of meta-object protocol, to the method dispatch system, but it is
- not yet documented.</p>
- <h5><a id="FOOT19" href="#DOCF19">(19)</a></h3>
- <p>For example, the author of this manual, merely out of
- curiosity, compared the sizes of two images: one that used the usual
- resumer and printed each of its command-line arguments, and one that
- performed <em>no</em> run-time system initialization — which eliminated
- the run-time system in the image, because it was untraceable from the
- resumer — and wrote directly to the standard output channel. The
- difference was a factor of about twenty. However, also note that the
- difference is constant; the run-time system happened to account for
- nineteen twentieths of the larger image.</p>
- <h5><a id="FOOT20" href="#DOCF20">(20)</a></h3>
- <p>In the original CML, these were called
- <em>events</em>, but that term was deemed too overloaded and confusing
- when Scheme48’s library was developed.</p>
- <h5><a id="FOOT21" href="#DOCF21">(21)</a></h3>
- <p>Known as <em>mailboxes</em> in Reppy’s original CML.</p>
- <h5><a id="FOOT22" href="#DOCF22">(22)</a></h3>
- <p>However, asynchronous channels are
- implemented by a thread that manages two synchronous channels (one for
- sends & one for receives), so this may block briefly if the thread is
- busy receiving other send or receive requests.</p>
- <h5><a id="FOOT23" href="#DOCF23">(23)</a></h3>
- <p>Called <em>I-variables</em> in Reppy’s CML,
- and <em>I-structures</em> in ID-90.</p>
- <h5><a id="FOOT24" href="#DOCF24">(24)</a></h3>
- <p>Termed <em>M-variables</em> in Reppy’s CML.</p>
- <h5><a id="FOOT25" href="#DOCF25">(25)</a></h3>
- <p>In the current implementation on
- Unix, this moment happens to be the first call to <code>real-time</code>; on
- Win32, this is the start of the Scheme process.</p>
- <h5><a id="FOOT26" href="#DOCF26">(26)</a></h3>
- <p>This is clearly
- a problem; we are working on a solution.</p>
- <h5><a id="FOOT27" href="#DOCF27">(27)</a></h3>
- <p>It
- may be possible to use Pre-Scheme’s C FFI to manually use <code>setjmp</code>
- & <code>longjmp</code>, but the author of this manual cannot attest to this
- working.</p>
- <h5><a id="FOOT28" href="#DOCF28">(28)</a></h3>
- <p>Scheme48’s VM does not use Pre-Scheme’s built-in I/O
- facilities to implement <a href="#Channels">channels</a> — it builds its
- own lower-level facilities that are still OS-independent, but, because
- they’re written individually for different OSs, they integrate better
- as low-level I/O channels with the OS. On Unix, the Scheme48 VM uses
- file descriptors; Pre-Scheme’s built-in I/O uses <code>stdio</code>.
- Scheme48’s VM uses Pre-Scheme’s built-in I/O only to read heap images.</p>
- <h5><a id="FOOT29" href="#DOCF29">(29)</a></h3>
- <p>The actual distribution of Scheme48 separates the garbage
- collector and the main virtual machine.</p>
- </div>
- <hr>
- </body>
- </html>
|