Fusionscript

Fusionscript is designed by PSTF.
==Language overview==
Fusionscript is a Turing-complete programming language that combines the simplicity of Python with the efficiency of C++ while maintaining the features of object-oriented programming (OOP). It aims to provide a programming environment that can be developed quickly and executed efficiently.
==Basic syntax concept==
===Variables, constants, and data structures===
// Initialization and declaration of a variable
var a = 10
var b = 3.14
var str = "Hello, FusionScript!"
var boolVal = true
var z = 3+6j
var z__ = 3-6j
 
// Explicit type declaration (optional)
int num = 42
float pi = 3.14159
bool flag = false
string greeting = "Hello, World!"
list my_list = [1, 2, [3, 4], "Hello, World!"]
You can use uppercase and lowercase letters, numbers, underlines and even Chinese, Japanese, Korean, Russian, but not special symbols such as dollar symbol($), no start with number, no keyword and reserved words.
Currently, there are these types: 
==== void ====
The void type is an empty type that undefined. It is the most basic type when defining variables. It can be converted to a boolean value and return false, or an integer value and return zero.
==== bool ====
A boolean is a logical variable that has both TRUE and FALSE properties (either True or False). 0, 0.0000000000, 0j, empty strings, NUL characters(its ASCII is zero), empty lists, empty tuples, empty dictionaries, empty objects (meaning objects that only have __init__ methods, and the only way is an empty function), and blank variables will all return False. All other values return True. The initialized value is False.
==== Numeric Variable ====
===== int =====
In this programming language, there is no upper and lower bound for integer types. This is the default integer type. The short integer type is from -32768 to 32767. The medium integer type is from -2147483648 to 2147483647, just like the int type in C++. The long integer type is from -9223372036854775808 to 9223372036854775807. There are also longer integer types, which are equivalent to __int128 types in C++. The initialized value is 0.
===== float =====
Like integer types, decimal types have no upper and lower bounds. The upper and lower bounds of a single-precision decimal type are equal to the upper and lower bounds of medium integers, and there are 6 to 7 significant decimal places. The upper and lower limits of the double decimal type are equal to the upper and lower limits of the long integer type, and the effective decimal places have reached 13 to 14 digits. There are also even more bizarre types of long double-precision decimals, with upper and lower bounds equal to those of 128-bit long integer types, with 20 to 21 significant decimal places. The initialized value is 0.0 .
===== comp =====
A complex number consists of its real and imaginary parts, usually in the form m+nj. If you only want to express imaginary numbers, omit m+. If you want to express the imaginary number 1, just use j. The initialized value is 0+0j.
At the mathematical level, we specify that the square of an imaginary number (0+1J) is minus one (-1+0j), and similarly, the sqrt(x) function multiplies the absolute value of x by the imaginary number when x is negative.
===== What they all have in common =====
If you converts 0, 0.0000000000000000000000000000000000, 0.0, 0+0j, 0j to BOOLEAN, you will get a FALSE, otherwise you will get a TRUE. When you try to convert bool to int, float or comp, it will be: 
# False to int: 0
# False to float: 0.0
# False to comp: 0+0j
# True to int: 1
# True to float: 1.0
# True to comp: 1+j
==== string ====
A string, as the name suggests, is made up of many characters. The string type support escaping characters, which are escaped by backslashes. In particular, lowercase n means new, lowercase t means horizontal tab, lowercase a means character 7 (BEL character), lowercase b means character 127 (DEL character), the number zero represents character 0 (NUL character), " means double-quote, ' means single-quote, variable wrap in a brace means output this variable(Only support by f string).
The string can quote by double quote, single quote, or even sextuple quote and triple quote for document string.
The string can only convert to int or float, such as, "24" to be 24, "53.2" to be 53.2, but "0x10" to be an error instead of 16.
# \n ---- newline
# \t ---- horizontal tabulation
# \b ---- backspace
# \a ---- alarm
# \0 ---- NULL
# \x[hhhh] ---- Hexadecimal character
# \[ddddd] ---- Decimal character
# {var} ---- output the variable
# \" ---- double quote
# \' ---- single quote
# \N[character name] ---- output the character named [character name]. For example, Cyrillic capital letter El outputs Л, Sinhala letter Kantaja Naasikyaya outputs ඞ, CJKV Unified Ideogram 0x3400 outputs 㐀, and so on.
# \v ---- vertical tabulation
==== list ====
A list is a type that can store several different pieces of data. When using lists, you can modify an element in a list with subscripts, just like Python does. A similar type to a list is an array, which can only store the same type of data.
=== Control flow ===
Because this programming language has the simplicity of Python, it doesn't use curly braces to separate each block of code, but instead indents.
==== Conditional ====
var a = 10
var b = 5
if (a > b)
 print(">")
