[{"data":1,"prerenderedAt":832},["ShallowReactive",2],{"navigation_docs":3,"-features-const":198,"-features-const-surround":827},[4,30,81,118,147,171,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"/getting-started","1.getting-started",[10,15,20,25],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","/getting-started/introduction","1.getting-started/2.introduction","i-lucide-house",{"title":16,"path":17,"stem":18,"icon":19},"Installation","/getting-started/installation","1.getting-started/3.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Quick start","/getting-started/quickstart","1.getting-started/4.quickstart","i-lucide-code-xml",{"title":26,"path":27,"stem":28,"icon":29},"Troubleshooting","/getting-started/troubleshooting","1.getting-started/5.troubleshooting","i-lucide-wrench",{"title":31,"icon":6,"path":32,"stem":33,"children":34,"page":6},"Core Features","/core-features","2.core-features",[35,39,43,48,52,56,60,64,68,73,77],{"title":36,"path":37,"stem":38,"icon":24},"Main function","/core-features/main-function","2.core-features/1.main-function",{"title":40,"path":41,"stem":42,"icon":24},"Variables","/core-features/variables","2.core-features/2.variables",{"title":44,"path":45,"stem":46,"icon":47},"Comment","/core-features/comment","2.core-features/3.comment","i-lucide-hash",{"title":49,"path":50,"stem":51,"icon":24},"Conditionals","/core-features/conditionals","2.core-features/4.conditionals",{"title":53,"path":54,"stem":55,"icon":24},"Loops","/core-features/loops","2.core-features/5.loops",{"title":57,"path":58,"stem":59,"icon":24},"Functions","/core-features/functions","2.core-features/6.functions",{"title":61,"path":62,"stem":63,"icon":24},"Pointers","/core-features/pointers","2.core-features/7.pointers",{"title":65,"path":66,"stem":67,"icon":24},"Data types","/core-features/datatypes","2.core-features/8.datatypes",{"title":69,"path":70,"stem":71,"icon":72},"Operators","/core-features/operators","2.core-features/9.operators","i-lucide-percent",{"title":74,"path":75,"stem":76,"icon":24},"Literals","/core-features/a.literals","2.core-features/a.literals",{"title":78,"path":79,"stem":80,"icon":24},"Keywords","/core-features/b.keywords","2.core-features/b.keywords",{"title":82,"icon":6,"path":83,"stem":84,"children":85,"page":6},"Features","/features","3.features",[86,90,94,98,102,106,110,114],{"title":87,"path":88,"stem":89,"icon":24},"Const","/features/const","3.features/1.const",{"title":91,"path":92,"stem":93,"icon":24},"Define","/features/define","3.features/2.define",{"title":95,"path":96,"stem":97,"icon":24},"Enum","/features/enum","3.features/3.enum",{"title":99,"path":100,"stem":101,"icon":24},"Union","/features/union","3.features/4.union",{"title":103,"path":104,"stem":105,"icon":24},"Overloading","/features/overloading","3.features/5.overloading",{"title":107,"path":108,"stem":109,"icon":24},"Lambda","/features/lambda","3.features/6.lambda",{"title":111,"path":112,"stem":113,"icon":24},"Callback","/features/callback","3.features/7.callback",{"title":115,"path":116,"stem":117,"icon":24},"Auto","/features/auto","3.features/8.auto",{"title":119,"icon":6,"path":120,"stem":121,"children":122,"page":6},"Advance Features","/advance","4.advance",[123,127,131,135,139,143],{"title":124,"path":125,"stem":126,"icon":24},"Generic Type","/advance/generic-type","4.advance/1.generic-type",{"title":128,"path":129,"stem":130,"icon":24},"Errors","/advance/error","4.advance/2.error",{"title":132,"path":133,"stem":134,"icon":24},"Annotation","/advance/annotation","4.advance/3.annotation",{"title":136,"path":137,"stem":138,"icon":24},"Variadic Function","/advance/variadic-func","4.advance/4.variadic-func",{"title":140,"path":141,"stem":142,"icon":24},"Module","/advance/module-interface","4.advance/5.module-interface",{"title":144,"path":145,"stem":146,"icon":24},"Operator Overloading","/advance/operator-overloading","4.advance/6.operator-overloading",{"title":148,"icon":6,"path":149,"stem":150,"children":151,"page":6},"Struct","/struct","5.struct",[152,155,159,163,167],{"title":148,"path":153,"stem":154,"icon":24},"/struct/struct","5.struct/1.struct",{"title":156,"path":157,"stem":158,"icon":24},"Methods","/struct/methods","5.struct/2.methods",{"title":160,"path":161,"stem":162,"icon":24},"Init/Deinit","/struct/init-deinit","5.struct/3.init-deinit",{"title":164,"path":165,"stem":166,"icon":24},"Encapsulation","/struct/encapsulation","5.struct/4.encapsulation",{"title":168,"path":169,"stem":170,"icon":24},"Static","/struct/static","5.struct/5.static",{"title":172,"icon":6,"path":173,"stem":174,"children":175,"page":6},"Data Structures","/data-structure","6.data-structure",[176,180],{"title":177,"path":178,"stem":179,"icon":24},"Array","/data-structure/array","6.data-structure/array",{"title":181,"path":182,"stem":183,"icon":24},"Structural Type","/data-structure/strutural-type","6.data-structure/strutural-type",{"title":185,"icon":6,"path":186,"stem":187,"children":188,"page":6},"Standard Libraries","/stdlib","7.stdlib",[189,194],{"title":190,"path":191,"stem":192,"icon":193},"stdlib","/stdlib/stdlib","7.stdlib/stdlib","i-lucide-library-big",{"title":195,"path":196,"stem":197,"icon":24},"syscall","/stdlib/syscall","7.stdlib/syscall",{"id":199,"title":87,"body":200,"description":820,"extension":821,"links":822,"meta":823,"navigation":824,"path":88,"seo":825,"stem":89,"__hash__":826},"docs/3.features/1.const.md",{"type":201,"value":202,"toc":814},"minimark",[203,211,222,227,232,267,272,295,301,308,312,318,324,462,472,476,479,488,492,752,759,781,791,795,806,810],[204,205,206,210],"p",{},[207,208,209],"code",{},"const"," is keyword that makes something stay constant, unchanged. it can be used to qualify:",[212,213,214,217,219],"ul",{},[215,216,40],"li",{},[215,218,57],{},[215,220,221],{},"Structs",[223,224,226],"h2",{"id":225},"const-variables","Const variables",[204,228,229,231],{},[207,230,209],{}," is used to make variables immutable, which means that they can only\nbe read but not modified.",[233,234,239],"pre",{"className":235,"code":236,"language":237,"meta":238,"style":238},"language-kh shiki shiki-themes material-theme-lighter one-light one-dark-pro","const type identifier = value;\n","kh","",[207,240,241],{"__ignoreMap":238},[242,243,246,249,252,256,260,263],"span",{"class":244,"line":245},"line",1,[242,247,209],{"class":248},"sQsOY",[242,250,251],{"class":248}," type",[242,253,255],{"class":254},"s8dPH"," identifier",[242,257,259],{"class":258},"sB4Xn"," =",[242,261,262],{"class":254}," value",[242,264,266],{"class":265},"sM89C",";\n",[268,269,271],"h4",{"id":270},"example","Example",[233,273,275],{"className":235,"code":274,"language":237,"meta":238,"style":238},"const float PI = 3.1415;\n",[207,276,277],{"__ignoreMap":238},[242,278,279,281,284,287,289,293],{"class":244,"line":245},[242,280,209],{"class":248},[242,282,283],{"class":254}," float",[242,285,286],{"class":254}," PI",[242,288,259],{"class":258},[242,290,292],{"class":291},"sriKn"," 3.1415",[242,294,266],{"class":265},[204,296,297,300],{},[207,298,299],{},"PI"," is now immutable. If you try to modify its value, it will result in compilation error.",[302,303,304,305,307],"note",{},"In Cambo, for primitive-typed variables that was declared with ",[207,306,209],{},", the compiler will automatically\nperform constant folding by substituting their literal value at usage site, which means the need for\nmemory allocation can be eliminated.",[223,309,311],{"id":310},"const-functions","Const functions",[204,313,314,315,317],{},"Just like variable, ",[207,316,209],{}," also works for functions. If a function is marked as constant, the entire function including parameters and its body should also be constant, which are known at compile time!",[204,319,320],{},[321,322,323],"strong",{},"Example:",[233,325,327],{"className":235,"code":326,"language":237,"meta":238,"style":238},"const int sum(int a, int b){\n  return a + b;\n}\n\nint main(string args[]){\n\n  int result = sum(1, 2); # result = 3\n\n  return 0;\n}\n",[207,328,329,360,375,381,388,407,412,442,447,457],{"__ignoreMap":238},[242,330,331,333,336,340,343,346,349,352,354,357],{"class":244,"line":245},[242,332,209],{"class":248},[242,334,335],{"class":254}," int",[242,337,339],{"class":338},"spnjr"," sum",[242,341,342],{"class":265},"(",[242,344,345],{"class":254},"int",[242,347,348],{"class":254}," a",[242,350,351],{"class":265},", ",[242,353,345],{"class":254},[242,355,356],{"class":254}," b",[242,358,359],{"class":265},"){\n",[242,361,363,366,368,371,373],{"class":244,"line":362},2,[242,364,365],{"class":248},"  return",[242,367,348],{"class":254},[242,369,370],{"class":258}," +",[242,372,356],{"class":254},[242,374,266],{"class":265},[242,376,378],{"class":244,"line":377},3,[242,379,380],{"class":265},"}\n",[242,382,384],{"class":244,"line":383},4,[242,385,387],{"emptyLinePlaceholder":386},true,"\n",[242,389,391,393,396,398,401,404],{"class":244,"line":390},5,[242,392,345],{"class":254},[242,394,395],{"class":338}," main",[242,397,342],{"class":265},[242,399,400],{"class":248},"string",[242,402,403],{"class":254}," args",[242,405,406],{"class":265},"[]){\n",[242,408,410],{"class":244,"line":409},6,[242,411,387],{"emptyLinePlaceholder":386},[242,413,415,418,421,423,425,427,430,432,435,438],{"class":244,"line":414},7,[242,416,417],{"class":254},"  int",[242,419,420],{"class":254}," result",[242,422,259],{"class":258},[242,424,339],{"class":338},[242,426,342],{"class":265},[242,428,429],{"class":291},"1",[242,431,351],{"class":265},[242,433,434],{"class":291},"2",[242,436,437],{"class":265},"); ",[242,439,441],{"class":440},"seacL","# result = 3\n",[242,443,445],{"class":244,"line":444},8,[242,446,387],{"emptyLinePlaceholder":386},[242,448,450,452,455],{"class":244,"line":449},9,[242,451,365],{"class":248},[242,453,454],{"class":291}," 0",[242,456,266],{"class":265},[242,458,460],{"class":244,"line":459},10,[242,461,380],{"class":265},[204,463,464,465,468,469,471],{},"The function ",[207,466,467],{},"sum"," will be run or computed at compile time as it's a const function. Furthermore, ",[207,470,467],{}," will be nowhere to be found in the program at run time.",[223,473,475],{"id":474},"const-struct","Const struct",[204,477,478],{},"A constant struct is a special struct that has all of its member as constant, no exception!",[480,481,482,483,487],"tip",{},"See ",[484,485,486],"a",{"href":238},"struct"," first!",[204,489,490],{},[321,491,323],{},[233,493,495],{"className":235,"code":494,"language":237,"meta":238,"style":238},"\nstruct RGB{\n  ubyte r, g, b;\n  init(self.r, self.g, self.b);\n}\n\nstatic const struct Color{\n  static const RGB orange = RGB(255, 165, 0);\n  static const RGB purple = RGB(128, 0, 128);\n  static const RGB pink   = RGB(255, 192, 203);\n  static const RGB gray   = RGB(128, 128, 128);\n  static const RGB brown  = RGB(165, 42, 42);\n}\n",[207,496,497,501,511,531,566,570,574,590,623,653,685,715,747],{"__ignoreMap":238},[242,498,499],{"class":244,"line":245},[242,500,387],{"emptyLinePlaceholder":386},[242,502,503,505,508],{"class":244,"line":362},[242,504,486],{"class":248},[242,506,507],{"class":254}," RGB",[242,509,510],{"class":265},"{\n",[242,512,513,516,519,521,524,526,529],{"class":244,"line":377},[242,514,515],{"class":254},"  ubyte",[242,517,518],{"class":254}," r",[242,520,351],{"class":265},[242,522,523],{"class":254},"g",[242,525,351],{"class":265},[242,527,528],{"class":254},"b",[242,530,266],{"class":265},[242,532,533,536,538,541,544,547,549,551,553,555,557,559,561,563],{"class":244,"line":383},[242,534,535],{"class":248},"  init",[242,537,342],{"class":265},[242,539,540],{"class":254},"self",[242,542,543],{"class":265},".",[242,545,546],{"class":254},"r",[242,548,351],{"class":265},[242,550,540],{"class":254},[242,552,543],{"class":265},[242,554,523],{"class":254},[242,556,351],{"class":265},[242,558,540],{"class":254},[242,560,543],{"class":265},[242,562,528],{"class":254},[242,564,565],{"class":265},");\n",[242,567,568],{"class":244,"line":390},[242,569,380],{"class":265},[242,571,572],{"class":244,"line":409},[242,573,387],{"emptyLinePlaceholder":386},[242,575,576,579,582,585,588],{"class":244,"line":414},[242,577,578],{"class":248},"static",[242,580,581],{"class":248}," const",[242,583,584],{"class":248}," struct",[242,586,587],{"class":254}," Color",[242,589,510],{"class":265},[242,591,592,595,597,599,602,604,606,608,611,613,616,618,621],{"class":244,"line":444},[242,593,594],{"class":248},"  static",[242,596,581],{"class":248},[242,598,507],{"class":254},[242,600,601],{"class":254}," orange",[242,603,259],{"class":258},[242,605,507],{"class":338},[242,607,342],{"class":265},[242,609,610],{"class":291},"255",[242,612,351],{"class":265},[242,614,615],{"class":291},"165",[242,617,351],{"class":265},[242,619,620],{"class":291},"0",[242,622,565],{"class":265},[242,624,625,627,629,631,634,636,638,640,643,645,647,649,651],{"class":244,"line":449},[242,626,594],{"class":248},[242,628,581],{"class":248},[242,630,507],{"class":254},[242,632,633],{"class":254}," purple",[242,635,259],{"class":258},[242,637,507],{"class":338},[242,639,342],{"class":265},[242,641,642],{"class":291},"128",[242,644,351],{"class":265},[242,646,620],{"class":291},[242,648,351],{"class":265},[242,650,642],{"class":291},[242,652,565],{"class":265},[242,654,655,657,659,661,664,667,669,671,673,675,678,680,683],{"class":244,"line":459},[242,656,594],{"class":248},[242,658,581],{"class":248},[242,660,507],{"class":254},[242,662,663],{"class":254}," pink",[242,665,666],{"class":258},"   =",[242,668,507],{"class":338},[242,670,342],{"class":265},[242,672,610],{"class":291},[242,674,351],{"class":265},[242,676,677],{"class":291},"192",[242,679,351],{"class":265},[242,681,682],{"class":291},"203",[242,684,565],{"class":265},[242,686,688,690,692,694,697,699,701,703,705,707,709,711,713],{"class":244,"line":687},11,[242,689,594],{"class":248},[242,691,581],{"class":248},[242,693,507],{"class":254},[242,695,696],{"class":254}," gray",[242,698,666],{"class":258},[242,700,507],{"class":338},[242,702,342],{"class":265},[242,704,642],{"class":291},[242,706,351],{"class":265},[242,708,642],{"class":291},[242,710,351],{"class":265},[242,712,642],{"class":291},[242,714,565],{"class":265},[242,716,718,720,722,724,727,730,732,734,736,738,741,743,745],{"class":244,"line":717},12,[242,719,594],{"class":248},[242,721,581],{"class":248},[242,723,507],{"class":254},[242,725,726],{"class":254}," brown",[242,728,729],{"class":258},"  =",[242,731,507],{"class":338},[242,733,342],{"class":265},[242,735,615],{"class":291},[242,737,351],{"class":265},[242,739,740],{"class":291},"42",[242,742,351],{"class":265},[242,744,740],{"class":291},[242,746,565],{"class":265},[242,748,750],{"class":244,"line":749},13,[242,751,380],{"class":265},[204,753,754,755,758],{},"This const struct exists is mainly because enum is not enough, as enum only works for primitive types, but here pops another question.\nAnd last but not least, this struct ",[207,756,757],{},"Color"," only exists at compile time, if optimization is on!",[760,761,762],"accordion",{},[763,764,767,773,776],"accordion-item",{"icon":765,"label":766},"i-lucide-circle-help","Why don't make enum also work for this?",[204,768,769,770,543],{},"The answer is really simeple, ",[321,771,772],{},"simplicity!",[204,774,775],{},"If enum were this powerful, then Cambo would be just as complicated as C++.",[204,777,778],{},[321,779,780],{},"\"With great power comes great responsibility!\" - uncle Ben",[480,782,783,784,787,788,790],{},"Color is a ",[207,785,786],{},"static const"," struct, so all of its members will be the same. Which means ",[207,789,786],{}," for RGB orange and others is optional, but including it makes code meaningful.",[223,792,794],{"id":793},"the-pros-cons","The pros & cons",[212,796,797,800,803],{},[215,798,799],{},"it reduces some memory usage.",[215,801,802],{},"it reduces the execution time at run time.",[215,804,805],{},"but it increases the compilation time.",[807,808,809],"warning",{},"This page is not completed, will be updated later.",[811,812,813],"style",{},"html pre.shiki code .sQsOY, html code.shiki .sQsOY{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#A626A4;--shiki-default-font-style:inherit;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .s8dPH, html code.shiki .s8dPH{--shiki-light:#90A4AE;--shiki-default:#E45649;--shiki-dark:#E06C75}html pre.shiki code .sB4Xn, html code.shiki .sB4Xn{--shiki-light:#39ADB5;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .sM89C, html code.shiki .sM89C{--shiki-light:#90A4AE;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sriKn, html code.shiki .sriKn{--shiki-light:#F76D47;--shiki-default:#986801;--shiki-dark:#D19A66}html pre.shiki code .spnjr, html code.shiki .spnjr{--shiki-light:#6182B8;--shiki-default:#4078F2;--shiki-dark:#61AFEF}html pre.shiki code .seacL, html code.shiki .seacL{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#A0A1A7;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}",{"title":238,"searchDepth":362,"depth":362,"links":815},[816,817,818,819],{"id":225,"depth":362,"text":226},{"id":310,"depth":362,"text":311},{"id":474,"depth":362,"text":475},{"id":793,"depth":362,"text":794},"Constant might be a better choice!","md",null,{},{"icon":24},{"title":87,"description":820},"Lygo_gLc9u93sL2eT9hNt4xQsVAIzpNK-hfSBzBRl9A",[828,830],{"title":78,"path":79,"stem":80,"description":829,"icon":24,"children":-1},"Explore all vocabularies in Cambo.",{"title":91,"path":92,"stem":93,"description":831,"icon":24,"children":-1},"Define alias for anything.",1774971227270]