Language basics
Variables, literals, conditions, loops, functions and imports before the advanced v12 type-system material.
00 verified runnable baseline§
RUNNABLE · WINDOWS X64 · EXACT RELEASE FIXTURE
print("Hello, DByte!")dbyte run examples\hello.dbyEXPECTED OUTPUT
Hello, DByte!The syntax fragments below teach individual constructs. Unless a block is explicitly marked RUNNABLE, treat it as a fragment to study rather than a complete file.
01 variables + literals§
let count: int = 10
let name: str = "DByte"
let magic: bytes = b"\xDE\xAD\xBE\xEF"
let inferred = 10
let inferred_bytes = b"abc"let introduces a local. Type annotations may be omitted where the checker can infer the legacy hosted type.
02 conditions§
if count > 0:
print("positive")
else:
print("zero or negative")03 loops§
while count > 0:
count = count - 1The historical hosted spec also documents multiline for blocks in the REPL contract, but the supplied spec excerpt does not define a general for-loop grammar here; this page does not invent one.
04 functions§
fn add(a: int, b: int) -> int:
return a + b
print(add(10, 20))05 modules§
import std.buffer as buf
import std.binary as bin
import "./calc.dby" as calc
pub fn add(a: int, b: int) -> int:
return a + b06 v12 boundary§
Do not confuse the hosted compatibility types str, list, bytes and buffer with new v12 public API design. The v12 normative contract keeps them for compatibility but directs new public APIs toward canonical v12 types such as fixed integers, raw pointers, borrowed slices and StringView. Owned String, dynamic Array, collections and automatic Drop remain deferred.
SOURCE POLICY: release/tag documents define contracts; examples are copied from the supplied v12.0.0 package or explicitly marked as explanatory. Unsupported claims are not upgraded by prose.