elif (a == b)
 print("=")
else
 print("<")
==== Loops ====
// for loop
for (int i = 0; i < 10; i++)
 print(i)
 
// while loop
var count = 0
while (count < 5)
 print(count)
 count++
==== Swtich-condition ====
In this programming language, the switch statement does not need to break to interrupt it, because after the execution of a statement, it will not be executed from the next judgment entry.
switch (a % 2)
 case 0:
 print("a is even")
 case 1:
 print("a is odd")
 default:
 print("Unexpected value")
=== Function ===
// Define and calling function
def add(int x, int y) -> int:
 return x + y
 
var result = add(5, 7)
print(result) // Output: 12
 
// Function with normal arguments
def greet(string name = "Guest") -> string:
 return "Hello, " + name + "!"
 
print(greet()) // Output: Hello, Guest!
print(greet("Alice")) // Output: Hello, Alice!
// No type function
def greet2(string name = "Guest"):
 print(greet(name))
greet2("Bob") // Output: Hello, Bob!
=== Class and object ===
// Define a class and create an object
class Person:
 var name: string
 var age: int
 __init__(string name, int age):
 this.name = name
 this.age = age
 def greet() -> string:
 return "Hello, my name is " + this.name + " and I am " + this.age + " years old."
var person = Person("Alice", 30) // "Spawn" a person
print(person.greet()) // Output: Hello, my name is Alice and I am 30 years old.
==== Inheritance and polymorphism ====
Let's say we've defined the person class.
class Employee: Person:
 var employeeId: string
 
 __init__(string name, int age, string employeeId):
 super(name, age)
 this.employeeId = employeeId
 
 override def greet() -> string:
 return super.greet() + " My employee ID is " + this.employeeId + "."
 
var employee = Employee("Bob", 40, "E12345")
print(employee.greet()) // Output: Hello, my name is Bob and I am 40 years old. My employee ID is E12345.
=== Error handling ===
try:
 int num = int("abc")
catch (Exception e):
 print("An error occurred: " + e.message)
// else:
// print("Successfully converted.")
// finally:
// print("This block will always execute.")
The annotated statement is optional.
=== Importing ===
// Suppose there is a module called "math_utils".
import math_utils
var result = math_utils.add(5, 7)
print(result) // Output: 12
== Advanced syntax concept ==
=== Lambda Expressions ===
r = (lambda x, y: x + y)(1, 2)
print(r) // Output: 3
=== Anonymous function ===
r = ([](x, y): @return x + y@)(1, 2)
print(r) // Output: 3
== Examples ==
=== Cat program ===
"""
The input() will receive the user's input (until the EOF is read, at which point the input will end)
and return the string corresponding to that input.
If you calculate a string with a number, it will parse the string into a number.
There are only plus and comparison operations between strings.
"""
while (True):
 var x = input()
 print(x, end = '\n')
=== Digital clock ===
import time // This library supports to get time, date, and so on.
import sys // System library, supports to operate the OS.
var x = input("UTC") // input(_prompt_) will use _prompt_ to be the prompt that let user to input.
x = int(x)
while (True):
 print(time.datetime(timezone = x)) // If timezone is blank, then it uses UTC+0 as timezone.
 wait(1000) // Uses millisecond to calculate.
 sys.cmd("cls")
== Categories ==
Category:Languages
Category:2024
Category:Turing complete
Category:High-level
Category:Generated by AI