Interfuse Syntax Guide
A modern programming language inspired by C. It blends familiar syntax with LLVM-powered performance for efficient, fun coding.
Variable Declaration
- Declare a variable with
@name : type
. - Example:
@sum : int
Function Declaration
- Define a function with
fn @name(@param: type, ...) -> return_type { ... }
. - Example:
fn @add(@a: int, @b: int) -> int { ret @a + @b }
Variable Assignment
- Assign a value to a variable with
@name : type = expression
. - Example:
@sum : int = @add(1, 2)
Conditional Statements
- Use
if
andelse
to control logic. - Example:
if @sum { @a = 10 } else { @a = 100 }
Loops
- Iterate with
for @var in condition : increment { ... }
. - Example:
for @i in @i < 100 : @i + 1 { @out(@i) }
Printing Output
- Print values using
@printf
or@puts
. - Example:
@puts("Hello, World!")
Sample Functions
- Fibonacci, Factorial, Power:
fn @fibonacci(@n : int) -> int { if @n <= 1 { ret @n } else { ret @fibonacci(@n - 1) + @fibonacci(@n - 2) } ret 0 # This should not be necessary } fn @factorial(@n : int) -> int { if @n == 0 { ret 1 } else { ret @n * @factorial(@n - 1) } ret 0 } fn @power(@base : int, @exponent : int) -> int { @result : int = 1 for @i in @i <= @exponent : @i + 1 { @result = @result * @base } ret @result }
Example Usage:
@puts("Fibonacci Sequence: ")
@a : int = 10
@fib : int = @fibonacci(@a)
@printf(@fib)
@puts("Factorial Sequence: ")
@fac : int = @factorial(20)
@printf(@fac)
@puts("Power Sequence: ")
@a : int = @power(2, 3)
@printf(@a)
Explore Interfuse’s blend of modern and familiar C-inspired syntax!