PageSourceSearch

https://noir-lang.org/docs/assets/js/069dbf1c.90f27b1d.js

js noir-lang.org collected 2026-10-03 22:53:21 UTC 3,347 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[2622],{63220(e,a,t){t.r(a),t.d(a,{assets:()=>d,contentTitle:()=>o,default:()=>u,frontMatter:()=>s,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"language/data_bus","title":"Data Bus","description":"Use call_data and return_data to enable a backend optimization for more efficient recursion, with examples and constraints.","source":"@site/versioned_docs/version-v1.0.0-rc.2/language/data_bus.mdx","sourceDirName":"language","slug":"/language/data_bus","permalink":"/docs/language/data_bus","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-rc.2/language/data_bus.mdx","tags":[],"version":"v1.0.0-rc.2","frontMatter":{"title":"Data Bus","description":"Use call_data and return_data to enable a backend optimization for more efficient recursion, with examples and constraints."},"sidebar":"sidebar","previous":{"title":"Shadowing","permalink":"/docs/language/shadowing"},"next":{"title":"Traits","permalink":"/docs/language/traits"}}');var r=t(74848),i=t(28453);const s={title:"Data Bus",description:"Use call_data and return_data to enable a backend optimization for more efficient recursion, with examples and constraints."},o=void 0,d={},c=[{value:"Example",id:"example",level:2}];function l(e){const a={code:"code",h2:"h2",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a.p,{children:["The data bus is an optimization that the backend can use to make recursion more efficient.\nIn order to use it, you must define some inputs of the program entry points (usually the ",(0,r.jsx)(a.code,{children:"main()"}),"\nfunction) with the ",(0,r.jsx)(a.code,{children:"call_data"})," modifier, and the return values with the ",(0,r.jsx)(a.code,{children:"return_data"})," modifier.\nThese modifiers are incompatible with ",(0,r.jsx)(a.code,{children:"pub"})," and ",(0,r.jsx)(a.code,{children:"mut"})," modifiers."]}),"\n",(0,r.jsx)(a.h2,{id:"example",children:"Example"}),"\n",(0,r.jsx)(a.pre,{children:(0,r.jsx)(a.code,{className:"language-rust",children:"fn main(mut x: u32, y: call_data(0) u32, z: call_data(0) [u32; 4]) -> return_data u32 {\n  let a = z[x];\n  a + y\n}\n"})}),"\n",(0,r.jsxs)(a.p,{children:["Each ",(0,r.jsx)(a.code,{children:"call_data"})," parameter takes an identifier (",(0,r.jsx)(a.code,{children:"call_data(<id>) T"}),") which groups parameters into the same call-data array \u2014 parameters sharing an identifier end up in the same read-only array, while different identifiers produce independent ones."]}),"\n",(0,r.jsx)(a.p,{children:"As a result, both call_data and return_data will be treated as private inputs and encapsulated into a read-only array each, for the backend to process."})]})}function u(e={}){const{wrapper:a}={...(0,i.R)(),...e.components};return a?(0,r.jsx)(a,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},28453(e,a,t){t.d(a,{R:()=>s,x:()=>o});var n=t(96540);const r={},i=n.createContext(r);function s(e){const a=n.useContext(i);return n.useMemo(function(){return"function"==typeof e?e(a):{...a,...e}},[a,e])}function o(e){let a;return a=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),n.createElement(i.Provider,{value:a},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.