A simple scripting language in C++
Ferenc Szontágh
2025-04-19 3c645799476e526b04e13f648cd30643c1f39112
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Functions Feature Test
 
# Define a simple greeting function (no return type)
function greet (string $name) {
    printnl("Hello, ", $name, "!");
}
 
# Define a sum function with explicit return type
function sum (int $a, int $b) int {
    return $a + $b;
}
 
# Define a function that uses other functions and local variables
function mulSum (int $x, int $y, int $z) int {
    int $product = $x * $y;
    int $result = sum($product, $z);
    return $result;
}
 
# Call the functions and print results
greet("VoidScript");
 
int $result1 = sum(7, 5);
printnl("sum(7, 5) = ", $result1);
 
int $result2 = mulSum(2, 3, 4);
printnl("mulSum(2, 3, 4) = ", $result2);
 
# Demonstrate nested call in expression
int $combined = mulSum(1, 2, 3) + sum(3, 4);
printnl("combined (mulSum(1,2,3) + sum(3,4)) = ", $combined);