{
    "componentChunkName": "component---src-components-layout-mdx-layout-tsx",
    "path": "/language/from-cpp",
    "result": {"data":{"site":{"siteMetadata":{"title":"Toit documentation"}},"mdx":{"body":"const _excluded = [\"components\"];\n\nfunction _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }\n\nfunction _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }\n\nfunction _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nconst _frontmatter = {};\nconst layoutProps = {\n  _frontmatter\n};\nconst MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  let {\n    components\n  } = _ref,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", {\n    \"id\": \"toit-for-c-and-c-programmers\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h1\",\n    \"href\": \"#toit-for-c-and-c-programmers\",\n    \"aria-label\": \"toit for c and c programmers permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Toit for C and C++ programmers\"), mdx(\"p\", null, \"This introduction covers Toit from a C/C++ starting point. Familiar operations\\nget a short explanation; calls, blocks, managed objects, and cooperative tasks\\nget more space. The examples run on your computer with the\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/beginner#1-run-your-first-program\"\n  }, \"Toit SDK\"), \".\"), mdx(\"p\", null, \"Each example is a complete program unless a filename is given. Replace the\\nprevious example when running the next one. For a quick syntax lookup, use the\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/cheat-sheet\"\n  }, \"comparison cheat sheet\"), \".\"), mdx(\"h2\", {\n    \"id\": \"a-program-starts-at-main\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#a-program-starts-at-main\",\n    \"aria-label\": \"a program starts at main permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"A program starts at main\"), mdx(\"p\", null, \"Toit uses indentation instead of braces. Functions can be defined directly in\\na file, and statements do not end with semicolons. Here is a complete program:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"add a b:\\n  return a + b\\n\\nmain:\\n  count := 3\\n  count++\\n  print (add count 2)  // Prints 6.\\n\")), mdx(\"p\", null, \"Use two spaces per indentation level. Comments use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"//\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/* ... */\"), \".\\nVariables and functions use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"kebab-case\"), \", classes use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"UpperCamelCase\"), \", and\\nconstants use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"UPPER-KEBAB-CASE\"), \". A hyphen can belong to a name: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"item-count\"), \" is\\none variable, while \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"item - count\"), \" is subtraction.\"), mdx(\"h2\", {\n    \"id\": \"variables-and-scope\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#variables-and-scope\",\n    \"aria-label\": \"variables and scope permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Variables and scope\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":=\"), \" declares a mutable binding; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"=\"), \" assigns a new value. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"::=\"), \" declares a final\\nbinding, which cannot be reassigned. Normally use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":=\"), \" inside functions. Prefer\\nfinal fields and globals when their bindings will not change.\"), mdx(\"p\", null, \"Finality applies to the binding, not to the referenced object's contents. It is\\nnot C++ \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"const\"), \" access to an object:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"NAMES ::= [\\\"Ada\\\"]\\n\\nmain:\\n  NAMES.add \\\"Grace\\\"\\n  print NAMES.size  // Prints 2.\\n\")), mdx(\"p\", null, \"Local names belong to their enclosing scope. Top-level variables are globals;\\ntheir initializers run on first access. Objects are managed references. Passing\\nan object to a function does not copy it, and assignment does not invoke a\\nuser-defined copy constructor.\"), mdx(\"h2\", {\n    \"id\": \"calling-functions-and-methods\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#calling-functions-and-methods\",\n    \"aria-label\": \"calling functions and methods permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Calling functions and methods\"), mdx(\"p\", null, \"Spaces separate call arguments: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"add 1 2\"), \". Parentheses group an expression\\nwhen its result is needed by another call: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"print (add 1 2)\"), \".\"), mdx(\"p\", null, \"Arithmetic binds more tightly than calls. Although \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"add 1 2 * 3\"), \" means\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"add 1 (2 * 3)\"), \", prefer the latter spelling, especially with multiple arguments.\"), mdx(\"p\", null, \"A zero-argument call needs no parentheses. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name.trim\"), \" invokes \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"trim\"), \"; it does\\nnot produce a member-function pointer. Public fields use the same access\\nsyntax, so a field can later become a computed getter without changing readers.\"), mdx(\"h3\", {\n    \"id\": \"named-and-default-arguments\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#named-and-default-arguments\",\n    \"aria-label\": \"named and default arguments permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Named and default arguments\"), mdx(\"p\", null, \"Both positional and named parameters can have default values. A named parameter\\nuses \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--\"), \" in its definition and calls:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"greet name=\\\"World\\\" --greeting=\\\"Hello\\\" --loud=false:\\n  text := \\\"$greeting $name\\\"\\n  print (loud ? \\\"$text!\\\" : text)\\n\\nmain:\\n  greet\\n  greet \\\"Ada\\\" --greeting=\\\"Hi\\\" --loud\\n  greet \\\"Grace\\\" --no-loud\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello World\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hi Ada!\"), \", then \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello Grace\"), \". A bare boolean flag\\npasses \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"true\"), \"; its \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--no-\"), \" form passes \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \".\"), mdx(\"p\", null, \"Toit overloads by argument count and names, not by parameter types. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \"\\nto supply a function's result. Type annotations can document and check the\\narguments and result, as we will see next.\"), mdx(\"span\", {\n    id: \"types-are-runtime-contracts\"\n  }), mdx(\"h2\", {\n    \"id\": \"types-and-null\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#types-and-null\",\n    \"aria-label\": \"types and null permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Types and null\"), mdx(\"p\", null, \"Types are optional. Parameters and variables use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/Type\"), \"; return annotations\\nuse \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"-> Type\"), \". The annotations check actual values at runtime:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"add a/int b/int -> int:\\n  return a + b\\n\\nmain:\\n  print (add 2 3)\\n  value/any := \\\"3\\\"\\n  error := catch: add 2 value\\n  if error:\\n    print \\\"Expected integers\\\"\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"5\"), \", then \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Expected integers\"), \". The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"any\"), \" annotation permits any\\nvalue in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value\"), \", but \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"add\"), \" still requires integers. Its second call fails a parameter\\ncheck; we will cover \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch\"), \" below. Unlike C++, not every type mismatch prevents\\ncompilation. Analysis catches some mistakes, while the runtime enforces the\\nannotations.\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" denotes absence. Types exclude it by default; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"string?\"), \" accepts a string\\nor \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \". \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"any\"), \" accepts any value, including \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"none\"), \" marks a function\\nwith no result. A nullable reference does not support pointer arithmetic or\\nmanual dereferencing.\"), mdx(\"p\", null, \"Toit permits assigning a nullable type to its non-nullable counterpart\\nstatically, with a runtime check on the value. The type \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Null\"), \" itself is the\\nexception. See the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus#nullable-types-and-assignments\"\n  }, \"nullable assignment example\"), \".\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value is Type\"), \" for a type test and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value as Type\"), \" for a checked cast.\\nA cast does not convert a value; conversions use methods such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"to-float\"), \"\\nor functions such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"int.parse\"), \".\"), mdx(\"h2\", {\n    \"id\": \"numbers-booleans-and-operators\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#numbers-booleans-and-operators\",\n    \"aria-label\": \"numbers booleans and operators permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Numbers, booleans, and operators\"), mdx(\"p\", null, \"Integers are signed 64-bit values; floats are double precision. Integer division\\ntruncates toward zero, as in C/C++: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"-5 / 2\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"-2\"), \". A float operand preserves\\nthe fractional part: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"5 / 2.0\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"2.5\"), \".\"), mdx(\"p\", null, \"Arithmetic and comparison operators are familiar: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"+\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"-\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"*\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"%\"), \",\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"==\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"!=\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<=\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \">\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \">=\"), \". Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"and\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"or\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"not\"), \" for logic.\\nOnly \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" are falsy; unlike C/C++, zero is truthy.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  print (0 or 10)      // Prints 0.\\n  print (null or 10)   // Prints 10.\\n  print (5 / 2)       // Prints 2.\\n  print (5 / 2.0)     // Prints 2.5.\\n\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"and\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"or\"), \" short-circuit and return an operand, rather than always producing\\na boolean. An empty list or string is also truthy; check its size or use a\\ncollection's \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"is-empty\"), \" getter when you mean emptiness.\"), mdx(\"p\", null, \"Bitwise operators are \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"&\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"|\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"^\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"~\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<<\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \">>\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \">>>\"), \". The last is\\nunsigned right shift. Hexadecimal and binary literals use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"0x\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"0b\"), \";\\nunderscores can group digits, as in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"0xffff_ffff\"), \".\"), mdx(\"h2\", {\n    \"id\": \"strings-and-formatting\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#strings-and-formatting\",\n    \"aria-label\": \"strings and formatting permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Strings and formatting\"), mdx(\"p\", null, \"Strings are immutable UTF-8 text. Double quotes create a string; single quotes\\ncreate an integer code point, so \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"'A'\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"65\"), \". Use triple double quotes for\\nmultiline strings, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\\n\"), \" for a newline, and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\\$\"), \" for a literal dollar sign.\"), mdx(\"p\", null, \"Insert values with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$name\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$(expression)\"), \". Formatting puts the specifier\\nnext to the value, instead of in a separate \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"printf\"), \" argument list:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  name := \\\"Ada\\\"\\n  print \\\"Hello $name\\\"\\n  print \\\"Name length: $name.size\\\"\\n  print \\\"Next: $(21 + 1)\\\"\\n  print \\\"Pi: $(%.2f 3.14159)\\\"\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello Ada\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Name length: 3\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Next: 22\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Pi: 3.14\"), \".\\nMember access and indexing can be part of interpolation. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$(name)-sensor\"), \"\\nwhen a literal hyphen should follow the name.\"), mdx(\"p\", null, \"String offsets count UTF-8 bytes: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\"\\xE9\\\".size\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"2\"), \". Indexing at a character\\nboundary returns a code point; indexing at a continuation byte returns \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \".\\nUse \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"text.do --runes:\"), \" to iterate over code points. See\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/strings\"\n  }, \"strings\"), \" for slicing and formatting details.\"), mdx(\"h2\", {\n    \"id\": \"conditions-and-loops\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#conditions-and-loops\",\n    \"aria-label\": \"conditions and loops permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Conditions and loops\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"if\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"else if\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"else\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"while\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"break\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"continue\"), \" work much as in C/C++,\\nwith indentation in place of braces. The conditional expression uses\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"condition ? yes : no\"), \". A C-style \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"for\"), \" loop is available:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  for i := 0; i < 4; i++:\\n    if i == 1: continue\\n    print i  // Prints 0, 2, then 3.\\n\\n  remaining := 3\\n  while remaining > 0:\\n    remaining--\\n  print remaining  // Prints 0.\\n\")), mdx(\"p\", null, \"For a fixed number of repetitions, normally use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"3.repeat:\"), \". To iterate over\\na collection, use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"values.do:\"), \". These are ordinary methods taking blocks,\\nwhich let library code provide control structures.\"), mdx(\"h2\", {\n    \"id\": \"blocks-provide-scoped-control-flow\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#blocks-provide-scoped-control-flow\",\n    \"aria-label\": \"blocks provide scoped control flow permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Blocks provide scoped control flow\"), mdx(\"p\", null, \"A block starts with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":\"), \". Parameters appear between \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"|\"), \" characters. The block\\ncan read and update locals in the surrounding function:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  total := 0\\n  3.repeat: |i|\\n    total += i\\n  print total  // Prints 3.\\n\")), mdx(\"p\", null, \"A \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \" in a block returns from the function in which the block was written.\\nThis is a \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"non-local return\"), \", unlike returning from a C++ lambda:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"first-positive values:\\n  values.do: |value|\\n    if value > 0:\\n      return value\\n  return null\\n\\nmain:\\n  print (first-positive [-1, 0, 4, 8])  // Prints 4.\\n\")), mdx(\"p\", null, \"The return leaves both the block and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"first-positive\"), \". Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"continue.do\"), \" to\\nskip one \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"do\"), \" iteration, or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"continue.repeat\"), \" for \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"repeat\"), \". Those exits leave\\nthe enclosing function running.\"), mdx(\"h3\", {\n    \"id\": \"accepting-a-block\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#accepting-a-block\",\n    \"aria-label\": \"accepting a block permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Accepting a block\"), mdx(\"p\", null, \"A block parameter is written in square brackets. Invoke it with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".call\"), \".\\nThe block's last expression supplies its result; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \" would instead leave\\nthe caller's enclosing function:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"with-offset offset/int [action]:\\n  return action.call offset\\n\\nmain:\\n  base := 10\\n  result := with-offset 5: |offset|\\n    base + offset\\n  print result  // Prints 15.\\n\")), mdx(\"h3\", {\n    \"id\": \"lifetime-and-cost\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#lifetime-and-cost\",\n    \"aria-label\": \"lifetime and cost permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Lifetime and cost\"), mdx(\"p\", null, \"Block references encode stack-relative positions as small integers. Passing a\\nblock pushes a reference; it does not allocate a heap closure to copy captured\\nlocals. The language enforces the lifetime that makes this safe: blocks cannot\\nescape into fields, globals, collections, or return values. A lambda cannot\\ncapture a block either.\"), mdx(\"p\", null, \"C++ lambdas can also avoid heap allocation, but a lambda capturing references\\ncan outlive the referenced locals. C++ does not enforce Toit's block lifetime\\nrestriction. Use blocks for scoped callbacks such as iteration and resource\\nmanagement.\"), mdx(\"h3\", {\n    \"id\": \"lambdas-for-stored-callbacks\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#lambdas-for-stored-callbacks\",\n    \"aria-label\": \"lambdas for stored callbacks permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Lambdas for stored callbacks\"), mdx(\"p\", null, \"A lambda starts with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"::\"), \" and can outlive the call that created it. Its last\\nexpression is its result; it cannot contain an explicit \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \":\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"make-adder amount/int -> Lambda:\\n  return :: |value| value + amount\\n\\nmain:\\n  add-five := make-adder 5\\n  print (add-five.call 3)  // Prints 8.\\n\")), mdx(\"p\", null, \"The lambda keeps access to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"amount\"), \". It can be stored in a field or returned,\\nas here. Use the form the API expects: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"[action]\"), \" accepts a block; a stored\\ncallback uses a lambda. See \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/blocks-and-lambdas\"\n  }, \"blocks and lambdas\"), \".\"), mdx(\"h2\", {\n    \"id\": \"collections-and-binary-data\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#collections-and-binary-data\",\n    \"aria-label\": \"collections and binary data permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Collections and binary data\"), mdx(\"p\", null, \"Lists, maps, sets, and byte arrays have literal syntax:\"), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Collection\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Literal\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Typical operation\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"List\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"[1, 2, 3]\"), \"; empty \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"[]\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"values.add 4\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Map\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"{\\\"name\\\": \\\"Ada\\\"}\"), \"; empty \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"{:}\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"labels[\\\"name\\\"]\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Set\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"{1, 2, 3}\"), \"; empty \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"{}\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"seen.contains 2\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Byte array\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"#[0, 127, 255]\"), \"; empty \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"#[]\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"bytes[0]\"))))), mdx(\"p\", null, \"Collections can hold mixed types. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"List\"), \" does not take a template argument for\\nits elements; use annotations or checks where element types matter.\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"map\"), \" to transform, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"filter\"), \" to select, and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"reduce\"), \" to combine elements.\\nShort one-parameter blocks can use the implicit name \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"it\"), \":\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  readings := [21, 26, 25]\\n  warm := readings.filter: it >= 25\\n  labels := readings.map: \\\"$it C\\\"\\n  total := readings.reduce --initial=0: |sum reading| sum + reading\\n  print warm               // Prints [26, 25].\\n  print (labels.join \\\", \\\")  // Prints 21 C, 26 C, 25 C.\\n  print total              // Prints 72.\\n\")), mdx(\"p\", null, \"A map lookup with brackets throws if the key is absent; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"labels.get \\\"name\\\"\"), \"\\nreturns \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" when absent. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--if-absent\"), \" to compute a different fallback.\"), mdx(\"p\", null, \"A slice such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"values[1..3]\"), \" includes index 1 and excludes index 3. List slices\\nare views into the original list: writes affect the shared elements, and the\\nslice keeps the entire original list alive. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".copy\"), \" for a shallow copy\\nwith independent element slots.\"), mdx(\"p\", null, \"Use a \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ByteArray\"), \" and encoding APIs for binary data. Do not depend on object\\nlayout or C struct packing:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"import io\\n\\nmain:\\n  bytes := ByteArray 4\\n  io.LITTLE-ENDIAN.put-uint32 bytes 0 0x1234\\n  print (io.LITTLE-ENDIAN.uint32 bytes 0)  // Prints 4660.\\n\")), mdx(\"span\", {\n    id: \"classes-are-constructed-by-calling-them\"\n  }), mdx(\"h2\", {\n    \"id\": \"classes-fields-and-methods\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#classes-fields-and-methods\",\n    \"aria-label\": \"classes fields and methods permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Classes, fields, and methods\"), mdx(\"p\", null, \"Call a class to construct an object, without \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"new\"), \". Declare fields in the class;\\nobjects cannot gain additional fields dynamically. Methods have fields and\\nother methods in scope, so \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"this.\"), \" is usually unnecessary:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"class Counter:\\n  value_/int := ?\\n\\n  constructor .value_=0:\\n\\n  value -> int: return value_\\n\\n  increment -> none:\\n    value_++\\n\\nmain:\\n  counter := Counter 4\\n  counter.increment\\n  print counter.value  // Prints 5.\\n\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":= ?\"), \" requires the constructor to initialize the field. The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".value_\"), \" parameter\\nstores its argument directly in the field. A field declared as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name/string\"), \"\\nwithout \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":=\"), \" is final and must also be initialized by the constructor.\"), mdx(\"p\", null, \"A trailing underscore marks a private member. The public \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value\"), \" getter uses\\nthe same call syntax as a public field. A setter is written \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value= new-value:\"), \"\\nand called with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"counter.value = new-value\"), \".\"), mdx(\"h3\", {\n    \"id\": \"inheritance-and-interfaces\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#inheritance-and-interfaces\",\n    \"aria-label\": \"inheritance and interfaces permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Inheritance and interfaces\"), mdx(\"p\", null, \"A class can extend one superclass and implement multiple interfaces. Interfaces\\nmust be implemented explicitly. Methods do not need a \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"virtual\"), \" declaration\\nto be overridden:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"interface Described:\\n  description -> string\\n\\nclass Device implements Described:\\n  name/string\\n\\n  constructor .name:\\n\\n  description -> string: return name\\n\\nclass Sensor extends Device:\\n  constructor name/string:\\n    super name\\n\\n  description -> string:\\n    return \\\"Sensor: $(super)\\\"\\n\\nmain:\\n  device/Described := Sensor \\\"Kitchen\\\"\\n  print device.description  // Prints Sensor: Kitchen.\\n\")), mdx(\"p\", null, \"In a constructor, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"super\"), \" calls the superclass constructor. In an overriding\\nmethod, it calls the superclass's method with the same name. This is not the\\nC++ spelling \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Base::method(...)\"), \".\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"abstract class\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"abstract\"), \" methods for partially implemented classes.\\nUse \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"static\"), \" for class-level methods and fields. Named constructors, such as\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Counter.from-reading\"), \", give different construction paths descriptive names.\"), mdx(\"h3\", {\n    \"id\": \"mixins-and-factory-constructors\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#mixins-and-factory-constructors\",\n    \"aria-label\": \"mixins and factory constructors permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Mixins and factory constructors\"), mdx(\"p\", null, \"Mixins share implementation across classes without adding another superclass.\\nFor example, a mixin can provide printing while requiring the class to supply\\na description:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"abstract mixin Printable:\\n  abstract description -> string\\n\\n  print-description -> none:\\n    print description\\n\\nclass Device extends Object with Printable:\\n  description -> string: return \\\"Device\\\"\\n\\nmain:\\n  device := Device\\n  device.print-description  // Prints Device.\\n\")), mdx(\"p\", null, \"A factory constructor returns an object instead of initializing a new instance\\nof its own class. Interfaces and abstract classes can expose factories that\\nchoose a concrete implementation:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"interface Named:\\n  constructor name/string:\\n    return Person name\\n\\n  name -> string\\n\\nclass Person implements Named:\\n  name/string\\n\\n  constructor .name:\\n\\nmain:\\n  person := Named \\\"Ada\\\"\\n  print person.name  // Prints Ada.\\n\")), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \" makes this a factory constructor. An interface can only have\\nfactories; an abstract class can also have regular constructors for subclasses\\nto call. See the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus#construct-an-implementation-through-its-interface\"\n  }, \"abstract-class factory example\"), \"\\nand the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/objects-constructors-inheritance-interfaces\"\n  }, \"class reference\"), \".\"), mdx(\"h2\", {\n    \"id\": \"memory-is-managed-resources-still-need-cleanup\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#memory-is-managed-resources-still-need-cleanup\",\n    \"aria-label\": \"memory is managed resources still need cleanup permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Memory is managed; resources still need cleanup\"), mdx(\"p\", null, \"You do not use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"malloc\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"free\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"new\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"delete\"), \", or pointer arithmetic. Garbage\\ncollection reclaims unreachable objects. It does not provide C++ destructor\\nsemantics for closing files, sockets, or peripherals at a particular time.\\nUse \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"try:\"), \" with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"finally:\"), \" for explicit cleanup.\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"throw\"), \" raises an exception. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch:\"), \" runs a block and returns the thrown value,\\nor \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" when nothing was thrown. Exceptions are values; strings are common:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  error := catch:\\n    try:\\n      print \\\"Using resource\\\"\\n      throw \\\"Operation failed\\\"\\n    finally:\\n      print \\\"Cleanup runs here\\\"\\n  if error:\\n    print \\\"Handled: $error\\\"\\n\")), mdx(\"p\", null, \"This prints the resource message, the cleanup message, then \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Handled: Operation\\nfailed\"), \". Replace the cleanup message with the resource's close operation in\\nreal code. There is no combined \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"try\"), \"/\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch\"), \" syntax: nest the cleanup inside\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch\"), \" when both are needed. Throw a truthy value when using \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"if error\"), \" to\\ndetect a failure. See \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/exceptions\"\n  }, \"exception handling\"), \".\"), mdx(\"h2\", {\n    \"id\": \"libraries-replace-headers\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#libraries-replace-headers\",\n    \"aria-label\": \"libraries replace headers permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Libraries replace headers\"), mdx(\"p\", null, \"Each \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".toit\"), \" file is an importable library; declarations do not need separate\\nheaders. Put imports at the top of the file. Core names such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"print\"), \" and\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"List\"), \" are available automatically:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"import math\\n\\nmain:\\n  print (math.sqrt 9.0)  // Prints 3.0.\\n\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"import .helpers\"), \" imports a sibling \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"helpers.toit\"), \" and exposes its members\\nwithout a prefix by default. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"import .helpers as helpers\"), \" chooses an explicit\\nprefix. SDK and package imports normally use a prefix; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"show\"), \" selects names.\\nSee the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus#files-are-libraries\"\n  }, \"two-file example\"), \".\"), mdx(\"p\", null, \"Dependencies on separately distributed libraries are declared in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"package.yaml\"), \";\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"package.lock\"), \" records resolved versions. Imports are resolved before execution.\\nUse the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/package/pkgguide\"\n  }, \"package quick start\"), \" to add a dependency.\"), mdx(\"h2\", {\n    \"id\": \"tasks-cooperate-within-a-program\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#tasks-cooperate-within-a-program\",\n    \"aria-label\": \"tasks cooperate within a program permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Tasks cooperate within a program\"), mdx(\"p\", null, \"Each task has a call stack. Tasks share objects and take turns running, switching\\nat yielding operations such as waiting for I/O or sleeping. Ordinary functions\\ncan wait without a special declaration or a callback at every call:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"report label/string delay/int -> none:\\n  2.repeat:\\n    sleep --ms=delay\\n    print label\\n\\nmain:\\n  task:: report \\\"Fast\\\" 10\\n  task:: report \\\"Slow\\\" 25\\n\")), mdx(\"p\", null, \"Each task prints twice. While one is waiting, another can run. The timing is\\nnot a real-time guarantee.\"), mdx(\"p\", null, \"Unlike preemptive threads, another task in the same program cannot interrupt a\\ncomputation that does not yield. A loop that never yields starves other tasks.\\nConversely, shared state can change across a waiting call, so operations spanning\\na wait may need synchronization. A helper can yield even though its call looks\\nordinary. See \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/tasks\"\n  }, \"tasks and synchronization\"), \".\"), mdx(\"h2\", {\n    \"id\": \"continue-with-a-project\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#continue-with-a-project\",\n    \"aria-label\": \"continue with a project permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Continue with a project\"), mdx(\"p\", null, \"You can use Toit for host scripts, command-line tools, network applications,\\nand device programs. Use the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/reference\"\n  }, \"language reference\"), \" to look\\nup details, the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/package/pkgguide\"\n  }, \"package quick start\"), \" to add libraries,\\nor \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/getstarted/device\"\n  }, \"Run on your device\"), \" to work with an ESP32.\"));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{"items":[{"url":"#toit-for-c-and-c-programmers","title":"Toit for C and C++ programmers","items":[{"url":"#a-program-starts-at-main","title":"A program starts at main"},{"url":"#variables-and-scope","title":"Variables and scope"},{"url":"#calling-functions-and-methods","title":"Calling functions and methods","items":[{"url":"#named-and-default-arguments","title":"Named and default arguments"}]},{"url":"#types-and-null","title":"Types and null"},{"url":"#numbers-booleans-and-operators","title":"Numbers, booleans, and operators"},{"url":"#strings-and-formatting","title":"Strings and formatting"},{"url":"#conditions-and-loops","title":"Conditions and loops"},{"url":"#blocks-provide-scoped-control-flow","title":"Blocks provide scoped control flow","items":[{"url":"#accepting-a-block","title":"Accepting a block"},{"url":"#lifetime-and-cost","title":"Lifetime and cost"},{"url":"#lambdas-for-stored-callbacks","title":"Lambdas for stored callbacks"}]},{"url":"#collections-and-binary-data","title":"Collections and binary data"},{"url":"#classes-fields-and-methods","title":"Classes, fields, and methods","items":[{"url":"#inheritance-and-interfaces","title":"Inheritance and interfaces"},{"url":"#mixins-and-factory-constructors","title":"Mixins and factory constructors"}]},{"url":"#memory-is-managed-resources-still-need-cleanup","title":"Memory is managed; resources still need cleanup"},{"url":"#libraries-replace-headers","title":"Libraries replace headers"},{"url":"#tasks-cooperate-within-a-program","title":"Tasks cooperate within a program"},{"url":"#continue-with-a-project","title":"Continue with a project"}]}]}}},"pageContext":{"title":"For C and C++ programmers","id":"5735b633-36cc-5425-a824-c11d42e1afab"}},
    "staticQueryHashes": ["2197327828"]}