[{"data":1,"prerenderedAt":713},["ShallowReactive",2],{"navigation_docs":3,"-core-features-pointers":198,"-core-features-pointers-surround":708},[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":61,"body":200,"description":701,"extension":702,"links":703,"meta":704,"navigation":705,"path":62,"seo":706,"stem":63,"__hash__":707},"docs/2.core-features/7.pointers.md",{"type":201,"value":202,"toc":695},"minimark",[203,207,263,270,275,386,390,393,399,564,580,584,590,594,605,611,688,691],[204,205,206],"p",{},"A pointer is simply a variable that stores the memory address of another\nvariable. Instead of holding a direct value, it holds the location in the\ncomputer's memory where the actual value is stored.",[208,209,215],"pre",{"className":210,"code":211,"filename":212,"language":213,"meta":214,"style":214},"language-kh shiki shiki-themes material-theme-lighter one-light one-dark-pro","type* identifier;\ntype *identifier;\ntype * identifier;\n","syntax","kh","",[216,217,218,239,252],"code",{"__ignoreMap":214},[219,220,223,227,231,235],"span",{"class":221,"line":222},"line",1,[219,224,226],{"class":225},"sQsOY","type",[219,228,230],{"class":229},"sB4Xn","*",[219,232,234],{"class":233},"s8dPH"," identifier",[219,236,238],{"class":237},"sM89C",";\n",[219,240,242,244,247,250],{"class":221,"line":241},2,[219,243,226],{"class":225},[219,245,246],{"class":229}," *",[219,248,249],{"class":233},"identifier",[219,251,238],{"class":237},[219,253,255,257,259,261],{"class":221,"line":254},3,[219,256,226],{"class":225},[219,258,246],{"class":229},[219,260,234],{"class":233},[219,262,238],{"class":237},[264,265,266,267,269],"note",{},"All are OK as long as the asterisk ",[216,268,230],{}," stays in the middle.",[271,272,274],"h2",{"id":273},"dereferencing","Dereferencing",[208,276,278],{"className":210,"code":277,"language":213,"meta":214,"style":214},"int num = 13;\nint *ptr = &num;\n\nprint(\"address: {}\\n\", ptr); # this will output the memory address: 0x3454...\nprint(\"value: {}\\n\", *ptr);  # this will output the value stored at that memeory address: 13 \n",[216,279,280,297,316,322,358],{"__ignoreMap":214},[219,281,282,285,288,291,295],{"class":221,"line":222},[219,283,284],{"class":233},"int",[219,286,287],{"class":233}," num",[219,289,290],{"class":229}," =",[219,292,294],{"class":293},"sriKn"," 13",[219,296,238],{"class":237},[219,298,299,301,303,306,308,311,314],{"class":221,"line":241},[219,300,284],{"class":233},[219,302,246],{"class":229},[219,304,305],{"class":233},"ptr",[219,307,290],{"class":229},[219,309,310],{"class":237}," &",[219,312,313],{"class":233},"num",[219,315,238],{"class":237},[219,317,318],{"class":221,"line":254},[219,319,321],{"emptyLinePlaceholder":320},true,"\n",[219,323,325,329,332,336,340,344,346,349,351,354],{"class":221,"line":324},4,[219,326,328],{"class":327},"spnjr","print",[219,330,331],{"class":237},"(",[219,333,335],{"class":334},"sVH1b","\"",[219,337,339],{"class":338},"spZWa","address: {}",[219,341,343],{"class":342},"scPpd","\\n",[219,345,335],{"class":334},[219,347,348],{"class":237},", ",[219,350,305],{"class":233},[219,352,353],{"class":237},"); ",[219,355,357],{"class":356},"seacL","# this will output the memory address: 0x3454...\n",[219,359,361,363,365,367,370,372,374,376,378,380,383],{"class":221,"line":360},5,[219,362,328],{"class":327},[219,364,331],{"class":237},[219,366,335],{"class":334},[219,368,369],{"class":338},"value: {}",[219,371,343],{"class":342},[219,373,335],{"class":334},[219,375,348],{"class":237},[219,377,230],{"class":229},[219,379,305],{"class":233},[219,381,382],{"class":237},");  ",[219,384,385],{"class":356},"# this will output the value stored at that memeory address: 13\n",[271,387,389],{"id":388},"passing-by-reference","Passing By Reference",[204,391,392],{},"By default, arguments are passed by value, meaning a copy of the data is passed directly to the function. While this approach ensures that the original data remains unchanged, it can be inefficient for large data structures. In such cases, passing the address of the data is more practical, either to improve performance or to allow the function to modify the original value.",[204,394,395],{},[396,397,398],"strong",{},"Example:",[208,400,402],{"className":210,"code":401,"language":213,"meta":214,"style":214},"void add_one(int* ptr){\n  *ptr += 1;\n}\n\nint main(){\n\n  int num = 1;\n  \n  println(\"before: {}\", num); # before: 1\n  add_one(num);\n  println(\"after: {}\", num); # after: 2\n\n  return 0;\n}\n",[216,403,404,424,439,444,448,458,463,477,483,507,520,543,548,559],{"__ignoreMap":214},[219,405,406,409,412,414,416,418,421],{"class":221,"line":222},[219,407,408],{"class":225},"void",[219,410,411],{"class":327}," add_one",[219,413,331],{"class":237},[219,415,284],{"class":233},[219,417,230],{"class":229},[219,419,420],{"class":233}," ptr",[219,422,423],{"class":237},"){\n",[219,425,426,429,431,434,437],{"class":221,"line":241},[219,427,428],{"class":229},"  *",[219,430,305],{"class":233},[219,432,433],{"class":229}," +=",[219,435,436],{"class":293}," 1",[219,438,238],{"class":237},[219,440,441],{"class":221,"line":254},[219,442,443],{"class":237},"}\n",[219,445,446],{"class":221,"line":324},[219,447,321],{"emptyLinePlaceholder":320},[219,449,450,452,455],{"class":221,"line":360},[219,451,284],{"class":233},[219,453,454],{"class":327}," main",[219,456,457],{"class":237},"(){\n",[219,459,461],{"class":221,"line":460},6,[219,462,321],{"emptyLinePlaceholder":320},[219,464,466,469,471,473,475],{"class":221,"line":465},7,[219,467,468],{"class":233},"  int",[219,470,287],{"class":233},[219,472,290],{"class":229},[219,474,436],{"class":293},[219,476,238],{"class":237},[219,478,480],{"class":221,"line":479},8,[219,481,482],{"class":237},"  \n",[219,484,486,489,491,493,496,498,500,502,504],{"class":221,"line":485},9,[219,487,488],{"class":327},"  println",[219,490,331],{"class":237},[219,492,335],{"class":334},[219,494,495],{"class":338},"before: {}",[219,497,335],{"class":334},[219,499,348],{"class":237},[219,501,313],{"class":233},[219,503,353],{"class":237},[219,505,506],{"class":356},"# before: 1\n",[219,508,510,513,515,517],{"class":221,"line":509},10,[219,511,512],{"class":327},"  add_one",[219,514,331],{"class":237},[219,516,313],{"class":233},[219,518,519],{"class":237},");\n",[219,521,523,525,527,529,532,534,536,538,540],{"class":221,"line":522},11,[219,524,488],{"class":327},[219,526,331],{"class":237},[219,528,335],{"class":334},[219,530,531],{"class":338},"after: {}",[219,533,335],{"class":334},[219,535,348],{"class":237},[219,537,313],{"class":233},[219,539,353],{"class":237},[219,541,542],{"class":356},"# after: 2\n",[219,544,546],{"class":221,"line":545},12,[219,547,321],{"emptyLinePlaceholder":320},[219,549,551,554,557],{"class":221,"line":550},13,[219,552,553],{"class":225},"  return",[219,555,556],{"class":293}," 0",[219,558,238],{"class":237},[219,560,562],{"class":221,"line":561},14,[219,563,443],{"class":237},[204,565,566,567,569,570,572,573,576,577,579],{},"Notice that in order to pass an argument by reference, the function parameter must be declared as a pointer, allowing the function to recieve and operate on the address of the original data. In the above example, variable ",[216,568,305],{}," is declared as an int pointer. The variable ",[216,571,313],{}," is passed normally to the function ",[216,574,575],{},"add_one",", in this case however, the address of ",[216,578,313],{}," is being served instead of its value.",[271,581,583],{"id":582},"returning-an-address","Returning An Address",[585,586,587],"blockquote",{},[204,588,589],{},"not yet documented!",[271,591,593],{"id":592},"pointer-arithmetic","Pointer Arithmetic",[204,595,596,597,600,601,604],{},"Unlike regular maths arithmetic, only addition ",[216,598,599],{},"+"," and substraction ",[216,602,603],{},"-"," are allowed.\nfor pointer arithmetic.",[204,606,607,608,610],{},"Suppose ",[216,609,305],{}," is a pointer pointing to a particular type, then",[208,612,614],{"className":210,"code":613,"language":213,"meta":214,"style":214},"ptr++;\nptr--;\nptr += n;\nptr -= n;\nptr1 = ptr2 + n;\nptr1 = ptr2 - n;\n",[216,615,616,625,634,645,656,673],{"__ignoreMap":214},[219,617,618,620,623],{"class":221,"line":222},[219,619,305],{"class":233},[219,621,622],{"class":229},"++",[219,624,238],{"class":237},[219,626,627,629,632],{"class":221,"line":241},[219,628,305],{"class":233},[219,630,631],{"class":229},"--",[219,633,238],{"class":237},[219,635,636,638,640,643],{"class":221,"line":254},[219,637,305],{"class":233},[219,639,433],{"class":229},[219,641,642],{"class":233}," n",[219,644,238],{"class":237},[219,646,647,649,652,654],{"class":221,"line":324},[219,648,305],{"class":233},[219,650,651],{"class":229}," -=",[219,653,642],{"class":233},[219,655,238],{"class":237},[219,657,658,661,663,666,669,671],{"class":221,"line":360},[219,659,660],{"class":233},"ptr1",[219,662,290],{"class":229},[219,664,665],{"class":233}," ptr2",[219,667,668],{"class":229}," +",[219,670,642],{"class":233},[219,672,238],{"class":237},[219,674,675,677,679,681,684,686],{"class":221,"line":460},[219,676,660],{"class":233},[219,678,290],{"class":229},[219,680,665],{"class":233},[219,682,683],{"class":229}," -",[219,685,642],{"class":233},[219,687,238],{"class":237},[264,689,690],{},"\"With great power comes great responsibility\", uncle Ben.",[692,693,694],"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 .sB4Xn, html code.shiki .sB4Xn{--shiki-light:#39ADB5;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .s8dPH, html code.shiki .s8dPH{--shiki-light:#90A4AE;--shiki-default:#E45649;--shiki-dark:#E06C75}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 .sVH1b, html code.shiki .sVH1b{--shiki-light:#39ADB5;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .spZWa, html code.shiki .spZWa{--shiki-light:#91B859;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .scPpd, html code.shiki .scPpd{--shiki-light:#90A4AE;--shiki-default:#0184BC;--shiki-dark:#56B6C2}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":214,"searchDepth":241,"depth":241,"links":696},[697,698,699,700],{"id":273,"depth":241,"text":274},{"id":388,"depth":241,"text":389},{"id":582,"depth":241,"text":583},{"id":592,"depth":241,"text":593},"Pointer Pointee","md",null,{},{"icon":24},{"title":61,"description":701},"fRwSi03P4CGXkuBuZAhbKLpV6UaYYJUEyPlExVjt27Y",[709,711],{"title":57,"path":58,"stem":59,"description":710,"icon":24,"children":-1},"Introduction to functions in Cambo.",{"title":65,"path":66,"stem":67,"description":712,"icon":24,"children":-1},"All built-in data types in Cambo.",1774971227270]