Keywords and Built-In Functions
This page covers Hachiās language-level built-ins and reserved constructs. It does not cover standard-library module functions such as strSplit, file_Read, or formatting helpers imported from modules like so, fs, or fmt.
Core Types and Language Keywords
Hachi includes the following core type names and built-in language-level constructs:
IntFltBoolByteStringVoidAnyT
These may appear in type signatures, conversions, type inspection, and initialization.
I/O Functions
Prints a value followed by a newline.
Syntax:
print: <value>
Examples:
print: 8
print: "Hello World"
print: tru
print
Calling print with no input prints a blank line.
printc
Prints a single character from an integer byte value.
Syntax:
printc: <integer>
Example:
printc: 65
input
Reads a line of string input.
Syntax:
<prompt>.input
You may also use String.input for an empty prompt.
Examples:
name: "Enter your name: ".input
blankPrompt: String.input
inputc
Reads a single character from standard input and returns its integer value.
Syntax:
key: inputc
Example:
key: inputc
print: key
inputInt
Reads an integer from standard input.
Syntax:
number: inputInt
Example:
age: inputInt
print: age
Flow and Control Helpers
pass
A no-op. Useful when you intentionally want an empty branch or placeholder.
Syntax:
pass
Example:
tru ? (
pass
)
cont
Continue to the next loop iteration.
Syntax:
cont
Example:
i: 0 | i < 5 | i: i + 1 @ (
i = 2 ? (
cont
)
print: i
)
exit
Terminates the program.
Syntax:
exit
Example:
print: "Leaving now."
exit
sleep
Sleeps for a number of seconds.
Syntax:
sleep: <seconds>
Example:
sleep: 2
Conversion and Type Functions
Hachi supports several built-in conversions. In practice, method-style conversions are the clearest and most reliable style to document.
Bool
Convert a value to Bool.
Examples:
flag1: 1.Bool
flag2: 0.Bool
flag3: Bool: 0
Int
Convert a value to Int.
Examples:
count1: "123".Int
count2: 8.9.Int
count3: Int: tru
Flt
Convert a value to Flt.
Examples:
ratio1: "2.5".Flt
ratio2: 8.Flt
ratio3: Flt: tru
Byte
Convert a value to Byte.
Examples:
letter1: 65.Byte
letter2: Byte: 65
String
Convert a value to String.
Examples:
text1: 42.String
text2: tru.String
text3: 8.5.String
typeName
Returns the type name of a value or type.
Examples:
print: "hay".typeName
print: Int.typeName
typeSize
Returns the size of a type or value in bytes.
Examples:
print: tru.typeSize
print: Byte.typeSize
print: Int.typeSize
String Functions
len
Returns the length of a string or the number of elements in an array.
Syntax:
<value>.len
Examples:
doggo: "Hachiko"
print: doggo.len
sub
Returns a substring using a start index and end index.
Syntax:
<string>.sub: <start-index>, <end-index>
Example:
aString: "Hello there"
print: aString.sub: 0, 5
at
Returns the integer code at a given string index.
Syntax:
<string>.at: <index>
Example:
doggo: "Hachiko"
print: doggo.at: 2
toascii
Converts an integer code into a one-character string.
Syntax:
<integer>.toascii
Example:
code: 101
print: code.toascii
Arrays
Hachi includes built-in integer and string arrays.
IntArray
A fixed-size integer array.
Create
numbers: IntArray: 5
Set
numbers.set: 0, 42
Get
print: numbers.get: 0
Length
print: numbers.len
StringArray
A fixed-size string array.
Create
words: StringArray: 3
Set
words.set: 0, "Four-Twenty"
Get
print: words.get: 0
Length
print: words.len
CLI and Runtime Values
tru
Boolean true.
isDaytime: tru
fls
Boolean false.
isNight: fls
arg
Returns the command-line argument at a given index.
Syntax:
arg: <index>
Example:
print: arg: 0
print: arg: 1
argLen
Returns the number of command-line arguments.
Syntax:
argLen
Example:
print: "there are " + argLen.String + " args."
i: 0 | i < argLen | i: i + 1 @ (
print: arg: i
)
VERSION
A built-in version tuple with fields x, y, and z.
Example:
print: VERSION.x.String + "." + VERSION.y.String + "." + VERSION.z.String
OS_IS_LINUX
Boolean constant indicating Linux.
print: OS_IS_LINUX
OS_IS_WINDOWS
Boolean constant indicating Windows.
print: OS_IS_WINDOWS
OS_IS_MAC
Boolean constant indicating macOS.
print: OS_IS_MAC
OS_IS_UNIX
Boolean constant indicating Unix-like platforms.
print: OS_IS_UNIX
IS_TRANSPILED
Indicates whether execution is happening in transpiled mode.
print: IS_TRANSPILED
Shell Execution
hcmd
Runs a shell command and returns its output as a String.
Syntax:
hcmd: "<command>"
Example:
osInfo: hcmd: "cat /etc/os-release"
print: osInfo
Memory and Pointer Helpers
These are more advanced built-ins and are generally intended for lower-level work.
new
Allocates a new value and returns a pointer to it.
Example:
ptr: new: 69
print: ptr.dif
dif
Dereferences a pointer, or assigns through a pointer depending on usage.
Examples:
ptr: new: 69
print: ptr.dif
ptr.dif: 42
print: ptr.dif
yeet
Explicitly releases a Hachi-managed string value.
Example:
text: "HELLO!"
yeet: text
destroy, release, copy
Internal lifecycle helpers used by Hachiās automatic memory management model.
These are real built-ins, but they are primarily advanced/runtime-level mechanisms rather than everyday user-facing functions.
Interoperability with C++
Using innerCPP and outerCPP, you can embed raw C++ directly inside Hachi code.
WARNING:
Hachi is built with automatic cleanup in mind, but raw C++ can introduce unsafe behavior. Use these features carefully.
innerCPP
C++ code defined in innerCPP is inserted inside the transpiled main function.
Syntax:
innerCPP: "<YOUR C++ CODE HERE>"
Example:
innerCPP: "std::cout << \"Here is some C++ code!!\" << std::endl;"
outerCPP
C++ code defined in outerCPP is inserted outside the transpiled main function.
Syntax:
outerCPP: "<YOUR C++ CODE HERE>"
Example:
outerCPP:"
#include <fstream>
#include <string>
"
Hachi Bindings
You can build bindings and native integrations directly inside Hachi functions.
Example:
file_Write:: {fName:String,fInput:String}:(
filename: Ri.fName
input: Ri.fInput
innerCPP: "
std::string input(reinterpret_cast<char const*>(input._data), input._size);
std::ofstream outputFile(reinterpret_cast<char const*>(filename._data), filename._size);
if (outputFile.is_open()) {
outputFile << input;
outputFile.close();
return 0;
} else {
return 1;
}
"
)