macros.html 530 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/macros</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/macros</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li><a class="reference" id="the-ast-in-nim_toc" href="#the-ast-in-nim">The AST in Nim</a></li>
  50. <li><a class="reference" id="leaf-nodesslashatoms_toc" href="#leaf-nodesslashatoms">Leaf nodes/Atoms</a></li>
  51. <li><a class="reference" id="callsslashexpressions_toc" href="#callsslashexpressions">Calls/expressions</a></li>
  52. <ul class="simple"><li><a class="reference" id="callsslashexpressions-command-call_toc" href="#callsslashexpressions-command-call">Command call</a></li>
  53. <li><a class="reference" id="callsslashexpressions-call-with_toc" href="#callsslashexpressions-call-with">Call with <tt class="docutils literal"><span class="pre">()</span></tt></a></li>
  54. <li><a class="reference" id="callsslashexpressions-infix-operator-call_toc" href="#callsslashexpressions-infix-operator-call">Infix operator call</a></li>
  55. <li><a class="reference" id="callsslashexpressions-prefix-operator-call_toc" href="#callsslashexpressions-prefix-operator-call">Prefix operator call</a></li>
  56. <li><a class="reference" id="callsslashexpressions-postfix-operator-call_toc" href="#callsslashexpressions-postfix-operator-call">Postfix operator call</a></li>
  57. <li><a class="reference" id="callsslashexpressions-call-with-named-arguments_toc" href="#callsslashexpressions-call-with-named-arguments">Call with named arguments</a></li>
  58. <li><a class="reference" id="callsslashexpressions-call-with-raw-string-literal_toc" href="#callsslashexpressions-call-with-raw-string-literal">Call with raw string literal</a></li>
  59. <li><a class="reference" id="callsslashexpressions-dereference-operator_toc" href="#callsslashexpressions-dereference-operator">Dereference operator <tt class="docutils literal"><span class="pre">[]</span></tt></a></li>
  60. <li><a class="reference" id="callsslashexpressions-addr-operator_toc" href="#callsslashexpressions-addr-operator">Addr operator</a></li>
  61. <li><a class="reference" id="callsslashexpressions-cast-operator_toc" href="#callsslashexpressions-cast-operator">Cast operator</a></li>
  62. <li><a class="reference" id="callsslashexpressions-object-access-operator-dot_toc" href="#callsslashexpressions-object-access-operator-dot">Object access operator <tt class="docutils literal"><span class="pre">.</span></tt></a></li>
  63. <li><a class="reference" id="callsslashexpressions-array-access-operator_toc" href="#callsslashexpressions-array-access-operator">Array access operator <tt class="docutils literal"><span class="pre">[]</span></tt></a></li>
  64. <li><a class="reference" id="callsslashexpressions-parentheses_toc" href="#callsslashexpressions-parentheses">Parentheses</a></li>
  65. <li><a class="reference" id="callsslashexpressions-tuple-constructors_toc" href="#callsslashexpressions-tuple-constructors">Tuple Constructors</a></li>
  66. <li><a class="reference" id="callsslashexpressions-curly-braces_toc" href="#callsslashexpressions-curly-braces">Curly braces</a></li>
  67. <li><a class="reference" id="callsslashexpressions-brackets_toc" href="#callsslashexpressions-brackets">Brackets</a></li>
  68. <li><a class="reference" id="callsslashexpressions-ranges_toc" href="#callsslashexpressions-ranges">Ranges</a></li>
  69. <li><a class="reference" id="callsslashexpressions-if-expression_toc" href="#callsslashexpressions-if-expression">If expression</a></li>
  70. <li><a class="reference" id="callsslashexpressions-documentation-comments_toc" href="#callsslashexpressions-documentation-comments">Documentation Comments</a></li>
  71. <li><a class="reference" id="callsslashexpressions-pragmas_toc" href="#callsslashexpressions-pragmas">Pragmas</a></li>
  72. </ul><li><a class="reference" id="statements_toc" href="#statements">Statements</a></li>
  73. <ul class="simple"><li><a class="reference" id="statements-if-statement_toc" href="#statements-if-statement">If statement</a></li>
  74. <li><a class="reference" id="statements-when-statement_toc" href="#statements-when-statement">When statement</a></li>
  75. <li><a class="reference" id="statements-assignment_toc" href="#statements-assignment">Assignment</a></li>
  76. <li><a class="reference" id="statements-statement-list_toc" href="#statements-statement-list">Statement list</a></li>
  77. <li><a class="reference" id="statements-case-statement_toc" href="#statements-case-statement">Case statement</a></li>
  78. <li><a class="reference" id="statements-while-statement_toc" href="#statements-while-statement">While statement</a></li>
  79. <li><a class="reference" id="statements-for-statement_toc" href="#statements-for-statement">For statement</a></li>
  80. <li><a class="reference" id="statements-try-statement_toc" href="#statements-try-statement">Try statement</a></li>
  81. <li><a class="reference" id="statements-return-statement_toc" href="#statements-return-statement">Return statement</a></li>
  82. <li><a class="reference" id="statements-yield-statement_toc" href="#statements-yield-statement">Yield statement</a></li>
  83. <li><a class="reference" id="statements-discard-statement_toc" href="#statements-discard-statement">Discard statement</a></li>
  84. <li><a class="reference" id="statements-continue-statement_toc" href="#statements-continue-statement">Continue statement</a></li>
  85. <li><a class="reference" id="statements-break-statement_toc" href="#statements-break-statement">Break statement</a></li>
  86. <li><a class="reference" id="statements-block-statement_toc" href="#statements-block-statement">Block statement</a></li>
  87. <li><a class="reference" id="statements-asm-statement_toc" href="#statements-asm-statement">Asm statement</a></li>
  88. <li><a class="reference" id="statements-import-section_toc" href="#statements-import-section">Import section</a></li>
  89. <li><a class="reference" id="statements-from-statement_toc" href="#statements-from-statement">From statement</a></li>
  90. <li><a class="reference" id="statements-export-statement_toc" href="#statements-export-statement">Export statement</a></li>
  91. <li><a class="reference" id="statements-include-statement_toc" href="#statements-include-statement">Include statement</a></li>
  92. <li><a class="reference" id="statements-var-section_toc" href="#statements-var-section">Var section</a></li>
  93. <li><a class="reference" id="statements-let-section_toc" href="#statements-let-section">Let section</a></li>
  94. <li><a class="reference" id="statements-const-section_toc" href="#statements-const-section">Const section</a></li>
  95. <li><a class="reference" id="statements-type-section_toc" href="#statements-type-section">Type section</a></li>
  96. <li><a class="reference" id="statements-mixin-statement_toc" href="#statements-mixin-statement">Mixin statement</a></li>
  97. <li><a class="reference" id="statements-bind-statement_toc" href="#statements-bind-statement">Bind statement</a></li>
  98. <li><a class="reference" id="statements-procedure-declaration_toc" href="#statements-procedure-declaration">Procedure declaration</a></li>
  99. <li><a class="reference" id="statements-iterator-declaration_toc" href="#statements-iterator-declaration">Iterator declaration</a></li>
  100. <li><a class="reference" id="statements-converter-declaration_toc" href="#statements-converter-declaration">Converter declaration</a></li>
  101. <li><a class="reference" id="statements-template-declaration_toc" href="#statements-template-declaration">Template declaration</a></li>
  102. <li><a class="reference" id="statements-macro-declaration_toc" href="#statements-macro-declaration">Macro declaration</a></li>
  103. <li><a class="reference" id="statements-hidden-standard-conversion_toc" href="#statements-hidden-standard-conversion">Hidden Standard Conversion</a></li>
  104. </ul><li><a class="reference" id="special-node-kinds_toc" href="#special-node-kinds">Special node kinds</a></li>
  105. <li>
  106. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  107. </li>
  108. <li>
  109. <details open>
  110. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  111. <ul class="simple simple-toc-section">
  112. <li><a class="reference" href="#BindSymRule" title="BindSymRule = enum
  113. brClosed, ## only the symbols in current scope are bound
  114. brOpen, ## open for overloaded symbols, but may be a single
  115. ## symbol if not ambiguous (the rules match that of
  116. ## binding in generics)
  117. brForceOpen ## same as brOpen, but it will always be open even
  118. ## if not ambiguous (this cannot be achieved with
  119. ## any other means in the language currently)">BindSymRule</a></li>
  120. <li><a class="reference" href="#LineInfo" title="LineInfo = object
  121. filename*: string
  122. line*, column*: int">LineInfo</a></li>
  123. <li><a class="reference" href="#NimIdent" title="NimIdent {.deprecated.} = object of RootObj">NimIdent</a></li>
  124. <li><a class="reference" href="#NimNodeKind" title="NimNodeKind = enum
  125. nnkNone, nnkEmpty, nnkIdent, nnkSym, nnkType, nnkCharLit, nnkIntLit,
  126. nnkInt8Lit, nnkInt16Lit, nnkInt32Lit, nnkInt64Lit, nnkUIntLit, nnkUInt8Lit,
  127. nnkUInt16Lit, nnkUInt32Lit, nnkUInt64Lit, nnkFloatLit, nnkFloat32Lit,
  128. nnkFloat64Lit, nnkFloat128Lit, nnkStrLit, nnkRStrLit, nnkTripleStrLit,
  129. nnkNilLit, nnkComesFrom, nnkDotCall, nnkCommand, nnkCall, nnkCallStrLit,
  130. nnkInfix, nnkPrefix, nnkPostfix, nnkHiddenCallConv, nnkExprEqExpr,
  131. nnkExprColonExpr, nnkIdentDefs, nnkVarTuple, nnkPar, nnkObjConstr, nnkCurly,
  132. nnkCurlyExpr, nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange, nnkDotExpr,
  133. nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr, nnkElifExpr, nnkElseExpr,
  134. nnkLambda, nnkDo, nnkAccQuoted, nnkTableConstr, nnkBind, nnkClosedSymChoice,
  135. nnkOpenSymChoice, nnkHiddenStdConv, nnkHiddenSubConv, nnkConv, nnkCast,
  136. nnkStaticExpr, nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv,
  137. nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, nnkStringToCString,
  138. nnkCStringToString, nnkAsgn, nnkFastAsgn, nnkGenericParams, nnkFormalParams,
  139. nnkOfInherit, nnkImportAs, nnkProcDef, nnkMethodDef, nnkConverterDef,
  140. nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, nnkElifBranch,
  141. nnkExceptBranch, nnkElse, nnkAsmStmt, nnkPragma, nnkPragmaBlock, nnkIfStmt,
  142. nnkWhenStmt, nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkCaseStmt,
  143. nnkTypeSection, nnkVarSection, nnkLetSection, nnkConstSection, nnkConstDef,
  144. nnkTypeDef, nnkYieldStmt, nnkDefer, nnkTryStmt, nnkFinally, nnkRaiseStmt,
  145. nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, nnkStaticStmt,
  146. nnkDiscardStmt, nnkStmtList, nnkImportStmt, nnkImportExceptStmt,
  147. nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkBindStmt,
  148. nnkMixinStmt, nnkUsingStmt, nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr,
  149. nnkStmtListType, nnkBlockType, nnkWith, nnkWithout, nnkTypeOfExpr,
  150. nnkObjectTy, nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy,
  151. nnkRecList, nnkRecCase, nnkRecWhen, nnkRefTy, nnkPtrTy, nnkVarTy, nnkConstTy,
  152. nnkOutTy, nnkDistinctTy, nnkProcTy, nnkIteratorTy, nnkSinkAsgn, nnkEnumTy,
  153. nnkEnumFieldDef, nnkArgList, nnkPattern, nnkHiddenTryStmt, nnkClosure,
  154. nnkGotoState, nnkState, nnkBreakState, nnkFuncDef, nnkTupleConstr, nnkError, ## erroneous AST node
  155. nnkModuleRef, nnkReplayAction, nnkNilRodNode, ## internal IC nodes
  156. nnkOpenSym">NimNodeKind</a></li>
  157. <li><a class="reference" href="#NimNodeKinds" title="NimNodeKinds = set[NimNodeKind]">NimNodeKinds</a></li>
  158. <li><a class="reference" href="#NimSym" title="NimSym {.deprecated.} = ref NimSymObj">NimSym</a></li>
  159. <li><a class="reference" href="#NimSymKind" title="NimSymKind = enum
  160. nskUnknown, nskConditional, nskDynLib, nskParam, nskGenericParam, nskTemp,
  161. nskModule, nskType, nskVar, nskLet, nskConst, nskResult, nskProc, nskFunc,
  162. nskMethod, nskIterator, nskConverter, nskMacro, nskTemplate, nskField,
  163. nskEnumField, nskForVar, nskLabel, nskStub">NimSymKind</a></li>
  164. <li><a class="reference" href="#NimTypeKind" title="NimTypeKind = enum
  165. ntyNone, ntyBool, ntyChar, ntyEmpty, ntyAlias, ntyNil, ntyExpr, ntyStmt,
  166. ntyTypeDesc, ntyGenericInvocation, ntyGenericBody, ntyGenericInst,
  167. ntyGenericParam, ntyDistinct, ntyEnum, ntyOrdinal, ntyArray, ntyObject,
  168. ntyTuple, ntySet, ntyRange, ntyPtr, ntyRef, ntyVar, ntySequence, ntyProc,
  169. ntyPointer, ntyOpenArray, ntyString, ntyCString, ntyForward, ntyInt, ntyInt8,
  170. ntyInt16, ntyInt32, ntyInt64, ntyFloat, ntyFloat32, ntyFloat64, ntyFloat128,
  171. ntyUInt, ntyUInt8, ntyUInt16, ntyUInt32, ntyUInt64, ntyUnused0, ntyUnused1,
  172. ntyUnused2, ntyVarargs, ntyUncheckedArray, ntyError, ntyBuiltinTypeClass,
  173. ntyUserTypeClass, ntyUserTypeClassInst, ntyCompositeTypeClass, ntyInferred,
  174. ntyAnd, ntyOr, ntyNot, ntyAnything, ntyStatic, ntyFromExpr, ntyOptDeprecated,
  175. ntyVoid">NimTypeKind</a></li>
  176. <li><a class="reference" href="#TNimSymKinds" title="TNimSymKinds {.deprecated.} = set[NimSymKind]">TNimSymKinds</a></li>
  177. <li><a class="reference" href="#TNimTypeKinds" title="TNimTypeKinds {.deprecated.} = set[NimTypeKind]">TNimTypeKinds</a></li>
  178. </ul>
  179. </details>
  180. </li>
  181. <li>
  182. <details open>
  183. <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
  184. <ul class="simple simple-toc-section">
  185. <li><a class="reference" href="#AtomicNodes" title="AtomicNodes = {nnkNone..nnkNilLit}">AtomicNodes</a></li>
  186. <li><a class="reference" href="#CallNodes" title="CallNodes = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
  187. nnkCallStrLit, nnkHiddenCallConv}">CallNodes</a></li>
  188. <li><a class="reference" href="#nnkCallKinds" title="nnkCallKinds = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
  189. nnkCallStrLit, nnkHiddenCallConv}">nnkCallKinds</a></li>
  190. <li><a class="reference" href="#nnkLiterals" title="nnkLiterals = {nnkCharLit..nnkNilLit}">nnkLiterals</a></li>
  191. <li><a class="reference" href="#nnkMutableTy" title="nnkMutableTy {.deprecated.} = nnkOutTy">nnkMutableTy</a></li>
  192. <li><a class="reference" href="#nnkSharedTy" title="nnkSharedTy {.deprecated.} = nnkSinkAsgn">nnkSharedTy</a></li>
  193. <li><a class="reference" href="#RoutineNodes" title="RoutineNodes = {nnkProcDef, nnkFuncDef, nnkMethodDef, nnkDo, nnkLambda,
  194. nnkIteratorDef, nnkTemplateDef, nnkConverterDef, nnkMacroDef}">RoutineNodes</a></li>
  195. </ul>
  196. </details>
  197. </li>
  198. <li>
  199. <details open>
  200. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  201. <ul class="simple simple-toc-section">
  202. <ul class="simple nested-toc-section">$
  203. <li><a class="reference" href="#%24%2CLineInfo" title="`$`(arg: LineInfo): string">`$`(arg: LineInfo): string</a></li>
  204. <li><a class="reference" href="#%24%2CNimIdent" title="`$`(i: NimIdent): string">`$`(i: NimIdent): string</a></li>
  205. <li><a class="reference" href="#%24%2CNimNode" title="`$`(node: NimNode): string">`$`(node: NimNode): string</a></li>
  206. <li><a class="reference" href="#%24%2CNimSym" title="`$`(s: NimSym): string">`$`(s: NimSym): string</a></li>
  207. </ul>
  208. <ul class="simple nested-toc-section">==
  209. <li><a class="reference" href="#%3D%3D%2CNimIdent%2CNimIdent" title="`==`(a, b: NimIdent): bool">`==`(a, b: NimIdent): bool</a></li>
  210. <li><a class="reference" href="#%3D%3D%2CNimNode%2CNimNode" title="`==`(a, b: NimNode): bool">`==`(a, b: NimNode): bool</a></li>
  211. <li><a class="reference" href="#%3D%3D%2CNimSym%2CNimSym" title="`==`(a, b: NimSym): bool">`==`(a, b: NimSym): bool</a></li>
  212. </ul>
  213. <ul class="simple nested-toc-section">[]
  214. <li><a class="reference" href="#%5B%5D%2CNimNode%2CBackwardsIndex" title="`[]`(n: NimNode; i: BackwardsIndex): NimNode">`[]`(n: NimNode; i: BackwardsIndex): NimNode</a></li>
  215. <li><a class="reference" href="#%5B%5D%2CNimNode%2Cint" title="`[]`(n: NimNode; i: int): NimNode">`[]`(n: NimNode; i: int): NimNode</a></li>
  216. <li><a class="reference" href="#%5B%5D%2CNimNode%2CHSlice%5BT%3A%20Ordinal%2CU%3A%20Ordinal%5D" title="`[]`[T, U: Ordinal](n: NimNode; x: HSlice[T, U]): seq[NimNode]">`[]`[T, U: Ordinal](n: NimNode; x: HSlice[T, U]): seq[NimNode]</a></li>
  217. </ul>
  218. <ul class="simple nested-toc-section">[]=
  219. <li><a class="reference" href="#%5B%5D%3D%2CNimNode%2CBackwardsIndex%2CNimNode" title="`[]=`(n: NimNode; i: BackwardsIndex; child: NimNode)">`[]=`(n: NimNode; i: BackwardsIndex; child: NimNode)</a></li>
  220. <li><a class="reference" href="#%5B%5D%3D%2CNimNode%2Cint%2CNimNode" title="`[]=`(n: NimNode; i: int; child: NimNode)">`[]=`(n: NimNode; i: int; child: NimNode)</a></li>
  221. </ul>
  222. <ul class="simple nested-toc-section">add
  223. <li><a class="reference" href="#add%2CNimNode%2CNimNode" title="add(father, child: NimNode): NimNode">add(father, child: NimNode): NimNode</a></li>
  224. <li><a class="reference" href="#add%2CNimNode%2Cvarargs%5BNimNode%5D" title="add(father: NimNode; children: varargs[NimNode]): NimNode">add(father: NimNode; children: varargs[NimNode]): NimNode</a></li>
  225. </ul>
  226. <ul class="simple nested-toc-section">addIdentIfAbsent
  227. <li><a class="reference" href="#addIdentIfAbsent%2CNimNode%2Cstring" title="addIdentIfAbsent(dest: NimNode; ident: string)">addIdentIfAbsent(dest: NimNode; ident: string)</a></li>
  228. </ul>
  229. <ul class="simple nested-toc-section">addPragma
  230. <li><a class="reference" href="#addPragma%2CNimNode%2CNimNode" title="addPragma(someProc, pragma: NimNode)">addPragma(someProc, pragma: NimNode)</a></li>
  231. </ul>
  232. <ul class="simple nested-toc-section">astGenRepr
  233. <li><a class="reference" href="#astGenRepr%2CNimNode" title="astGenRepr(n: NimNode): string">astGenRepr(n: NimNode): string</a></li>
  234. </ul>
  235. <ul class="simple nested-toc-section">basename
  236. <li><a class="reference" href="#basename%2CNimNode" title="basename(a: NimNode): NimNode">basename(a: NimNode): NimNode</a></li>
  237. </ul>
  238. <ul class="simple nested-toc-section">basename=
  239. <li><a class="reference" href="#basename%3D%2CNimNode%2Cstring" title="basename=(a: NimNode; val: string)">basename=(a: NimNode; val: string)</a></li>
  240. </ul>
  241. <ul class="simple nested-toc-section">bindSym
  242. <li><a class="reference" href="#bindSym%2C%2CBindSymRule" title="bindSym(ident: string | NimNode; rule: BindSymRule = brClosed): NimNode">bindSym(ident: string | NimNode; rule: BindSymRule = brClosed): NimNode</a></li>
  243. </ul>
  244. <ul class="simple nested-toc-section">body
  245. <li><a class="reference" href="#body%2CNimNode" title="body(someProc: NimNode): NimNode">body(someProc: NimNode): NimNode</a></li>
  246. </ul>
  247. <ul class="simple nested-toc-section">body=
  248. <li><a class="reference" href="#body%3D%2CNimNode%2CNimNode" title="body=(someProc: NimNode; val: NimNode)">body=(someProc: NimNode; val: NimNode)</a></li>
  249. </ul>
  250. <ul class="simple nested-toc-section">boolVal
  251. <li><a class="reference" href="#boolVal%2CNimNode" title="boolVal(n: NimNode): bool">boolVal(n: NimNode): bool</a></li>
  252. </ul>
  253. <ul class="simple nested-toc-section">callsite
  254. <li><a class="reference" href="#callsite" title="callsite(): NimNode">callsite(): NimNode</a></li>
  255. </ul>
  256. <ul class="simple nested-toc-section">copy
  257. <li><a class="reference" href="#copy%2CNimNode" title="copy(node: NimNode): NimNode">copy(node: NimNode): NimNode</a></li>
  258. </ul>
  259. <ul class="simple nested-toc-section">copyChildrenTo
  260. <li><a class="reference" href="#copyChildrenTo%2CNimNode%2CNimNode" title="copyChildrenTo(src, dest: NimNode)">copyChildrenTo(src, dest: NimNode)</a></li>
  261. </ul>
  262. <ul class="simple nested-toc-section">copyLineInfo
  263. <li><a class="reference" href="#copyLineInfo%2CNimNode%2CNimNode" title="copyLineInfo(arg: NimNode; info: NimNode)">copyLineInfo(arg: NimNode; info: NimNode)</a></li>
  264. </ul>
  265. <ul class="simple nested-toc-section">copyNimNode
  266. <li><a class="reference" href="#copyNimNode%2CNimNode" title="copyNimNode(n: NimNode): NimNode">copyNimNode(n: NimNode): NimNode</a></li>
  267. </ul>
  268. <ul class="simple nested-toc-section">copyNimTree
  269. <li><a class="reference" href="#copyNimTree%2CNimNode" title="copyNimTree(n: NimNode): NimNode">copyNimTree(n: NimNode): NimNode</a></li>
  270. </ul>
  271. <ul class="simple nested-toc-section">del
  272. <li><a class="reference" href="#del%2CNimNode%2Cint%2Cint" title="del(father: NimNode; idx = 0; n = 1)">del(father: NimNode; idx = 0; n = 1)</a></li>
  273. </ul>
  274. <ul class="simple nested-toc-section">eqIdent
  275. <li><a class="reference" href="#eqIdent%2CNimNode%2CNimNode" title="eqIdent(a: NimNode; b: NimNode): bool">eqIdent(a: NimNode; b: NimNode): bool</a></li>
  276. <li><a class="reference" href="#eqIdent%2CNimNode%2Cstring" title="eqIdent(a: NimNode; b: string): bool">eqIdent(a: NimNode; b: string): bool</a></li>
  277. <li><a class="reference" href="#eqIdent%2Cstring%2CNimNode" title="eqIdent(a: string; b: NimNode): bool">eqIdent(a: string; b: NimNode): bool</a></li>
  278. <li><a class="reference" href="#eqIdent%2Cstring%2Cstring" title="eqIdent(a: string; b: string): bool">eqIdent(a: string; b: string): bool</a></li>
  279. </ul>
  280. <ul class="simple nested-toc-section">error
  281. <li><a class="reference" href="#error%2Cstring%2CNimNode" title="error(msg: string; n: NimNode = nil)">error(msg: string; n: NimNode = nil)</a></li>
  282. </ul>
  283. <ul class="simple nested-toc-section">expectIdent
  284. <li><a class="reference" href="#expectIdent%2CNimNode%2Cstring" title="expectIdent(n: NimNode; name: string)">expectIdent(n: NimNode; name: string)</a></li>
  285. </ul>
  286. <ul class="simple nested-toc-section">expectKind
  287. <li><a class="reference" href="#expectKind%2CNimNode%2CNimNodeKind" title="expectKind(n: NimNode; k: NimNodeKind)">expectKind(n: NimNode; k: NimNodeKind)</a></li>
  288. <li><a class="reference" href="#expectKind%2CNimNode%2Cset%5BNimNodeKind%5D" title="expectKind(n: NimNode; k: set[NimNodeKind])">expectKind(n: NimNode; k: set[NimNodeKind])</a></li>
  289. </ul>
  290. <ul class="simple nested-toc-section">expectLen
  291. <li><a class="reference" href="#expectLen%2CNimNode%2Cint" title="expectLen(n: NimNode; len: int)">expectLen(n: NimNode; len: int)</a></li>
  292. <li><a class="reference" href="#expectLen%2CNimNode%2Cint%2Cint" title="expectLen(n: NimNode; min, max: int)">expectLen(n: NimNode; min, max: int)</a></li>
  293. </ul>
  294. <ul class="simple nested-toc-section">expectMinLen
  295. <li><a class="reference" href="#expectMinLen%2CNimNode%2Cint" title="expectMinLen(n: NimNode; min: int)">expectMinLen(n: NimNode; min: int)</a></li>
  296. </ul>
  297. <ul class="simple nested-toc-section">extractDocCommentsAndRunnables
  298. <li><a class="reference" href="#extractDocCommentsAndRunnables%2CNimNode" title="extractDocCommentsAndRunnables(n: NimNode): NimNode">extractDocCommentsAndRunnables(n: NimNode): NimNode</a></li>
  299. </ul>
  300. <ul class="simple nested-toc-section">floatVal
  301. <li><a class="reference" href="#floatVal%2CNimNode" title="floatVal(n: NimNode): BiggestFloat">floatVal(n: NimNode): BiggestFloat</a></li>
  302. </ul>
  303. <ul class="simple nested-toc-section">floatVal=
  304. <li><a class="reference" href="#floatVal%3D%2CNimNode%2CBiggestFloat" title="floatVal=(n: NimNode; val: BiggestFloat)">floatVal=(n: NimNode; val: BiggestFloat)</a></li>
  305. </ul>
  306. <ul class="simple nested-toc-section">genSym
  307. <li><a class="reference" href="#genSym%2CNimSymKind%2Cstring" title="genSym(kind: NimSymKind = nskLet; ident = &quot;&quot;): NimNode">genSym(kind: NimSymKind = nskLet; ident = &quot;&quot;): NimNode</a></li>
  308. </ul>
  309. <ul class="simple nested-toc-section">getAlign
  310. <li><a class="reference" href="#getAlign%2CNimNode" title="getAlign(arg: NimNode): int">getAlign(arg: NimNode): int</a></li>
  311. </ul>
  312. <ul class="simple nested-toc-section">getAst
  313. <li><a class="reference" href="#getAst%2Cuntyped" title="getAst(macroOrTemplate: untyped): NimNode">getAst(macroOrTemplate: untyped): NimNode</a></li>
  314. </ul>
  315. <ul class="simple nested-toc-section">getImpl
  316. <li><a class="reference" href="#getImpl%2CNimSym" title="getImpl(s: NimSym): NimNode">getImpl(s: NimSym): NimNode</a></li>
  317. <li><a class="reference" href="#getImpl%2CNimNode" title="getImpl(symbol: NimNode): NimNode">getImpl(symbol: NimNode): NimNode</a></li>
  318. </ul>
  319. <ul class="simple nested-toc-section">getImplTransformed
  320. <li><a class="reference" href="#getImplTransformed%2CNimNode" title="getImplTransformed(symbol: NimNode): NimNode">getImplTransformed(symbol: NimNode): NimNode</a></li>
  321. </ul>
  322. <ul class="simple nested-toc-section">getOffset
  323. <li><a class="reference" href="#getOffset%2CNimNode" title="getOffset(arg: NimNode): int">getOffset(arg: NimNode): int</a></li>
  324. </ul>
  325. <ul class="simple nested-toc-section">getProjectPath
  326. <li><a class="reference" href="#getProjectPath" title="getProjectPath(): string">getProjectPath(): string</a></li>
  327. </ul>
  328. <ul class="simple nested-toc-section">getSize
  329. <li><a class="reference" href="#getSize%2CNimNode" title="getSize(arg: NimNode): int">getSize(arg: NimNode): int</a></li>
  330. </ul>
  331. <ul class="simple nested-toc-section">getType
  332. <li><a class="reference" href="#getType%2CNimNode" title="getType(n: NimNode): NimNode">getType(n: NimNode): NimNode</a></li>
  333. <li><a class="reference" href="#getType%2Ctypedesc" title="getType(n: typedesc): NimNode">getType(n: typedesc): NimNode</a></li>
  334. </ul>
  335. <ul class="simple nested-toc-section">getTypeImpl
  336. <li><a class="reference" href="#getTypeImpl%2CNimNode" title="getTypeImpl(n: NimNode): NimNode">getTypeImpl(n: NimNode): NimNode</a></li>
  337. <li><a class="reference" href="#getTypeImpl%2Ctypedesc" title="getTypeImpl(n: typedesc): NimNode">getTypeImpl(n: typedesc): NimNode</a></li>
  338. </ul>
  339. <ul class="simple nested-toc-section">getTypeInst
  340. <li><a class="reference" href="#getTypeInst%2CNimNode" title="getTypeInst(n: NimNode): NimNode">getTypeInst(n: NimNode): NimNode</a></li>
  341. <li><a class="reference" href="#getTypeInst%2Ctypedesc" title="getTypeInst(n: typedesc): NimNode">getTypeInst(n: typedesc): NimNode</a></li>
  342. </ul>
  343. <ul class="simple nested-toc-section">hasArgOfName
  344. <li><a class="reference" href="#hasArgOfName%2CNimNode%2Cstring" title="hasArgOfName(params: NimNode; name: string): bool">hasArgOfName(params: NimNode; name: string): bool</a></li>
  345. </ul>
  346. <ul class="simple nested-toc-section">hint
  347. <li><a class="reference" href="#hint%2Cstring%2CNimNode" title="hint(msg: string; n: NimNode = nil)">hint(msg: string; n: NimNode = nil)</a></li>
  348. </ul>
  349. <ul class="simple nested-toc-section">ident
  350. <li><a class="reference" href="#ident%2CNimNode" title="ident(n: NimNode): NimIdent">ident(n: NimNode): NimIdent</a></li>
  351. <li><a class="reference" href="#ident%2Cstring" title="ident(name: string): NimNode">ident(name: string): NimNode</a></li>
  352. </ul>
  353. <ul class="simple nested-toc-section">ident=
  354. <li><a class="reference" href="#ident%3D%2CNimNode%2CNimIdent" title="ident=(n: NimNode; val: NimIdent)">ident=(n: NimNode; val: NimIdent)</a></li>
  355. </ul>
  356. <ul class="simple nested-toc-section">infix
  357. <li><a class="reference" href="#infix%2CNimNode%2Cstring%2CNimNode" title="infix(a: NimNode; op: string; b: NimNode): NimNode">infix(a: NimNode; op: string; b: NimNode): NimNode</a></li>
  358. </ul>
  359. <ul class="simple nested-toc-section">insert
  360. <li><a class="reference" href="#insert%2CNimNode%2Cint%2CNimNode" title="insert(a: NimNode; pos: int; b: NimNode)">insert(a: NimNode; pos: int; b: NimNode)</a></li>
  361. </ul>
  362. <ul class="simple nested-toc-section">internalErrorFlag
  363. <li><a class="reference" href="#internalErrorFlag" title="internalErrorFlag(): string">internalErrorFlag(): string</a></li>
  364. </ul>
  365. <ul class="simple nested-toc-section">intVal
  366. <li><a class="reference" href="#intVal%2CNimNode" title="intVal(n: NimNode): BiggestInt">intVal(n: NimNode): BiggestInt</a></li>
  367. </ul>
  368. <ul class="simple nested-toc-section">intVal=
  369. <li><a class="reference" href="#intVal%3D%2CNimNode%2CBiggestInt" title="intVal=(n: NimNode; val: BiggestInt)">intVal=(n: NimNode; val: BiggestInt)</a></li>
  370. </ul>
  371. <ul class="simple nested-toc-section">isExported
  372. <li><a class="reference" href="#isExported%2CNimNode" title="isExported(n: NimNode): bool">isExported(n: NimNode): bool</a></li>
  373. </ul>
  374. <ul class="simple nested-toc-section">isInstantiationOf
  375. <li><a class="reference" href="#isInstantiationOf%2CNimNode%2CNimNode" title="isInstantiationOf(instanceProcSym, genProcSym: NimNode): bool">isInstantiationOf(instanceProcSym, genProcSym: NimNode): bool</a></li>
  376. </ul>
  377. <ul class="simple nested-toc-section">kind
  378. <li><a class="reference" href="#kind%2CNimNode" title="kind(n: NimNode): NimNodeKind">kind(n: NimNode): NimNodeKind</a></li>
  379. </ul>
  380. <ul class="simple nested-toc-section">last
  381. <li><a class="reference" href="#last%2CNimNode" title="last(node: NimNode): NimNode">last(node: NimNode): NimNode</a></li>
  382. </ul>
  383. <ul class="simple nested-toc-section">len
  384. <li><a class="reference" href="#len%2CNimNode" title="len(n: NimNode): int">len(n: NimNode): int</a></li>
  385. </ul>
  386. <ul class="simple nested-toc-section">lineInfo
  387. <li><a class="reference" href="#lineInfo%2CNimNode" title="lineInfo(arg: NimNode): string">lineInfo(arg: NimNode): string</a></li>
  388. </ul>
  389. <ul class="simple nested-toc-section">lineInfoObj
  390. <li><a class="reference" href="#lineInfoObj%2CNimNode" title="lineInfoObj(n: NimNode): LineInfo">lineInfoObj(n: NimNode): LineInfo</a></li>
  391. </ul>
  392. <ul class="simple nested-toc-section">lispRepr
  393. <li><a class="reference" href="#lispRepr%2CNimNode" title="lispRepr(n: NimNode; indented = false): string">lispRepr(n: NimNode; indented = false): string</a></li>
  394. </ul>
  395. <ul class="simple nested-toc-section">name
  396. <li><a class="reference" href="#name%2CNimNode" title="name(someProc: NimNode): NimNode">name(someProc: NimNode): NimNode</a></li>
  397. </ul>
  398. <ul class="simple nested-toc-section">name=
  399. <li><a class="reference" href="#name%3D%2CNimNode%2CNimNode" title="name=(someProc: NimNode; val: NimNode)">name=(someProc: NimNode; val: NimNode)</a></li>
  400. </ul>
  401. <ul class="simple nested-toc-section">nestList
  402. <li><a class="reference" href="#nestList%2CNimNode%2CNimNode" title="nestList(op: NimNode; pack: NimNode): NimNode">nestList(op: NimNode; pack: NimNode): NimNode</a></li>
  403. <li><a class="reference" href="#nestList%2CNimNode%2CNimNode%2CNimNode" title="nestList(op: NimNode; pack: NimNode; init: NimNode): NimNode">nestList(op: NimNode; pack: NimNode; init: NimNode): NimNode</a></li>
  404. </ul>
  405. <ul class="simple nested-toc-section">newAssignment
  406. <li><a class="reference" href="#newAssignment%2CNimNode%2CNimNode" title="newAssignment(lhs, rhs: NimNode): NimNode">newAssignment(lhs, rhs: NimNode): NimNode</a></li>
  407. </ul>
  408. <ul class="simple nested-toc-section">newBlockStmt
  409. <li><a class="reference" href="#newBlockStmt%2CNimNode" title="newBlockStmt(body: NimNode): NimNode">newBlockStmt(body: NimNode): NimNode</a></li>
  410. <li><a class="reference" href="#newBlockStmt%2CNimNode%2CNimNode" title="newBlockStmt(label, body: NimNode): NimNode">newBlockStmt(label, body: NimNode): NimNode</a></li>
  411. </ul>
  412. <ul class="simple nested-toc-section">newCall
  413. <li><a class="reference" href="#newCall%2CNimIdent%2Cvarargs%5BNimNode%5D" title="newCall(theProc: NimIdent; args: varargs[NimNode]): NimNode">newCall(theProc: NimIdent; args: varargs[NimNode]): NimNode</a></li>
  414. <li><a class="reference" href="#newCall%2CNimNode%2Cvarargs%5BNimNode%5D" title="newCall(theProc: NimNode; args: varargs[NimNode]): NimNode">newCall(theProc: NimNode; args: varargs[NimNode]): NimNode</a></li>
  415. <li><a class="reference" href="#newCall%2Cstring%2Cvarargs%5BNimNode%5D" title="newCall(theProc: string; args: varargs[NimNode]): NimNode">newCall(theProc: string; args: varargs[NimNode]): NimNode</a></li>
  416. </ul>
  417. <ul class="simple nested-toc-section">newColonExpr
  418. <li><a class="reference" href="#newColonExpr%2CNimNode%2CNimNode" title="newColonExpr(a, b: NimNode): NimNode">newColonExpr(a, b: NimNode): NimNode</a></li>
  419. </ul>
  420. <ul class="simple nested-toc-section">newCommentStmtNode
  421. <li><a class="reference" href="#newCommentStmtNode%2Cstring" title="newCommentStmtNode(s: string): NimNode">newCommentStmtNode(s: string): NimNode</a></li>
  422. </ul>
  423. <ul class="simple nested-toc-section">newConstStmt
  424. <li><a class="reference" href="#newConstStmt%2CNimNode%2CNimNode" title="newConstStmt(name, value: NimNode): NimNode">newConstStmt(name, value: NimNode): NimNode</a></li>
  425. </ul>
  426. <ul class="simple nested-toc-section">newDotExpr
  427. <li><a class="reference" href="#newDotExpr%2CNimNode%2CNimNode" title="newDotExpr(a, b: NimNode): NimNode">newDotExpr(a, b: NimNode): NimNode</a></li>
  428. </ul>
  429. <ul class="simple nested-toc-section">newEmptyNode
  430. <li><a class="reference" href="#newEmptyNode" title="newEmptyNode(): NimNode">newEmptyNode(): NimNode</a></li>
  431. </ul>
  432. <ul class="simple nested-toc-section">newEnum
  433. <li><a class="reference" href="#newEnum%2CNimNode%2CopenArray%5BNimNode%5D%2Cbool%2Cbool" title="newEnum(name: NimNode; fields: openArray[NimNode]; public, pure: bool): NimNode">newEnum(name: NimNode; fields: openArray[NimNode]; public, pure: bool): NimNode</a></li>
  434. </ul>
  435. <ul class="simple nested-toc-section">newFloatLitNode
  436. <li><a class="reference" href="#newFloatLitNode%2CBiggestFloat" title="newFloatLitNode(f: BiggestFloat): NimNode">newFloatLitNode(f: BiggestFloat): NimNode</a></li>
  437. </ul>
  438. <ul class="simple nested-toc-section">newIdentDefs
  439. <li><a class="reference" href="#newIdentDefs%2CNimNode%2CNimNode" title="newIdentDefs(name, kind: NimNode; default = newEmptyNode()): NimNode">newIdentDefs(name, kind: NimNode; default = newEmptyNode()): NimNode</a></li>
  440. </ul>
  441. <ul class="simple nested-toc-section">newIdentNode
  442. <li><a class="reference" href="#newIdentNode%2CNimIdent" title="newIdentNode(i: NimIdent): NimNode">newIdentNode(i: NimIdent): NimNode</a></li>
  443. <li><a class="reference" href="#newIdentNode%2Cstring" title="newIdentNode(i: string): NimNode">newIdentNode(i: string): NimNode</a></li>
  444. </ul>
  445. <ul class="simple nested-toc-section">newIfStmt
  446. <li><a class="reference" href="#newIfStmt%2Cvarargs%5Btuple%5BNimNode%2CNimNode%5D%5D" title="newIfStmt(branches: varargs[tuple[cond, body: NimNode]]): NimNode">newIfStmt(branches: varargs[tuple[cond, body: NimNode]]): NimNode</a></li>
  447. </ul>
  448. <ul class="simple nested-toc-section">newIntLitNode
  449. <li><a class="reference" href="#newIntLitNode%2CBiggestInt" title="newIntLitNode(i: BiggestInt): NimNode">newIntLitNode(i: BiggestInt): NimNode</a></li>
  450. </ul>
  451. <ul class="simple nested-toc-section">newLetStmt
  452. <li><a class="reference" href="#newLetStmt%2CNimNode%2CNimNode" title="newLetStmt(name, value: NimNode): NimNode">newLetStmt(name, value: NimNode): NimNode</a></li>
  453. </ul>
  454. <ul class="simple nested-toc-section">newLit
  455. <li><a class="reference" href="#newLit" title="newLit(arg: enum): NimNode">newLit(arg: enum): NimNode</a></li>
  456. <li><a class="reference" href="#newLit_2" title="newLit(arg: object): NimNode">newLit(arg: object): NimNode</a></li>
  457. <li><a class="reference" href="#newLit%2Cref." title="newLit(arg: ref object): NimNode">newLit(arg: ref object): NimNode</a></li>
  458. <li><a class="reference" href="#newLit%2Cbool" title="newLit(b: bool): NimNode">newLit(b: bool): NimNode</a></li>
  459. <li><a class="reference" href="#newLit%2Cchar" title="newLit(c: char): NimNode">newLit(c: char): NimNode</a></li>
  460. <li><a class="reference" href="#newLit%2Cfloat32" title="newLit(f: float32): NimNode">newLit(f: float32): NimNode</a></li>
  461. <li><a class="reference" href="#newLit%2Cfloat64" title="newLit(f: float64): NimNode">newLit(f: float64): NimNode</a></li>
  462. <li><a class="reference" href="#newLit%2Cint" title="newLit(i: int): NimNode">newLit(i: int): NimNode</a></li>
  463. <li><a class="reference" href="#newLit%2Cint8" title="newLit(i: int8): NimNode">newLit(i: int8): NimNode</a></li>
  464. <li><a class="reference" href="#newLit%2Cint16" title="newLit(i: int16): NimNode">newLit(i: int16): NimNode</a></li>
  465. <li><a class="reference" href="#newLit%2Cint32" title="newLit(i: int32): NimNode">newLit(i: int32): NimNode</a></li>
  466. <li><a class="reference" href="#newLit%2Cint64" title="newLit(i: int64): NimNode">newLit(i: int64): NimNode</a></li>
  467. <li><a class="reference" href="#newLit%2Cuint" title="newLit(i: uint): NimNode">newLit(i: uint): NimNode</a></li>
  468. <li><a class="reference" href="#newLit%2Cuint8" title="newLit(i: uint8): NimNode">newLit(i: uint8): NimNode</a></li>
  469. <li><a class="reference" href="#newLit%2Cuint16" title="newLit(i: uint16): NimNode">newLit(i: uint16): NimNode</a></li>
  470. <li><a class="reference" href="#newLit%2Cuint32" title="newLit(i: uint32): NimNode">newLit(i: uint32): NimNode</a></li>
  471. <li><a class="reference" href="#newLit%2Cuint64" title="newLit(i: uint64): NimNode">newLit(i: uint64): NimNode</a></li>
  472. <li><a class="reference" href="#newLit%2Cstring" title="newLit(s: string): NimNode">newLit(s: string): NimNode</a></li>
  473. <li><a class="reference" href="#newLit%2Carray%5BN%2CT%5D" title="newLit[N, T](arg: array[N, T]): NimNode">newLit[N, T](arg: array[N, T]): NimNode</a></li>
  474. <li><a class="reference" href="#newLit%2CT" title="newLit[T: tuple](arg: T): NimNode">newLit[T: tuple](arg: T): NimNode</a></li>
  475. <li><a class="reference" href="#newLit%2Cseq%5BT%5D" title="newLit[T](arg: seq[T]): NimNode">newLit[T](arg: seq[T]): NimNode</a></li>
  476. <li><a class="reference" href="#newLit%2Cset%5BT%5D" title="newLit[T](s: set[T]): NimNode">newLit[T](s: set[T]): NimNode</a></li>
  477. </ul>
  478. <ul class="simple nested-toc-section">newNilLit
  479. <li><a class="reference" href="#newNilLit" title="newNilLit(): NimNode">newNilLit(): NimNode</a></li>
  480. </ul>
  481. <ul class="simple nested-toc-section">newNimNode
  482. <li><a class="reference" href="#newNimNode%2CNimNodeKind%2CNimNode" title="newNimNode(kind: NimNodeKind; lineInfoFrom: NimNode = nil): NimNode">newNimNode(kind: NimNodeKind; lineInfoFrom: NimNode = nil): NimNode</a></li>
  483. </ul>
  484. <ul class="simple nested-toc-section">newPar
  485. <li><a class="reference" href="#newPar%2CNimNode" title="newPar(exprs: NimNode): NimNode">newPar(exprs: NimNode): NimNode</a></li>
  486. <li><a class="reference" href="#newPar%2Cvarargs%5BNimNode%5D" title="newPar(exprs: varargs[NimNode]): NimNode">newPar(exprs: varargs[NimNode]): NimNode</a></li>
  487. </ul>
  488. <ul class="simple nested-toc-section">newProc
  489. <li><a class="reference" href="#newProc%2CopenArray%5BNimNode%5D%2CNimNode%2CNimNode" title="newProc(name = newEmptyNode(); params: openArray[NimNode] = [newEmptyNode()];
  490. body: NimNode = newStmtList(); procType = nnkProcDef;
  491. pragmas: NimNode = newEmptyNode()): NimNode">newProc(name = newEmptyNode(); params: openArray[NimNode] = [newEmptyNode()];
  492. body: NimNode = newStmtList(); procType = nnkProcDef;
  493. pragmas: NimNode = newEmptyNode()): NimNode</a></li>
  494. </ul>
  495. <ul class="simple nested-toc-section">newStmtList
  496. <li><a class="reference" href="#newStmtList%2Cvarargs%5BNimNode%5D" title="newStmtList(stmts: varargs[NimNode]): NimNode">newStmtList(stmts: varargs[NimNode]): NimNode</a></li>
  497. </ul>
  498. <ul class="simple nested-toc-section">newStrLitNode
  499. <li><a class="reference" href="#newStrLitNode%2Cstring" title="newStrLitNode(s: string): NimNode">newStrLitNode(s: string): NimNode</a></li>
  500. </ul>
  501. <ul class="simple nested-toc-section">newTree
  502. <li><a class="reference" href="#newTree%2CNimNodeKind%2Cvarargs%5BNimNode%5D" title="newTree(kind: NimNodeKind; children: varargs[NimNode]): NimNode">newTree(kind: NimNodeKind; children: varargs[NimNode]): NimNode</a></li>
  503. </ul>
  504. <ul class="simple nested-toc-section">newVarStmt
  505. <li><a class="reference" href="#newVarStmt%2CNimNode%2CNimNode" title="newVarStmt(name, value: NimNode): NimNode">newVarStmt(name, value: NimNode): NimNode</a></li>
  506. </ul>
  507. <ul class="simple nested-toc-section">nodeID
  508. <li><a class="reference" href="#nodeID%2CNimNode" title="nodeID(n: NimNode): int">nodeID(n: NimNode): int</a></li>
  509. </ul>
  510. <ul class="simple nested-toc-section">owner
  511. <li><a class="reference" href="#owner%2CNimNode" title="owner(sym: NimNode): NimNode">owner(sym: NimNode): NimNode</a></li>
  512. </ul>
  513. <ul class="simple nested-toc-section">params
  514. <li><a class="reference" href="#params%2CNimNode" title="params(someProc: NimNode): NimNode">params(someProc: NimNode): NimNode</a></li>
  515. </ul>
  516. <ul class="simple nested-toc-section">params=
  517. <li><a class="reference" href="#params%3D%2CNimNode%2CNimNode" title="params=(someProc: NimNode; params: NimNode)">params=(someProc: NimNode; params: NimNode)</a></li>
  518. </ul>
  519. <ul class="simple nested-toc-section">parseExpr
  520. <li><a class="reference" href="#parseExpr%2Cstring%2Cstring" title="parseExpr(s: string; filename: string = &quot;&quot;): NimNode">parseExpr(s: string; filename: string = &quot;&quot;): NimNode</a></li>
  521. </ul>
  522. <ul class="simple nested-toc-section">parseStmt
  523. <li><a class="reference" href="#parseStmt%2Cstring%2Cstring" title="parseStmt(s: string; filename: string = &quot;&quot;): NimNode">parseStmt(s: string; filename: string = &quot;&quot;): NimNode</a></li>
  524. </ul>
  525. <ul class="simple nested-toc-section">postfix
  526. <li><a class="reference" href="#postfix%2CNimNode%2Cstring" title="postfix(node: NimNode; op: string): NimNode">postfix(node: NimNode; op: string): NimNode</a></li>
  527. </ul>
  528. <ul class="simple nested-toc-section">pragma
  529. <li><a class="reference" href="#pragma%2CNimNode" title="pragma(someProc: NimNode): NimNode">pragma(someProc: NimNode): NimNode</a></li>
  530. </ul>
  531. <ul class="simple nested-toc-section">pragma=
  532. <li><a class="reference" href="#pragma%3D%2CNimNode%2CNimNode" title="pragma=(someProc: NimNode; val: NimNode)">pragma=(someProc: NimNode; val: NimNode)</a></li>
  533. </ul>
  534. <ul class="simple nested-toc-section">prefix
  535. <li><a class="reference" href="#prefix%2CNimNode%2Cstring" title="prefix(node: NimNode; op: string): NimNode">prefix(node: NimNode; op: string): NimNode</a></li>
  536. </ul>
  537. <ul class="simple nested-toc-section">quote
  538. <li><a class="reference" href="#quote%2Ctyped%2Cstring" title="quote(bl: typed; op = &quot;``&quot;): NimNode">quote(bl: typed; op = &quot;``&quot;): NimNode</a></li>
  539. </ul>
  540. <ul class="simple nested-toc-section">sameType
  541. <li><a class="reference" href="#sameType%2CNimNode%2CNimNode" title="sameType(a, b: NimNode): bool">sameType(a, b: NimNode): bool</a></li>
  542. </ul>
  543. <ul class="simple nested-toc-section">setLineInfo
  544. <li><a class="reference" href="#setLineInfo%2CNimNode%2Cstring%2Cint%2Cint" title="setLineInfo(arg: NimNode; file: string; line: int; column: int)">setLineInfo(arg: NimNode; file: string; line: int; column: int)</a></li>
  545. <li><a class="reference" href="#setLineInfo%2CNimNode%2CLineInfo" title="setLineInfo(arg: NimNode; lineInfo: LineInfo)">setLineInfo(arg: NimNode; lineInfo: LineInfo)</a></li>
  546. </ul>
  547. <ul class="simple nested-toc-section">signatureHash
  548. <li><a class="reference" href="#signatureHash%2CNimNode" title="signatureHash(n: NimNode): string">signatureHash(n: NimNode): string</a></li>
  549. </ul>
  550. <ul class="simple nested-toc-section">strVal
  551. <li><a class="reference" href="#strVal%2CNimNode" title="strVal(n: NimNode): string">strVal(n: NimNode): string</a></li>
  552. </ul>
  553. <ul class="simple nested-toc-section">strVal=
  554. <li><a class="reference" href="#strVal%3D%2CNimNode%2Cstring" title="strVal=(n: NimNode; val: string)">strVal=(n: NimNode; val: string)</a></li>
  555. </ul>
  556. <ul class="simple nested-toc-section">symBodyHash
  557. <li><a class="reference" href="#symBodyHash%2CNimNode" title="symBodyHash(s: NimNode): string">symBodyHash(s: NimNode): string</a></li>
  558. </ul>
  559. <ul class="simple nested-toc-section">symbol
  560. <li><a class="reference" href="#symbol%2CNimNode" title="symbol(n: NimNode): NimSym">symbol(n: NimNode): NimSym</a></li>
  561. </ul>
  562. <ul class="simple nested-toc-section">symbol=
  563. <li><a class="reference" href="#symbol%3D%2CNimNode%2CNimSym" title="symbol=(n: NimNode; val: NimSym)">symbol=(n: NimNode; val: NimSym)</a></li>
  564. </ul>
  565. <ul class="simple nested-toc-section">symKind
  566. <li><a class="reference" href="#symKind%2CNimNode" title="symKind(symbol: NimNode): NimSymKind">symKind(symbol: NimNode): NimSymKind</a></li>
  567. </ul>
  568. <ul class="simple nested-toc-section">toNimIdent
  569. <li><a class="reference" href="#toNimIdent%2Cstring" title="toNimIdent(s: string): NimIdent">toNimIdent(s: string): NimIdent</a></li>
  570. </ul>
  571. <ul class="simple nested-toc-section">toStrLit
  572. <li><a class="reference" href="#toStrLit%2CNimNode" title="toStrLit(n: NimNode): NimNode">toStrLit(n: NimNode): NimNode</a></li>
  573. </ul>
  574. <ul class="simple nested-toc-section">treeRepr
  575. <li><a class="reference" href="#treeRepr%2CNimNode" title="treeRepr(n: NimNode): string">treeRepr(n: NimNode): string</a></li>
  576. </ul>
  577. <ul class="simple nested-toc-section">typeKind
  578. <li><a class="reference" href="#typeKind%2CNimNode" title="typeKind(n: NimNode): NimTypeKind">typeKind(n: NimNode): NimTypeKind</a></li>
  579. </ul>
  580. <ul class="simple nested-toc-section">unpackInfix
  581. <li><a class="reference" href="#unpackInfix%2CNimNode" title="unpackInfix(node: NimNode): tuple[left: NimNode, op: string, right: NimNode]">unpackInfix(node: NimNode): tuple[left: NimNode, op: string, right: NimNode]</a></li>
  582. </ul>
  583. <ul class="simple nested-toc-section">unpackPostfix
  584. <li><a class="reference" href="#unpackPostfix%2CNimNode" title="unpackPostfix(node: NimNode): tuple[node: NimNode, op: string]">unpackPostfix(node: NimNode): tuple[node: NimNode, op: string]</a></li>
  585. </ul>
  586. <ul class="simple nested-toc-section">unpackPrefix
  587. <li><a class="reference" href="#unpackPrefix%2CNimNode" title="unpackPrefix(node: NimNode): tuple[node: NimNode, op: string]">unpackPrefix(node: NimNode): tuple[node: NimNode, op: string]</a></li>
  588. </ul>
  589. <ul class="simple nested-toc-section">warning
  590. <li><a class="reference" href="#warning%2Cstring%2CNimNode" title="warning(msg: string; n: NimNode = nil)">warning(msg: string; n: NimNode = nil)</a></li>
  591. </ul>
  592. </ul>
  593. </details>
  594. </li>
  595. <li>
  596. <details open>
  597. <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
  598. <ul class="simple simple-toc-section">
  599. <ul class="simple nested-toc-section">children
  600. <li><a class="reference" href="#children.i%2CNimNode" title="children(n: NimNode): NimNode">children(n: NimNode): NimNode</a></li>
  601. </ul>
  602. <ul class="simple nested-toc-section">items
  603. <li><a class="reference" href="#items.i%2CNimNode" title="items(n: NimNode): NimNode">items(n: NimNode): NimNode</a></li>
  604. </ul>
  605. <ul class="simple nested-toc-section">pairs
  606. <li><a class="reference" href="#pairs.i%2CNimNode" title="pairs(n: NimNode): (int, NimNode)">pairs(n: NimNode): (int, NimNode)</a></li>
  607. </ul>
  608. </ul>
  609. </details>
  610. </li>
  611. <li>
  612. <details open>
  613. <summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
  614. <ul class="simple simple-toc-section">
  615. <ul class="simple nested-toc-section">dumpAstGen
  616. <li><a class="reference" href="#dumpAstGen.m%2Cuntyped" title="dumpAstGen(s: untyped): untyped">dumpAstGen(s: untyped): untyped</a></li>
  617. </ul>
  618. <ul class="simple nested-toc-section">dumpLisp
  619. <li><a class="reference" href="#dumpLisp.m%2Cuntyped" title="dumpLisp(s: untyped): untyped">dumpLisp(s: untyped): untyped</a></li>
  620. </ul>
  621. <ul class="simple nested-toc-section">dumpTree
  622. <li><a class="reference" href="#dumpTree.m%2Cuntyped" title="dumpTree(s: untyped): untyped">dumpTree(s: untyped): untyped</a></li>
  623. </ul>
  624. <ul class="simple nested-toc-section">expandMacros
  625. <li><a class="reference" href="#expandMacros.m%2Ctyped" title="expandMacros(body: typed): untyped">expandMacros(body: typed): untyped</a></li>
  626. </ul>
  627. <ul class="simple nested-toc-section">getCustomPragmaVal
  628. <li><a class="reference" href="#getCustomPragmaVal.m%2Ctyped%2C" title="getCustomPragmaVal(n: typed; cp: typed{nkSym}): untyped">getCustomPragmaVal(n: typed; cp: typed{nkSym}): untyped</a></li>
  629. </ul>
  630. <ul class="simple nested-toc-section">hasCustomPragma
  631. <li><a class="reference" href="#hasCustomPragma.m%2Ctyped%2C" title="hasCustomPragma(n: typed; cp: typed{nkSym}): untyped">hasCustomPragma(n: typed; cp: typed{nkSym}): untyped</a></li>
  632. </ul>
  633. <ul class="simple nested-toc-section">unpackVarargs
  634. <li><a class="reference" href="#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D" title="unpackVarargs(callee: untyped; args: varargs[untyped]): untyped">unpackVarargs(callee: untyped; args: varargs[untyped]): untyped</a></li>
  635. </ul>
  636. </ul>
  637. </details>
  638. </li>
  639. <li>
  640. <details open>
  641. <summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
  642. <ul class="simple simple-toc-section">
  643. <ul class="simple nested-toc-section">findChild
  644. <li><a class="reference" href="#findChild.t%2CNimNode%2Cuntyped" title="findChild(n: NimNode; cond: untyped): NimNode">findChild(n: NimNode; cond: untyped): NimNode</a></li>
  645. </ul>
  646. <ul class="simple nested-toc-section">or
  647. <li><a class="reference" href="#or.t%2CNimNode%2CNimNode" title="`or`(x, y: NimNode): NimNode">`or`(x, y: NimNode): NimNode</a></li>
  648. </ul>
  649. </ul>
  650. </details>
  651. </li>
  652. </ul>
  653. </div>
  654. <div class="nine columns" id="content">
  655. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  656. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  657. <div id="tocRoot"></div>
  658. <p class="module-desc"><p>This module contains the interface to the compiler's abstract syntax tree (<span id="ast_1">AST</span>). Macros operate on this tree.</p>
  659. <p>See also:</p>
  660. <ul class="simple"><li><a class="reference external" href="tut3.html">macros tutorial</a></li>
  661. <li><a class="reference external" href="manual.html#macros">macros section in Nim manual</a></li>
  662. </ul>
  663. <h1><a class="toc-backref" id="the-ast-in-nim" href="#the-ast-in-nim">The AST in Nim</a></h1><p>This section describes how the AST is modelled with Nim's type system. The AST consists of nodes (<tt class="docutils literal"><span class="pre">NimNode</span></tt>) with a variable number of children. Each node has a field named <tt class="docutils literal"><span class="pre">kind</span></tt> which describes what the node contains:</p>
  664. <p><pre class="listing"><span class="Keyword">type</span>
  665. <span class="Identifier">NimNodeKind</span> <span class="Operator">=</span> <span class="Keyword">enum</span> <span class="Comment">## kind of a node; only explanatory</span>
  666. <span class="Identifier">nnkNone</span><span class="Punctuation">,</span> <span class="Comment">## invalid node kind</span>
  667. <span class="Identifier">nnkEmpty</span><span class="Punctuation">,</span> <span class="Comment">## empty node</span>
  668. <span class="Identifier">nnkIdent</span><span class="Punctuation">,</span> <span class="Comment">## node contains an identifier</span>
  669. <span class="Identifier">nnkIntLit</span><span class="Punctuation">,</span> <span class="Comment">## node contains an int literal (example: 10)</span>
  670. <span class="Identifier">nnkStrLit</span><span class="Punctuation">,</span> <span class="Comment">## node contains a string literal (example: &quot;abc&quot;)</span>
  671. <span class="Identifier">nnkNilLit</span><span class="Punctuation">,</span> <span class="Comment">## node contains a nil literal (example: nil)</span>
  672. <span class="Identifier">nnkCaseStmt</span><span class="Punctuation">,</span> <span class="Comment">## node represents a case statement</span>
  673. <span class="Operator">...</span> <span class="Comment">## many more</span>
  674. <span class="Identifier">NimNode</span> <span class="Operator">=</span> <span class="Keyword">ref</span> <span class="Identifier">NimNodeObj</span>
  675. <span class="Identifier">NimNodeObj</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  676. <span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Punctuation">:</span> <span class="Identifier">NimNodeKind</span> <span class="Comment">## the node's kind</span>
  677. <span class="Keyword">of</span> <span class="Identifier">nnkNone</span><span class="Punctuation">,</span> <span class="Identifier">nnkEmpty</span><span class="Punctuation">,</span> <span class="Identifier">nnkNilLit</span><span class="Punctuation">:</span>
  678. <span class="Keyword">discard</span> <span class="Comment">## node contains no additional fields</span>
  679. <span class="Keyword">of</span> <span class="Identifier">nnkCharLit</span><span class="Operator">..</span><span class="Identifier">nnkUInt64Lit</span><span class="Punctuation">:</span>
  680. <span class="Identifier">intVal</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span> <span class="Comment">## the int literal</span>
  681. <span class="Keyword">of</span> <span class="Identifier">nnkFloatLit</span><span class="Operator">..</span><span class="Identifier">nnkFloat64Lit</span><span class="Punctuation">:</span>
  682. <span class="Identifier">floatVal</span><span class="Punctuation">:</span> <span class="Identifier">BiggestFloat</span> <span class="Comment">## the float literal</span>
  683. <span class="Keyword">of</span> <span class="Identifier">nnkStrLit</span><span class="Operator">..</span><span class="Identifier">nnkTripleStrLit</span><span class="Punctuation">,</span> <span class="Identifier">nnkCommentStmt</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">,</span> <span class="Identifier">nnkSym</span><span class="Punctuation">:</span>
  684. <span class="Identifier">strVal</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Comment">## the string literal</span>
  685. <span class="Keyword">else</span><span class="Punctuation">:</span>
  686. <span class="Identifier">sons</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">NimNode</span><span class="Punctuation">]</span> <span class="Comment">## the node's sons (or children)</span></pre></p>
  687. <p>For the <tt class="docutils literal"><span class="pre">NimNode</span></tt> type, the <tt class="docutils literal"><span class="pre">[]</span></tt> operator has been overloaded: <tt class="docutils literal"><span class="pre">n[i]</span></tt> is <tt class="docutils literal"><span class="pre">n</span></tt>'s <tt class="docutils literal"><span class="pre">i</span></tt>-th child.</p>
  688. <p>To specify the AST for the different Nim constructs, the notation <tt class="docutils literal"><span class="pre">nodekind(son1, son2, ...)</span></tt> or <tt class="docutils literal"><span class="pre">nodekind(value)</span></tt> or <tt class="docutils literal"><span class="pre">nodekind(field=value)</span></tt> is used.</p>
  689. <p>Some child may be missing. A missing child is a node of kind <tt class="docutils literal"><span class="pre">nnkEmpty</span></tt>; a child can never be nil.</p>
  690. <h1><a class="toc-backref" id="leaf-nodesslashatoms" href="#leaf-nodesslashatoms">Leaf nodes/Atoms</a></h1><p>A leaf of the AST often corresponds to a terminal symbol in the concrete syntax. Note that the default <tt class="docutils literal"><span class="pre">float</span></tt> in Nim maps to <tt class="docutils literal"><span class="pre">float64</span></tt> such that the default AST for a float is <tt class="docutils literal"><span class="pre">nnkFloat64Lit</span></tt> as below.</p>
  691. <table border="1" class="docutils"><tr><th>Nim expression</th><th>Corresponding AST</th></tr>
  692. <tr><td><tt class="docutils literal"><span class="pre">42</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkIntLit(intVal = 42)</span></tt></td></tr>
  693. <tr><td><tt class="docutils literal"><span class="pre">42'i8</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkInt8Lit(intVal = 42)</span></tt></td></tr>
  694. <tr><td><tt class="docutils literal"><span class="pre">42'i16</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkInt16Lit(intVal = 42)</span></tt></td></tr>
  695. <tr><td><tt class="docutils literal"><span class="pre">42'i32</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkInt32Lit(intVal = 42)</span></tt></td></tr>
  696. <tr><td><tt class="docutils literal"><span class="pre">42'i64</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkInt64Lit(intVal = 42)</span></tt></td></tr>
  697. <tr><td><tt class="docutils literal"><span class="pre">42'u8</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkUInt8Lit(intVal = 42)</span></tt></td></tr>
  698. <tr><td><tt class="docutils literal"><span class="pre">42'u16</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkUInt16Lit(intVal = 42)</span></tt></td></tr>
  699. <tr><td><tt class="docutils literal"><span class="pre">42'u32</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkUInt32Lit(intVal = 42)</span></tt></td></tr>
  700. <tr><td><tt class="docutils literal"><span class="pre">42'u64</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkUInt64Lit(intVal = 42)</span></tt></td></tr>
  701. <tr><td><tt class="docutils literal"><span class="pre">42.0</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkFloat64Lit(floatVal = 42.0)</span></tt></td></tr>
  702. <tr><td><tt class="docutils literal"><span class="pre">42.0'f32</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkFloat32Lit(floatVal = 42.0)</span></tt></td></tr>
  703. <tr><td><tt class="docutils literal"><span class="pre">42.0'f64</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkFloat64Lit(floatVal = 42.0)</span></tt></td></tr>
  704. <tr><td><tt class="docutils literal"><span class="pre">&quot;abc&quot;</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkStrLit(strVal = &quot;abc&quot;)</span></tt></td></tr>
  705. <tr><td><tt class="docutils literal"><span class="pre">r&quot;abc&quot;</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkRStrLit(strVal = &quot;abc&quot;)</span></tt></td></tr>
  706. <tr><td><tt class="docutils literal"><span class="pre">&quot;&quot;&quot;abc&quot;&quot;&quot;</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkTripleStrLit(strVal = &quot;abc&quot;)</span></tt></td></tr>
  707. <tr><td><tt class="docutils literal"><span class="pre">' '</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkCharLit(intVal = 32)</span></tt></td></tr>
  708. <tr><td><tt class="docutils literal"><span class="pre">nil</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkNilLit()</span></tt></td></tr>
  709. <tr><td><tt class="docutils literal"><span class="pre">myIdentifier</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkIdent(strVal = &quot;myIdentifier&quot;)</span></tt></td></tr>
  710. <tr><td><tt class="docutils literal"><span class="pre">myIdentifier</span></tt></td><td>after lookup pass: <tt class="docutils literal"><span class="pre">nnkSym(strVal = &quot;myIdentifier&quot;, ...)</span></tt></td></tr>
  711. </table><p>Identifiers are <tt class="docutils literal"><span class="pre">nnkIdent</span></tt> nodes. After the name lookup pass these nodes get transferred into <tt class="docutils literal"><span class="pre">nnkSym</span></tt> nodes.</p>
  712. <h1><a class="toc-backref" id="callsslashexpressions" href="#callsslashexpressions">Calls/expressions</a></h1>
  713. <h2><a class="toc-backref" id="callsslashexpressions-command-call" href="#callsslashexpressions-command-call">Command call</a></h2><p>Concrete syntax:</p>
  714. <p><pre class="listing"><span class="Identifier">echo</span> <span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;xyz&quot;</span></pre></p>
  715. <p>AST:</p>
  716. <p><pre class="listing"><span class="Identifier">nnkCommand</span><span class="Punctuation">(</span>
  717. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  718. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  719. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;xyz&quot;</span><span class="Punctuation">)</span>
  720. <span class="Punctuation">)</span></pre></p>
  721. <h2><a class="toc-backref" id="callsslashexpressions-call-with" href="#callsslashexpressions-call-with">Call with <tt class="docutils literal"><span class="pre">()</span></tt></a></h2><p>Concrete syntax:</p>
  722. <p><pre class="listing"><span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;xyz&quot;</span><span class="Punctuation">)</span></pre></p>
  723. <p>AST:</p>
  724. <p><pre class="listing"><span class="Identifier">nnkCall</span><span class="Punctuation">(</span>
  725. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  726. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  727. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;xyz&quot;</span><span class="Punctuation">)</span>
  728. <span class="Punctuation">)</span></pre></p>
  729. <h2><a class="toc-backref" id="callsslashexpressions-infix-operator-call" href="#callsslashexpressions-infix-operator-call">Infix operator call</a></h2><p>Concrete syntax:</p>
  730. <p><pre class="listing"><span class="StringLit">&quot;abc&quot;</span> <span class="Operator">&amp;</span> <span class="StringLit">&quot;xyz&quot;</span></pre></p>
  731. <p>AST:</p>
  732. <p><pre class="listing"><span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  733. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;&amp;&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  734. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  735. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;xyz&quot;</span><span class="Punctuation">)</span>
  736. <span class="Punctuation">)</span></pre></p>
  737. <p>Note that with multiple infix operators, the command is parsed by operator precedence.</p>
  738. <p>Concrete syntax:</p>
  739. <p><pre class="listing"><span class="DecNumber">5</span> <span class="Operator">+</span> <span class="DecNumber">3</span> <span class="Operator">*</span> <span class="DecNumber">4</span></pre></p>
  740. <p>AST:</p>
  741. <p><pre class="listing"><span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  742. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;+&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  743. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">5</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  744. <span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  745. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;*&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  746. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  747. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
  748. <span class="Punctuation">)</span>
  749. <span class="Punctuation">)</span></pre></p>
  750. <p>As a side note, if you choose to use infix operators in a prefix form, the AST behaves as a <a class="reference external" href="#callsslashexpressions-call-with">parenthetical function call</a> with <tt class="docutils literal"><span class="pre">nnkAccQuoted</span></tt>, as follows:</p>
  751. <p>Concrete syntax:</p>
  752. <p><pre class="listing"><span class="Punctuation">`</span><span class="Operator">+</span><span class="Punctuation">`</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span></pre></p>
  753. <p>AST:</p>
  754. <p><pre class="listing"><span class="Identifier">nnkCall</span><span class="Punctuation">(</span>
  755. <span class="Identifier">nnkAccQuoted</span><span class="Punctuation">(</span>
  756. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;+&quot;</span><span class="Punctuation">)</span>
  757. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  758. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  759. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
  760. <span class="Punctuation">)</span></pre></p>
  761. <h2><a class="toc-backref" id="callsslashexpressions-prefix-operator-call" href="#callsslashexpressions-prefix-operator-call">Prefix operator call</a></h2><p>Concrete syntax:</p>
  762. <p><pre class="listing"><span class="Operator">?</span> <span class="StringLit">&quot;xyz&quot;</span></pre></p>
  763. <p>AST:</p>
  764. <p><pre class="listing"><span class="Identifier">nnkPrefix</span><span class="Punctuation">(</span>
  765. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;?&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  766. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;abc&quot;</span><span class="Punctuation">)</span>
  767. <span class="Punctuation">)</span></pre></p>
  768. <h2><a class="toc-backref" id="callsslashexpressions-postfix-operator-call" href="#callsslashexpressions-postfix-operator-call">Postfix operator call</a></h2><p><strong>Note:</strong> There are no postfix operators in Nim. However, the <tt class="docutils literal"><span class="pre">nnkPostfix</span></tt> node is used for the <em>asterisk export marker</em> <tt class="docutils literal"><span class="pre">*</span></tt>:</p>
  769. <p>Concrete syntax:</p>
  770. <p><pre class="listing"><span class="Identifier">identifier</span><span class="Operator">*</span></pre></p>
  771. <p>AST:</p>
  772. <p><pre class="listing"><span class="Identifier">nnkPostfix</span><span class="Punctuation">(</span>
  773. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;*&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  774. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;identifier&quot;</span><span class="Punctuation">)</span>
  775. <span class="Punctuation">)</span></pre></p>
  776. <h2><a class="toc-backref" id="callsslashexpressions-call-with-named-arguments" href="#callsslashexpressions-call-with-named-arguments">Call with named arguments</a></h2><p>Concrete syntax:</p>
  777. <p><pre class="listing"><span class="Identifier">writeLine</span><span class="Punctuation">(</span><span class="Identifier">file</span><span class="Operator">=</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">&quot;hallo&quot;</span><span class="Punctuation">)</span></pre></p>
  778. <p>AST:</p>
  779. <p><pre class="listing"><span class="Identifier">nnkCall</span><span class="Punctuation">(</span>
  780. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;writeLine&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  781. <span class="Identifier">nnkExprEqExpr</span><span class="Punctuation">(</span>
  782. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;file&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  783. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;stdout&quot;</span><span class="Punctuation">)</span>
  784. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  785. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;hallo&quot;</span><span class="Punctuation">)</span>
  786. <span class="Punctuation">)</span></pre></p>
  787. <h2><a class="toc-backref" id="callsslashexpressions-call-with-raw-string-literal" href="#callsslashexpressions-call-with-raw-string-literal">Call with raw string literal</a></h2><p>This is used, for example, in the <tt class="docutils literal"><span class="pre">bindSym</span></tt> examples <a class="reference external" href="manual.html#macros-bindsym">here</a> and with <tt class="docutils literal"><span class="pre">re&quot;some regexp&quot;</span></tt> in the regular expression module.</p>
  788. <p>Concrete syntax:</p>
  789. <p><pre class="listing"><span class="RawData">echo&quot;abc&quot;</span></pre></p>
  790. <p>AST:</p>
  791. <p><pre class="listing"><span class="Identifier">nnkCallStrLit</span><span class="Punctuation">(</span>
  792. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  793. <span class="Identifier">nnkRStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;hello&quot;</span><span class="Punctuation">)</span>
  794. <span class="Punctuation">)</span></pre></p>
  795. <h2><a class="toc-backref" id="callsslashexpressions-dereference-operator" href="#callsslashexpressions-dereference-operator">Dereference operator <tt class="docutils literal"><span class="pre">[]</span></tt></a></h2><p>Concrete syntax:</p>
  796. <p><pre class="listing"><span class="Identifier">x</span><span class="Punctuation">[</span><span class="Punctuation">]</span></pre></p>
  797. <p>AST:</p>
  798. <p><pre class="listing"><span class="Identifier">nnkDerefExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  799. <h2><a class="toc-backref" id="callsslashexpressions-addr-operator" href="#callsslashexpressions-addr-operator">Addr operator</a></h2><p>Concrete syntax:</p>
  800. <p><pre class="listing"><span class="Keyword">addr</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">)</span></pre></p>
  801. <p>AST:</p>
  802. <p><pre class="listing"><span class="Identifier">nnkAddr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  803. <h2><a class="toc-backref" id="callsslashexpressions-cast-operator" href="#callsslashexpressions-cast-operator">Cast operator</a></h2><p>Concrete syntax:</p>
  804. <p><pre class="listing"><span class="Keyword">cast</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">)</span></pre></p>
  805. <p>AST:</p>
  806. <p><pre class="listing"><span class="Identifier">nnkCast</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  807. <h2><a class="toc-backref" id="callsslashexpressions-object-access-operator-dot" href="#callsslashexpressions-object-access-operator-dot">Object access operator <tt class="docutils literal"><span class="pre">.</span></tt></a></h2><p>Concrete syntax:</p>
  808. <p><pre class="listing"><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">y</span></pre></p>
  809. <p>AST:</p>
  810. <p><pre class="listing"><span class="Identifier">nnkDotExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;y&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  811. <p>If you use Nim's flexible calling syntax (as in <tt class="docutils literal"><span class="pre">x.len()</span></tt>), the result is the same as above but wrapped in an <tt class="docutils literal"><span class="pre">nnkCall</span></tt>.</p>
  812. <h2><a class="toc-backref" id="callsslashexpressions-array-access-operator" href="#callsslashexpressions-array-access-operator">Array access operator <tt class="docutils literal"><span class="pre">[]</span></tt></a></h2><p>Concrete syntax:</p>
  813. <p><pre class="listing"><span class="Identifier">x</span><span class="Punctuation">[</span><span class="Identifier">y</span><span class="Punctuation">]</span></pre></p>
  814. <p>AST:</p>
  815. <p><pre class="listing"><span class="Identifier">nnkBracketExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;y&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  816. <h2><a class="toc-backref" id="callsslashexpressions-parentheses" href="#callsslashexpressions-parentheses">Parentheses</a></h2><p>Parentheses for affecting operator precedence use the <tt class="docutils literal"><span class="pre">nnkPar</span></tt> node.</p>
  817. <p>Concrete syntax:</p>
  818. <p><pre class="listing"><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">+</span> <span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">*</span> <span class="Identifier">c</span></pre></p>
  819. <p>AST:</p>
  820. <p><pre class="listing"><span class="Identifier">nnkInfix</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;*&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  821. <span class="Identifier">nnkPar</span><span class="Punctuation">(</span>
  822. <span class="Identifier">nnkInfix</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;+&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  823. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;c&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  824. <h2><a class="toc-backref" id="callsslashexpressions-tuple-constructors" href="#callsslashexpressions-tuple-constructors">Tuple Constructors</a></h2><p>Nodes for tuple construction are built with the <tt class="docutils literal"><span class="pre">nnkTupleConstr</span></tt> node.</p>
  825. <p>Concrete syntax:</p>
  826. <p><pre class="listing"><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
  827. <span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
  828. <span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
  829. <p>AST:</p>
  830. <p><pre class="listing"><span class="Identifier">nnkTupleConstr</span><span class="Punctuation">(</span><span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  831. <span class="Identifier">nnkTupleConstr</span><span class="Punctuation">(</span>
  832. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  833. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  834. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;c&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  835. <span class="Identifier">nnkTupleConstr</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
  836. <p>Since the one tuple would be syntactically identical to parentheses with an expression in them, the parser expects a trailing comma for them. For tuple constructors with field names, this is not necessary.</p>
  837. <p><pre class="listing"><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span><span class="Punctuation">)</span>
  838. <span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">)</span></pre></p>
  839. <p>AST:</p>
  840. <p><pre class="listing"><span class="Identifier">nnkTupleConstr</span><span class="Punctuation">(</span><span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  841. <span class="Identifier">nnkTupleConstr</span><span class="Punctuation">(</span>
  842. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  843. <h2><a class="toc-backref" id="callsslashexpressions-curly-braces" href="#callsslashexpressions-curly-braces">Curly braces</a></h2><p>Curly braces are used as the set constructor.</p>
  844. <p>Concrete syntax:</p>
  845. <p><pre class="listing"><span class="Punctuation">{</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">}</span></pre></p>
  846. <p>AST:</p>
  847. <p><pre class="listing"><span class="Identifier">nnkCurly</span><span class="Punctuation">(</span><span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  848. <p>When used as a table constructor, the syntax is different.</p>
  849. <p>Concrete syntax:</p>
  850. <p><pre class="listing"><span class="Punctuation">{</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="DecNumber">5</span><span class="Punctuation">}</span></pre></p>
  851. <p>AST:</p>
  852. <p><pre class="listing"><span class="Identifier">nnkTableConstr</span><span class="Punctuation">(</span>
  853. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  854. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">5</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  855. <span class="Punctuation">)</span></pre></p>
  856. <h2><a class="toc-backref" id="callsslashexpressions-brackets" href="#callsslashexpressions-brackets">Brackets</a></h2><p>Brackets are used as the array constructor.</p>
  857. <p>Concrete syntax:</p>
  858. <p><pre class="listing"><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span></pre></p>
  859. <p>AST:</p>
  860. <p><pre class="listing"><span class="Identifier">nnkBracket</span><span class="Punctuation">(</span><span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  861. <h2><a class="toc-backref" id="callsslashexpressions-ranges" href="#callsslashexpressions-ranges">Ranges</a></h2><p>Ranges occur in set constructors, case statement branches, or array slices. Internally, the node kind <tt class="docutils literal"><span class="pre">nnkRange</span></tt> is used, but when constructing the AST, construction with <tt class="docutils literal"><span class="pre">..</span></tt> as an infix operator should be used instead.</p>
  862. <p>Concrete syntax:</p>
  863. <p><pre class="listing"><span class="FloatNumber">1.</span><span class="Operator">.</span><span class="DecNumber">3</span></pre></p>
  864. <p>AST:</p>
  865. <p><pre class="listing"><span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  866. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;..&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  867. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  868. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span>
  869. <span class="Punctuation">)</span></pre></p>
  870. <p>Example code:</p>
  871. <p><pre class="listing"><span class="Keyword">macro</span> <span class="Identifier">genRepeatEcho</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  872. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">newNimNode</span><span class="Punctuation">(</span><span class="Identifier">nnkStmtList</span><span class="Punctuation">)</span>
  873. <span class="Keyword">var</span> <span class="Identifier">forStmt</span> <span class="Operator">=</span> <span class="Identifier">newNimNode</span><span class="Punctuation">(</span><span class="Identifier">nnkForStmt</span><span class="Punctuation">)</span> <span class="Comment"># generate a for statement</span>
  874. <span class="Identifier">forStmt</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;i&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># use the variable `i` for iteration</span>
  875. <span class="Keyword">var</span> <span class="Identifier">rangeDef</span> <span class="Operator">=</span> <span class="Identifier">newNimNode</span><span class="Punctuation">(</span><span class="Identifier">nnkInfix</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span>
  876. <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;..&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span>
  877. <span class="Identifier">newIntLitNode</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span><span class="Identifier">newIntLitNode</span><span class="Punctuation">(</span><span class="DecNumber">5</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># iterate over the range 3..5</span>
  878. <span class="Identifier">forStmt</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">rangeDef</span><span class="Punctuation">)</span>
  879. <span class="Identifier">forStmt</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">newCall</span><span class="Punctuation">(</span><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newIntLitNode</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># meat of the loop</span>
  880. <span class="Identifier">result</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">forStmt</span><span class="Punctuation">)</span>
  881. <span class="Identifier">genRepeatEcho</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># gives:</span>
  882. <span class="Comment"># 3</span>
  883. <span class="Comment"># 3</span>
  884. <span class="Comment"># 3</span></pre></p>
  885. <h2><a class="toc-backref" id="callsslashexpressions-if-expression" href="#callsslashexpressions-if-expression">If expression</a></h2><p>The representation of the <tt class="docutils literal"><span class="pre">if</span></tt> expression is subtle, but easy to traverse.</p>
  886. <p>Concrete syntax:</p>
  887. <p><pre class="listing"><span class="Keyword">if</span> <span class="Identifier">cond1</span><span class="Punctuation">:</span> <span class="Identifier">expr1</span> <span class="Keyword">elif</span> <span class="Identifier">cond2</span><span class="Punctuation">:</span> <span class="Identifier">expr2</span> <span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Identifier">expr3</span></pre></p>
  888. <p>AST:</p>
  889. <p><pre class="listing"><span class="Identifier">nnkIfExpr</span><span class="Punctuation">(</span>
  890. <span class="Identifier">nnkElifExpr</span><span class="Punctuation">(</span><span class="Identifier">cond1</span><span class="Punctuation">,</span> <span class="Identifier">expr1</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  891. <span class="Identifier">nnkElifExpr</span><span class="Punctuation">(</span><span class="Identifier">cond2</span><span class="Punctuation">,</span> <span class="Identifier">expr2</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  892. <span class="Identifier">nnkElseExpr</span><span class="Punctuation">(</span><span class="Identifier">expr3</span><span class="Punctuation">)</span>
  893. <span class="Punctuation">)</span></pre></p>
  894. <h2><a class="toc-backref" id="callsslashexpressions-documentation-comments" href="#callsslashexpressions-documentation-comments">Documentation Comments</a></h2><p>Double-hash (<tt class="docutils literal"><span class="pre">##</span></tt>) comments in the code actually have their own format, using <tt class="docutils literal"><span class="pre">strVal</span></tt> to get and set the comment text. Single-hash (<tt class="docutils literal"><span class="pre">#</span></tt>) comments are ignored.</p>
  895. <p>Concrete syntax:</p>
  896. <p><pre class="listing"><span class="Comment">## This is a comment</span>
  897. <span class="Comment">## This is part of the first comment</span>
  898. <span class="Identifier">stmt1</span>
  899. <span class="Comment">## Yet another</span></pre></p>
  900. <p>AST:</p>
  901. <p><pre class="listing"><span class="Identifier">nnkCommentStmt</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># only appears once for the first two lines!</span>
  902. <span class="Identifier">stmt1</span>
  903. <span class="Identifier">nnkCommentStmt</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># another nnkCommentStmt because there is another comment</span>
  904. <span class="Comment"># (separate from the first)</span></pre></p>
  905. <h2><a class="toc-backref" id="callsslashexpressions-pragmas" href="#callsslashexpressions-pragmas">Pragmas</a></h2><p>One of Nim's cool features is pragmas, which allow fine-tuning of various aspects of the language. They come in all types, such as adorning procs and objects, but the standalone <tt class="docutils literal"><span class="pre">emit</span></tt> pragma shows the basics with the AST.</p>
  906. <p>Concrete syntax:</p>
  907. <p><pre class="listing"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">emit</span><span class="Punctuation">:</span> <span class="StringLit">&quot;#include &lt;stdio.h&gt;&quot;</span><span class="Operator">.</span><span class="Punctuation">}</span></pre></p>
  908. <p>AST:</p>
  909. <p><pre class="listing"><span class="Identifier">nnkPragma</span><span class="Punctuation">(</span>
  910. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span>
  911. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;emit&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  912. <span class="Identifier">nnkStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;#include &lt;stdio.h&gt;&quot;</span><span class="Punctuation">)</span> <span class="Comment"># the &quot;argument&quot;</span>
  913. <span class="Punctuation">)</span>
  914. <span class="Punctuation">)</span></pre></p>
  915. <p>As many <tt class="docutils literal"><span class="pre">nnkIdent</span></tt> appear as there are pragmas between <tt class="docutils literal"><span class="pre">{..}</span></tt>. Note that the declaration of new pragmas is essentially the same:</p>
  916. <p>Concrete syntax:</p>
  917. <p><pre class="listing"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">pragma</span><span class="Punctuation">:</span> <span class="Identifier">cdeclRename</span><span class="Punctuation">,</span> <span class="Identifier">cdecl</span><span class="Operator">.</span><span class="Punctuation">}</span></pre></p>
  918. <p>AST:</p>
  919. <p><pre class="listing"><span class="Identifier">nnkPragma</span><span class="Punctuation">(</span>
  920. <span class="Identifier">nnkExprColonExpr</span><span class="Punctuation">(</span>
  921. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;pragma&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># this is always first when declaring a new pragma</span>
  922. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;cdeclRename&quot;</span><span class="Punctuation">)</span> <span class="Comment"># the name of the pragma</span>
  923. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  924. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;cdecl&quot;</span><span class="Punctuation">)</span>
  925. <span class="Punctuation">)</span></pre></p>
  926. <h1><a class="toc-backref" id="statements" href="#statements">Statements</a></h1>
  927. <h2><a class="toc-backref" id="statements-if-statement" href="#statements-if-statement">If statement</a></h2><p>The representation of the if statement is subtle, but easy to traverse. If there is no <tt class="docutils literal"><span class="pre">else</span></tt> branch, no <tt class="docutils literal"><span class="pre">nnkElse</span></tt> child exists.</p>
  928. <p>Concrete syntax:</p>
  929. <p><pre class="listing"><span class="Keyword">if</span> <span class="Identifier">cond1</span><span class="Punctuation">:</span>
  930. <span class="Identifier">stmt1</span>
  931. <span class="Keyword">elif</span> <span class="Identifier">cond2</span><span class="Punctuation">:</span>
  932. <span class="Identifier">stmt2</span>
  933. <span class="Keyword">elif</span> <span class="Identifier">cond3</span><span class="Punctuation">:</span>
  934. <span class="Identifier">stmt3</span>
  935. <span class="Keyword">else</span><span class="Punctuation">:</span>
  936. <span class="Identifier">stmt4</span></pre></p>
  937. <p>AST:</p>
  938. <p><pre class="listing"><span class="Identifier">nnkIfStmt</span><span class="Punctuation">(</span>
  939. <span class="Identifier">nnkElifBranch</span><span class="Punctuation">(</span><span class="Identifier">cond1</span><span class="Punctuation">,</span> <span class="Identifier">stmt1</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  940. <span class="Identifier">nnkElifBranch</span><span class="Punctuation">(</span><span class="Identifier">cond2</span><span class="Punctuation">,</span> <span class="Identifier">stmt2</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  941. <span class="Identifier">nnkElifBranch</span><span class="Punctuation">(</span><span class="Identifier">cond3</span><span class="Punctuation">,</span> <span class="Identifier">stmt3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  942. <span class="Identifier">nnkElse</span><span class="Punctuation">(</span><span class="Identifier">stmt4</span><span class="Punctuation">)</span>
  943. <span class="Punctuation">)</span></pre></p>
  944. <h2><a class="toc-backref" id="statements-when-statement" href="#statements-when-statement">When statement</a></h2><p>Like the <tt class="docutils literal"><span class="pre">if</span></tt> statement, but the root has the kind <tt class="docutils literal"><span class="pre">nnkWhenStmt</span></tt>.</p>
  945. <h2><a class="toc-backref" id="statements-assignment" href="#statements-assignment">Assignment</a></h2><p>Concrete syntax:</p>
  946. <p><pre class="listing"><span class="Identifier">x</span> <span class="Operator">=</span> <span class="DecNumber">42</span></pre></p>
  947. <p>AST:</p>
  948. <p><pre class="listing"><span class="Identifier">nnkAsgn</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">42</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  949. <p>This is not the syntax for assignment when combined with <tt class="docutils literal"><span class="pre">var</span></tt>, <tt class="docutils literal"><span class="pre">let</span></tt>, or <tt class="docutils literal"><span class="pre">const</span></tt>.</p>
  950. <h2><a class="toc-backref" id="statements-statement-list" href="#statements-statement-list">Statement list</a></h2><p>Concrete syntax:</p>
  951. <p><pre class="listing"><span class="Identifier">stmt1</span>
  952. <span class="Identifier">stmt2</span>
  953. <span class="Identifier">stmt3</span></pre></p>
  954. <p>AST:</p>
  955. <p><pre class="listing"><span class="Identifier">nnkStmtList</span><span class="Punctuation">(</span><span class="Identifier">stmt1</span><span class="Punctuation">,</span> <span class="Identifier">stmt2</span><span class="Punctuation">,</span> <span class="Identifier">stmt3</span><span class="Punctuation">)</span></pre></p>
  956. <h2><a class="toc-backref" id="statements-case-statement" href="#statements-case-statement">Case statement</a></h2><p>Concrete syntax:</p>
  957. <p><pre class="listing"><span class="Keyword">case</span> <span class="Identifier">expr1</span>
  958. <span class="Keyword">of</span> <span class="Identifier">expr2</span><span class="Punctuation">,</span> <span class="Identifier">expr3</span><span class="Operator">..</span><span class="Identifier">expr4</span><span class="Punctuation">:</span>
  959. <span class="Identifier">stmt1</span>
  960. <span class="Keyword">of</span> <span class="Identifier">expr5</span><span class="Punctuation">:</span>
  961. <span class="Identifier">stmt2</span>
  962. <span class="Keyword">elif</span> <span class="Identifier">cond1</span><span class="Punctuation">:</span>
  963. <span class="Identifier">stmt3</span>
  964. <span class="Keyword">else</span><span class="Punctuation">:</span>
  965. <span class="Identifier">stmt4</span></pre></p>
  966. <p>AST:</p>
  967. <p><pre class="listing"><span class="Identifier">nnkCaseStmt</span><span class="Punctuation">(</span>
  968. <span class="Identifier">expr1</span><span class="Punctuation">,</span>
  969. <span class="Identifier">nnkOfBranch</span><span class="Punctuation">(</span><span class="Identifier">expr2</span><span class="Punctuation">,</span> <span class="Identifier">nnkRange</span><span class="Punctuation">(</span><span class="Identifier">expr3</span><span class="Punctuation">,</span> <span class="Identifier">expr4</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">stmt1</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  970. <span class="Identifier">nnkOfBranch</span><span class="Punctuation">(</span><span class="Identifier">expr5</span><span class="Punctuation">,</span> <span class="Identifier">stmt2</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  971. <span class="Identifier">nnkElifBranch</span><span class="Punctuation">(</span><span class="Identifier">cond1</span><span class="Punctuation">,</span> <span class="Identifier">stmt3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  972. <span class="Identifier">nnkElse</span><span class="Punctuation">(</span><span class="Identifier">stmt4</span><span class="Punctuation">)</span>
  973. <span class="Punctuation">)</span></pre></p>
  974. <p>The <tt class="docutils literal"><span class="pre">nnkElifBranch</span></tt> and <tt class="docutils literal"><span class="pre">nnkElse</span></tt> parts may be missing.</p>
  975. <h2><a class="toc-backref" id="statements-while-statement" href="#statements-while-statement">While statement</a></h2><p>Concrete syntax:</p>
  976. <p><pre class="listing"><span class="Keyword">while</span> <span class="Identifier">expr1</span><span class="Punctuation">:</span>
  977. <span class="Identifier">stmt1</span></pre></p>
  978. <p>AST:</p>
  979. <p><pre class="listing"><span class="Identifier">nnkWhileStmt</span><span class="Punctuation">(</span><span class="Identifier">expr1</span><span class="Punctuation">,</span> <span class="Identifier">stmt1</span><span class="Punctuation">)</span></pre></p>
  980. <h2><a class="toc-backref" id="statements-for-statement" href="#statements-for-statement">For statement</a></h2><p>Concrete syntax:</p>
  981. <p><pre class="listing"><span class="Keyword">for</span> <span class="Identifier">ident1</span><span class="Punctuation">,</span> <span class="Identifier">ident2</span> <span class="Keyword">in</span> <span class="Identifier">expr1</span><span class="Punctuation">:</span>
  982. <span class="Identifier">stmt1</span></pre></p>
  983. <p>AST:</p>
  984. <p><pre class="listing"><span class="Identifier">nnkForStmt</span><span class="Punctuation">(</span><span class="Identifier">ident1</span><span class="Punctuation">,</span> <span class="Identifier">ident2</span><span class="Punctuation">,</span> <span class="Identifier">expr1</span><span class="Punctuation">,</span> <span class="Identifier">stmt1</span><span class="Punctuation">)</span></pre></p>
  985. <h2><a class="toc-backref" id="statements-try-statement" href="#statements-try-statement">Try statement</a></h2><p>Concrete syntax:</p>
  986. <p><pre class="listing"><span class="Keyword">try</span><span class="Punctuation">:</span>
  987. <span class="Identifier">stmt1</span>
  988. <span class="Keyword">except</span> <span class="Identifier">e1</span><span class="Punctuation">,</span> <span class="Identifier">e2</span><span class="Punctuation">:</span>
  989. <span class="Identifier">stmt2</span>
  990. <span class="Keyword">except</span> <span class="Identifier">e3</span><span class="Punctuation">:</span>
  991. <span class="Identifier">stmt3</span>
  992. <span class="Keyword">except</span><span class="Punctuation">:</span>
  993. <span class="Identifier">stmt4</span>
  994. <span class="Keyword">finally</span><span class="Punctuation">:</span>
  995. <span class="Identifier">stmt5</span></pre></p>
  996. <p>AST:</p>
  997. <p><pre class="listing"><span class="Identifier">nnkTryStmt</span><span class="Punctuation">(</span>
  998. <span class="Identifier">stmt1</span><span class="Punctuation">,</span>
  999. <span class="Identifier">nnkExceptBranch</span><span class="Punctuation">(</span><span class="Identifier">e1</span><span class="Punctuation">,</span> <span class="Identifier">e2</span><span class="Punctuation">,</span> <span class="Identifier">stmt2</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1000. <span class="Identifier">nnkExceptBranch</span><span class="Punctuation">(</span><span class="Identifier">e3</span><span class="Punctuation">,</span> <span class="Identifier">stmt3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1001. <span class="Identifier">nnkExceptBranch</span><span class="Punctuation">(</span><span class="Identifier">stmt4</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1002. <span class="Identifier">nnkFinally</span><span class="Punctuation">(</span><span class="Identifier">stmt5</span><span class="Punctuation">)</span>
  1003. <span class="Punctuation">)</span></pre></p>
  1004. <h2><a class="toc-backref" id="statements-return-statement" href="#statements-return-statement">Return statement</a></h2><p>Concrete syntax:</p>
  1005. <p><pre class="listing"><span class="Keyword">return</span> <span class="Identifier">expr1</span></pre></p>
  1006. <p>AST:</p>
  1007. <p><pre class="listing"><span class="Identifier">nnkReturnStmt</span><span class="Punctuation">(</span><span class="Identifier">expr1</span><span class="Punctuation">)</span></pre></p>
  1008. <h2><a class="toc-backref" id="statements-yield-statement" href="#statements-yield-statement">Yield statement</a></h2><p>Like <tt class="docutils literal"><span class="pre">return</span></tt>, but with <tt class="docutils literal"><span class="pre">nnkYieldStmt</span></tt> kind.</p>
  1009. <p><pre class="listing"><span class="Identifier">nnkYieldStmt</span><span class="Punctuation">(</span><span class="Identifier">expr1</span><span class="Punctuation">)</span></pre></p>
  1010. <h2><a class="toc-backref" id="statements-discard-statement" href="#statements-discard-statement">Discard statement</a></h2><p>Like <tt class="docutils literal"><span class="pre">return</span></tt>, but with <tt class="docutils literal"><span class="pre">nnkDiscardStmt</span></tt> kind.</p>
  1011. <p><pre class="listing"><span class="Identifier">nnkDiscardStmt</span><span class="Punctuation">(</span><span class="Identifier">expr1</span><span class="Punctuation">)</span></pre></p>
  1012. <h2><a class="toc-backref" id="statements-continue-statement" href="#statements-continue-statement">Continue statement</a></h2><p>Concrete syntax:</p>
  1013. <p><pre class="listing"><span class="Keyword">continue</span></pre></p>
  1014. <p>AST:</p>
  1015. <p><pre class="listing"><span class="Identifier">nnkContinueStmt</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
  1016. <h2><a class="toc-backref" id="statements-break-statement" href="#statements-break-statement">Break statement</a></h2><p>Concrete syntax:</p>
  1017. <p><pre class="listing"><span class="Keyword">break</span> <span class="Identifier">otherLocation</span></pre></p>
  1018. <p>AST:</p>
  1019. <p><pre class="listing"><span class="Identifier">nnkBreakStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;otherLocation&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1020. <p>If <tt class="docutils literal"><span class="pre">break</span></tt> is used without a jump-to location, <tt class="docutils literal"><span class="pre">nnkEmpty</span></tt> replaces <tt class="docutils literal"><span class="pre">nnkIdent</span></tt>.</p>
  1021. <h2><a class="toc-backref" id="statements-block-statement" href="#statements-block-statement">Block statement</a></h2><p>Concrete syntax:</p>
  1022. <p><pre class="listing"><span class="Keyword">block</span> <span class="Identifier">name</span><span class="Punctuation">:</span></pre></p>
  1023. <p>AST:</p>
  1024. <p><pre class="listing"><span class="Identifier">nnkBlockStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;name&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkStmtList</span><span class="Punctuation">(</span><span class="Operator">...</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1025. <p>A <tt class="docutils literal"><span class="pre">block</span></tt> doesn't need an name, in which case <tt class="docutils literal"><span class="pre">nnkEmpty</span></tt> is used.</p>
  1026. <h2><a class="toc-backref" id="statements-asm-statement" href="#statements-asm-statement">Asm statement</a></h2><p>Concrete syntax:</p>
  1027. <p><pre class="listing"><span class="Keyword">asm</span> <span class="LongStringLit">&quot;&quot;&quot;
  1028. some asm
  1029. &quot;&quot;&quot;</span></pre></p>
  1030. <p>AST:</p>
  1031. <p><pre class="listing"><span class="Identifier">nnkAsmStmt</span><span class="Punctuation">(</span>
  1032. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># for pragmas</span>
  1033. <span class="Identifier">nnkTripleStrLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;some asm&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1034. <span class="Punctuation">)</span></pre></p>
  1035. <h2><a class="toc-backref" id="statements-import-section" href="#statements-import-section">Import section</a></h2><p>Nim's <tt class="docutils literal"><span class="pre">import</span></tt> statement actually takes different variations depending on what keywords are present. Let's start with the simplest form.</p>
  1036. <p>Concrete syntax:</p>
  1037. <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">math</span></pre></p>
  1038. <p>AST:</p>
  1039. <p><pre class="listing"><span class="Identifier">nnkImportStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;math&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1040. <p>With <tt class="docutils literal"><span class="pre">except</span></tt>, we get <tt class="docutils literal"><span class="pre">nnkImportExceptStmt</span></tt>.</p>
  1041. <p>Concrete syntax:</p>
  1042. <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">math</span> <span class="Keyword">except</span> <span class="Identifier">pow</span></pre></p>
  1043. <p>AST:</p>
  1044. <p><pre class="listing"><span class="Identifier">nnkImportExceptStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;math&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;pow&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1045. <p>Note that <tt class="docutils literal"><span class="pre">import std/math as m</span></tt> does not use a different node; rather, we use <tt class="docutils literal"><span class="pre">nnkImportStmt</span></tt> with <tt class="docutils literal"><span class="pre">as</span></tt> as an infix operator.</p>
  1046. <p>Concrete syntax:</p>
  1047. <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">strutils</span> <span class="Keyword">as</span> <span class="Identifier">su</span></pre></p>
  1048. <p>AST:</p>
  1049. <p><pre class="listing"><span class="Identifier">nnkImportStmt</span><span class="Punctuation">(</span>
  1050. <span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  1051. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;as&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1052. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;strutils&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1053. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;su&quot;</span><span class="Punctuation">)</span>
  1054. <span class="Punctuation">)</span>
  1055. <span class="Punctuation">)</span></pre></p>
  1056. <h2><a class="toc-backref" id="statements-from-statement" href="#statements-from-statement">From statement</a></h2><p>If we use <tt class="docutils literal"><span class="pre">from ... import</span></tt>, the result is different, too.</p>
  1057. <p>Concrete syntax:</p>
  1058. <p><pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">math</span> <span class="Keyword">import</span> <span class="Identifier">pow</span></pre></p>
  1059. <p>AST:</p>
  1060. <p><pre class="listing"><span class="Identifier">nnkFromStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;math&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;pow&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1061. <p>Using <tt class="docutils literal"><span class="pre">from std/math as m import pow</span></tt> works identically to the <tt class="docutils literal"><span class="pre">as</span></tt> modifier with the <tt class="docutils literal"><span class="pre">import</span></tt> statement, but wrapped in <tt class="docutils literal"><span class="pre">nnkFromStmt</span></tt>.</p>
  1062. <h2><a class="toc-backref" id="statements-export-statement" href="#statements-export-statement">Export statement</a></h2><p>When you are making an imported module accessible by modules that import yours, the <tt class="docutils literal"><span class="pre">export</span></tt> syntax is pretty straightforward.</p>
  1063. <p>Concrete syntax:</p>
  1064. <p><pre class="listing"><span class="Keyword">export</span> <span class="Identifier">unsigned</span></pre></p>
  1065. <p>AST:</p>
  1066. <p><pre class="listing"><span class="Identifier">nnkExportStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;unsigned&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1067. <p>Similar to the <tt class="docutils literal"><span class="pre">import</span></tt> statement, the AST is different for <tt class="docutils literal"><span class="pre">export ... except</span></tt>.</p>
  1068. <p>Concrete syntax:</p>
  1069. <p><pre class="listing"><span class="Keyword">export</span> <span class="Identifier">math</span> <span class="Keyword">except</span> <span class="Identifier">pow</span> <span class="Comment"># we're going to implement our own exponentiation</span></pre></p>
  1070. <p>AST:</p>
  1071. <p><pre class="listing"><span class="Identifier">nnkExportExceptStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;math&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;pow&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1072. <h2><a class="toc-backref" id="statements-include-statement" href="#statements-include-statement">Include statement</a></h2><p>Like a plain <tt class="docutils literal"><span class="pre">import</span></tt> statement but with <tt class="docutils literal"><span class="pre">nnkIncludeStmt</span></tt>.</p>
  1073. <p>Concrete syntax:</p>
  1074. <p><pre class="listing"><span class="Keyword">include</span> <span class="Identifier">blocks</span></pre></p>
  1075. <p>AST:</p>
  1076. <p><pre class="listing"><span class="Identifier">nnkIncludeStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;blocks&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1077. <h2><a class="toc-backref" id="statements-var-section" href="#statements-var-section">Var section</a></h2><p>Concrete syntax:</p>
  1078. <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="DecNumber">3</span></pre></p>
  1079. <p>AST:</p>
  1080. <p><pre class="listing"><span class="Identifier">nnkVarSection</span><span class="Punctuation">(</span>
  1081. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1082. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1083. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># or nnkIdent(...) if the variable declares the type</span>
  1084. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1085. <span class="Punctuation">)</span>
  1086. <span class="Punctuation">)</span></pre></p>
  1087. <p>Note that either the second or third (or both) parameters above must exist, as the compiler needs to know the type somehow (which it can infer from the given assignment).</p>
  1088. <p>This is not the same AST for all uses of <tt class="docutils literal"><span class="pre">var</span></tt>. See <a class="reference external" href="macros.html#statements-procedure-declaration">Procedure declaration</a> for details.</p>
  1089. <h2><a class="toc-backref" id="statements-let-section" href="#statements-let-section">Let section</a></h2><p>This is equivalent to <tt class="docutils literal"><span class="pre">var</span></tt>, but with <tt class="docutils literal"><span class="pre">nnkLetSection</span></tt> rather than <tt class="docutils literal"><span class="pre">nnkVarSection</span></tt>.</p>
  1090. <p>Concrete syntax:</p>
  1091. <p><pre class="listing"><span class="Keyword">let</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="DecNumber">3</span></pre></p>
  1092. <p>AST:</p>
  1093. <p><pre class="listing"><span class="Identifier">nnkLetSection</span><span class="Punctuation">(</span>
  1094. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1095. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1096. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># or nnkIdent(...) for the type</span>
  1097. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1098. <span class="Punctuation">)</span>
  1099. <span class="Punctuation">)</span></pre></p>
  1100. <h2><a class="toc-backref" id="statements-const-section" href="#statements-const-section">Const section</a></h2><p>Concrete syntax:</p>
  1101. <p><pre class="listing"><span class="Keyword">const</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="DecNumber">3</span></pre></p>
  1102. <p>AST:</p>
  1103. <p><pre class="listing"><span class="Identifier">nnkConstSection</span><span class="Punctuation">(</span>
  1104. <span class="Identifier">nnkConstDef</span><span class="Punctuation">(</span> <span class="Comment"># not nnkConstDefs!</span>
  1105. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1106. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># or nnkIdent(...) if the variable declares the type</span>
  1107. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># required in a const declaration!</span>
  1108. <span class="Punctuation">)</span>
  1109. <span class="Punctuation">)</span></pre></p>
  1110. <h2><a class="toc-backref" id="statements-type-section" href="#statements-type-section">Type section</a></h2><p>Starting with the simplest case, a <tt class="docutils literal"><span class="pre">type</span></tt> section appears much like <tt class="docutils literal"><span class="pre">var</span></tt> and <tt class="docutils literal"><span class="pre">const</span></tt>.</p>
  1111. <p>Concrete syntax:</p>
  1112. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">A</span> <span class="Operator">=</span> <span class="Identifier">int</span></pre></p>
  1113. <p>AST:</p>
  1114. <p><pre class="listing"><span class="Identifier">nnkTypeSection</span><span class="Punctuation">(</span>
  1115. <span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1116. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;A&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1117. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1118. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span>
  1119. <span class="Punctuation">)</span>
  1120. <span class="Punctuation">)</span></pre></p>
  1121. <p>Declaring <tt class="docutils literal"><span class="pre">distinct</span></tt> types is similar, with the last <tt class="docutils literal"><span class="pre">nnkIdent</span></tt> wrapped in <tt class="docutils literal"><span class="pre">nnkDistinctTy</span></tt>.</p>
  1122. <p>Concrete syntax:</p>
  1123. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">MyInt</span> <span class="Operator">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int</span></pre></p>
  1124. <p>AST:</p>
  1125. <p><pre class="listing"><span class="Comment"># ...</span>
  1126. <span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1127. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;MyInt&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1128. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1129. <span class="Identifier">nnkDistinctTy</span><span class="Punctuation">(</span>
  1130. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span>
  1131. <span class="Punctuation">)</span>
  1132. <span class="Punctuation">)</span></pre></p>
  1133. <p>If a type section uses generic parameters, they are treated here:</p>
  1134. <p>Concrete syntax:</p>
  1135. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">A</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">expr1</span></pre></p>
  1136. <p>AST:</p>
  1137. <p><pre class="listing"><span class="Identifier">nnkTypeSection</span><span class="Punctuation">(</span>
  1138. <span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1139. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;A&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1140. <span class="Identifier">nnkGenericParams</span><span class="Punctuation">(</span>
  1141. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1142. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1143. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># if the type is declared with options, like</span>
  1144. <span class="Comment"># ``[T: SomeInteger]``, they are given here</span>
  1145. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1146. <span class="Punctuation">)</span>
  1147. <span class="Punctuation">)</span>
  1148. <span class="Identifier">expr1</span><span class="Punctuation">,</span>
  1149. <span class="Punctuation">)</span>
  1150. <span class="Punctuation">)</span></pre></p>
  1151. <p>Note that not all <tt class="docutils literal"><span class="pre">nnkTypeDef</span></tt> utilize <tt class="docutils literal"><span class="pre">nnkIdent</span></tt> as their parameter. One of the most common uses of type declarations is to work with objects.</p>
  1152. <p>Concrete syntax:</p>
  1153. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">IO</span> <span class="Operator">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">RootObj</span></pre></p>
  1154. <p>AST:</p>
  1155. <p><pre class="listing"><span class="Comment"># ...</span>
  1156. <span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1157. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;IO&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1158. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1159. <span class="Identifier">nnkObjectTy</span><span class="Punctuation">(</span>
  1160. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># no pragmas here</span>
  1161. <span class="Identifier">nnkOfInherit</span><span class="Punctuation">(</span>
  1162. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;RootObj&quot;</span><span class="Punctuation">)</span> <span class="Comment"># inherits from RootObj</span>
  1163. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1164. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1165. <span class="Punctuation">)</span>
  1166. <span class="Punctuation">)</span></pre></p>
  1167. <p>Nim's object syntax is rich. Let's take a look at an involved example in its entirety to see some of the complexities.</p>
  1168. <p>Concrete syntax:</p>
  1169. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">Obj</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">inheritable</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  1170. <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  1171. <span class="Keyword">case</span> <span class="Identifier">isFat</span><span class="Punctuation">:</span> <span class="Identifier">bool</span>
  1172. <span class="Keyword">of</span> <span class="Identifier">true</span><span class="Punctuation">:</span>
  1173. <span class="Identifier">m</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="DecNumber">100_000</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span>
  1174. <span class="Keyword">of</span> <span class="Identifier">false</span><span class="Punctuation">:</span>
  1175. <span class="Identifier">m</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span></pre></p>
  1176. <p>AST:</p>
  1177. <p><pre class="listing"><span class="Comment"># ...</span>
  1178. <span class="Identifier">nnkPragmaExpr</span><span class="Punctuation">(</span>
  1179. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Obj&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1180. <span class="Identifier">nnkPragma</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;inheritable&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  1181. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1182. <span class="Identifier">nnkGenericParams</span><span class="Punctuation">(</span>
  1183. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1184. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1185. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1186. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  1187. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1188. <span class="Identifier">nnkObjectTy</span><span class="Punctuation">(</span>
  1189. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1190. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1191. <span class="Identifier">nnkRecList</span><span class="Punctuation">(</span> <span class="Comment"># list of object parameters</span>
  1192. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1193. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;name&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1194. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;string&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1195. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1196. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1197. <span class="Identifier">nnkRecCase</span><span class="Punctuation">(</span> <span class="Comment"># case statement within object (not nnkCaseStmt)</span>
  1198. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1199. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;isFat&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1200. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;bool&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1201. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1202. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1203. <span class="Identifier">nnkOfBranch</span><span class="Punctuation">(</span>
  1204. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;true&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1205. <span class="Identifier">nnkRecList</span><span class="Punctuation">(</span> <span class="Comment"># again, a list of object parameters</span>
  1206. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1207. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;m&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1208. <span class="Identifier">nnkBracketExpr</span><span class="Punctuation">(</span>
  1209. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;array&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1210. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">100000</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1211. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span>
  1212. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1213. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1214. <span class="Punctuation">)</span>
  1215. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1216. <span class="Identifier">nnkOfBranch</span><span class="Punctuation">(</span>
  1217. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;false&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1218. <span class="Identifier">nnkRecList</span><span class="Punctuation">(</span>
  1219. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1220. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;m&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1221. <span class="Identifier">nnkBracketExpr</span><span class="Punctuation">(</span>
  1222. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;array&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1223. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">10</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1224. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span>
  1225. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1226. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1227. <span class="Punctuation">)</span>
  1228. <span class="Punctuation">)</span>
  1229. <span class="Punctuation">)</span>
  1230. <span class="Punctuation">)</span>
  1231. <span class="Punctuation">)</span>
  1232. <span class="Punctuation">)</span></pre></p>
  1233. <p>Using an <tt class="docutils literal"><span class="pre">enum</span></tt> is similar to using an <tt class="docutils literal"><span class="pre">object</span></tt>.</p>
  1234. <p>Concrete syntax:</p>
  1235. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">X</span> <span class="Operator">=</span> <span class="Keyword">enum</span>
  1236. <span class="Identifier">First</span></pre></p>
  1237. <p>AST:</p>
  1238. <p><pre class="listing"><span class="Comment"># ...</span>
  1239. <span class="Identifier">nnkEnumTy</span><span class="Punctuation">(</span>
  1240. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1241. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;First&quot;</span><span class="Punctuation">)</span> <span class="Comment"># you need at least one nnkIdent or the compiler complains</span>
  1242. <span class="Punctuation">)</span></pre></p>
  1243. <p>The usage of <tt class="docutils literal"><span class="pre">concept</span></tt> (experimental) is similar to objects.</p>
  1244. <p>Concrete syntax:</p>
  1245. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">Con</span> <span class="Operator">=</span> <span class="Keyword">concept</span> <span class="Identifier">x</span><span class="Punctuation">,</span><span class="Identifier">y</span><span class="Punctuation">,</span><span class="Identifier">z</span>
  1246. <span class="Punctuation">(</span><span class="Identifier">x</span> <span class="Operator">&amp;</span> <span class="Identifier">y</span> <span class="Operator">&amp;</span> <span class="Identifier">z</span><span class="Punctuation">)</span> <span class="Keyword">is</span> <span class="Identifier">string</span></pre></p>
  1247. <p>AST:</p>
  1248. <p><pre class="listing"><span class="Comment"># ...</span>
  1249. <span class="Identifier">nnkTypeClassTy</span><span class="Punctuation">(</span> <span class="Comment"># note this isn't nnkConceptTy!</span>
  1250. <span class="Identifier">nnkArgList</span><span class="Punctuation">(</span>
  1251. <span class="Comment"># ... idents for x, y, z</span>
  1252. <span class="Punctuation">)</span>
  1253. <span class="Comment"># ...</span>
  1254. <span class="Punctuation">)</span></pre></p>
  1255. <p>Static types, like <tt class="docutils literal"><span class="pre">static[int]</span></tt>, use <tt class="docutils literal"><span class="pre">nnkIdent</span></tt> wrapped in <tt class="docutils literal"><span class="pre">nnkStaticTy</span></tt>.</p>
  1256. <p>Concrete syntax:</p>
  1257. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">A</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">:</span> <span class="Keyword">static</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span></pre></p>
  1258. <p>AST:</p>
  1259. <p><pre class="listing"><span class="Comment"># ... within nnkGenericParams</span>
  1260. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1261. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1262. <span class="Identifier">nnkStaticTy</span><span class="Punctuation">(</span>
  1263. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span>
  1264. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1265. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1266. <span class="Punctuation">)</span>
  1267. <span class="Comment"># ...</span></pre></p>
  1268. <p>In general, declaring types mirrors this syntax (i.e., <tt class="docutils literal"><span class="pre">nnkStaticTy</span></tt> for <tt class="docutils literal"><span class="pre">static</span></tt>, etc.). Examples follow (exceptions marked by <tt class="docutils literal"><span class="pre">*</span></tt>):</p>
  1269. <table border="1" class="docutils"><tr><th>Nim type</th><th>Corresponding AST</th></tr>
  1270. <tr><td><tt class="docutils literal"><span class="pre">static</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkStaticTy</span></tt></td></tr>
  1271. <tr><td><tt class="docutils literal"><span class="pre">tuple</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkTupleTy</span></tt></td></tr>
  1272. <tr><td><tt class="docutils literal"><span class="pre">var</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkVarTy</span></tt></td></tr>
  1273. <tr><td><tt class="docutils literal"><span class="pre">ptr</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkPtrTy</span></tt></td></tr>
  1274. <tr><td><tt class="docutils literal"><span class="pre">ref</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkRefTy</span></tt></td></tr>
  1275. <tr><td><tt class="docutils literal"><span class="pre">distinct</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkDistinctTy</span></tt></td></tr>
  1276. <tr><td><tt class="docutils literal"><span class="pre">enum</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkEnumTy</span></tt></td></tr>
  1277. <tr><td><tt class="docutils literal"><span class="pre">concept</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkTypeClassTy</span></tt>*</td></tr>
  1278. <tr><td><tt class="docutils literal"><span class="pre">array</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkBracketExpr(nnkIdent(&quot;array&quot;),...</span></tt>*</td></tr>
  1279. <tr><td><tt class="docutils literal"><span class="pre">proc</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkProcTy</span></tt></td></tr>
  1280. <tr><td><tt class="docutils literal"><span class="pre">iterator</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkIteratorTy</span></tt></td></tr>
  1281. <tr><td><tt class="docutils literal"><span class="pre">object</span></tt></td><td><tt class="docutils literal"><span class="pre">nnkObjectTy</span></tt></td></tr>
  1282. </table><p>Take special care when declaring types as <tt class="docutils literal"><span class="pre">proc</span></tt>. The behavior is similar to <tt class="docutils literal"><span class="pre">Procedure declaration</span></tt>, below, but does not treat <tt class="docutils literal"><span class="pre">nnkGenericParams</span></tt>. Generic parameters are treated in the type, not the <tt class="docutils literal"><span class="pre">proc</span></tt> itself.</p>
  1283. <p>Concrete syntax:</p>
  1284. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">MyProc</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">proc</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">T</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">nimcall</span><span class="Operator">.</span><span class="Punctuation">}</span></pre></p>
  1285. <p>AST:</p>
  1286. <p><pre class="listing"><span class="Comment"># ...</span>
  1287. <span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1288. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;MyProc&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1289. <span class="Identifier">nnkGenericParams</span><span class="Punctuation">(</span> <span class="Comment"># here, not with the proc</span>
  1290. <span class="Comment"># ...</span>
  1291. <span class="Punctuation">)</span>
  1292. <span class="Identifier">nnkProcTy</span><span class="Punctuation">(</span> <span class="Comment"># behaves like a procedure declaration from here on</span>
  1293. <span class="Identifier">nnkFormalParams</span><span class="Punctuation">(</span>
  1294. <span class="Comment"># ...</span>
  1295. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1296. <span class="Identifier">nnkPragma</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;nimcall&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  1297. <span class="Punctuation">)</span>
  1298. <span class="Punctuation">)</span></pre></p>
  1299. <p>The same syntax applies to <tt class="docutils literal"><span class="pre">iterator</span></tt> (with <tt class="docutils literal"><span class="pre">nnkIteratorTy</span></tt>), but <em>does not</em> apply to <tt class="docutils literal"><span class="pre">converter</span></tt> or <tt class="docutils literal"><span class="pre">template</span></tt>.</p>
  1300. <p>Type class versions of these nodes generally share the same node kind but without any child nodes. The <tt class="docutils literal"><span class="pre">tuple</span></tt> type class is represented by <tt class="docutils literal"><span class="pre">nnkTupleClassTy</span></tt>, while a <tt class="docutils literal"><span class="pre">proc</span></tt> or <tt class="docutils literal"><span class="pre">iterator</span></tt> type class with pragmas has an <tt class="docutils literal"><span class="pre">nnkEmpty</span></tt> node in place of the <tt class="docutils literal"><span class="pre">nnkFormalParams</span></tt> node of a concrete <tt class="docutils literal"><span class="pre">proc</span></tt> or <tt class="docutils literal"><span class="pre">iterator</span></tt> type node.</p>
  1301. <p><pre class="listing"><span class="Keyword">type</span> <span class="Identifier">TypeClass</span> <span class="Operator">=</span> <span class="Keyword">proc</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">nimcall</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">|</span> <span class="Keyword">ref</span> <span class="Operator">|</span> <span class="Keyword">tuple</span></pre></p>
  1302. <p>AST:</p>
  1303. <p><pre class="listing"><span class="Identifier">nnkTypeDef</span><span class="Punctuation">(</span>
  1304. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;TypeClass&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1305. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1306. <span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  1307. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;|&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1308. <span class="Identifier">nnkProcTy</span><span class="Punctuation">(</span>
  1309. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1310. <span class="Identifier">nnkPragma</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;nimcall&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  1311. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1312. <span class="Identifier">nnkInfix</span><span class="Punctuation">(</span>
  1313. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;|&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1314. <span class="Identifier">nnkRefTy</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1315. <span class="Identifier">nnkTupleClassTy</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1316. <span class="Punctuation">)</span>
  1317. <span class="Punctuation">)</span>
  1318. <span class="Punctuation">)</span></pre></p>
  1319. <h2><a class="toc-backref" id="statements-mixin-statement" href="#statements-mixin-statement">Mixin statement</a></h2><p>Concrete syntax:</p>
  1320. <p><pre class="listing"><span class="Keyword">mixin</span> <span class="Identifier">x</span></pre></p>
  1321. <p>AST:</p>
  1322. <p><pre class="listing"><span class="Identifier">nnkMixinStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1323. <h2><a class="toc-backref" id="statements-bind-statement" href="#statements-bind-statement">Bind statement</a></h2><p>Concrete syntax:</p>
  1324. <p><pre class="listing"><span class="Keyword">bind</span> <span class="Identifier">x</span></pre></p>
  1325. <p>AST:</p>
  1326. <p><pre class="listing"><span class="Identifier">nnkBindStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1327. <h2><a class="toc-backref" id="statements-procedure-declaration" href="#statements-procedure-declaration">Procedure declaration</a></h2><p>Let's take a look at a procedure with a lot of interesting aspects to get a feel for how procedure calls are broken down.</p>
  1328. <p>Concrete syntax:</p>
  1329. <p><pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Operator">*</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">:</span> <span class="Identifier">SomeInteger</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">float32</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">inline</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">discard</span></pre></p>
  1330. <p>AST:</p>
  1331. <p><pre class="listing"><span class="Identifier">nnkProcDef</span><span class="Punctuation">(</span>
  1332. <span class="Identifier">nnkPostfix</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;*&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;hello&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># the exported proc name</span>
  1333. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># patterns for term rewriting in templates and macros (not procs)</span>
  1334. <span class="Identifier">nnkGenericParams</span><span class="Punctuation">(</span> <span class="Comment"># generic type parameters, like with type declaration</span>
  1335. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1336. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;T&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1337. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;SomeInteger&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1338. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1339. <span class="Punctuation">)</span>
  1340. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1341. <span class="Identifier">nnkFormalParams</span><span class="Punctuation">(</span>
  1342. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># the first FormalParam is the return type. nnkEmpty() if there is none</span>
  1343. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1344. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;x&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1345. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># type type (required for procs, not for templates)</span>
  1346. <span class="Identifier">nnkIntLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Comment"># a default value</span>
  1347. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1348. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1349. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;y&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1350. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;float32&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1351. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  1352. <span class="Punctuation">)</span>
  1353. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1354. <span class="Identifier">nnkPragma</span><span class="Punctuation">(</span><span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;inline&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1355. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># reserved slot for future use</span>
  1356. <span class="Identifier">nnkStmtList</span><span class="Punctuation">(</span><span class="Identifier">nnkDiscardStmt</span><span class="Punctuation">(</span><span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># the meat of the proc</span>
  1357. <span class="Punctuation">)</span></pre></p>
  1358. <p>There is another consideration. Nim has flexible type identification for its procs. Even though <tt class="docutils literal"><span class="pre">proc(a: int, b: int)</span></tt> and <tt class="docutils literal"><span class="pre">proc(a, b: int)</span></tt> are equivalent in the code, the AST is a little different for the latter.</p>
  1359. <p>Concrete syntax:</p>
  1360. <p><pre class="listing"><span class="Keyword">proc</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span></pre></p>
  1361. <p>AST:</p>
  1362. <p><pre class="listing"><span class="Comment"># ...AST as above...</span>
  1363. <span class="Identifier">nnkFormalParams</span><span class="Punctuation">(</span>
  1364. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># no return here</span>
  1365. <span class="Identifier">nnkIdentDefs</span><span class="Punctuation">(</span>
  1366. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># the first parameter</span>
  1367. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># directly to the second parameter</span>
  1368. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># their shared type identifier</span>
  1369. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Comment"># default value would go here</span>
  1370. <span class="Punctuation">)</span>
  1371. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1372. <span class="Comment"># ...</span></pre></p>
  1373. <p>When a procedure uses the special <tt class="docutils literal"><span class="pre">var</span></tt> type return variable, the result is different from that of a var section.</p>
  1374. <p>Concrete syntax:</p>
  1375. <p><pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span></pre></p>
  1376. <p>AST:</p>
  1377. <p><pre class="listing"><span class="Comment"># ...</span>
  1378. <span class="Identifier">nnkFormalParams</span><span class="Punctuation">(</span>
  1379. <span class="Identifier">nnkVarTy</span><span class="Punctuation">(</span>
  1380. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;int&quot;</span><span class="Punctuation">)</span>
  1381. <span class="Punctuation">)</span>
  1382. <span class="Punctuation">)</span></pre></p>
  1383. <h2><a class="toc-backref" id="statements-iterator-declaration" href="#statements-iterator-declaration">Iterator declaration</a></h2><p>The syntax for iterators is similar to procs, but with <tt class="docutils literal"><span class="pre">nnkIteratorDef</span></tt> replacing <tt class="docutils literal"><span class="pre">nnkProcDef</span></tt>.</p>
  1384. <p>Concrete syntax:</p>
  1385. <p><pre class="listing"><span class="Keyword">iterator</span> <span class="Identifier">nonsense</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">float</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">closure</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Operator">...</span></pre></p>
  1386. <p>AST:</p>
  1387. <p><pre class="listing"><span class="Identifier">nnkIteratorDef</span><span class="Punctuation">(</span>
  1388. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;nonsense&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1389. <span class="Identifier">nnkEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1390. <span class="Operator">...</span>
  1391. <span class="Punctuation">)</span></pre></p>
  1392. <h2><a class="toc-backref" id="statements-converter-declaration" href="#statements-converter-declaration">Converter declaration</a></h2><p>A converter is similar to a proc.</p>
  1393. <p>Concrete syntax:</p>
  1394. <p><pre class="listing"><span class="Keyword">converter</span> <span class="Identifier">toBool</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">float</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">bool</span></pre></p>
  1395. <p>AST:</p>
  1396. <p><pre class="listing"><span class="Identifier">nnkConverterDef</span><span class="Punctuation">(</span>
  1397. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;toBool&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1398. <span class="Comment"># ...</span>
  1399. <span class="Punctuation">)</span></pre></p>
  1400. <h2><a class="toc-backref" id="statements-template-declaration" href="#statements-template-declaration">Template declaration</a></h2><p>Templates (as well as macros, as we'll see) have a slightly expanded AST when compared to procs and iterators. The reason for this is <a class="reference external" href="manual.html#term-rewriting-macros">term-rewriting macros</a>. Notice the <tt class="docutils literal"><span class="pre">nnkEmpty()</span></tt> as the second argument to <tt class="docutils literal"><span class="pre">nnkProcDef</span></tt> and <tt class="docutils literal"><span class="pre">nnkIteratorDef</span></tt> above? That's where the term-rewriting macros go.</p>
  1401. <p>Concrete syntax:</p>
  1402. <p><pre class="listing"><span class="Keyword">template</span> <span class="Identifier">optOpt</span><span class="Punctuation">{</span><span class="Identifier">expr1</span><span class="Punctuation">}</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span></pre></p>
  1403. <p>AST:</p>
  1404. <p><pre class="listing"><span class="Identifier">nnkTemplateDef</span><span class="Punctuation">(</span>
  1405. <span class="Identifier">nnkIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;optOpt&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1406. <span class="Identifier">nnkStmtList</span><span class="Punctuation">(</span> <span class="Comment"># instead of nnkEmpty()</span>
  1407. <span class="Identifier">expr1</span>
  1408. <span class="Punctuation">)</span><span class="Punctuation">,</span>
  1409. <span class="Comment"># follows like a proc or iterator</span>
  1410. <span class="Punctuation">)</span></pre></p>
  1411. <p>If the template does not have types for its parameters, the type identifiers inside <tt class="docutils literal"><span class="pre">nnkFormalParams</span></tt> just becomes <tt class="docutils literal"><span class="pre">nnkEmpty</span></tt>.</p>
  1412. <h2><a class="toc-backref" id="statements-macro-declaration" href="#statements-macro-declaration">Macro declaration</a></h2><p>Macros behave like templates, but <tt class="docutils literal"><span class="pre">nnkTemplateDef</span></tt> is replaced with <tt class="docutils literal"><span class="pre">nnkMacroDef</span></tt>.</p>
  1413. <h2><a class="toc-backref" id="statements-hidden-standard-conversion" href="#statements-hidden-standard-conversion">Hidden Standard Conversion</a></h2><p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span><span class="Punctuation">:</span> <span class="Identifier">float</span> <span class="Operator">=</span> <span class="DecNumber">1</span></pre></p>
  1414. <p>The type of &quot;f&quot; is <tt class="docutils literal"><span class="pre">float</span></tt> but the type of &quot;1&quot; is actually <tt class="docutils literal"><span class="pre">int</span></tt>. Inserting <tt class="docutils literal"><span class="pre">int</span></tt> into a <tt class="docutils literal"><span class="pre">float</span></tt> is a type error. Nim inserts the <tt class="docutils literal"><span class="pre">nnkHiddenStdConv</span></tt> node around the <tt class="docutils literal"><span class="pre">nnkIntLit</span></tt> node so that the new node has the correct type of <tt class="docutils literal"><span class="pre">float</span></tt>. This works for any auto converted nodes and makes the conversion explicit.</p>
  1415. <h1><a class="toc-backref" id="special-node-kinds" href="#special-node-kinds">Special node kinds</a></h1><p>There are several node kinds that are used for semantic checking or code generation. These are accessible from this module, but should not be used. Other node kinds are especially designed to make AST manipulations easier. These are explained here.</p>
  1416. <p>To be written. </p>
  1417. </p>
  1418. <div class="section" id="6">
  1419. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  1420. <dl class="item">
  1421. <a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="formatfloat.html">formatfloat</a>
  1422. </dl>
  1423. </div>
  1424. <div class="section" id="7">
  1425. <h1><a class="toc-backref" href="#7">Types</a></h1>
  1426. <dl class="item">
  1427. <div id="BindSymRule">
  1428. <dt><pre><a href="macros.html#BindSymRule"><span class="Identifier">BindSymRule</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  1429. <span class="Identifier">brClosed</span><span class="Other">,</span> <span class="Comment">## only the symbols in current scope are bound</span>
  1430. <span class="Identifier">brOpen</span><span class="Other">,</span> <span class="Comment">## open for overloaded symbols, but may be a single</span>
  1431. <span class="Comment">## symbol if not ambiguous (the rules match that of</span>
  1432. <span class="Comment">## binding in generics)</span>
  1433. <span class="Identifier">brForceOpen</span> <span class="Comment">## same as brOpen, but it will always be open even</span>
  1434. <span class="Comment">## if not ambiguous (this cannot be achieved with</span>
  1435. <span class="Comment">## any other means in the language currently)</span></pre></dt>
  1436. <dd>
  1437. Specifies how <tt class="docutils literal"><span class="pre"><span class="Identifier">bindSym</span></span></tt> behaves. The difference between open and closed symbols can be found in <a class="reference external" href="manual.html#symbol-lookup-in-generics-open-and-closed-symbols">manual.html#symbol-lookup-in-generics-open-and-closed-symbols</a>
  1438. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L484" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1439. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L484" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1440. </dd>
  1441. </div>
  1442. <div id="LineInfo">
  1443. <dt><pre><a href="macros.html#LineInfo"><span class="Identifier">LineInfo</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
  1444. <span class="Identifier">filename</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
  1445. <span class="Identifier">line</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">column</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
  1446. <dd>
  1447. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L525" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1448. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L525" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1449. </dd>
  1450. </div>
  1451. <div id="NimIdent">
  1452. <dt><pre><a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#RootObj"><span class="Identifier">RootObj</span></a></pre></dt>
  1453. <dd>
  1454. <div class="deprecation-message">
  1455. <b>Deprecated</b>
  1456. </div>
  1457. Represents a Nim identifier in the AST. <strong>Note</strong>: This is only rarely useful, for identifier construction from a string use <tt class="docutils literal"><span class="pre"><span class="RawData">ident&quot;abc&quot;</span></span></tt>.
  1458. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L137" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1459. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L137" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1460. </dd>
  1461. </div>
  1462. <div id="NimNodeKind">
  1463. <dt><pre><a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  1464. <span class="Identifier">nnkNone</span><span class="Other">,</span> <span class="Identifier">nnkEmpty</span><span class="Other">,</span> <span class="Identifier">nnkIdent</span><span class="Other">,</span> <span class="Identifier">nnkSym</span><span class="Other">,</span> <span class="Identifier">nnkType</span><span class="Other">,</span> <span class="Identifier">nnkCharLit</span><span class="Other">,</span> <span class="Identifier">nnkIntLit</span><span class="Other">,</span>
  1465. <span class="Identifier">nnkInt8Lit</span><span class="Other">,</span> <span class="Identifier">nnkInt16Lit</span><span class="Other">,</span> <span class="Identifier">nnkInt32Lit</span><span class="Other">,</span> <span class="Identifier">nnkInt64Lit</span><span class="Other">,</span> <span class="Identifier">nnkUIntLit</span><span class="Other">,</span> <span class="Identifier">nnkUInt8Lit</span><span class="Other">,</span>
  1466. <span class="Identifier">nnkUInt16Lit</span><span class="Other">,</span> <span class="Identifier">nnkUInt32Lit</span><span class="Other">,</span> <span class="Identifier">nnkUInt64Lit</span><span class="Other">,</span> <span class="Identifier">nnkFloatLit</span><span class="Other">,</span> <span class="Identifier">nnkFloat32Lit</span><span class="Other">,</span>
  1467. <span class="Identifier">nnkFloat64Lit</span><span class="Other">,</span> <span class="Identifier">nnkFloat128Lit</span><span class="Other">,</span> <span class="Identifier">nnkStrLit</span><span class="Other">,</span> <span class="Identifier">nnkRStrLit</span><span class="Other">,</span> <span class="Identifier">nnkTripleStrLit</span><span class="Other">,</span>
  1468. <span class="Identifier">nnkNilLit</span><span class="Other">,</span> <span class="Identifier">nnkComesFrom</span><span class="Other">,</span> <span class="Identifier">nnkDotCall</span><span class="Other">,</span> <span class="Identifier">nnkCommand</span><span class="Other">,</span> <span class="Identifier">nnkCall</span><span class="Other">,</span> <span class="Identifier">nnkCallStrLit</span><span class="Other">,</span>
  1469. <span class="Identifier">nnkInfix</span><span class="Other">,</span> <span class="Identifier">nnkPrefix</span><span class="Other">,</span> <span class="Identifier">nnkPostfix</span><span class="Other">,</span> <span class="Identifier">nnkHiddenCallConv</span><span class="Other">,</span> <span class="Identifier">nnkExprEqExpr</span><span class="Other">,</span>
  1470. <span class="Identifier">nnkExprColonExpr</span><span class="Other">,</span> <span class="Identifier">nnkIdentDefs</span><span class="Other">,</span> <span class="Identifier">nnkVarTuple</span><span class="Other">,</span> <span class="Identifier">nnkPar</span><span class="Other">,</span> <span class="Identifier">nnkObjConstr</span><span class="Other">,</span> <span class="Identifier">nnkCurly</span><span class="Other">,</span>
  1471. <span class="Identifier">nnkCurlyExpr</span><span class="Other">,</span> <span class="Identifier">nnkBracket</span><span class="Other">,</span> <span class="Identifier">nnkBracketExpr</span><span class="Other">,</span> <span class="Identifier">nnkPragmaExpr</span><span class="Other">,</span> <span class="Identifier">nnkRange</span><span class="Other">,</span> <span class="Identifier">nnkDotExpr</span><span class="Other">,</span>
  1472. <span class="Identifier">nnkCheckedFieldExpr</span><span class="Other">,</span> <span class="Identifier">nnkDerefExpr</span><span class="Other">,</span> <span class="Identifier">nnkIfExpr</span><span class="Other">,</span> <span class="Identifier">nnkElifExpr</span><span class="Other">,</span> <span class="Identifier">nnkElseExpr</span><span class="Other">,</span>
  1473. <span class="Identifier">nnkLambda</span><span class="Other">,</span> <span class="Identifier">nnkDo</span><span class="Other">,</span> <span class="Identifier">nnkAccQuoted</span><span class="Other">,</span> <span class="Identifier">nnkTableConstr</span><span class="Other">,</span> <span class="Identifier">nnkBind</span><span class="Other">,</span> <span class="Identifier">nnkClosedSymChoice</span><span class="Other">,</span>
  1474. <span class="Identifier">nnkOpenSymChoice</span><span class="Other">,</span> <span class="Identifier">nnkHiddenStdConv</span><span class="Other">,</span> <span class="Identifier">nnkHiddenSubConv</span><span class="Other">,</span> <span class="Identifier">nnkConv</span><span class="Other">,</span> <span class="Identifier">nnkCast</span><span class="Other">,</span>
  1475. <span class="Identifier">nnkStaticExpr</span><span class="Other">,</span> <span class="Identifier">nnkAddr</span><span class="Other">,</span> <span class="Identifier">nnkHiddenAddr</span><span class="Other">,</span> <span class="Identifier">nnkHiddenDeref</span><span class="Other">,</span> <span class="Identifier">nnkObjDownConv</span><span class="Other">,</span>
  1476. <span class="Identifier">nnkObjUpConv</span><span class="Other">,</span> <span class="Identifier">nnkChckRangeF</span><span class="Other">,</span> <span class="Identifier">nnkChckRange64</span><span class="Other">,</span> <span class="Identifier">nnkChckRange</span><span class="Other">,</span> <span class="Identifier">nnkStringToCString</span><span class="Other">,</span>
  1477. <span class="Identifier">nnkCStringToString</span><span class="Other">,</span> <span class="Identifier">nnkAsgn</span><span class="Other">,</span> <span class="Identifier">nnkFastAsgn</span><span class="Other">,</span> <span class="Identifier">nnkGenericParams</span><span class="Other">,</span> <span class="Identifier">nnkFormalParams</span><span class="Other">,</span>
  1478. <span class="Identifier">nnkOfInherit</span><span class="Other">,</span> <span class="Identifier">nnkImportAs</span><span class="Other">,</span> <span class="Identifier">nnkProcDef</span><span class="Other">,</span> <span class="Identifier">nnkMethodDef</span><span class="Other">,</span> <span class="Identifier">nnkConverterDef</span><span class="Other">,</span>
  1479. <span class="Identifier">nnkMacroDef</span><span class="Other">,</span> <span class="Identifier">nnkTemplateDef</span><span class="Other">,</span> <span class="Identifier">nnkIteratorDef</span><span class="Other">,</span> <span class="Identifier">nnkOfBranch</span><span class="Other">,</span> <span class="Identifier">nnkElifBranch</span><span class="Other">,</span>
  1480. <span class="Identifier">nnkExceptBranch</span><span class="Other">,</span> <span class="Identifier">nnkElse</span><span class="Other">,</span> <span class="Identifier">nnkAsmStmt</span><span class="Other">,</span> <span class="Identifier">nnkPragma</span><span class="Other">,</span> <span class="Identifier">nnkPragmaBlock</span><span class="Other">,</span> <span class="Identifier">nnkIfStmt</span><span class="Other">,</span>
  1481. <span class="Identifier">nnkWhenStmt</span><span class="Other">,</span> <span class="Identifier">nnkForStmt</span><span class="Other">,</span> <span class="Identifier">nnkParForStmt</span><span class="Other">,</span> <span class="Identifier">nnkWhileStmt</span><span class="Other">,</span> <span class="Identifier">nnkCaseStmt</span><span class="Other">,</span>
  1482. <span class="Identifier">nnkTypeSection</span><span class="Other">,</span> <span class="Identifier">nnkVarSection</span><span class="Other">,</span> <span class="Identifier">nnkLetSection</span><span class="Other">,</span> <span class="Identifier">nnkConstSection</span><span class="Other">,</span> <span class="Identifier">nnkConstDef</span><span class="Other">,</span>
  1483. <span class="Identifier">nnkTypeDef</span><span class="Other">,</span> <span class="Identifier">nnkYieldStmt</span><span class="Other">,</span> <span class="Identifier">nnkDefer</span><span class="Other">,</span> <span class="Identifier">nnkTryStmt</span><span class="Other">,</span> <span class="Identifier">nnkFinally</span><span class="Other">,</span> <span class="Identifier">nnkRaiseStmt</span><span class="Other">,</span>
  1484. <span class="Identifier">nnkReturnStmt</span><span class="Other">,</span> <span class="Identifier">nnkBreakStmt</span><span class="Other">,</span> <span class="Identifier">nnkContinueStmt</span><span class="Other">,</span> <span class="Identifier">nnkBlockStmt</span><span class="Other">,</span> <span class="Identifier">nnkStaticStmt</span><span class="Other">,</span>
  1485. <span class="Identifier">nnkDiscardStmt</span><span class="Other">,</span> <span class="Identifier">nnkStmtList</span><span class="Other">,</span> <span class="Identifier">nnkImportStmt</span><span class="Other">,</span> <span class="Identifier">nnkImportExceptStmt</span><span class="Other">,</span>
  1486. <span class="Identifier">nnkExportStmt</span><span class="Other">,</span> <span class="Identifier">nnkExportExceptStmt</span><span class="Other">,</span> <span class="Identifier">nnkFromStmt</span><span class="Other">,</span> <span class="Identifier">nnkIncludeStmt</span><span class="Other">,</span> <span class="Identifier">nnkBindStmt</span><span class="Other">,</span>
  1487. <span class="Identifier">nnkMixinStmt</span><span class="Other">,</span> <span class="Identifier">nnkUsingStmt</span><span class="Other">,</span> <span class="Identifier">nnkCommentStmt</span><span class="Other">,</span> <span class="Identifier">nnkStmtListExpr</span><span class="Other">,</span> <span class="Identifier">nnkBlockExpr</span><span class="Other">,</span>
  1488. <span class="Identifier">nnkStmtListType</span><span class="Other">,</span> <span class="Identifier">nnkBlockType</span><span class="Other">,</span> <span class="Identifier">nnkWith</span><span class="Other">,</span> <span class="Identifier">nnkWithout</span><span class="Other">,</span> <span class="Identifier">nnkTypeOfExpr</span><span class="Other">,</span>
  1489. <span class="Identifier">nnkObjectTy</span><span class="Other">,</span> <span class="Identifier">nnkTupleTy</span><span class="Other">,</span> <span class="Identifier">nnkTupleClassTy</span><span class="Other">,</span> <span class="Identifier">nnkTypeClassTy</span><span class="Other">,</span> <span class="Identifier">nnkStaticTy</span><span class="Other">,</span>
  1490. <span class="Identifier">nnkRecList</span><span class="Other">,</span> <span class="Identifier">nnkRecCase</span><span class="Other">,</span> <span class="Identifier">nnkRecWhen</span><span class="Other">,</span> <span class="Identifier">nnkRefTy</span><span class="Other">,</span> <span class="Identifier">nnkPtrTy</span><span class="Other">,</span> <span class="Identifier">nnkVarTy</span><span class="Other">,</span> <span class="Identifier">nnkConstTy</span><span class="Other">,</span>
  1491. <span class="Identifier">nnkOutTy</span><span class="Other">,</span> <span class="Identifier">nnkDistinctTy</span><span class="Other">,</span> <span class="Identifier">nnkProcTy</span><span class="Other">,</span> <span class="Identifier">nnkIteratorTy</span><span class="Other">,</span> <span class="Identifier">nnkSinkAsgn</span><span class="Other">,</span> <span class="Identifier">nnkEnumTy</span><span class="Other">,</span>
  1492. <span class="Identifier">nnkEnumFieldDef</span><span class="Other">,</span> <span class="Identifier">nnkArgList</span><span class="Other">,</span> <span class="Identifier">nnkPattern</span><span class="Other">,</span> <span class="Identifier">nnkHiddenTryStmt</span><span class="Other">,</span> <span class="Identifier">nnkClosure</span><span class="Other">,</span>
  1493. <span class="Identifier">nnkGotoState</span><span class="Other">,</span> <span class="Identifier">nnkState</span><span class="Other">,</span> <span class="Identifier">nnkBreakState</span><span class="Other">,</span> <span class="Identifier">nnkFuncDef</span><span class="Other">,</span> <span class="Identifier">nnkTupleConstr</span><span class="Other">,</span> <span class="Identifier">nnkError</span><span class="Other">,</span> <span class="Comment">## erroneous AST node</span>
  1494. <span class="Identifier">nnkModuleRef</span><span class="Other">,</span> <span class="Identifier">nnkReplayAction</span><span class="Other">,</span> <span class="Identifier">nnkNilRodNode</span><span class="Other">,</span> <span class="Comment">## internal IC nodes</span>
  1495. <span class="Identifier">nnkOpenSym</span></pre></dt>
  1496. <dd>
  1497. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L32" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1498. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L32" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1499. </dd>
  1500. </div>
  1501. <div id="NimNodeKinds">
  1502. <dt><pre><a href="macros.html#NimNodeKinds"><span class="Identifier">NimNodeKinds</span></a> <span class="Other">=</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a><span class="Other">]</span></pre></dt>
  1503. <dd>
  1504. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L99" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1505. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L99" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1506. </dd>
  1507. </div>
  1508. <div id="NimSym">
  1509. <dt><pre><a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Identifier">NimSymObj</span></pre></dt>
  1510. <dd>
  1511. <div class="deprecation-message">
  1512. <b>Deprecated</b>
  1513. </div>
  1514. Represents a Nim <em>symbol</em> in the compiler; a <em>symbol</em> is a looked-up <em>ident</em>.
  1515. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L143" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1516. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L143" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1517. </dd>
  1518. </div>
  1519. <div id="NimSymKind">
  1520. <dt><pre><a href="macros.html#NimSymKind"><span class="Identifier">NimSymKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  1521. <span class="Identifier">nskUnknown</span><span class="Other">,</span> <span class="Identifier">nskConditional</span><span class="Other">,</span> <span class="Identifier">nskDynLib</span><span class="Other">,</span> <span class="Identifier">nskParam</span><span class="Other">,</span> <span class="Identifier">nskGenericParam</span><span class="Other">,</span> <span class="Identifier">nskTemp</span><span class="Other">,</span>
  1522. <span class="Identifier">nskModule</span><span class="Other">,</span> <span class="Identifier">nskType</span><span class="Other">,</span> <span class="Identifier">nskVar</span><span class="Other">,</span> <span class="Identifier">nskLet</span><span class="Other">,</span> <span class="Identifier">nskConst</span><span class="Other">,</span> <span class="Identifier">nskResult</span><span class="Other">,</span> <span class="Identifier">nskProc</span><span class="Other">,</span> <span class="Identifier">nskFunc</span><span class="Other">,</span>
  1523. <span class="Identifier">nskMethod</span><span class="Other">,</span> <span class="Identifier">nskIterator</span><span class="Other">,</span> <span class="Identifier">nskConverter</span><span class="Other">,</span> <span class="Identifier">nskMacro</span><span class="Other">,</span> <span class="Identifier">nskTemplate</span><span class="Other">,</span> <span class="Identifier">nskField</span><span class="Other">,</span>
  1524. <span class="Identifier">nskEnumField</span><span class="Other">,</span> <span class="Identifier">nskForVar</span><span class="Other">,</span> <span class="Identifier">nskLabel</span><span class="Other">,</span> <span class="Identifier">nskStub</span></pre></dt>
  1525. <dd>
  1526. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L121" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1527. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L121" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1528. </dd>
  1529. </div>
  1530. <div id="NimTypeKind">
  1531. <dt><pre><a href="macros.html#NimTypeKind"><span class="Identifier">NimTypeKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  1532. <span class="Identifier">ntyNone</span><span class="Other">,</span> <span class="Identifier">ntyBool</span><span class="Other">,</span> <span class="Identifier">ntyChar</span><span class="Other">,</span> <span class="Identifier">ntyEmpty</span><span class="Other">,</span> <span class="Identifier">ntyAlias</span><span class="Other">,</span> <span class="Identifier">ntyNil</span><span class="Other">,</span> <span class="Identifier">ntyExpr</span><span class="Other">,</span> <span class="Identifier">ntyStmt</span><span class="Other">,</span>
  1533. <span class="Identifier">ntyTypeDesc</span><span class="Other">,</span> <span class="Identifier">ntyGenericInvocation</span><span class="Other">,</span> <span class="Identifier">ntyGenericBody</span><span class="Other">,</span> <span class="Identifier">ntyGenericInst</span><span class="Other">,</span>
  1534. <span class="Identifier">ntyGenericParam</span><span class="Other">,</span> <span class="Identifier">ntyDistinct</span><span class="Other">,</span> <span class="Identifier">ntyEnum</span><span class="Other">,</span> <span class="Identifier">ntyOrdinal</span><span class="Other">,</span> <span class="Identifier">ntyArray</span><span class="Other">,</span> <span class="Identifier">ntyObject</span><span class="Other">,</span>
  1535. <span class="Identifier">ntyTuple</span><span class="Other">,</span> <span class="Identifier">ntySet</span><span class="Other">,</span> <span class="Identifier">ntyRange</span><span class="Other">,</span> <span class="Identifier">ntyPtr</span><span class="Other">,</span> <span class="Identifier">ntyRef</span><span class="Other">,</span> <span class="Identifier">ntyVar</span><span class="Other">,</span> <span class="Identifier">ntySequence</span><span class="Other">,</span> <span class="Identifier">ntyProc</span><span class="Other">,</span>
  1536. <span class="Identifier">ntyPointer</span><span class="Other">,</span> <span class="Identifier">ntyOpenArray</span><span class="Other">,</span> <span class="Identifier">ntyString</span><span class="Other">,</span> <span class="Identifier">ntyCString</span><span class="Other">,</span> <span class="Identifier">ntyForward</span><span class="Other">,</span> <span class="Identifier">ntyInt</span><span class="Other">,</span> <span class="Identifier">ntyInt8</span><span class="Other">,</span>
  1537. <span class="Identifier">ntyInt16</span><span class="Other">,</span> <span class="Identifier">ntyInt32</span><span class="Other">,</span> <span class="Identifier">ntyInt64</span><span class="Other">,</span> <span class="Identifier">ntyFloat</span><span class="Other">,</span> <span class="Identifier">ntyFloat32</span><span class="Other">,</span> <span class="Identifier">ntyFloat64</span><span class="Other">,</span> <span class="Identifier">ntyFloat128</span><span class="Other">,</span>
  1538. <span class="Identifier">ntyUInt</span><span class="Other">,</span> <span class="Identifier">ntyUInt8</span><span class="Other">,</span> <span class="Identifier">ntyUInt16</span><span class="Other">,</span> <span class="Identifier">ntyUInt32</span><span class="Other">,</span> <span class="Identifier">ntyUInt64</span><span class="Other">,</span> <span class="Identifier">ntyUnused0</span><span class="Other">,</span> <span class="Identifier">ntyUnused1</span><span class="Other">,</span>
  1539. <span class="Identifier">ntyUnused2</span><span class="Other">,</span> <span class="Identifier">ntyVarargs</span><span class="Other">,</span> <span class="Identifier">ntyUncheckedArray</span><span class="Other">,</span> <span class="Identifier">ntyError</span><span class="Other">,</span> <span class="Identifier">ntyBuiltinTypeClass</span><span class="Other">,</span>
  1540. <span class="Identifier">ntyUserTypeClass</span><span class="Other">,</span> <span class="Identifier">ntyUserTypeClassInst</span><span class="Other">,</span> <span class="Identifier">ntyCompositeTypeClass</span><span class="Other">,</span> <span class="Identifier">ntyInferred</span><span class="Other">,</span>
  1541. <span class="Identifier">ntyAnd</span><span class="Other">,</span> <span class="Identifier">ntyOr</span><span class="Other">,</span> <span class="Identifier">ntyNot</span><span class="Other">,</span> <span class="Identifier">ntyAnything</span><span class="Other">,</span> <span class="Identifier">ntyStatic</span><span class="Other">,</span> <span class="Identifier">ntyFromExpr</span><span class="Other">,</span> <span class="Identifier">ntyOptDeprecated</span><span class="Other">,</span>
  1542. <span class="Identifier">ntyVoid</span></pre></dt>
  1543. <dd>
  1544. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L100" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1545. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L100" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1546. </dd>
  1547. </div>
  1548. <div id="TNimSymKinds">
  1549. <dt><pre><a href="macros.html#TNimSymKinds"><span class="Identifier">TNimSymKinds</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="macros.html#NimSymKind"><span class="Identifier">NimSymKind</span></a><span class="Other">]</span></pre></dt>
  1550. <dd>
  1551. <div class="deprecation-message">
  1552. <b>Deprecated</b>
  1553. </div>
  1554. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L130" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1555. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L130" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1556. </dd>
  1557. </div>
  1558. <div id="TNimTypeKinds">
  1559. <dt><pre><a href="macros.html#TNimTypeKinds"><span class="Identifier">TNimTypeKinds</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="macros.html#NimTypeKind"><span class="Identifier">NimTypeKind</span></a><span class="Other">]</span></pre></dt>
  1560. <dd>
  1561. <div class="deprecation-message">
  1562. <b>Deprecated</b>
  1563. </div>
  1564. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L120" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1565. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L120" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1566. </dd>
  1567. </div>
  1568. </dl>
  1569. </div>
  1570. <div class="section" id="10">
  1571. <h1><a class="toc-backref" href="#10">Consts</a></h1>
  1572. <dl class="item">
  1573. <div id="AtomicNodes">
  1574. <dt><pre><a href="macros.html#AtomicNodes"><span class="Identifier">AtomicNodes</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nnkNone</span><span class="Other">..</span><span class="DecNumber">nnkNilLit</span><span class="Other">}</span></pre></dt>
  1575. <dd>
  1576. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1217" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1577. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1217" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1578. </dd>
  1579. </div>
  1580. <div id="CallNodes">
  1581. <dt><pre><a href="macros.html#CallNodes"><span class="Identifier">CallNodes</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nnkCall</span><span class="Other">,</span> <span class="DecNumber">nnkInfix</span><span class="Other">,</span> <span class="DecNumber">nnkPrefix</span><span class="Other">,</span> <span class="DecNumber">nnkPostfix</span><span class="Other">,</span> <span class="DecNumber">nnkCommand</span><span class="Other">,</span>
  1582. <span class="DecNumber">nnkCallStrLit</span><span class="Other">,</span> <span class="DecNumber">nnkHiddenCallConv</span><span class="Other">}</span></pre></dt>
  1583. <dd>
  1584. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1219" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1585. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1219" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1586. </dd>
  1587. </div>
  1588. <div id="nnkCallKinds">
  1589. <dt><pre><a href="macros.html#nnkCallKinds"><span class="Identifier">nnkCallKinds</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nnkCall</span><span class="Other">,</span> <span class="DecNumber">nnkInfix</span><span class="Other">,</span> <span class="DecNumber">nnkPrefix</span><span class="Other">,</span> <span class="DecNumber">nnkPostfix</span><span class="Other">,</span> <span class="DecNumber">nnkCommand</span><span class="Other">,</span>
  1590. <span class="DecNumber">nnkCallStrLit</span><span class="Other">,</span> <span class="DecNumber">nnkHiddenCallConv</span><span class="Other">}</span></pre></dt>
  1591. <dd>
  1592. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L151" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1593. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L151" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1594. </dd>
  1595. </div>
  1596. <div id="nnkLiterals">
  1597. <dt><pre><a href="macros.html#nnkLiterals"><span class="Identifier">nnkLiterals</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nnkCharLit</span><span class="Other">..</span><span class="DecNumber">nnkNilLit</span><span class="Other">}</span></pre></dt>
  1598. <dd>
  1599. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L149" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1600. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L149" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1601. </dd>
  1602. </div>
  1603. <div id="nnkMutableTy">
  1604. <dt><pre><a href="macros.html#nnkMutableTy"><span class="Identifier">nnkMutableTy</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <span class="DecNumber">nnkOutTy</span></pre></dt>
  1605. <dd>
  1606. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L133" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1607. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L133" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1608. </dd>
  1609. </div>
  1610. <div id="nnkSharedTy">
  1611. <dt><pre><a href="macros.html#nnkSharedTy"><span class="Identifier">nnkSharedTy</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span></span>.} <span class="Other">=</span> <span class="DecNumber">nnkSinkAsgn</span></pre></dt>
  1612. <dd>
  1613. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L134" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1614. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L134" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1615. </dd>
  1616. </div>
  1617. <div id="RoutineNodes">
  1618. <dt><pre><a href="macros.html#RoutineNodes"><span class="Identifier">RoutineNodes</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nnkProcDef</span><span class="Other">,</span> <span class="DecNumber">nnkFuncDef</span><span class="Other">,</span> <span class="DecNumber">nnkMethodDef</span><span class="Other">,</span> <span class="DecNumber">nnkDo</span><span class="Other">,</span> <span class="DecNumber">nnkLambda</span><span class="Other">,</span>
  1619. <span class="DecNumber">nnkIteratorDef</span><span class="Other">,</span> <span class="DecNumber">nnkTemplateDef</span><span class="Other">,</span> <span class="DecNumber">nnkConverterDef</span><span class="Other">,</span> <span class="DecNumber">nnkMacroDef</span><span class="Other">}</span></pre></dt>
  1620. <dd>
  1621. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1215" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1622. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1215" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1623. </dd>
  1624. </div>
  1625. </dl>
  1626. </div>
  1627. <div class="section" id="12">
  1628. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  1629. <dl class="item">
  1630. <div id="$-procs-all">
  1631. <div id="$,LineInfo">
  1632. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CLineInfo"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="macros.html#LineInfo"><span class="Identifier">LineInfo</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1633. <dd>
  1634. Return a string representation in the form <tt class="docutils literal"><span class="pre"><span class="Identifier">filepath</span><span class="Punctuation">(</span><span class="Identifier">line</span><span class="Punctuation">,</span> <span class="Identifier">column</span><span class="Punctuation">)</span></span></tt>.
  1635. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L529" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1636. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L529" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1637. </dd>
  1638. </div>
  1639. <div id="$,NimIdent">
  1640. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CNimIdent"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NStrVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Use \'strVal\' instead.&quot;</span><span class="Other">,</span>
  1641. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1642. <dd>
  1643. <div class="deprecation-message">
  1644. <b>Deprecated:</b> Deprecated since version 0.18.1; Use &apos;strVal&apos; instead.
  1645. </div>
  1646. Converts a Nim identifier to a string.
  1647. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L265" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1648. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L265" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1649. </dd>
  1650. </div>
  1651. <div id="$,NimNode">
  1652. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CNimNode"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1653. <dd>
  1654. Get the string of an identifier node.
  1655. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1405" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1656. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1405" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1657. </dd>
  1658. </div>
  1659. <div id="$,NimSym">
  1660. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CNimSym"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NStrVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Use \'strVal\' instead.&quot;</span><span class="Other">,</span>
  1661. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1662. <dd>
  1663. <div class="deprecation-message">
  1664. <b>Deprecated:</b> Deprecated since version 0.18.1; Use &apos;strVal&apos; instead.
  1665. </div>
  1666. Converts a Nim symbol to a string.
  1667. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L269" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1668. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L269" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1669. </dd>
  1670. </div>
  1671. </div>
  1672. <div id="==-procs-all">
  1673. <div id="==,NimIdent,NimIdent">
  1674. <dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CNimIdent%2CNimIdent"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Use \'==\' on \'NimNode\' instead.&quot;</span><span class="Other">,</span>
  1675. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1676. <dd>
  1677. <div class="deprecation-message">
  1678. <b>Deprecated:</b> Deprecated since version 0.18.1; Use &apos;==&apos; on &apos;NimNode&apos; instead.
  1679. </div>
  1680. Compares two Nim identifiers.
  1681. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L161" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1682. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L161" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1683. </dd>
  1684. </div>
  1685. <div id="==,NimNode,NimNode">
  1686. <dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CNimNode%2CNimNode"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqNimrodNode&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1687. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1688. <dd>
  1689. Compare two Nim nodes. Return true if nodes are structurally equivalent. This means two independently created nodes can be equal.
  1690. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L165" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1691. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L165" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1692. </dd>
  1693. </div>
  1694. <div id="==,NimSym,NimSym">
  1695. <dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CNimSym%2CNimSym"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqNimrodNode&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Use \'==(NimNode, NimNode)\' instead.&quot;</span><span class="Other">,</span>
  1696. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1697. <dd>
  1698. <div class="deprecation-message">
  1699. <b>Deprecated:</b> Deprecated since version 0.18.1; Use &apos;==(NimNode, NimNode)&apos; instead.
  1700. </div>
  1701. Compares two Nim symbols.
  1702. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L169" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1703. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L169" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1704. </dd>
  1705. </div>
  1706. </div>
  1707. <div id="[]-procs-all">
  1708. <div id="[],NimNode,BackwardsIndex">
  1709. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CNimNode%2CBackwardsIndex"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#BackwardsIndex"><span class="Identifier">BackwardsIndex</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1710. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1711. <dd>
  1712. Get <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child.
  1713. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L186" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1714. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L186" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1715. </dd>
  1716. </div>
  1717. <div id="[],NimNode,int">
  1718. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CNimNode%2Cint"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NChild&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1719. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1720. <dd>
  1721. Get <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child.
  1722. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L183" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1723. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L183" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1724. </dd>
  1725. </div>
  1726. <div id="[],NimNode,HSlice[T: Ordinal,U: Ordinal]">
  1727. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CNimNode%2CHSlice%5BT%3A%20Ordinal%2CU%3A%20Ordinal%5D"><span class="Identifier">`[]`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">U</span><span class="Other">:</span> <a href="system.html#Ordinal"><span class="Identifier">Ordinal</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#HSlice"><span class="Identifier">HSlice</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">U</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span></pre></dt>
  1728. <dd>
  1729. Slice operation for NimNode. Returns a seq of child of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> who inclusive range <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Identifier">n</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">a</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">n</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">b</span><span class="Punctuation">]</span><span class="Punctuation">]</span></span></tt>.
  1730. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L192" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1731. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L192" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1732. </dd>
  1733. </div>
  1734. </div>
  1735. <div id="[]=-procs-all">
  1736. <div id="[]=,NimNode,BackwardsIndex,NimNode">
  1737. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%3D%2CNimNode%2CBackwardsIndex%2CNimNode"><span class="Identifier">`[]=`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#BackwardsIndex"><span class="Identifier">BackwardsIndex</span></a><span class="Other">;</span> <span class="Identifier">child</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1738. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1739. <dd>
  1740. Set <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child to <tt class="docutils literal"><span class="pre"><span class="Identifier">child</span></span></tt>.
  1741. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L205" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1742. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L205" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1743. </dd>
  1744. </div>
  1745. <div id="[]=,NimNode,int,NimNode">
  1746. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%3D%2CNimNode%2Cint%2CNimNode"><span class="Identifier">`[]=`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">child</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetChild&quot;</span><span class="Other">,</span>
  1747. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1748. <dd>
  1749. Set <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child to <tt class="docutils literal"><span class="pre"><span class="Identifier">child</span></span></tt>.
  1750. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L201" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1751. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L201" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1752. </dd>
  1753. </div>
  1754. </div>
  1755. <div id="add-procs-all">
  1756. <div id="add,NimNode,NimNode">
  1757. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CNimNode%2CNimNode"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">,</span> <span class="Identifier">child</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NAdd&quot;</span><span class="Other">,</span> <span class="Identifier">discardable</span><span class="Other">,</span>
  1758. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1759. <dd>
  1760. Adds the <tt class="docutils literal"><span class="pre"><span class="Identifier">child</span></span></tt> to the <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> node. Returns the father node so that calls can be nested.
  1761. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L223" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1762. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L223" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1763. </dd>
  1764. </div>
  1765. <div id="add,NimNode,varargs[NimNode]">
  1766. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CNimNode%2Cvarargs%5BNimNode%5D"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">children</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  1767. <span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NAddMultiple&quot;</span><span class="Other">,</span> <span class="Identifier">discardable</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1768. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1769. <dd>
  1770. Adds each child of <tt class="docutils literal"><span class="pre"><span class="Identifier">children</span></span></tt> to the <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> node. Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> node so that calls can be nested.
  1771. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L228" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1772. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L228" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1773. </dd>
  1774. </div>
  1775. </div>
  1776. <div id="addIdentIfAbsent-procs-all">
  1777. <div id="addIdentIfAbsent,NimNode,string">
  1778. <dt><pre><span class="Keyword">proc</span> <a href="#addIdentIfAbsent%2CNimNode%2Cstring"><span class="Identifier">addIdentIfAbsent</span></a><span class="Other">(</span><span class="Identifier">dest</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">ident</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1779. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1780. <dd>
  1781. Add <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> if it is not present. This is intended for use with pragmas.
  1782. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1518" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1783. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1518" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1784. </dd>
  1785. </div>
  1786. </div>
  1787. <div id="addPragma-procs-all">
  1788. <div id="addPragma,NimNode,NimNode">
  1789. <dt><pre><span class="Keyword">proc</span> <a href="#addPragma%2CNimNode%2CNimNode"><span class="Identifier">addPragma</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">,</span> <span class="Identifier">pragma</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1790. <dd>
  1791. Adds pragma to routine definition.
  1792. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1361" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1793. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1361" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1794. </dd>
  1795. </div>
  1796. </div>
  1797. <div id="astGenRepr-procs-all">
  1798. <div id="astGenRepr,NimNode">
  1799. <dt><pre><span class="Keyword">proc</span> <a href="#astGenRepr%2CNimNode"><span class="Identifier">astGenRepr</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1800. <dd>
  1801. <p>Convert the AST <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> to the code required to generate that AST.</p>
  1802. <p>See also <a class="reference external" href="./system.html#repr,HSlice[T,U]">system: repr</a>, <a class="reference internal nimdoc" title="proc treeRepr(n: NimNode): string" href="#treeRepr,NimNode">treeRepr</a>, and <a class="reference internal nimdoc" title="proc lispRepr(n: NimNode; indented = false): string" href="#lispRepr,NimNode">lispRepr</a>.</p>
  1803. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L999" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1804. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L999" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1805. </dd>
  1806. </div>
  1807. </div>
  1808. <div id="basename-procs-all">
  1809. <div id="basename,NimNode">
  1810. <dt><pre><span class="Keyword">proc</span> <a href="#basename%2CNimNode"><span class="Identifier">basename</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1811. <dd>
  1812. Pull an identifier from prefix/postfix expressions.
  1813. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1395" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1814. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1395" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1815. </dd>
  1816. </div>
  1817. </div>
  1818. <div id="basename=-procs-all">
  1819. <div id="basename=,NimNode,string">
  1820. <dt><pre><span class="Keyword">proc</span> <a href="#basename%3D%2CNimNode%2Cstring"><span class="Identifier">basename=</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1821. <dd>
  1822. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1465" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1823. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1465" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1824. </dd>
  1825. </div>
  1826. </div>
  1827. <div id="bindSym-procs-all">
  1828. <div id="bindSym,,BindSymRule">
  1829. <dt><pre><span class="Keyword">proc</span> <a href="#bindSym%2C%2CBindSymRule"><span class="Identifier">bindSym</span></a><span class="Other">(</span><span class="Identifier">ident</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Operator">|</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">rule</span><span class="Other">:</span> <a href="macros.html#BindSymRule"><span class="Identifier">BindSymRule</span></a> <span class="Other">=</span> <span class="Identifier">brClosed</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  1830. <span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NBindSym&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1831. <dd>
  1832. <p>Creates a node that binds <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> to a symbol node. The bound symbol may be an overloaded symbol. if <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> is a NimNode, it must have <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkIdent</span></span></tt> kind. If <tt class="docutils literal"><span class="pre"><span class="Identifier">rule</span> <span class="Operator">==</span> <span class="Identifier">brClosed</span></span></tt> either an <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkClosedSymChoice</span></span></tt> tree is returned or <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkSym</span></span></tt> if the symbol is not ambiguous. If <tt class="docutils literal"><span class="pre"><span class="Identifier">rule</span> <span class="Operator">==</span> <span class="Identifier">brOpen</span></span></tt> either an <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkOpenSymChoice</span></span></tt> tree is returned or <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkSym</span></span></tt> if the symbol is not ambiguous. If <tt class="docutils literal"><span class="pre"><span class="Identifier">rule</span> <span class="Operator">==</span> <span class="Identifier">brForceOpen</span></span></tt> always an <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkOpenSymChoice</span></span></tt> tree is returned even if the symbol is not ambiguous.</p>
  1833. <p>See the <a class="reference external" href="manual.html#macros-bindsym">manual</a> for more details.</p>
  1834. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L495" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1835. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L495" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1836. </dd>
  1837. </div>
  1838. </div>
  1839. <div id="body-procs-all">
  1840. <div id="body,NimNode">
  1841. <dt><pre><span class="Keyword">proc</span> <a href="#body%2CNimNode"><span class="Identifier">body</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1842. <dd>
  1843. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1373" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1844. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1373" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1845. </dd>
  1846. </div>
  1847. </div>
  1848. <div id="body=-procs-all">
  1849. <div id="body=,NimNode,NimNode">
  1850. <dt><pre><span class="Keyword">proc</span> <a href="#body%3D%2CNimNode%2CNimNode"><span class="Identifier">body=</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1851. <dd>
  1852. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1384" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1853. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1384" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1854. </dd>
  1855. </div>
  1856. </div>
  1857. <div id="boolVal-procs-all">
  1858. <div id="boolVal,NimNode">
  1859. <dt><pre><span class="Keyword">proc</span> <a href="#boolVal%2CNimNode"><span class="Identifier">boolVal</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1860. <dd>
  1861. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1530" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1862. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1530" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1863. </dd>
  1864. </div>
  1865. </div>
  1866. <div id="callsite-procs-all">
  1867. <div id="callsite">
  1868. <dt><pre><span class="Keyword">proc</span> <a href="#callsite"><span class="Identifier">callsite</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NCallSite&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since v0.18.1; use `varargs[untyped]` in the macro prototype instead&quot;</span><span class="Other">,</span>
  1869. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1870. <dd>
  1871. <div class="deprecation-message">
  1872. <b>Deprecated:</b> Deprecated since v0.18.1; use `varargs[untyped]` in the macro prototype instead
  1873. </div>
  1874. Returns the AST of the invocation expression that invoked this macro.
  1875. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L514" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1876. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L514" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1877. </dd>
  1878. </div>
  1879. </div>
  1880. <div id="copy-procs-all">
  1881. <div id="copy,NimNode">
  1882. <dt><pre><span class="Keyword">proc</span> <a href="#copy%2CNimNode"><span class="Identifier">copy</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1883. <dd>
  1884. An alias for <a class="reference external" href="#copyNimTree,NimNode">copyNimTree</a>.
  1885. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1498" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1886. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1498" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1887. </dd>
  1888. </div>
  1889. </div>
  1890. <div id="copyChildrenTo-procs-all">
  1891. <div id="copyChildrenTo,NimNode,NimNode">
  1892. <dt><pre><span class="Keyword">proc</span> <a href="#copyChildrenTo%2CNimNode%2CNimNode"><span class="Identifier">copyChildrenTo</span></a><span class="Other">(</span><span class="Identifier">src</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1893. <dd>
  1894. Copy all children from <tt class="docutils literal"><span class="pre"><span class="Identifier">src</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt>.
  1895. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1304" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1896. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1304" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1897. </dd>
  1898. </div>
  1899. </div>
  1900. <div id="copyLineInfo-procs-all">
  1901. <div id="copyLineInfo,NimNode,NimNode">
  1902. <dt><pre><span class="Keyword">proc</span> <a href="#copyLineInfo%2CNimNode%2CNimNode"><span class="Identifier">copyLineInfo</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">info</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NLineInfo&quot;</span><span class="Other">,</span>
  1903. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1904. <dd>
  1905. Copy lineinfo from <tt class="docutils literal"><span class="pre"><span class="Identifier">info</span></span></tt>.
  1906. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L542" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1907. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L542" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1908. </dd>
  1909. </div>
  1910. </div>
  1911. <div id="copyNimNode-procs-all">
  1912. <div id="copyNimNode,NimNode">
  1913. <dt><pre><span class="Keyword">proc</span> <a href="#copyNimNode%2CNimNode"><span class="Identifier">copyNimNode</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NCopyNimNode&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1914. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1915. <dd>
  1916. Creates a new AST node by copying the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>. Note that unlike <tt class="docutils literal"><span class="pre"><span class="Identifier">copyNimTree</span></span></tt>, child nodes of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> are not copied.
  1917. <p><strong class="examples_text">Example:</strong></p>
  1918. <pre class="listing"><span class="Keyword">macro</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  1919. <span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">copyNimNode</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">)</span>
  1920. <span class="Identifier">doAssert</span> <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  1921. <span class="Identifier">doAssert</span> <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">nnkStmtList</span>
  1922. <span class="Identifier">foo</span><span class="Punctuation">:</span>
  1923. <span class="Keyword">let</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="DecNumber">12</span>
  1924. <span class="Identifier">echo</span> <span class="Identifier">x</span></pre>
  1925. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L405" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1926. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L405" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1927. </dd>
  1928. </div>
  1929. </div>
  1930. <div id="copyNimTree-procs-all">
  1931. <div id="copyNimTree,NimNode">
  1932. <dt><pre><span class="Keyword">proc</span> <a href="#copyNimTree%2CNimNode"><span class="Identifier">copyNimTree</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NCopyNimTree&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1933. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1934. <dd>
  1935. Creates a new AST node by recursively copying the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>. Note that unlike <tt class="docutils literal"><span class="pre"><span class="Identifier">copyNimNode</span></span></tt>, this copies <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>, the children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>, etc.
  1936. <p><strong class="examples_text">Example:</strong></p>
  1937. <pre class="listing"><span class="Keyword">macro</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  1938. <span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">copyNimTree</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">)</span>
  1939. <span class="Identifier">doAssert</span> <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  1940. <span class="Identifier">doAssert</span> <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">nnkStmtList</span>
  1941. <span class="Identifier">foo</span><span class="Punctuation">:</span>
  1942. <span class="Keyword">let</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="DecNumber">12</span>
  1943. <span class="Identifier">echo</span> <span class="Identifier">x</span></pre>
  1944. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L418" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1945. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L418" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1946. </dd>
  1947. </div>
  1948. </div>
  1949. <div id="del-procs-all">
  1950. <div id="del,NimNode,int,int">
  1951. <dt><pre><span class="Keyword">proc</span> <a href="#del%2CNimNode%2Cint%2Cint"><span class="Identifier">del</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">idx</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">n</span> <span class="Other">=</span> <span class="DecNumber">1</span><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NDel&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1952. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1953. <dd>
  1954. Deletes <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> children of <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> starting at index <tt class="docutils literal"><span class="pre"><span class="Identifier">idx</span></span></tt>.
  1955. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L233" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1956. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L233" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1957. </dd>
  1958. </div>
  1959. </div>
  1960. <div id="eqIdent-procs-all">
  1961. <div id="eqIdent,NimNode,NimNode">
  1962. <dt><pre><span class="Keyword">proc</span> <a href="#eqIdent%2CNimNode%2CNimNode"><span class="Identifier">eqIdent</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1963. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1964. <dd>
  1965. Style insensitive comparison. <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> can be an identifier or a symbol. Both may be wrapped in an export marker (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkPostfix</span></span></tt>) or quoted with backticks (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkAccQuoted</span></span></tt>), these nodes will be unwrapped.
  1966. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L928" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1967. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L928" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1968. </dd>
  1969. </div>
  1970. <div id="eqIdent,NimNode,string">
  1971. <dt><pre><span class="Keyword">proc</span> <a href="#eqIdent%2CNimNode%2Cstring"><span class="Identifier">eqIdent</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1972. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1973. <dd>
  1974. Style insensitive comparison. <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> can be an identifier or a symbol. <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> may be wrapped in an export marker (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkPostfix</span></span></tt>) or quoted with backticks (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkAccQuoted</span></span></tt>), these nodes will be unwrapped.
  1975. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L916" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1976. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L916" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1977. </dd>
  1978. </div>
  1979. <div id="eqIdent,string,NimNode">
  1980. <dt><pre><span class="Keyword">proc</span> <a href="#eqIdent%2Cstring%2CNimNode"><span class="Identifier">eqIdent</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1981. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1982. <dd>
  1983. Style insensitive comparison. <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> can be an identifier or a symbol. <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> may be wrapped in an export marker (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkPostfix</span></span></tt>) or quoted with backticks (<tt class="docutils literal"><span class="pre"><span class="Identifier">nnkAccQuoted</span></span></tt>), these nodes will be unwrapped.
  1984. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L922" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1985. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L922" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1986. </dd>
  1987. </div>
  1988. <div id="eqIdent,string,string">
  1989. <dt><pre><span class="Keyword">proc</span> <a href="#eqIdent%2Cstring%2Cstring"><span class="Identifier">eqIdent</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;EqIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  1990. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1991. <dd>
  1992. Style insensitive comparison.
  1993. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L913" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1994. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L913" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1995. </dd>
  1996. </div>
  1997. </div>
  1998. <div id="error-procs-all">
  1999. <div id="error,string,NimNode">
  2000. <dt><pre><span class="Keyword">proc</span> <a href="#error%2Cstring%2CNimNode"><span class="Identifier">error</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NError&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> </span><span class="Identifier">noreturn</span><span class="Other">,</span>
  2001. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2002. <dd>
  2003. Writes an error message at compile time. The optional <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span><span class="Punctuation">:</span> <span class="Identifier">NimNode</span></span></tt> parameter is used as the source for file and line number information in the compilation error message.
  2004. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L436" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2005. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L436" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2006. </dd>
  2007. </div>
  2008. </div>
  2009. <div id="expectIdent-procs-all">
  2010. <div id="expectIdent,NimNode,string">
  2011. <dt><pre><span class="Keyword">proc</span> <a href="#expectIdent%2CNimNode%2Cstring"><span class="Identifier">expectIdent</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2012. <dd>
  2013. Check that <tt class="docutils literal"><span class="pre"><span class="Identifier">eqIdent</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Punctuation">,</span><span class="Identifier">name</span><span class="Punctuation">)</span></span></tt> holds true. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check the AST that is passed to them.
  2014. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1502" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2015. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1502" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2016. </dd>
  2017. </div>
  2018. </div>
  2019. <div id="expectKind-procs-all">
  2020. <div id="expectKind,NimNode,NimNodeKind">
  2021. <dt><pre><span class="Keyword">proc</span> <a href="#expectKind%2CNimNode%2CNimNodeKind"><span class="Identifier">expectKind</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">k</span><span class="Other">:</span> <a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2022. <dd>
  2023. Checks that <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> is of kind <tt class="docutils literal"><span class="pre"><span class="Identifier">k</span></span></tt>. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check the AST that is passed to them.
  2024. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L687" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2025. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L687" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2026. </dd>
  2027. </div>
  2028. <div id="expectKind,NimNode,set[NimNodeKind]">
  2029. <dt><pre><span class="Keyword">proc</span> <a href="#expectKind%2CNimNode%2Cset%5BNimNodeKind%5D"><span class="Identifier">expectKind</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">k</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2030. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2031. <dd>
  2032. Checks that <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> is of kind <tt class="docutils literal"><span class="pre"><span class="Identifier">k</span></span></tt>. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check the AST that is passed to them.
  2033. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1221" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2034. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1221" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2035. </dd>
  2036. </div>
  2037. </div>
  2038. <div id="expectLen-procs-all">
  2039. <div id="expectLen,NimNode,int">
  2040. <dt><pre><span class="Keyword">proc</span> <a href="#expectLen%2CNimNode%2Cint"><span class="Identifier">expectLen</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2041. <dd>
  2042. Checks that <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> has exactly <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> children. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check its number of arguments.
  2043. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L699" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2044. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L699" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2045. </dd>
  2046. </div>
  2047. <div id="expectLen,NimNode,int,int">
  2048. <dt><pre><span class="Keyword">proc</span> <a href="#expectLen%2CNimNode%2Cint%2Cint"><span class="Identifier">expectLen</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">min</span><span class="Other">,</span> <span class="Identifier">max</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2049. <dd>
  2050. Checks that <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> has a number of children in the range <tt class="docutils literal"><span class="pre"><span class="Identifier">min</span><span class="Operator">..</span><span class="Identifier">max</span></span></tt>. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check its number of arguments.
  2051. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L705" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2052. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L705" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2053. </dd>
  2054. </div>
  2055. </div>
  2056. <div id="expectMinLen-procs-all">
  2057. <div id="expectMinLen,NimNode,int">
  2058. <dt><pre><span class="Keyword">proc</span> <a href="#expectMinLen%2CNimNode%2Cint"><span class="Identifier">expectMinLen</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">min</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2059. <dd>
  2060. Checks that <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> has at least <tt class="docutils literal"><span class="pre"><span class="Identifier">min</span></span></tt> children. If this is not the case, compilation aborts with an error message. This is useful for writing macros that check its number of arguments.
  2061. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L693" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2062. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L693" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2063. </dd>
  2064. </div>
  2065. </div>
  2066. <div id="extractDocCommentsAndRunnables-procs-all">
  2067. <div id="extractDocCommentsAndRunnables,NimNode">
  2068. <dt><pre><span class="Keyword">proc</span> <a href="#extractDocCommentsAndRunnables%2CNimNode"><span class="Identifier">extractDocCommentsAndRunnables</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2069. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2070. <dd>
  2071. <p>returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkStmtList</span></span></tt> containing the top-level doc comments and runnableExamples in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>, stopping at the first child that is neither. Example:</p>
  2072. <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">macros</span>
  2073. <span class="Keyword">macro</span> <span class="Identifier">transf</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span> <span class="Operator">=</span>
  2074. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">quote</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
  2075. <span class="Keyword">proc</span> <span class="Identifier">fun2</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Keyword">discard</span>
  2076. <span class="Keyword">let</span> <span class="Identifier">header</span> <span class="Operator">=</span> <span class="Identifier">extractDocCommentsAndRunnables</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">body</span><span class="Punctuation">)</span>
  2077. <span class="Comment"># correct usage: rest is appended</span>
  2078. <span class="Identifier">result</span><span class="Operator">.</span><span class="Identifier">body</span> <span class="Operator">=</span> <span class="Identifier">header</span>
  2079. <span class="Identifier">result</span><span class="Operator">.</span><span class="Identifier">body</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">quote</span> <span class="Keyword">do</span><span class="Punctuation">:</span> <span class="Keyword">discard</span> <span class="Comment"># just an example</span>
  2080. <span class="Comment"># incorrect usage: nesting inside a nnkStmtList:</span>
  2081. <span class="Comment"># result.body = quote do: (`header`; discard)</span>
  2082. <span class="Keyword">proc</span> <span class="Identifier">fun</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">transf</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
  2083. <span class="Comment">## first comment</span>
  2084. <span class="Identifier">runnableExamples</span><span class="Punctuation">:</span> <span class="Keyword">discard</span>
  2085. <span class="Identifier">runnableExamples</span><span class="Punctuation">:</span> <span class="Keyword">discard</span>
  2086. <span class="Comment">## last comment</span>
  2087. <span class="Keyword">discard</span> <span class="Comment"># first statement after doc comments + runnableExamples</span>
  2088. <span class="Comment">## not docgen'd</span></pre></p>
  2089. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1780" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2090. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1780" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2091. </dd>
  2092. </div>
  2093. </div>
  2094. <div id="floatVal-procs-all">
  2095. <div id="floatVal,NimNode">
  2096. <dt><pre><span class="Keyword">proc</span> <a href="#floatVal%2CNimNode"><span class="Identifier">floatVal</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NFloatVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2097. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2098. <dd>
  2099. Returns a float from any floating point literal.
  2100. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L242" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2101. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L242" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2102. </dd>
  2103. </div>
  2104. </div>
  2105. <div id="floatVal=-procs-all">
  2106. <div id="floatVal=,NimNode,BiggestFloat">
  2107. <dt><pre><span class="Keyword">proc</span> <a href="#floatVal%3D%2CNimNode%2CBiggestFloat"><span class="Identifier">floatVal=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetFloatVal&quot;</span><span class="Other">,</span>
  2108. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2109. <dd>
  2110. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L374" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2111. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L374" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2112. </dd>
  2113. </div>
  2114. </div>
  2115. <div id="genSym-procs-all">
  2116. <div id="genSym,NimSymKind,string">
  2117. <dt><pre><span class="Keyword">proc</span> <a href="#genSym%2CNimSymKind%2Cstring"><span class="Identifier">genSym</span></a><span class="Other">(</span><span class="Identifier">kind</span><span class="Other">:</span> <a href="macros.html#NimSymKind"><span class="Identifier">NimSymKind</span></a> <span class="Other">=</span> <span class="Identifier">nskLet</span><span class="Other">;</span> <span class="Identifier">ident</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGenSym&quot;</span><span class="Other">,</span>
  2118. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2119. <dd>
  2120. Generates a fresh symbol that is guaranteed to be unique. The symbol needs to occur in a declaration context.
  2121. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L509" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2122. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L509" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2123. </dd>
  2124. </div>
  2125. </div>
  2126. <div id="getAlign-procs-all">
  2127. <div id="getAlign,NimNode">
  2128. <dt><pre><span class="Keyword">proc</span> <a href="#getAlign%2CNimNode"><span class="Identifier">getAlign</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSizeOf&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2129. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2130. <dd>
  2131. Returns the same result as <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">alignof</span></span></tt> if the alignment is known by the Nim compiler. It works on <tt class="docutils literal"><span class="pre"><span class="Identifier">NimNode</span></span></tt> for use in macro context. Returns a negative value if the Nim compiler does not know the alignment.
  2132. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1764" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2133. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1764" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2134. </dd>
  2135. </div>
  2136. </div>
  2137. <div id="getAst-procs-all">
  2138. <div id="getAst,untyped">
  2139. <dt><pre><span class="Keyword">proc</span> <a href="#getAst%2Cuntyped"><span class="Identifier">getAst</span></a><span class="Other">(</span><span class="Identifier">macroOrTemplate</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;ExpandToAst&quot;</span><span class="Other">,</span>
  2140. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2141. <dd>
  2142. <p>Obtains the AST nodes returned from a macro or template invocation. See also <tt class="docutils literal"><span class="pre"><span class="Identifier">genasts</span><span class="Operator">.</span><span class="Identifier">genAst</span></span></tt>. Example:</p>
  2143. <p><pre class="listing"><span class="Keyword">macro</span> <span class="Identifier">FooMacro</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  2144. <span class="Keyword">var</span> <span class="Identifier">ast</span> <span class="Operator">=</span> <span class="Identifier">getAst</span><span class="Punctuation">(</span><span class="Identifier">BarTemplate</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  2145. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L595" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2146. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L595" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2147. </dd>
  2148. </div>
  2149. </div>
  2150. <div id="getImpl-procs-all">
  2151. <div id="getImpl,NimSym">
  2152. <dt><pre><span class="Keyword">proc</span> <a href="#getImpl%2CNimSym"><span class="Identifier">getImpl</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;GetImpl&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use `getImpl: NimNode -&gt; NimNode` instead&quot;</span><span class="Other">,</span>
  2153. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2154. <dd>
  2155. <div class="deprecation-message">
  2156. <b>Deprecated:</b> use `getImpl: NimNode -&gt; NimNode` instead
  2157. </div>
  2158. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L263" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2159. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L263" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2160. </dd>
  2161. </div>
  2162. <div id="getImpl,NimNode">
  2163. <dt><pre><span class="Keyword">proc</span> <a href="#getImpl%2CNimNode"><span class="Identifier">getImpl</span></a><span class="Other">(</span><span class="Identifier">symbol</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;GetImpl&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2164. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2165. <dd>
  2166. Returns a copy of the declaration of a symbol or <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>.
  2167. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L247" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2168. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L247" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2169. </dd>
  2170. </div>
  2171. </div>
  2172. <div id="getImplTransformed-procs-all">
  2173. <div id="getImplTransformed,NimNode">
  2174. <dt><pre><span class="Keyword">proc</span> <a href="#getImplTransformed%2CNimNode"><span class="Identifier">getImplTransformed</span></a><span class="Other">(</span><span class="Identifier">symbol</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;GetImplTransf&quot;</span><span class="Other">,</span>
  2175. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2176. <dd>
  2177. For a typed proc returns the AST after transformation pass; this is useful for debugging how the compiler transforms code (e.g.: <tt class="docutils literal"><span class="pre"><span class="Keyword">defer</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Keyword">for</span></span></tt>) but note that code transformations are implementation dependent and subject to change. See an example in <tt class="docutils literal"><span class="pre"><span class="Identifier">tests</span><span class="Operator">/</span><span class="Identifier">macros</span><span class="Operator">/</span><span class="Identifier">tmacros_various</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt>.
  2178. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L276" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2179. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L276" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2180. </dd>
  2181. </div>
  2182. </div>
  2183. <div id="getOffset-procs-all">
  2184. <div id="getOffset,NimNode">
  2185. <dt><pre><span class="Keyword">proc</span> <a href="#getOffset%2CNimNode"><span class="Identifier">getOffset</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSizeOf&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2186. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2187. <dd>
  2188. Returns the same result as <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">offsetof</span></span></tt> if the offset is known by the Nim compiler. It expects a resolved symbol node from a field of a type. Therefore it only requires one argument instead of two. Returns a negative value if the Nim compiler does not know the offset.
  2189. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1769" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2190. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1769" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2191. </dd>
  2192. </div>
  2193. </div>
  2194. <div id="getProjectPath-procs-all">
  2195. <div id="getProjectPath">
  2196. <dt><pre><span class="Keyword">proc</span> <a href="#getProjectPath"><span class="Identifier">getProjectPath</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2197. <dd>
  2198. <p>Returns the path to the currently compiling project.</p>
  2199. <p>This is not to be confused with <a class="reference external" href="system.html#currentSourcePath.t">system.currentSourcePath</a> which returns the path of the source file containing that template call.</p>
  2200. <p>For example, assume a <tt class="docutils literal"><span class="pre"><span class="Identifier">dir1</span><span class="Operator">/</span><span class="Identifier">foo</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> that imports a <tt class="docutils literal"><span class="pre"><span class="Identifier">dir2</span><span class="Operator">/</span><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt>, have the <tt class="docutils literal"><span class="pre"><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> print out both <tt class="docutils literal"><span class="pre"><span class="Identifier">getProjectPath</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">currentSourcePath</span></span></tt> outputs.</p>
  2201. <p>Now when <tt class="docutils literal"><span class="pre"><span class="Identifier">foo</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> is compiled, the <tt class="docutils literal"><span class="pre"><span class="Identifier">getProjectPath</span></span></tt> from <tt class="docutils literal"><span class="pre"><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> will return the <tt class="docutils literal"><span class="pre"><span class="Identifier">dir1</span><span class="Operator">/</span></span></tt> path, while the <tt class="docutils literal"><span class="pre"><span class="Identifier">currentSourcePath</span></span></tt> will return the path to the <tt class="docutils literal"><span class="pre"><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> source file.</p>
  2202. <p>Now when <tt class="docutils literal"><span class="pre"><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> is compiled directly, the <tt class="docutils literal"><span class="pre"><span class="Identifier">getProjectPath</span></span></tt> will now return the <tt class="docutils literal"><span class="pre"><span class="Identifier">dir2</span><span class="Operator">/</span></span></tt> path, and the <tt class="docutils literal"><span class="pre"><span class="Identifier">currentSourcePath</span></span></tt> will still return the same path, the path to the <tt class="docutils literal"><span class="pre"><span class="Identifier">bar</span><span class="Operator">.</span><span class="Identifier">nim</span></span></tt> source file.</p>
  2203. <p>The path returned by this proc is set at compile time.</p>
  2204. <p>See also:</p>
  2205. <ul class="simple"><li><a class="reference external" href="os.html#getCurrentDir">getCurrentDir proc</a></li>
  2206. </ul>
  2207. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1735" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2208. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1735" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2209. </dd>
  2210. </div>
  2211. </div>
  2212. <div id="getSize-procs-all">
  2213. <div id="getSize,NimNode">
  2214. <dt><pre><span class="Keyword">proc</span> <a href="#getSize%2CNimNode"><span class="Identifier">getSize</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSizeOf&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2215. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2216. <dd>
  2217. Returns the same result as <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">sizeof</span></span></tt> if the size is known by the Nim compiler. Returns a negative value if the Nim compiler does not know the size.
  2218. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1760" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2219. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1760" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2220. </dd>
  2221. </div>
  2222. </div>
  2223. <div id="getType-procs-all">
  2224. <div id="getType,NimNode">
  2225. <dt><pre><span class="Keyword">proc</span> <a href="#getType%2CNimNode"><span class="Identifier">getType</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2226. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2227. <dd>
  2228. With 'getType' you can access the node's <span id="type_1">type</span>. A Nim type is mapped to a Nim AST too, so it's slightly confusing but it means the same API can be used to traverse types. Recursive types are flattened for you so there is no danger of infinite recursions during traversal. To resolve recursive types, you have to call 'getType' again. To see what kind of type it is, call <tt class="docutils literal"><span class="pre"><span class="Identifier">typeKind</span></span></tt> on getType's result.
  2229. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L298" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2230. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L298" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2231. </dd>
  2232. </div>
  2233. <div id="getType,typedesc">
  2234. <dt><pre><span class="Keyword">proc</span> <a href="#getType%2Ctypedesc"><span class="Identifier">getType</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#typedesc"><span class="Identifier">typedesc</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2235. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2236. <dd>
  2237. Version of <tt class="docutils literal"><span class="pre"><span class="Identifier">getType</span></span></tt> which takes a <tt class="docutils literal"><span class="pre"><span class="Identifier">typedesc</span></span></tt>.
  2238. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L306" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2239. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L306" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2240. </dd>
  2241. </div>
  2242. </div>
  2243. <div id="getTypeImpl-procs-all">
  2244. <div id="getTypeImpl,NimNode">
  2245. <dt><pre><span class="Keyword">proc</span> <a href="#getTypeImpl%2CNimNode"><span class="Identifier">getTypeImpl</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2246. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2247. <dd>
  2248. Returns the <span id="type_2">type</span> of a node in a form matching the implementation of the type. Any intermediate aliases are expanded to arrive at the final type implementation. You can instead use <tt class="docutils literal"><span class="pre"><span class="Identifier">getImpl</span></span></tt> on a symbol if you want to find the intermediate aliases.
  2249. <p><strong class="examples_text">Example:</strong></p>
  2250. <pre class="listing"><span class="Keyword">type</span>
  2251. <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="Identifier">N</span><span class="Punctuation">:</span> <span class="Keyword">static</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  2252. <span class="Identifier">arr</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="Identifier">N</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span>
  2253. <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span>
  2254. <span class="Identifier">Vec4f</span> <span class="Operator">=</span> <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">float32</span><span class="Punctuation">]</span>
  2255. <span class="Keyword">var</span> <span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">Vec4f</span>
  2256. <span class="Keyword">var</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">float32</span><span class="Punctuation">]</span>
  2257. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">float32</span><span class="Punctuation">]</span>
  2258. <span class="Keyword">macro</span> <span class="Identifier">dumpTypeImpl</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span> <span class="Operator">=</span>
  2259. <span class="Identifier">newLit</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">getTypeImpl</span><span class="Operator">.</span><span class="Identifier">repr</span><span class="Punctuation">)</span>
  2260. <span class="Keyword">let</span> <span class="Identifier">t</span> <span class="Operator">=</span> <span class="LongStringLit">&quot;&quot;&quot;
  2261. object
  2262. arr: array[0 .. 3, float32]&quot;&quot;&quot;</span>
  2263. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeImpl</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">t</span><span class="Punctuation">)</span>
  2264. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeImpl</span><span class="Punctuation">(</span><span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">t</span><span class="Punctuation">)</span>
  2265. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeImpl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">t</span><span class="Punctuation">)</span></pre>
  2266. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L334" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2267. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L334" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2268. </dd>
  2269. </div>
  2270. <div id="getTypeImpl,typedesc">
  2271. <dt><pre><span class="Keyword">proc</span> <a href="#getTypeImpl%2Ctypedesc"><span class="Identifier">getTypeImpl</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#typedesc"><span class="Identifier">typedesc</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2272. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2273. <dd>
  2274. Version of <tt class="docutils literal"><span class="pre"><span class="Identifier">getTypeImpl</span></span></tt> which takes a <tt class="docutils literal"><span class="pre"><span class="Identifier">typedesc</span></span></tt>.
  2275. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L370" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2276. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L370" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2277. </dd>
  2278. </div>
  2279. </div>
  2280. <div id="getTypeInst-procs-all">
  2281. <div id="getTypeInst,NimNode">
  2282. <dt><pre><span class="Keyword">proc</span> <a href="#getTypeInst%2CNimNode"><span class="Identifier">getTypeInst</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2283. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2284. <dd>
  2285. Returns the <span id="type_3">type</span> of a node in a form matching the way the type instance was declared in the code.
  2286. <p><strong class="examples_text">Example:</strong></p>
  2287. <pre class="listing"><span class="Keyword">type</span>
  2288. <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="Identifier">N</span><span class="Punctuation">:</span> <span class="Keyword">static</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  2289. <span class="Identifier">arr</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="Identifier">N</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span>
  2290. <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">T</span><span class="Punctuation">]</span>
  2291. <span class="Identifier">Vec4f</span> <span class="Operator">=</span> <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">float32</span><span class="Punctuation">]</span>
  2292. <span class="Keyword">var</span> <span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">Vec4f</span>
  2293. <span class="Keyword">var</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="Identifier">Vec4</span><span class="Punctuation">[</span><span class="Identifier">float32</span><span class="Punctuation">]</span>
  2294. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">Vec</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">float32</span><span class="Punctuation">]</span>
  2295. <span class="Keyword">macro</span> <span class="Identifier">dumpTypeInst</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span> <span class="Operator">=</span>
  2296. <span class="Identifier">newLit</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">getTypeInst</span><span class="Operator">.</span><span class="Identifier">repr</span><span class="Punctuation">)</span>
  2297. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeInst</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;Vec4f&quot;</span><span class="Punctuation">)</span>
  2298. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeInst</span><span class="Punctuation">(</span><span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;Vec4[float32]&quot;</span><span class="Punctuation">)</span>
  2299. <span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Identifier">dumpTypeInst</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;Vec[4, float32]&quot;</span><span class="Punctuation">)</span></pre>
  2300. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L313" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2301. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L313" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2302. </dd>
  2303. </div>
  2304. <div id="getTypeInst,typedesc">
  2305. <dt><pre><span class="Keyword">proc</span> <a href="#getTypeInst%2Ctypedesc"><span class="Identifier">getTypeInst</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#typedesc"><span class="Identifier">typedesc</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2306. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2307. <dd>
  2308. Version of <tt class="docutils literal"><span class="pre"><span class="Identifier">getTypeInst</span></span></tt> which takes a <tt class="docutils literal"><span class="pre"><span class="Identifier">typedesc</span></span></tt>.
  2309. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L331" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2310. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L331" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2311. </dd>
  2312. </div>
  2313. </div>
  2314. <div id="hasArgOfName-procs-all">
  2315. <div id="hasArgOfName,NimNode,string">
  2316. <dt><pre><span class="Keyword">proc</span> <a href="#hasArgOfName%2CNimNode%2Cstring"><span class="Identifier">hasArgOfName</span></a><span class="Other">(</span><span class="Identifier">params</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2317. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2318. <dd>
  2319. Search <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkFormalParams</span></span></tt> for an argument.
  2320. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1509" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2321. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1509" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2322. </dd>
  2323. </div>
  2324. </div>
  2325. <div id="hint-procs-all">
  2326. <div id="hint,string,NimNode">
  2327. <dt><pre><span class="Keyword">proc</span> <a href="#hint%2Cstring%2CNimNode"><span class="Identifier">hint</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NHint&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2328. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2329. <dd>
  2330. Writes a hint message at compile time.
  2331. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L444" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2332. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L444" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2333. </dd>
  2334. </div>
  2335. </div>
  2336. <div id="ident-procs-all">
  2337. <div id="ident,NimNode">
  2338. <dt><pre><span class="Keyword">proc</span> <a href="#ident%2CNimNode"><span class="Identifier">ident</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; All functionality is defined on \'NimNode\'.&quot;</span><span class="Other">,</span>
  2339. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2340. <dd>
  2341. <div class="deprecation-message">
  2342. <b>Deprecated:</b> Deprecated since version 0.18.1; All functionality is defined on &apos;NimNode&apos;.
  2343. </div>
  2344. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L257" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2345. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L257" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2346. </dd>
  2347. </div>
  2348. <div id="ident,string">
  2349. <dt><pre><span class="Keyword">proc</span> <a href="#ident%2Cstring"><span class="Identifier">ident</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;StrToIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2350. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2351. <dd>
  2352. Create a new ident node from a string.
  2353. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L480" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2354. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L480" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2355. </dd>
  2356. </div>
  2357. </div>
  2358. <div id="ident=-procs-all">
  2359. <div id="ident=,NimNode,NimIdent">
  2360. <dt><pre><span class="Keyword">proc</span> <a href="#ident%3D%2CNimNode%2CNimIdent"><span class="Identifier">ident=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Generate a new \'NimNode\' with \'ident(string)\' instead.&quot;</span><span class="Other">,</span>
  2361. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2362. <dd>
  2363. <div class="deprecation-message">
  2364. <b>Deprecated:</b> Deprecated since version 0.18.1; Generate a new &apos;NimNode&apos; with &apos;ident(string)&apos; instead.
  2365. </div>
  2366. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L381" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2367. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L381" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2368. </dd>
  2369. </div>
  2370. </div>
  2371. <div id="infix-procs-all">
  2372. <div id="infix,NimNode,string,NimNode">
  2373. <dt><pre><span class="Keyword">proc</span> <a href="#infix%2CNimNode%2Cstring%2CNimNode"><span class="Identifier">infix</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2374. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2375. <dd>
  2376. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1482" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2377. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1482" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2378. </dd>
  2379. </div>
  2380. </div>
  2381. <div id="insert-procs-all">
  2382. <div id="insert,NimNode,int,NimNode">
  2383. <dt><pre><span class="Keyword">proc</span> <a href="#insert%2CNimNode%2Cint%2CNimNode"><span class="Identifier">insert</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">pos</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2384. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2385. <dd>
  2386. Insert node <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> into node <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> at <tt class="docutils literal"><span class="pre"><span class="Identifier">pos</span></span></tt>.
  2387. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1450" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2388. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1450" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2389. </dd>
  2390. </div>
  2391. </div>
  2392. <div id="internalErrorFlag-procs-all">
  2393. <div id="internalErrorFlag">
  2394. <dt><pre><span class="Keyword">proc</span> <a href="#internalErrorFlag"><span class="Identifier">internalErrorFlag</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NError&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2395. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2396. <dd>
  2397. Some builtins set an error flag. This is then turned into a proper exception. <strong>Note</strong>: Ordinary application code should not call this.
  2398. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L575" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2399. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L575" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2400. </dd>
  2401. </div>
  2402. </div>
  2403. <div id="intVal-procs-all">
  2404. <div id="intVal,NimNode">
  2405. <dt><pre><span class="Keyword">proc</span> <a href="#intVal%2CNimNode"><span class="Identifier">intVal</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NIntVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2406. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2407. <dd>
  2408. Returns an integer value from any integer literal or enum field symbol.
  2409. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L239" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2410. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L239" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2411. </dd>
  2412. </div>
  2413. </div>
  2414. <div id="intVal=-procs-all">
  2415. <div id="intVal=,NimNode,BiggestInt">
  2416. <dt><pre><span class="Keyword">proc</span> <a href="#intVal%3D%2CNimNode%2CBiggestInt"><span class="Identifier">intVal=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetIntVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2417. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2418. <dd>
  2419. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L373" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2420. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L373" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2421. </dd>
  2422. </div>
  2423. </div>
  2424. <div id="isExported-procs-all">
  2425. <div id="isExported,NimNode">
  2426. <dt><pre><span class="Keyword">proc</span> <a href="#isExported%2CNimNode"><span class="Identifier">isExported</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2427. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2428. <dd>
  2429. Returns whether the symbol is exported or not.
  2430. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1776" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2431. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1776" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2432. </dd>
  2433. </div>
  2434. </div>
  2435. <div id="isInstantiationOf-procs-all">
  2436. <div id="isInstantiationOf,NimNode,NimNode">
  2437. <dt><pre><span class="Keyword">proc</span> <a href="#isInstantiationOf%2CNimNode%2CNimNode"><span class="Identifier">isInstantiationOf</span></a><span class="Other">(</span><span class="Identifier">instanceProcSym</span><span class="Other">,</span> <span class="Identifier">genProcSym</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
  2438. <span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;SymIsInstantiationOf&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2439. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2440. <dd>
  2441. Checks if a proc symbol is an instance of the generic proc symbol. Useful to check proc symbols against generic symbols returned by <tt class="docutils literal"><span class="pre"><span class="Identifier">bindSym</span></span></tt>.
  2442. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L293" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2443. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L293" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2444. </dd>
  2445. </div>
  2446. </div>
  2447. <div id="kind-procs-all">
  2448. <div id="kind,NimNode">
  2449. <dt><pre><span class="Keyword">proc</span> <a href="#kind%2CNimNode"><span class="Identifier">kind</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NKind&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2450. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2451. <dd>
  2452. Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">kind</span></span></tt> of the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  2453. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L236" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2454. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L236" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2455. </dd>
  2456. </div>
  2457. </div>
  2458. <div id="last-procs-all">
  2459. <div id="last,NimNode">
  2460. <dt><pre><span class="Keyword">proc</span> <a href="#last%2CNimNode"><span class="Identifier">last</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2461. <dd>
  2462. Return the last item in nodes children. Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">node</span><span class="Punctuation">[</span><span class="Operator">^</span><span class="DecNumber">1</span><span class="Punctuation">]</span></span></tt>.
  2463. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1210" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2464. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1210" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2465. </dd>
  2466. </div>
  2467. </div>
  2468. <div id="len-procs-all">
  2469. <div id="len,NimNode">
  2470. <dt><pre><span class="Keyword">proc</span> <a href="#len%2CNimNode"><span class="Identifier">len</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NLen&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2471. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2472. <dd>
  2473. Returns the number of children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  2474. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L180" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2475. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L180" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2476. </dd>
  2477. </div>
  2478. </div>
  2479. <div id="lineInfo-procs-all">
  2480. <div id="lineInfo,NimNode">
  2481. <dt><pre><span class="Keyword">proc</span> <a href="#lineInfo%2CNimNode"><span class="Identifier">lineInfo</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2482. <dd>
  2483. Return line info in the form <tt class="docutils literal"><span class="pre"><span class="Identifier">filepath</span><span class="Punctuation">(</span><span class="Identifier">line</span><span class="Punctuation">,</span> <span class="Identifier">column</span><span class="Punctuation">)</span></span></tt>.
  2484. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L565" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2485. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L565" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2486. </dd>
  2487. </div>
  2488. </div>
  2489. <div id="lineInfoObj-procs-all">
  2490. <div id="lineInfoObj,NimNode">
  2491. <dt><pre><span class="Keyword">proc</span> <a href="#lineInfoObj%2CNimNode"><span class="Identifier">lineInfoObj</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#LineInfo"><span class="Identifier">LineInfo</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2492. <dd>
  2493. Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">LineInfo</span></span></tt> of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>, using absolute path for <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.
  2494. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L561" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2495. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L561" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2496. </dd>
  2497. </div>
  2498. </div>
  2499. <div id="lispRepr-procs-all">
  2500. <div id="lispRepr,NimNode">
  2501. <dt><pre><span class="Keyword">proc</span> <a href="#lispRepr%2CNimNode"><span class="Identifier">lispRepr</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">indented</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2502. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2503. <dd>
  2504. <p>Convert the AST <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> to a human-readable lisp-like string.</p>
  2505. <p>See also <tt class="docutils literal"><span class="pre"><span class="Identifier">repr</span></span></tt>, <a class="reference internal nimdoc" title="proc treeRepr(n: NimNode): string" href="#treeRepr,NimNode">treeRepr</a>, and <a class="reference internal nimdoc" title="proc astGenRepr(n: NimNode): string" href="#astGenRepr,NimNode">astGenRepr</a>.</p>
  2506. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L992" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2507. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L992" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2508. </dd>
  2509. </div>
  2510. </div>
  2511. <div id="name-procs-all">
  2512. <div id="name,NimNode">
  2513. <dt><pre><span class="Keyword">proc</span> <a href="#name%2CNimNode"><span class="Identifier">name</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2514. <dd>
  2515. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1312" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2516. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1312" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2517. </dd>
  2518. </div>
  2519. </div>
  2520. <div id="name=-procs-all">
  2521. <div id="name=,NimNode,NimNode">
  2522. <dt><pre><span class="Keyword">proc</span> <a href="#name%3D%2CNimNode%2CNimNode"><span class="Identifier">name=</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2523. <dd>
  2524. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1323" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2525. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1323" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2526. </dd>
  2527. </div>
  2528. </div>
  2529. <div id="nestList-procs-all">
  2530. <div id="nestList,NimNode,NimNode">
  2531. <dt><pre><span class="Keyword">proc</span> <a href="#nestList%2CNimNode%2CNimNode"><span class="Identifier">nestList</span></a><span class="Other">(</span><span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">pack</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2532. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2533. <dd>
  2534. Nests the list <tt class="docutils literal"><span class="pre"><span class="Identifier">pack</span></span></tt> into a tree of call expressions: <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">,</span> <span class="Identifier">c</span><span class="Punctuation">]</span></span></tt> is transformed into <tt class="docutils literal"><span class="pre"><span class="Identifier">op</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">op</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">d</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt>. This is also known as fold expression.
  2535. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L895" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2536. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L895" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2537. </dd>
  2538. </div>
  2539. <div id="nestList,NimNode,NimNode,NimNode">
  2540. <dt><pre><span class="Keyword">proc</span> <a href="#nestList%2CNimNode%2CNimNode%2CNimNode"><span class="Identifier">nestList</span></a><span class="Other">(</span><span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">pack</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">init</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2541. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2542. <dd>
  2543. Nests the list <tt class="docutils literal"><span class="pre"><span class="Identifier">pack</span></span></tt> into a tree of call expressions: <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">,</span> <span class="Identifier">c</span><span class="Punctuation">]</span></span></tt> is transformed into <tt class="docutils literal"><span class="pre"><span class="Identifier">op</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">op</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">d</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt>. This is also known as fold expression.
  2544. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L905" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2545. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L905" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2546. </dd>
  2547. </div>
  2548. </div>
  2549. <div id="newAssignment-procs-all">
  2550. <div id="newAssignment,NimNode,NimNode">
  2551. <dt><pre><span class="Keyword">proc</span> <a href="#newAssignment%2CNimNode%2CNimNode"><span class="Identifier">newAssignment</span></a><span class="Other">(</span><span class="Identifier">lhs</span><span class="Other">,</span> <span class="Identifier">rhs</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2552. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2553. <dd>
  2554. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1162" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2555. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1162" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2556. </dd>
  2557. </div>
  2558. </div>
  2559. <div id="newBlockStmt-procs-all">
  2560. <div id="newBlockStmt,NimNode">
  2561. <dt><pre><span class="Keyword">proc</span> <a href="#newBlockStmt%2CNimNode"><span class="Identifier">newBlockStmt</span></a><span class="Other">(</span><span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2562. <dd>
  2563. Create a new block: stmt.
  2564. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1143" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2565. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1143" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2566. </dd>
  2567. </div>
  2568. <div id="newBlockStmt,NimNode,NimNode">
  2569. <dt><pre><span class="Keyword">proc</span> <a href="#newBlockStmt%2CNimNode%2CNimNode"><span class="Identifier">newBlockStmt</span></a><span class="Other">(</span><span class="Identifier">label</span><span class="Other">,</span> <span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2570. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2571. <dd>
  2572. Create a new block statement with label.
  2573. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1139" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2574. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1139" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2575. </dd>
  2576. </div>
  2577. </div>
  2578. <div id="newCall-procs-all">
  2579. <div id="newCall,NimIdent,varargs[NimNode]">
  2580. <dt><pre><span class="Keyword">proc</span> <a href="#newCall%2CNimIdent%2Cvarargs%5BNimNode%5D"><span class="Identifier">newCall</span></a><span class="Other">(</span><span class="Identifier">theProc</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since v0.18.1; use \'newCall(string, ...)\' or \'newCall(NimNode, ...)\' instead&quot;</span><span class="Other">,</span>
  2581. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2582. <dd>
  2583. <div class="deprecation-message">
  2584. <b>Deprecated:</b> Deprecated since v0.18.1; use &apos;newCall(string, ...)&apos; or &apos;newCall(NimNode, ...)&apos; instead
  2585. </div>
  2586. Produces a new call node. <tt class="docutils literal"><span class="pre"><span class="Identifier">theProc</span></span></tt> is the proc that is called with the arguments <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span><span class="Punctuation">[</span><span class="FloatNumber">0.</span><span class="Operator">.</span><span class="Punctuation">]</span></span></tt>.
  2587. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L727" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2588. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L727" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2589. </dd>
  2590. </div>
  2591. <div id="newCall,NimNode,varargs[NimNode]">
  2592. <dt><pre><span class="Keyword">proc</span> <a href="#newCall%2CNimNode%2Cvarargs%5BNimNode%5D"><span class="Identifier">newCall</span></a><span class="Other">(</span><span class="Identifier">theProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2593. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2594. <dd>
  2595. Produces a new call node. <tt class="docutils literal"><span class="pre"><span class="Identifier">theProc</span></span></tt> is the proc that is called with the arguments <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span><span class="Punctuation">[</span><span class="FloatNumber">0.</span><span class="Operator">.</span><span class="Punctuation">]</span></span></tt>.
  2596. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L718" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2597. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L718" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2598. </dd>
  2599. </div>
  2600. <div id="newCall,string,varargs[NimNode]">
  2601. <dt><pre><span class="Keyword">proc</span> <a href="#newCall%2Cstring%2Cvarargs%5BNimNode%5D"><span class="Identifier">newCall</span></a><span class="Other">(</span><span class="Identifier">theProc</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2602. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2603. <dd>
  2604. Produces a new call node. <tt class="docutils literal"><span class="pre"><span class="Identifier">theProc</span></span></tt> is the proc that is called with the arguments <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span><span class="Punctuation">[</span><span class="FloatNumber">0.</span><span class="Operator">.</span><span class="Punctuation">]</span></span></tt>.
  2605. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L737" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2606. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L737" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2607. </dd>
  2608. </div>
  2609. </div>
  2610. <div id="newColonExpr-procs-all">
  2611. <div id="newColonExpr,NimNode,NimNode">
  2612. <dt><pre><span class="Keyword">proc</span> <a href="#newColonExpr%2CNimNode%2CNimNode"><span class="Identifier">newColonExpr</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2613. <dd>
  2614. Create new colon expression. newColonExpr(a, b) -&gt; <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">b</span></span></tt>
  2615. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1170" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2616. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1170" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2617. </dd>
  2618. </div>
  2619. </div>
  2620. <div id="newCommentStmtNode-procs-all">
  2621. <div id="newCommentStmtNode,string">
  2622. <dt><pre><span class="Keyword">proc</span> <a href="#newCommentStmtNode%2Cstring"><span class="Identifier">newCommentStmtNode</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2623. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2624. <dd>
  2625. Creates a comment statement node.
  2626. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L452" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2627. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L452" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2628. </dd>
  2629. </div>
  2630. </div>
  2631. <div id="newConstStmt-procs-all">
  2632. <div id="newConstStmt,NimNode,NimNode">
  2633. <dt><pre><span class="Keyword">proc</span> <a href="#newConstStmt%2CNimNode%2CNimNode"><span class="Identifier">newConstStmt</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2634. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2635. <dd>
  2636. Create a new const stmt.
  2637. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1157" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2638. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1157" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2639. </dd>
  2640. </div>
  2641. </div>
  2642. <div id="newDotExpr-procs-all">
  2643. <div id="newDotExpr,NimNode,NimNode">
  2644. <dt><pre><span class="Keyword">proc</span> <a href="#newDotExpr%2CNimNode%2CNimNode"><span class="Identifier">newDotExpr</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2645. <dd>
  2646. Create new dot expression. a.dot(b) -&gt; <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">b</span></span></tt>
  2647. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1165" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2648. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1165" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2649. </dd>
  2650. </div>
  2651. </div>
  2652. <div id="newEmptyNode-procs-all">
  2653. <div id="newEmptyNode">
  2654. <dt><pre><span class="Keyword">proc</span> <a href="#newEmptyNode"><span class="Identifier">newEmptyNode</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2655. <dd>
  2656. Create a new empty node.
  2657. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1122" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2658. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1122" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2659. </dd>
  2660. </div>
  2661. </div>
  2662. <div id="newEnum-procs-all">
  2663. <div id="newEnum,NimNode,openArray[NimNode],bool,bool">
  2664. <dt><pre><span class="Keyword">proc</span> <a href="#newEnum%2CNimNode%2CopenArray%5BNimNode%5D%2Cbool%2Cbool"><span class="Identifier">newEnum</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">fields</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">public</span><span class="Other">,</span> <span class="Identifier">pure</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  2665. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2666. <dd>
  2667. <p>Creates a new enum. <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt> must be an ident. Fields are allowed to be either idents or EnumFieldDef:</p>
  2668. <p><pre class="listing"><span class="Identifier">newEnum</span><span class="Punctuation">(</span>
  2669. <span class="Identifier">name</span> <span class="Operator">=</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;Colors&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  2670. <span class="Identifier">fields</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;Blue&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;Red&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
  2671. <span class="Identifier">public</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">,</span> <span class="Identifier">pure</span> <span class="Operator">=</span> <span class="Identifier">false</span><span class="Punctuation">)</span>
  2672. <span class="Comment"># type Colors* = Blue Red</span></pre></p>
  2673. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1262" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2674. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1262" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2675. </dd>
  2676. </div>
  2677. </div>
  2678. <div id="newFloatLitNode-procs-all">
  2679. <div id="newFloatLitNode,BiggestFloat">
  2680. <dt><pre><span class="Keyword">proc</span> <a href="#newFloatLitNode%2CBiggestFloat"><span class="Identifier">newFloatLitNode</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2681. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2682. <dd>
  2683. Creates a float literal node from <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>.
  2684. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L462" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2685. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L462" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2686. </dd>
  2687. </div>
  2688. </div>
  2689. <div id="newIdentDefs-procs-all">
  2690. <div id="newIdentDefs,NimNode,NimNode">
  2691. <dt><pre><span class="Keyword">proc</span> <a href="#newIdentDefs%2CNimNode%2CNimNode"><span class="Identifier">newIdentDefs</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">kind</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">default</span> <span class="Other">=</span> <span class="Identifier">newEmptyNode</span><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  2692. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2693. <dd>
  2694. <p>Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkIdentDefs</span></span></tt> node of a specific kind and value.</p>
  2695. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">nnkIdentDefs</span></span></tt> need to have at least three children, but they can have more: first comes a list of identifiers followed by a type and value nodes. This helper proc creates a three node subtree, the first subnode being a single identifier name. Both the <tt class="docutils literal"><span class="pre"><span class="Identifier">kind</span></span></tt> node and <tt class="docutils literal"><span class="pre"><span class="Identifier">default</span></span></tt> (value) nodes may be empty depending on where the <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkIdentDefs</span></span></tt> appears: tuple or object definitions will have an empty <tt class="docutils literal"><span class="pre"><span class="Identifier">default</span></span></tt> node, <tt class="docutils literal"><span class="pre"><span class="Keyword">let</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Keyword">var</span></span></tt> blocks may have an empty <tt class="docutils literal"><span class="pre"><span class="Identifier">kind</span></span></tt> node if the identifier is being assigned a value. Example:</p>
  2696. <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">varSection</span> <span class="Operator">=</span> <span class="Identifier">newNimNode</span><span class="Punctuation">(</span><span class="Identifier">nnkVarSection</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span>
  2697. <span class="Identifier">newIdentDefs</span><span class="Punctuation">(</span><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;string&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  2698. <span class="Identifier">newIdentDefs</span><span class="Punctuation">(</span><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newEmptyNode</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newLit</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  2699. <span class="Comment"># --&gt; var</span>
  2700. <span class="Comment"># a: string</span>
  2701. <span class="Comment"># b = 3</span></pre></p>
  2702. <p>If you need to create multiple identifiers you need to use the lower level <tt class="docutils literal"><span class="pre"><span class="Identifier">newNimNode</span></span></tt>:</p>
  2703. <p><pre class="listing"><span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">newNimNode</span><span class="Punctuation">(</span><span class="Identifier">nnkIdentDefs</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span>
  2704. <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;b&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;c&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">ident</span><span class="Punctuation">(</span><span class="StringLit">&quot;string&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  2705. <span class="Identifier">newStrLitNode</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  2706. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1175" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2707. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1175" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2708. </dd>
  2709. </div>
  2710. </div>
  2711. <div id="newIdentNode-procs-all">
  2712. <div id="newIdentNode,NimIdent">
  2713. <dt><pre><span class="Keyword">proc</span> <a href="#newIdentNode%2CNimIdent"><span class="Identifier">newIdentNode</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use ident(string)&quot;</span><span class="Other">,</span>
  2714. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2715. <dd>
  2716. <div class="deprecation-message">
  2717. <b>Deprecated:</b> use ident(string)
  2718. </div>
  2719. Creates an identifier node from <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>.
  2720. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L469" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2721. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L469" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2722. </dd>
  2723. </div>
  2724. <div id="newIdentNode,string">
  2725. <dt><pre><span class="Keyword">proc</span> <a href="#newIdentNode%2Cstring"><span class="Identifier">newIdentNode</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;StrToIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  2726. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2727. <dd>
  2728. Creates an identifier node from <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>. It is simply an alias for <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span><span class="Punctuation">(</span><span class="Identifier">string</span><span class="Punctuation">)</span></span></tt>. Use that, it's shorter.
  2729. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L476" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2730. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L476" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2731. </dd>
  2732. </div>
  2733. </div>
  2734. <div id="newIfStmt-procs-all">
  2735. <div id="newIfStmt,varargs[tuple[NimNode,NimNode]]">
  2736. <dt><pre><span class="Keyword">proc</span> <a href="#newIfStmt%2Cvarargs%5Btuple%5BNimNode%2CNimNode%5D%5D"><span class="Identifier">newIfStmt</span></a><span class="Other">(</span><span class="Identifier">branches</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">cond</span><span class="Other">,</span> <span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  2737. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2738. <dd>
  2739. <p>Constructor for <tt class="docutils literal"><span class="pre"><span class="Keyword">if</span></span></tt> statements.</p>
  2740. <p><pre class="listing"><span class="Identifier">newIfStmt</span><span class="Punctuation">(</span>
  2741. <span class="Punctuation">(</span><span class="Identifier">Ident</span><span class="Punctuation">,</span> <span class="Identifier">StmtList</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  2742. <span class="Operator">...</span>
  2743. <span class="Punctuation">)</span></pre></p>
  2744. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1248" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2745. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1248" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2746. </dd>
  2747. </div>
  2748. </div>
  2749. <div id="newIntLitNode-procs-all">
  2750. <div id="newIntLitNode,BiggestInt">
  2751. <dt><pre><span class="Keyword">proc</span> <a href="#newIntLitNode%2CBiggestInt"><span class="Identifier">newIntLitNode</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2752. <dd>
  2753. Creates an int literal node from <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>.
  2754. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L457" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2755. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L457" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2756. </dd>
  2757. </div>
  2758. </div>
  2759. <div id="newLetStmt-procs-all">
  2760. <div id="newLetStmt,NimNode,NimNode">
  2761. <dt><pre><span class="Keyword">proc</span> <a href="#newLetStmt%2CNimNode%2CNimNode"><span class="Identifier">newLetStmt</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2762. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2763. <dd>
  2764. Create a new let stmt.
  2765. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1152" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2766. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1152" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2767. </dd>
  2768. </div>
  2769. </div>
  2770. <div id="newLit-procs-all">
  2771. <div id="newLit">
  2772. <dt><pre><span class="Keyword">proc</span> <a href="#newLit"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Keyword">enum</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2773. <dd>
  2774. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L832" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2775. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L832" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2776. </dd>
  2777. </div>
  2778. <div id="newLit_2">
  2779. <dt><pre><span class="Keyword">proc</span> <a href="#newLit_2"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Keyword">object</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2780. <dd>
  2781. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L843" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2782. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L843" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2783. </dd>
  2784. </div>
  2785. <div id="newLit,ref.">
  2786. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cref."><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Keyword">object</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2787. <dd>
  2788. produces a new ref type literal node.
  2789. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L848" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2790. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L848" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2791. </dd>
  2792. </div>
  2793. <div id="newLit,bool">
  2794. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cbool"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2795. <dd>
  2796. Produces a new boolean literal node.
  2797. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L800" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2798. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L800" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2799. </dd>
  2800. </div>
  2801. <div id="newLit,char">
  2802. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cchar"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2803. <dd>
  2804. Produces a new character literal node.
  2805. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L745" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2806. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L745" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2807. </dd>
  2808. </div>
  2809. <div id="newLit,float32">
  2810. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cfloat32"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="system.html#float32"><span class="Identifier">float32</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2811. <dd>
  2812. Produces a new float literal node.
  2813. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L816" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2814. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L816" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2815. </dd>
  2816. </div>
  2817. <div id="newLit,float64">
  2818. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cfloat64"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="system.html#float64"><span class="Identifier">float64</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2819. <dd>
  2820. Produces a new float literal node.
  2821. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L821" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2822. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L821" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2823. </dd>
  2824. </div>
  2825. <div id="newLit,int">
  2826. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cint"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2827. <dd>
  2828. Produces a new integer literal node.
  2829. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L750" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2830. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L750" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2831. </dd>
  2832. </div>
  2833. <div id="newLit,int8">
  2834. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cint8"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int8"><span class="Identifier">int8</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2835. <dd>
  2836. Produces a new integer literal node.
  2837. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L755" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2838. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L755" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2839. </dd>
  2840. </div>
  2841. <div id="newLit,int16">
  2842. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cint16"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int16"><span class="Identifier">int16</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2843. <dd>
  2844. Produces a new integer literal node.
  2845. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L760" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2846. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L760" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2847. </dd>
  2848. </div>
  2849. <div id="newLit,int32">
  2850. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cint32"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int32"><span class="Identifier">int32</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2851. <dd>
  2852. Produces a new integer literal node.
  2853. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L765" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2854. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L765" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2855. </dd>
  2856. </div>
  2857. <div id="newLit,int64">
  2858. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cint64"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2859. <dd>
  2860. Produces a new integer literal node.
  2861. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L770" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2862. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L770" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2863. </dd>
  2864. </div>
  2865. <div id="newLit,uint">
  2866. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cuint"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#uint"><span class="Identifier">uint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2867. <dd>
  2868. Produces a new unsigned integer literal node.
  2869. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L775" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2870. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L775" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2871. </dd>
  2872. </div>
  2873. <div id="newLit,uint8">
  2874. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cuint8"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#uint8"><span class="Identifier">uint8</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2875. <dd>
  2876. Produces a new unsigned integer literal node.
  2877. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L780" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2878. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L780" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2879. </dd>
  2880. </div>
  2881. <div id="newLit,uint16">
  2882. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cuint16"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#uint16"><span class="Identifier">uint16</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2883. <dd>
  2884. Produces a new unsigned integer literal node.
  2885. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L785" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2886. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L785" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2887. </dd>
  2888. </div>
  2889. <div id="newLit,uint32">
  2890. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cuint32"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#uint32"><span class="Identifier">uint32</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2891. <dd>
  2892. Produces a new unsigned integer literal node.
  2893. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L790" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2894. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L790" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2895. </dd>
  2896. </div>
  2897. <div id="newLit,uint64">
  2898. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cuint64"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#uint64"><span class="Identifier">uint64</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2899. <dd>
  2900. Produces a new unsigned integer literal node.
  2901. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L795" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2902. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L795" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2903. </dd>
  2904. </div>
  2905. <div id="newLit,string">
  2906. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cstring"><span class="Identifier">newLit</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2907. <dd>
  2908. Produces a new string literal node.
  2909. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L804" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2910. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L804" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2911. </dd>
  2912. </div>
  2913. <div id="newLit,array[N,T]">
  2914. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Carray%5BN%2CT%5D"><span class="Identifier">newLit</span></a><span class="Other">[</span><span class="Identifier">N</span><span class="Other">,</span> <span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#array"><span class="Identifier">array</span></a><span class="Other">[</span><span class="Identifier">N</span><span class="Other">,</span> <span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2915. <dd>
  2916. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L838" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2917. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L838" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2918. </dd>
  2919. </div>
  2920. <div id="newLit,T">
  2921. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2CT"><span class="Identifier">newLit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2922. <dd>
  2923. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L841" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2924. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L841" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2925. </dd>
  2926. </div>
  2927. <div id="newLit,seq[T]">
  2928. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cseq%5BT%5D"><span class="Identifier">newLit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2929. <dd>
  2930. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L839" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2931. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L839" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2932. </dd>
  2933. </div>
  2934. <div id="newLit,set[T]">
  2935. <dt><pre><span class="Keyword">proc</span> <a href="#newLit%2Cset%5BT%5D"><span class="Identifier">newLit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  2936. <dd>
  2937. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L840" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2938. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L840" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2939. </dd>
  2940. </div>
  2941. </div>
  2942. <div id="newNilLit-procs-all">
  2943. <div id="newNilLit">
  2944. <dt><pre><span class="Keyword">proc</span> <a href="#newNilLit"><span class="Identifier">newNilLit</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2945. <dd>
  2946. New nil literal shortcut.
  2947. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1206" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2948. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1206" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2949. </dd>
  2950. </div>
  2951. </div>
  2952. <div id="newNimNode-procs-all">
  2953. <div id="newNimNode,NimNodeKind,NimNode">
  2954. <dt><pre><span class="Keyword">proc</span> <a href="#newNimNode%2CNimNodeKind%2CNimNode"><span class="Identifier">newNimNode</span></a><span class="Other">(</span><span class="Identifier">kind</span><span class="Other">:</span> <a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a><span class="Other">;</span> <span class="Identifier">lineInfoFrom</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  2955. <span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NNewNimNode&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2956. <dd>
  2957. <p>Creates a new AST node of the specified kind.</p>
  2958. <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">lineInfoFrom</span></span></tt> parameter is used for line information when the produced code crashes. You should ensure that it is set to a node that you are transforming.</p>
  2959. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L396" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2960. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L396" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2961. </dd>
  2962. </div>
  2963. </div>
  2964. <div id="newPar-procs-all">
  2965. <div id="newPar,NimNode">
  2966. <dt><pre><span class="Keyword">proc</span> <a href="#newPar%2CNimNode"><span class="Identifier">newPar</span></a><span class="Other">(</span><span class="Identifier">exprs</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2967. <dd>
  2968. Create a new parentheses-enclosed expression.
  2969. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1130" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2970. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1130" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2971. </dd>
  2972. </div>
  2973. <div id="newPar,varargs[NimNode]">
  2974. <dt><pre><span class="Keyword">proc</span> <a href="#newPar%2Cvarargs%5BNimNode%5D"><span class="Identifier">newPar</span></a><span class="Other">(</span><span class="Identifier">exprs</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;don\'t use newPar/nnkPar to construct tuple expressions; use nnkTupleConstr instead&quot;</span><span class="Other">,</span>
  2975. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2976. <dd>
  2977. <div class="deprecation-message">
  2978. <b>Deprecated:</b> don&apos;t use newPar/nnkPar to construct tuple expressions; use nnkTupleConstr instead
  2979. </div>
  2980. Create a new parentheses-enclosed expression.
  2981. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1134" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2982. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1134" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2983. </dd>
  2984. </div>
  2985. </div>
  2986. <div id="newProc-procs-all">
  2987. <div id="newProc,openArray[NimNode],NimNode,NimNode">
  2988. <dt><pre><span class="Keyword">proc</span> <a href="#newProc%2CopenArray%5BNimNode%5D%2CNimNode%2CNimNode"><span class="Identifier">newProc</span></a><span class="Other">(</span><span class="Identifier">name</span> <span class="Other">=</span> <span class="Identifier">newEmptyNode</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span>
  2989. <span class="Identifier">params</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">[</span><span class="Identifier">newEmptyNode</span><span class="Other">(</span><span class="Other">)</span><span class="Other">]</span><span class="Other">;</span>
  2990. <span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Identifier">newStmtList</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">procType</span> <span class="Other">=</span> <span class="Identifier">nnkProcDef</span><span class="Other">;</span>
  2991. <span class="Identifier">pragmas</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Identifier">newEmptyNode</span><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  2992. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  2993. <dd>
  2994. <p>Shortcut for creating a new proc.</p>
  2995. <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">params</span></span></tt> array must start with the return type of the proc, followed by a list of IdentDefs which specify the params.</p>
  2996. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1227" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  2997. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1227" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  2998. </dd>
  2999. </div>
  3000. </div>
  3001. <div id="newStmtList-procs-all">
  3002. <div id="newStmtList,varargs[NimNode]">
  3003. <dt><pre><span class="Keyword">proc</span> <a href="#newStmtList%2Cvarargs%5BNimNode%5D"><span class="Identifier">newStmtList</span></a><span class="Other">(</span><span class="Identifier">stmts</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3004. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3005. <dd>
  3006. Create a new statement list.
  3007. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1126" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3008. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1126" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3009. </dd>
  3010. </div>
  3011. </div>
  3012. <div id="newStrLitNode-procs-all">
  3013. <div id="newStrLitNode,string">
  3014. <dt><pre><span class="Keyword">proc</span> <a href="#newStrLitNode%2Cstring"><span class="Identifier">newStrLitNode</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3015. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3016. <dd>
  3017. Creates a string literal node from <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.
  3018. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L447" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3019. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L447" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3020. </dd>
  3021. </div>
  3022. </div>
  3023. <div id="newTree-procs-all">
  3024. <div id="newTree,NimNodeKind,varargs[NimNode]">
  3025. <dt><pre><span class="Keyword">proc</span> <a href="#newTree%2CNimNodeKind%2Cvarargs%5BNimNode%5D"><span class="Identifier">newTree</span></a><span class="Other">(</span><span class="Identifier">kind</span><span class="Other">:</span> <a href="macros.html#NimNodeKind"><span class="Identifier">NimNodeKind</span></a><span class="Other">;</span> <span class="Identifier">children</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.
  3026. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3027. <dd>
  3028. Produces a new node with children.
  3029. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L712" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3030. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L712" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3031. </dd>
  3032. </div>
  3033. </div>
  3034. <div id="newVarStmt-procs-all">
  3035. <div id="newVarStmt,NimNode,NimNode">
  3036. <dt><pre><span class="Keyword">proc</span> <a href="#newVarStmt%2CNimNode%2CNimNode"><span class="Identifier">newVarStmt</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3037. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3038. <dd>
  3039. Create a new var stmt.
  3040. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1147" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3041. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1147" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3042. </dd>
  3043. </div>
  3044. </div>
  3045. <div id="nodeID-procs-all">
  3046. <div id="nodeID,NimNode">
  3047. <dt><pre><span class="Keyword">proc</span> <a href="#nodeID%2CNimNode"><span class="Identifier">nodeID</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NodeId&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3048. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3049. <dd>
  3050. Returns the id of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>, when the compiler has been compiled with the flag <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">useNodeids</span></span></tt>, otherwise returns <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="DecNumber">1</span></span></tt>. This proc is for the purpose to debug the compiler only.
  3051. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1534" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3052. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1534" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3053. </dd>
  3054. </div>
  3055. </div>
  3056. <div id="owner-procs-all">
  3057. <div id="owner,NimNode">
  3058. <dt><pre><span class="Keyword">proc</span> <a href="#owner%2CNimNode"><span class="Identifier">owner</span></a><span class="Other">(</span><span class="Identifier">sym</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;SymOwner&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">,</span>
  3059. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3060. <dd>
  3061. <div class="deprecation-message">
  3062. <b>Deprecated</b>
  3063. </div>
  3064. <p>Accepts a node of kind <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkSym</span></span></tt> and returns its owner's symbol. The meaning of 'owner' depends on <tt class="docutils literal"><span class="pre"><span class="Identifier">sym</span></span></tt>'s <tt class="docutils literal"><span class="pre"><span class="Identifier">NimSymKind</span></span></tt> and declaration context. For top level declarations this is an <tt class="docutils literal"><span class="pre"><span class="Identifier">nskModule</span></span></tt> symbol, for proc local variables an <tt class="docutils literal"><span class="pre"><span class="Identifier">nskProc</span></span></tt> symbol, for enum/object fields an <tt class="docutils literal"><span class="pre"><span class="Identifier">nskType</span></span></tt> symbol, etc. For symbols without an owner, <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt> is returned.</p>
  3065. <p>See also:</p>
  3066. <ul class="simple"><li><a class="reference external" href="#symKind,NimNode">symKind proc</a> to get the kind of a symbol</li>
  3067. <li><a class="reference external" href="#getImpl,NimNode">getImpl proc</a> to get the declaration of a symbol</li>
  3068. </ul>
  3069. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L282" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3070. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L282" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3071. </dd>
  3072. </div>
  3073. </div>
  3074. <div id="params-procs-all">
  3075. <div id="params,NimNode">
  3076. <dt><pre><span class="Keyword">proc</span> <a href="#params%2CNimNode"><span class="Identifier">params</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3077. <dd>
  3078. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1329" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3079. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1329" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3080. </dd>
  3081. </div>
  3082. </div>
  3083. <div id="params=-procs-all">
  3084. <div id="params=,NimNode,NimNode">
  3085. <dt><pre><span class="Keyword">proc</span> <a href="#params%3D%2CNimNode%2CNimNode"><span class="Identifier">params=</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">params</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3086. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3087. <dd>
  3088. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1336" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3089. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1336" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3090. </dd>
  3091. </div>
  3092. </div>
  3093. <div id="parseExpr-procs-all">
  3094. <div id="parseExpr,string,string">
  3095. <dt><pre><span class="Keyword">proc</span> <a href="#parseExpr%2Cstring%2Cstring"><span class="Identifier">parseExpr</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3096. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3097. <dd>
  3098. Compiles the passed string to its AST representation. Expects a single expression. Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> for parsing errors. A filename can be given for more informative errors.
  3099. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L579" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3100. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L579" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3101. </dd>
  3102. </div>
  3103. </div>
  3104. <div id="parseStmt-procs-all">
  3105. <div id="parseStmt,string,string">
  3106. <dt><pre><span class="Keyword">proc</span> <a href="#parseStmt%2Cstring%2Cstring"><span class="Identifier">parseStmt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3107. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3108. <dd>
  3109. Compiles the passed string to its AST representation. Expects one or more statements. Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> for parsing errors. A filename can be given for more informative errors.
  3110. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L587" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3111. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L587" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3112. </dd>
  3113. </div>
  3114. </div>
  3115. <div id="postfix-procs-all">
  3116. <div id="postfix,NimNode,string">
  3117. <dt><pre><span class="Keyword">proc</span> <a href="#postfix%2CNimNode%2Cstring"><span class="Identifier">postfix</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3118. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3119. <dd>
  3120. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1476" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3121. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1476" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3122. </dd>
  3123. </div>
  3124. </div>
  3125. <div id="pragma-procs-all">
  3126. <div id="pragma,NimNode">
  3127. <dt><pre><span class="Keyword">proc</span> <a href="#pragma%2CNimNode"><span class="Identifier">pragma</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3128. <dd>
  3129. Get the pragma of a proc type. These will be expanded.
  3130. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1344" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3131. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1344" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3132. </dd>
  3133. </div>
  3134. </div>
  3135. <div id="pragma=-procs-all">
  3136. <div id="pragma=,NimNode,NimNode">
  3137. <dt><pre><span class="Keyword">proc</span> <a href="#pragma%3D%2CNimNode%2CNimNode"><span class="Identifier">pragma=</span></a><span class="Other">(</span><span class="Identifier">someProc</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3138. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3139. <dd>
  3140. Set the pragma of a proc type.
  3141. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1352" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3142. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1352" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3143. </dd>
  3144. </div>
  3145. </div>
  3146. <div id="prefix-procs-all">
  3147. <div id="prefix,NimNode,string">
  3148. <dt><pre><span class="Keyword">proc</span> <a href="#prefix%2CNimNode%2Cstring"><span class="Identifier">prefix</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3149. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3150. <dd>
  3151. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1479" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3152. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1479" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3153. </dd>
  3154. </div>
  3155. </div>
  3156. <div id="quote-procs-all">
  3157. <div id="quote,typed,string">
  3158. <dt><pre><span class="Keyword">proc</span> <a href="#quote%2Ctyped%2Cstring"><span class="Identifier">quote</span></a><span class="Other">(</span><span class="Identifier">bl</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">op</span> <span class="Other">=</span> <span class="StringLit">&quot;``&quot;</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;QuoteAst&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3159. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3160. <dd>
  3161. <p>Quasi-quoting operator. Accepts an expression or a block and returns the AST that represents it. Within the quoted AST, you are able to interpolate NimNode expressions from the surrounding scope. If no operator is given, quoting is done using backticks. Otherwise, the given operator must be used as a prefix operator for any interpolated expression. The original meaning of the interpolation operator may be obtained by escaping it (by prefixing it with itself) when used as a unary operator: e.g. <tt class="docutils literal"><span class="pre"><span class="Operator">@</span></span></tt> is escaped as <tt class="docutils literal"><span class="pre"><span class="Operator">@@</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Operator">&amp;%</span></span></tt> is escaped as <tt class="docutils literal"><span class="pre"><span class="Operator">&amp;%&amp;%</span></span></tt> and so on; see examples.</p>
  3162. <p>A custom operator interpolation needs accent quoted (``) whenever it resolves to a symbol.</p>
  3163. <p>See also <a class="reference external" href="genasts.html">genasts</a> which avoids some issues with <tt class="docutils literal"><span class="pre"><span class="Identifier">quote</span></span></tt>.</p>
  3164. <p><strong class="examples_text">Example:</strong></p>
  3165. <pre class="listing"><span class="Keyword">macro</span> <span class="Identifier">check</span><span class="Punctuation">(</span><span class="Identifier">ex</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  3166. <span class="Comment"># this is a simplified version of the check macro from the</span>
  3167. <span class="Comment"># unittest module.</span>
  3168. <span class="Comment"># If there is a failed check, we want to make it easy for</span>
  3169. <span class="Comment"># the user to jump to the faulty line in the code, so we</span>
  3170. <span class="Comment"># get the line info here:</span>
  3171. <span class="Keyword">var</span> <span class="Identifier">info</span> <span class="Operator">=</span> <span class="Identifier">ex</span><span class="Operator">.</span><span class="Identifier">lineinfo</span>
  3172. <span class="Comment"># We will also display the code string of the failed check:</span>
  3173. <span class="Keyword">var</span> <span class="Identifier">expString</span> <span class="Operator">=</span> <span class="Identifier">ex</span><span class="Operator">.</span><span class="Identifier">toStrLit</span>
  3174. <span class="Comment"># Finally we compose the code to implement the check:</span>
  3175. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">quote</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
  3176. <span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Punctuation">`</span><span class="Identifier">ex</span><span class="Punctuation">`</span><span class="Punctuation">:</span>
  3177. <span class="Identifier">echo</span> <span class="Punctuation">`</span><span class="Identifier">info</span><span class="Punctuation">`</span> <span class="Operator">&amp;</span> <span class="StringLit">&quot;: Check failed: &quot;</span> <span class="Operator">&amp;</span> <span class="Punctuation">`</span><span class="Identifier">expString</span><span class="Punctuation">`</span>
  3178. <span class="Identifier">check</span> <span class="DecNumber">1</span> <span class="Operator">+</span> <span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  3179. <p><strong class="examples_text">Example:</strong></p>
  3180. <pre class="listing"><span class="Comment"># example showing how to define a symbol that requires backtick without</span>
  3181. <span class="Comment"># quoting it.</span>
  3182. <span class="Keyword">var</span> <span class="Identifier">destroyCalled</span> <span class="Operator">=</span> <span class="Identifier">false</span>
  3183. <span class="Keyword">macro</span> <span class="Identifier">bar</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  3184. <span class="Keyword">let</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newTree</span><span class="Punctuation">(</span><span class="Identifier">nnkAccQuoted</span><span class="Punctuation">,</span> <span class="RawData">ident&quot;=destroy&quot;</span><span class="Punctuation">)</span>
  3185. <span class="Comment"># let s = ident&quot;`=destroy`&quot; # this would not work</span>
  3186. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">quote</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
  3187. <span class="Keyword">type</span> <span class="Identifier">Foo</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  3188. <span class="Comment"># proc `=destroy`(a: var Foo) = destroyCalled = true # this would not work</span>
  3189. <span class="Keyword">proc</span> <span class="Punctuation">`</span><span class="Identifier">s</span><span class="Punctuation">`</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Keyword">var</span> <span class="Identifier">Foo</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Identifier">destroyCalled</span> <span class="Operator">=</span> <span class="Identifier">true</span>
  3190. <span class="Keyword">block</span><span class="Punctuation">:</span>
  3191. <span class="Keyword">let</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">Foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  3192. <span class="Identifier">bar</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  3193. <span class="Identifier">doAssert</span> <span class="Identifier">destroyCalled</span></pre>
  3194. <p><strong class="examples_text">Example:</strong></p>
  3195. <pre class="listing"><span class="Comment"># custom `op`</span>
  3196. <span class="Keyword">var</span> <span class="Identifier">destroyCalled</span> <span class="Operator">=</span> <span class="Identifier">false</span>
  3197. <span class="Keyword">macro</span> <span class="Identifier">bar</span><span class="Punctuation">(</span><span class="Identifier">ident</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  3198. <span class="Keyword">var</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="FloatNumber">1.5</span>
  3199. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">quote</span><span class="Punctuation">(</span><span class="StringLit">&quot;@&quot;</span><span class="Punctuation">)</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
  3200. <span class="Keyword">type</span> <span class="Identifier">Foo</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  3201. <span class="Keyword">let</span> <span class="Punctuation">`</span><span class="Operator">@</span><span class="Identifier">ident</span><span class="Punctuation">`</span> <span class="Operator">=</span> <span class="DecNumber">0</span> <span class="Comment"># custom op interpolated symbols need quoted (``)</span>
  3202. <span class="Keyword">proc</span> <span class="Punctuation">`</span><span class="Operator">=</span><span class="Identifier">destroy</span><span class="Punctuation">`</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Keyword">var</span> <span class="Identifier">Foo</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  3203. <span class="Identifier">doAssert</span> <span class="Operator">@</span><span class="Identifier">x</span> <span class="Operator">==</span> <span class="FloatNumber">1.5</span>
  3204. <span class="Identifier">doAssert</span> <span class="Identifier">compiles</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Identifier">x</span> <span class="Operator">==</span> <span class="FloatNumber">1.5</span><span class="Punctuation">)</span>
  3205. <span class="Keyword">let</span> <span class="Identifier">b1</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span><span class="DecNumber">2</span><span class="Punctuation">]</span>
  3206. <span class="Keyword">let</span> <span class="Identifier">b2</span> <span class="Operator">=</span> <span class="Operator">@@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span><span class="DecNumber">2</span><span class="Punctuation">]</span>
  3207. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">b1</span> <span class="Operator">==</span> <span class="StringLit">&quot;[1, 2]&quot;</span>
  3208. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">b2</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[1, 2]&quot;</span>
  3209. <span class="Identifier">destroyCalled</span> <span class="Operator">=</span> <span class="Identifier">true</span>
  3210. <span class="Keyword">block</span><span class="Punctuation">:</span>
  3211. <span class="Keyword">let</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">Foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  3212. <span class="Identifier">bar</span><span class="Punctuation">(</span><span class="Identifier">someident</span><span class="Punctuation">)</span>
  3213. <span class="Identifier">doAssert</span> <span class="Identifier">destroyCalled</span>
  3214. <span class="Keyword">proc</span> <span class="Punctuation">`</span><span class="Operator">&amp;%</span><span class="Punctuation">`</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
  3215. <span class="Keyword">proc</span> <span class="Punctuation">`</span><span class="Operator">&amp;%</span><span class="Punctuation">`</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span> <span class="DecNumber">2</span>
  3216. <span class="Keyword">macro</span> <span class="Identifier">bar2</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  3217. <span class="Keyword">var</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="DecNumber">3</span>
  3218. <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">quote</span><span class="Punctuation">(</span><span class="StringLit">&quot;&amp;%&quot;</span><span class="Punctuation">)</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
  3219. <span class="Keyword">var</span> <span class="Identifier">y</span> <span class="Operator">=</span> <span class="Operator">&amp;%</span><span class="Identifier">x</span> <span class="Comment"># quoting operator</span>
  3220. <span class="Identifier">doAssert</span> <span class="Operator">&amp;%&amp;%</span><span class="Identifier">y</span> <span class="Operator">==</span> <span class="DecNumber">1</span> <span class="Comment"># unary operator =&gt; need to escape</span>
  3221. <span class="Identifier">doAssert</span> <span class="Identifier">y</span> <span class="Operator">&amp;%</span> <span class="Identifier">y</span> <span class="Operator">==</span> <span class="DecNumber">2</span> <span class="Comment"># binary operator =&gt; no need to escape</span>
  3222. <span class="Identifier">doAssert</span> <span class="Identifier">y</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  3223. <span class="Identifier">bar2</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
  3224. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L604" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3225. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L604" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3226. </dd>
  3227. </div>
  3228. </div>
  3229. <div id="sameType-procs-all">
  3230. <div id="sameType,NimNode,NimNode">
  3231. <dt><pre><span class="Keyword">proc</span> <a href="#sameType%2CNimNode%2CNimNode"><span class="Identifier">sameType</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;SameNodeType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3232. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3233. <dd>
  3234. Compares two Nim nodes' types. Return true if the types are the same, e.g. true when comparing alias with original type.
  3235. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L175" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3236. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L175" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3237. </dd>
  3238. </div>
  3239. </div>
  3240. <div id="setLineInfo-procs-all">
  3241. <div id="setLineInfo,NimNode,string,int,int">
  3242. <dt><pre><span class="Keyword">proc</span> <a href="#setLineInfo%2CNimNode%2Cstring%2Cint%2Cint"><span class="Identifier">setLineInfo</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">line</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">column</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.
  3243. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3244. <dd>
  3245. Sets the line info on the NimNode. The file needs to exists, but can be a relative path. If you want to attach line info to a block using <tt class="docutils literal"><span class="pre"><span class="Identifier">quote</span></span></tt> you'll need to add the line information after the quote block.
  3246. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L549" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3247. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L549" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3248. </dd>
  3249. </div>
  3250. <div id="setLineInfo,NimNode,LineInfo">
  3251. <dt><pre><span class="Keyword">proc</span> <a href="#setLineInfo%2CNimNode%2CLineInfo"><span class="Identifier">setLineInfo</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">lineInfo</span><span class="Other">:</span> <a href="macros.html#LineInfo"><span class="Identifier">LineInfo</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3252. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3253. <dd>
  3254. See <a class="reference external" href="#setLineInfo,NimNode,string,int,int">setLineInfo proc</a>
  3255. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L557" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3256. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L557" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3257. </dd>
  3258. </div>
  3259. </div>
  3260. <div id="signatureHash-procs-all">
  3261. <div id="signatureHash,NimNode">
  3262. <dt><pre><span class="Keyword">proc</span> <a href="#signatureHash%2CNimNode"><span class="Identifier">signatureHash</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSigHash&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3263. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3264. <dd>
  3265. Returns a stable identifier derived from the signature of a symbol. The signature combines many factors such as the type of the symbol, the owning module of the symbol and others. The same identifier is used in the back-end to produce the mangled symbol name.
  3266. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L357" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3267. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L357" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3268. </dd>
  3269. </div>
  3270. </div>
  3271. <div id="strVal-procs-all">
  3272. <div id="strVal,NimNode">
  3273. <dt><pre><span class="Keyword">proc</span> <a href="#strVal%2CNimNode"><span class="Identifier">strVal</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NStrVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3274. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3275. <dd>
  3276. <p>Returns the string value of an identifier, symbol, comment, or string literal.</p>
  3277. <p>See also:</p>
  3278. <ul class="simple"><li><a class="reference external" href="#strVal=,NimNode,string">strVal= proc</a> for setting the string value.</li>
  3279. </ul>
  3280. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L249" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3281. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L249" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3282. </dd>
  3283. </div>
  3284. </div>
  3285. <div id="strVal=-procs-all">
  3286. <div id="strVal=,NimNode,string">
  3287. <dt><pre><span class="Keyword">proc</span> <a href="#strVal%3D%2CNimNode%2Cstring"><span class="Identifier">strVal=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetStrVal&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3288. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3289. <dd>
  3290. <p>Sets the string value of a string literal or comment. Setting <tt class="docutils literal"><span class="pre"><span class="Identifier">strVal</span></span></tt> is disallowed for <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkIdent</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkSym</span></span></tt> nodes; a new node must be created using <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">bindSym</span></span></tt> instead.</p>
  3291. <p>See also:</p>
  3292. <ul class="simple"><li><a class="reference external" href="#strVal,NimNode">strVal proc</a> for getting the string value.</li>
  3293. <li><a class="reference external" href="#ident,string">ident proc</a> for creating an identifier.</li>
  3294. <li><a class="reference external" href="#bindSym%2C%2CBindSymRule">bindSym proc</a> for binding a symbol.</li>
  3295. </ul>
  3296. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L386" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3297. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L386" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3298. </dd>
  3299. </div>
  3300. </div>
  3301. <div id="symBodyHash-procs-all">
  3302. <div id="symBodyHash,NimNode">
  3303. <dt><pre><span class="Keyword">proc</span> <a href="#symBodyHash%2CNimNode"><span class="Identifier">symBodyHash</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3304. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3305. <dd>
  3306. Returns a stable digest for symbols derived not only from type signature and owning module, but also implementation body. All procs/variables used in the implementation of this symbol are hashed recursively as well, including magics from system module.
  3307. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L363" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3308. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L363" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3309. </dd>
  3310. </div>
  3311. </div>
  3312. <div id="symbol-procs-all">
  3313. <div id="symbol,NimNode">
  3314. <dt><pre><span class="Keyword">proc</span> <a href="#symbol%2CNimNode"><span class="Identifier">symbol</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSymbol&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; All functionality is defined on \'NimNode\'.&quot;</span><span class="Other">,</span>
  3315. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3316. <dd>
  3317. <div class="deprecation-message">
  3318. <b>Deprecated:</b> Deprecated since version 0.18.1; All functionality is defined on &apos;NimNode&apos;.
  3319. </div>
  3320. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L260" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3321. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L260" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3322. </dd>
  3323. </div>
  3324. </div>
  3325. <div id="symbol=-procs-all">
  3326. <div id="symbol=,NimNode,NimSym">
  3327. <dt><pre><span class="Keyword">proc</span> <a href="#symbol%3D%2CNimNode%2CNimSym"><span class="Identifier">symbol=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="macros.html#NimSym"><span class="Identifier">NimSym</span></a><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSetSymbol&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.1; Generate a new \'NimNode\' with \'genSym\' instead.&quot;</span><span class="Other">,</span>
  3328. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3329. <dd>
  3330. <div class="deprecation-message">
  3331. <b>Deprecated:</b> Deprecated since version 0.18.1; Generate a new &apos;NimNode&apos; with &apos;genSym&apos; instead.
  3332. </div>
  3333. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L378" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3334. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L378" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3335. </dd>
  3336. </div>
  3337. </div>
  3338. <div id="symKind-procs-all">
  3339. <div id="symKind,NimNode">
  3340. <dt><pre><span class="Keyword">proc</span> <a href="#symKind%2CNimNode"><span class="Identifier">symKind</span></a><span class="Other">(</span><span class="Identifier">symbol</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimSymKind"><span class="Identifier">NimSymKind</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NSymKind&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3341. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3342. <dd>
  3343. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L246" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3344. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L246" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3345. </dd>
  3346. </div>
  3347. </div>
  3348. <div id="toNimIdent-procs-all">
  3349. <div id="toNimIdent,string">
  3350. <dt><pre><span class="Keyword">proc</span> <a href="#toNimIdent%2Cstring"><span class="Identifier">toNimIdent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimIdent"><span class="Identifier">NimIdent</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;StrToIdent&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;Deprecated since version 0.18.0: Use \'ident\' or \'newIdentNode\' instead.&quot;</span><span class="Other">,</span>
  3351. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3352. <dd>
  3353. <div class="deprecation-message">
  3354. <b>Deprecated:</b> Deprecated since version 0.18.0: Use &apos;ident&apos; or &apos;newIdentNode&apos; instead.
  3355. </div>
  3356. Constructs an identifier from the string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.
  3357. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L157" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3358. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L157" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3359. </dd>
  3360. </div>
  3361. </div>
  3362. <div id="toStrLit-procs-all">
  3363. <div id="toStrLit,NimNode">
  3364. <dt><pre><span class="Keyword">proc</span> <a href="#toStrLit%2CNimNode"><span class="Identifier">toStrLit</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3365. <dd>
  3366. Converts the AST <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> to the concrete Nim code and wraps that in a string literal node.
  3367. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L519" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3368. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L519" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3369. </dd>
  3370. </div>
  3371. </div>
  3372. <div id="treeRepr-procs-all">
  3373. <div id="treeRepr,NimNode">
  3374. <dt><pre><span class="Keyword">proc</span> <a href="#treeRepr%2CNimNode"><span class="Identifier">treeRepr</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3375. <dd>
  3376. <p>Convert the AST <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> to a human-readable tree-like string.</p>
  3377. <p>See also <tt class="docutils literal"><span class="pre"><span class="Identifier">repr</span></span></tt>, <a class="reference internal nimdoc" title="proc lispRepr(n: NimNode; indented = false): string" href="#lispRepr,NimNode">lispRepr</a>, and <a class="reference internal nimdoc" title="proc astGenRepr(n: NimNode): string" href="#astGenRepr,NimNode">astGenRepr</a>.</p>
  3378. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L985" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3379. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L985" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3380. </dd>
  3381. </div>
  3382. </div>
  3383. <div id="typeKind-procs-all">
  3384. <div id="typeKind,NimNode">
  3385. <dt><pre><span class="Keyword">proc</span> <a href="#typeKind%2CNimNode"><span class="Identifier">typeKind</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="macros.html#NimTypeKind"><span class="Identifier">NimTypeKind</span></a> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NGetType&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  3386. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3387. <dd>
  3388. Returns the type kind of the node 'n' that should represent a type, that means the node should have been obtained via <tt class="docutils literal"><span class="pre"><span class="Identifier">getType</span></span></tt>.
  3389. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L309" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3390. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L309" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3391. </dd>
  3392. </div>
  3393. </div>
  3394. <div id="unpackInfix-procs-all">
  3395. <div id="unpackInfix,NimNode">
  3396. <dt><pre><span class="Keyword">proc</span> <a href="#unpackInfix%2CNimNode"><span class="Identifier">unpackInfix</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">left</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">,</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">right</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">]</span> {.
  3397. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3398. <dd>
  3399. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1494" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3400. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1494" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3401. </dd>
  3402. </div>
  3403. </div>
  3404. <div id="unpackPostfix-procs-all">
  3405. <div id="unpackPostfix,NimNode">
  3406. <dt><pre><span class="Keyword">proc</span> <a href="#unpackPostfix%2CNimNode"><span class="Identifier">unpackPostfix</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">,</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.
  3407. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3408. <dd>
  3409. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1486" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3410. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1486" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3411. </dd>
  3412. </div>
  3413. </div>
  3414. <div id="unpackPrefix-procs-all">
  3415. <div id="unpackPrefix,NimNode">
  3416. <dt><pre><span class="Keyword">proc</span> <a href="#unpackPrefix%2CNimNode"><span class="Identifier">unpackPrefix</span></a><span class="Other">(</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">node</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">,</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3417. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3418. <dd>
  3419. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1490" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3420. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1490" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3421. </dd>
  3422. </div>
  3423. </div>
  3424. <div id="warning-procs-all">
  3425. <div id="warning,string,NimNode">
  3426. <dt><pre><span class="Keyword">proc</span> <a href="#warning%2Cstring%2CNimNode"><span class="Identifier">warning</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;NWarning&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  3427. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3428. <dd>
  3429. Writes a warning message at compile time.
  3430. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L441" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3431. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L441" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3432. </dd>
  3433. </div>
  3434. </div>
  3435. </dl>
  3436. </div>
  3437. <div class="section" id="15">
  3438. <h1><a class="toc-backref" href="#15">Iterators</a></h1>
  3439. <dl class="item">
  3440. <div id="children-iterators-all">
  3441. <div id="children.i,NimNode">
  3442. <dt><pre><span class="Keyword">iterator</span> <a href="#children.i%2CNimNode"><span class="Identifier">children</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3443. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3444. <dd>
  3445. Iterates over the children of the NimNode <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  3446. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1431" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3447. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1431" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3448. </dd>
  3449. </div>
  3450. </div>
  3451. <div id="items-iterators-all">
  3452. <div id="items.i,NimNode">
  3453. <dt><pre><span class="Keyword">iterator</span> <a href="#items.i%2CNimNode"><span class="Identifier">items</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3454. <dd>
  3455. Iterates over the children of the NimNode <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  3456. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1421" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3457. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1421" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3458. </dd>
  3459. </div>
  3460. </div>
  3461. <div id="pairs-iterators-all">
  3462. <div id="pairs.i,NimNode">
  3463. <dt><pre><span class="Keyword">iterator</span> <a href="#pairs.i%2CNimNode"><span class="Identifier">pairs</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">,</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  3464. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  3465. <dd>
  3466. Iterates over the children of the NimNode <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> and its indices.
  3467. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1426" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3468. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1426" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3469. </dd>
  3470. </div>
  3471. </div>
  3472. </dl>
  3473. </div>
  3474. <div class="section" id="17">
  3475. <h1><a class="toc-backref" href="#17">Macros</a></h1>
  3476. <dl class="item">
  3477. <div id="dumpAstGen-macros-all">
  3478. <div id="dumpAstGen.m,untyped">
  3479. <dt><pre><span class="Keyword">macro</span> <a href="#dumpAstGen.m%2Cuntyped"><span class="Identifier">dumpAstGen</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3480. <dd>
  3481. <p>Accepts a block of nim code and prints the parsed abstract syntax tree using the <tt class="docutils literal"><span class="pre"><span class="Identifier">astGenRepr</span></span></tt> proc. Printing is done <em>at compile time</em>.</p>
  3482. <p>You can use this as a tool to write macros quicker by writing example outputs and then copying the snippets into the macro for modification.</p>
  3483. <p>For example:</p>
  3484. <p><pre class="listing"><span class="Identifier">dumpAstGen</span><span class="Punctuation">:</span>
  3485. <span class="Identifier">echo</span> <span class="StringLit">&quot;Hello, World!&quot;</span></pre></p>
  3486. <p>Outputs:</p>
  3487. <p><pre class="listing"><span class="Identifier">nnkStmtList</span><span class="Operator">.</span><span class="Identifier">newTree</span><span class="Punctuation">(</span>
  3488. <span class="Identifier">nnkCommand</span><span class="Operator">.</span><span class="Identifier">newTree</span><span class="Punctuation">(</span>
  3489. <span class="Identifier">newIdentNode</span><span class="Punctuation">(</span><span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  3490. <span class="Identifier">newLit</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, World!&quot;</span><span class="Punctuation">)</span>
  3491. <span class="Punctuation">)</span>
  3492. <span class="Punctuation">)</span></pre></p>
  3493. <p>Also see <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpTree</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpLisp</span></span></tt>.</p>
  3494. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1097" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3495. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1097" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3496. </dd>
  3497. </div>
  3498. </div>
  3499. <div id="dumpLisp-macros-all">
  3500. <div id="dumpLisp.m,untyped">
  3501. <dt><pre><span class="Keyword">macro</span> <a href="#dumpLisp.m%2Cuntyped"><span class="Identifier">dumpLisp</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3502. <dd>
  3503. <p>Accepts a block of nim code and prints the parsed abstract syntax tree using the <tt class="docutils literal"><span class="pre"><span class="Identifier">lispRepr</span></span></tt> proc. Printing is done <em>at compile time</em>.</p>
  3504. <p>You can use this as a tool to explore the Nim's abstract syntax tree and to discover what kind of nodes must be created to represent a certain expression/statement.</p>
  3505. <p>For example:</p>
  3506. <p><pre class="listing"><span class="Identifier">dumpLisp</span><span class="Punctuation">:</span>
  3507. <span class="Identifier">echo</span> <span class="StringLit">&quot;Hello, World!&quot;</span></pre></p>
  3508. <p>Outputs:</p>
  3509. <p><pre class="listing"><span class="Punctuation">(</span><span class="Identifier">StmtList</span>
  3510. <span class="Punctuation">(</span><span class="Identifier">Command</span>
  3511. <span class="Punctuation">(</span><span class="Identifier">Ident</span> <span class="StringLit">&quot;echo&quot;</span><span class="Punctuation">)</span>
  3512. <span class="Punctuation">(</span><span class="Identifier">StrLit</span> <span class="StringLit">&quot;Hello, World!&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  3513. <p>Also see <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpAstGen</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpTree</span></span></tt>.</p>
  3514. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1073" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3515. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1073" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3516. </dd>
  3517. </div>
  3518. </div>
  3519. <div id="dumpTree-macros-all">
  3520. <div id="dumpTree.m,untyped">
  3521. <dt><pre><span class="Keyword">macro</span> <a href="#dumpTree.m%2Cuntyped"><span class="Identifier">dumpTree</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3522. <dd>
  3523. <p>Accepts a block of nim code and prints the parsed abstract syntax tree using the <tt class="docutils literal"><span class="pre"><span class="Identifier">treeRepr</span></span></tt> proc. Printing is done <em>at compile time</em>.</p>
  3524. <p>You can use this as a tool to explore the Nim's abstract syntax tree and to discover what kind of nodes must be created to represent a certain expression/statement.</p>
  3525. <p>For example:</p>
  3526. <p><pre class="listing"><span class="Identifier">dumpTree</span><span class="Punctuation">:</span>
  3527. <span class="Identifier">echo</span> <span class="StringLit">&quot;Hello, World!&quot;</span></pre></p>
  3528. <p>Outputs:</p>
  3529. <p><pre class="listing"><span class="Identifier">StmtList</span>
  3530. <span class="Identifier">Command</span>
  3531. <span class="Identifier">Ident</span> <span class="StringLit">&quot;echo&quot;</span>
  3532. <span class="Identifier">StrLit</span> <span class="StringLit">&quot;Hello, World!&quot;</span></pre></p>
  3533. <p>Also see <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpAstGen</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">dumpLisp</span></span></tt>.</p>
  3534. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1049" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3535. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1049" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3536. </dd>
  3537. </div>
  3538. </div>
  3539. <div id="expandMacros-macros-all">
  3540. <div id="expandMacros.m,typed">
  3541. <dt><pre><span class="Keyword">macro</span> <a href="#expandMacros.m%2Ctyped"><span class="Identifier">expandMacros</span></a><span class="Other">(</span><span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3542. <dd>
  3543. <p>Expands one level of macro - useful for debugging. Can be used to inspect what happens when a macro call is expanded, without altering its result.</p>
  3544. <p>For instance,</p>
  3545. <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">sugar</span><span class="Punctuation">,</span> <span class="Identifier">macros</span><span class="Punctuation">]</span>
  3546. <span class="Keyword">let</span>
  3547. <span class="Identifier">x</span> <span class="Operator">=</span> <span class="DecNumber">10</span>
  3548. <span class="Identifier">y</span> <span class="Operator">=</span> <span class="DecNumber">20</span>
  3549. <span class="Identifier">expandMacros</span><span class="Punctuation">:</span>
  3550. <span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">x</span> <span class="Operator">+</span> <span class="Identifier">y</span><span class="Punctuation">)</span></pre></p>
  3551. <p>will actually dump <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span> <span class="Operator">+</span> <span class="Identifier">y</span></span></tt>, but at the same time will print at compile time the expansion of the <tt class="docutils literal"><span class="pre"><span class="Identifier">dump</span></span></tt> macro, which in this case is <tt class="docutils literal"><span class="pre"><span class="Identifier">debugEcho</span> <span class="Punctuation">[</span><span class="StringLit">&quot;x + y&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot; = &quot;</span><span class="Punctuation">,</span> <span class="Identifier">x</span> <span class="Operator">+</span> <span class="Identifier">y</span><span class="Punctuation">]</span></span></tt>.</p>
  3552. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1539" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3553. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1539" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3554. </dd>
  3555. </div>
  3556. </div>
  3557. <div id="getCustomPragmaVal-macros-all">
  3558. <div id="getCustomPragmaVal.m,typed,">
  3559. <dt><pre><span class="Keyword">macro</span> <a href="#getCustomPragmaVal.m%2Ctyped%2C"><span class="Identifier">getCustomPragmaVal</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">cp</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">{</span><span class="Identifier">nkSym</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3560. <dd>
  3561. <p>Expands to value of custom pragma <tt class="docutils literal"><span class="pre"><span class="Identifier">cp</span></span></tt> of expression <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> which is expected to be <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkDotExpr</span></span></tt>, a proc or a type.</p>
  3562. <p>See also <a class="reference internal nimdoc" title="macro hasCustomPragma(n: typed; cp: typed{nkSym}): untyped" href="#hasCustomPragma.m,typed,">hasCustomPragma</a>.</p>
  3563. <p><pre class="listing"><span class="Keyword">template</span> <span class="Identifier">serializationKey</span><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">pragma</span><span class="Operator">.</span><span class="Punctuation">}</span>
  3564. <span class="Keyword">type</span>
  3565. <span class="Identifier">MyObj</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">serializationKey</span><span class="Punctuation">:</span> <span class="StringLit">&quot;mo&quot;</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  3566. <span class="Identifier">myField</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">serializationKey</span><span class="Punctuation">:</span> <span class="StringLit">&quot;mf&quot;</span><span class="Operator">.</span><span class="Punctuation">}</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  3567. <span class="Keyword">var</span> <span class="Identifier">o</span><span class="Punctuation">:</span> <span class="Identifier">MyObj</span>
  3568. <span class="Identifier">assert</span><span class="Punctuation">(</span><span class="Identifier">o</span><span class="Operator">.</span><span class="Identifier">myField</span><span class="Operator">.</span><span class="Identifier">getCustomPragmaVal</span><span class="Punctuation">(</span><span class="Identifier">serializationKey</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;mf&quot;</span><span class="Punctuation">)</span>
  3569. <span class="Identifier">assert</span><span class="Punctuation">(</span><span class="Identifier">o</span><span class="Operator">.</span><span class="Identifier">getCustomPragmaVal</span><span class="Punctuation">(</span><span class="Identifier">serializationKey</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;mo&quot;</span><span class="Punctuation">)</span>
  3570. <span class="Identifier">assert</span><span class="Punctuation">(</span><span class="Identifier">MyObj</span><span class="Operator">.</span><span class="Identifier">getCustomPragmaVal</span><span class="Punctuation">(</span><span class="Identifier">serializationKey</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;mo&quot;</span><span class="Punctuation">)</span></pre></p>
  3571. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1682" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3572. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1682" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3573. </dd>
  3574. </div>
  3575. </div>
  3576. <div id="hasCustomPragma-macros-all">
  3577. <div id="hasCustomPragma.m,typed,">
  3578. <dt><pre><span class="Keyword">macro</span> <a href="#hasCustomPragma.m%2Ctyped%2C"><span class="Identifier">hasCustomPragma</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">cp</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">{</span><span class="Identifier">nkSym</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3579. <dd>
  3580. <p>Expands to <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> if expression <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> which is expected to be <tt class="docutils literal"><span class="pre"><span class="Identifier">nnkDotExpr</span></span></tt> (if checking a field), a proc or a type has custom pragma <tt class="docutils literal"><span class="pre"><span class="Identifier">cp</span></span></tt>.</p>
  3581. <p>See also <a class="reference internal nimdoc" title="macro getCustomPragmaVal(n: typed; cp: typed{nkSym}): untyped" href="#getCustomPragmaVal.m,typed,">getCustomPragmaVal</a>.</p>
  3582. <p><pre class="listing"><span class="Keyword">template</span> <span class="Identifier">myAttr</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">pragma</span><span class="Operator">.</span><span class="Punctuation">}</span>
  3583. <span class="Keyword">type</span>
  3584. <span class="Identifier">MyObj</span> <span class="Operator">=</span> <span class="Keyword">object</span>
  3585. <span class="Identifier">myField</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">myAttr</span><span class="Operator">.</span><span class="Punctuation">}</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  3586. <span class="Keyword">proc</span> <span class="Identifier">myProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">myAttr</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">discard</span>
  3587. <span class="Keyword">var</span> <span class="Identifier">o</span><span class="Punctuation">:</span> <span class="Identifier">MyObj</span>
  3588. <span class="Identifier">assert</span><span class="Punctuation">(</span><span class="Identifier">o</span><span class="Operator">.</span><span class="Identifier">myField</span><span class="Operator">.</span><span class="Identifier">hasCustomPragma</span><span class="Punctuation">(</span><span class="Identifier">myAttr</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  3589. <span class="Identifier">assert</span><span class="Punctuation">(</span><span class="Identifier">myProc</span><span class="Operator">.</span><span class="Identifier">hasCustomPragma</span><span class="Punctuation">(</span><span class="Identifier">myAttr</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  3590. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1657" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3591. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1657" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3592. </dd>
  3593. </div>
  3594. </div>
  3595. <div id="unpackVarargs-macros-all">
  3596. <div id="unpackVarargs.m,untyped,varargs[untyped]">
  3597. <dt><pre><span class="Keyword">macro</span> <a href="#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D"><span class="Identifier">unpackVarargs</span></a><span class="Other">(</span><span class="Identifier">callee</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  3598. <dd>
  3599. Calls <tt class="docutils literal"><span class="pre"><span class="Identifier">callee</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span></span></tt> unpacked as individual arguments. This is useful in 2 cases:<ul class="simple"><li>when forwarding <tt class="docutils literal"><span class="pre"><span class="Identifier">varargs</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> for some typed <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt></li>
  3600. <li>when forwarding <tt class="docutils literal"><span class="pre"><span class="Identifier">varargs</span><span class="Punctuation">[</span><span class="Identifier">untyped</span><span class="Punctuation">]</span></span></tt> when <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span></span></tt> can potentially be empty, due to a compiler limitation</li>
  3601. </ul>
  3602. <p><strong class="examples_text">Example:</strong></p>
  3603. <pre class="listing"><span class="Keyword">template</span> <span class="Identifier">call1</span><span class="Punctuation">(</span><span class="Identifier">fun</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">;</span> <span class="Identifier">args</span><span class="Punctuation">:</span> <span class="Identifier">varargs</span><span class="Punctuation">[</span><span class="Identifier">untyped</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span> <span class="Operator">=</span>
  3604. <span class="Identifier">unpackVarargs</span><span class="Punctuation">(</span><span class="Identifier">fun</span><span class="Punctuation">,</span> <span class="Identifier">args</span><span class="Punctuation">)</span>
  3605. <span class="Comment"># when varargsLen(args) &gt; 0: fun(args) else: fun() # this would also work</span>
  3606. <span class="Keyword">template</span> <span class="Identifier">call2</span><span class="Punctuation">(</span><span class="Identifier">fun</span><span class="Punctuation">:</span> <span class="Identifier">typed</span><span class="Punctuation">;</span> <span class="Identifier">args</span><span class="Punctuation">:</span> <span class="Identifier">varargs</span><span class="Punctuation">[</span><span class="Identifier">typed</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">untyped</span> <span class="Operator">=</span>
  3607. <span class="Identifier">unpackVarargs</span><span class="Punctuation">(</span><span class="Identifier">fun</span><span class="Punctuation">,</span> <span class="Identifier">args</span><span class="Punctuation">)</span>
  3608. <span class="Keyword">proc</span> <span class="Identifier">fn1</span><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">=</span> <span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="Identifier">b</span> <span class="Operator">=</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Keyword">discard</span> <span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">)</span>
  3609. <span class="Identifier">call1</span><span class="Punctuation">(</span><span class="Identifier">fn1</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">11</span><span class="Punctuation">)</span>
  3610. <span class="Identifier">call1</span><span class="Punctuation">(</span><span class="Identifier">fn1</span><span class="Punctuation">)</span> <span class="Comment"># `args` is empty in this case</span>
  3611. <span class="Keyword">if</span> <span class="Identifier">false</span><span class="Punctuation">:</span> <span class="Identifier">call2</span><span class="Punctuation">(</span><span class="Identifier">echo</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">11</span><span class="Punctuation">)</span> <span class="Comment"># would print 1011</span></pre>
  3612. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1715" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3613. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1715" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3614. </dd>
  3615. </div>
  3616. </div>
  3617. </dl>
  3618. </div>
  3619. <div class="section" id="18">
  3620. <h1><a class="toc-backref" href="#18">Templates</a></h1>
  3621. <dl class="item">
  3622. <div id="findChild-templates-all">
  3623. <div id="findChild.t,NimNode,untyped">
  3624. <dt><pre><span class="Keyword">template</span> <a href="#findChild.t%2CNimNode%2Cuntyped"><span class="Identifier">findChild</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">;</span> <span class="Identifier">cond</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a> {.<span class="Identifier">dirty</span>.}</pre></dt>
  3625. <dd>
  3626. <p>Find the first child node matching condition (or nil).</p>
  3627. <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span> <span class="Operator">=</span> <span class="Identifier">findChild</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Punctuation">,</span> <span class="Identifier">it</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">nnkPostfix</span> <span class="Keyword">and</span>
  3628. <span class="Identifier">it</span><span class="Operator">.</span><span class="Identifier">basename</span><span class="Operator">.</span><span class="Identifier">ident</span> <span class="Operator">==</span> <span class="RawData">ident&quot;foo&quot;</span><span class="Punctuation">)</span></pre></p>
  3629. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L1436" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3630. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L1436" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3631. </dd>
  3632. </div>
  3633. </div>
  3634. <div id="or-templates-all">
  3635. <div id="or.t,NimNode,NimNode">
  3636. <dt><pre><span class="Keyword">template</span> <a href="#or.t%2CNimNode%2CNimNode"><span class="Identifier">`or`</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#NimNode"><span class="Identifier">NimNode</span></a></pre></dt>
  3637. <dd>
  3638. <p>Evaluate <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> and when it is not an empty node, return it. Otherwise evaluate to <tt class="docutils literal"><span class="pre"><span class="Identifier">y</span></span></tt>. Can be used to chain several expressions to get the first expression that is not empty.</p>
  3639. <p><pre class="listing"><span class="Keyword">let</span> <span class="Identifier">node</span> <span class="Operator">=</span> <span class="Identifier">mightBeEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Keyword">or</span> <span class="Identifier">mightAlsoBeEmpty</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Keyword">or</span> <span class="Identifier">fallbackNode</span></pre></p>
  3640. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/core/macros.nim#L209" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  3641. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/core/macros.nim#L209" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  3642. </dd>
  3643. </div>
  3644. </div>
  3645. </dl>
  3646. </div>
  3647. </div>
  3648. </div>
  3649. <div class="twelve-columns footer">
  3650. <span class="nim-sprite"></span>
  3651. <br>
  3652. <small style="color: var(--hint);">Made with Nim. Generated: 2025-04-03 14:19:07 UTC</small>
  3653. </div>
  3654. </div>
  3655. </div>
  3656. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  3657. </body>
  3658. </html>