-
-
Notifications
You must be signed in to change notification settings - Fork 0
Docs
_ __ __
| | / /_ _______/ /_
| | /| / / / / / ___/ __ \
| |/ |/ / /_/ (__ ) /_/ /
|__/|__/\__, /____/_.___/
/____/
Wysb is a strongly and statically typed language, which means that when defining variables and arguments, you need to define the type of the value to be stored. To understand this better, let's look at an example: Here are 4 types of (random) data:
- ball;
- 4;
- 8.45;
- True;
- Look at this data. The first is a string, the second is an integer, the third is a float and the last is a bool. In summary, strings are letters of the alphabet, integers are numbers that don't have a comma, floats are numbers that carry some value after the comma, and booleans can only be two values: True or False. Now, in practice, in the Wysb language, here's an example:
$[string] name = "John">;
$[int32] age= 21>;
$[float32] weight = 64.72>;
$[bool] isProgrammer = True>;
In a nutshell, functions are encapsulated, reusable blocks of code that can be called at any time (with arguments or not). In Wysb, functions are created with the keyword "!fun", and the arguments are enclosed in parentheses, with the types in square brackets ([]). Here's an example:
$[string] name = "John"
!fun sayHello(name[string]) {
return "Good moring, hello ${name}"
}
@::sayHello()?
In Wysb, the function call works as follows: first, you use the identifier "@::", then the name of the function, then the arguments (if any) in parentheses, and finally the closing "?". Here's an example:
@::sayHello()?
You can use the built-in "math" library to perform arithmetic operations. math
is imported automatically, and does not need to be imported explicitly.
Spacing between the first number, the symbol and the second number is mandatory. With the math library, only operations with 2 numbers are supported, i.e. to operate with more numbers, you need to use several variables
$[int32] num1 = <math.sum 5 + 5!>>;
$[float64] num2 = <math.div 12 / 6!>>;
$[int32] num3 = <math.sub ${num1} - 3!>>;
$[float64] num4 = <math.mult 5 * <math.pi!>!>>;
$[int32] num5 = <math.pow 4 :: 2!>>;
$[int32] num6 = <math.sqrt 81!>>;
There are several ways of working with data inputs, one of which is the terminal itself. You can read what the user types and process the information you collect as you wish. This can be done with the standard "io" library, which is imported automatically. Here's a simple example:
[string] name = <io.input!>
println("Your name is ${name}?")
It's not enough to create variables, you'll need to use their values later. For this, you can use an easy solution, which is to use the standard referrer, which consists of: using the identifier "${", putting the name of the variable you want to get the value of, and closing with "}". Here's an example:
println("Your name is ${name}?")
Often, you'll need to know what's going on in parts of your code. Think about it, you'll need to process the data, and do different things with it depending on the situation, and that is, conditions. In Wysb, there is no else or else if, only "if", so you'll need to build your own else and else if. See examples:
$if[==] name :: John ! hiJohn();
$if[!=] name :: John ! isNotJohn();
$if[<] age :: 12 ! kid();
$if[>] age :: 18 ! adult();
Of course, at some point you will need files. Maybe you need to read them, maybe you need to rename them, maybe you need to delete them, maybe you need to move them. Here are some examples:
<os.WriteFile example.txt :: "Hello World"!>
$[string] filecontent = <os.ReadFile example.txt!>>;
<os.RenameFile example.txt :: newexample.txt!>
Encryption is great security. It's basically a piece of information (large or small) that you want to protect and hide, with several random characters that are defined with a key, and with that same key, you can decrypt and visualize the hidden content, as if it were a chest, which had a single key, and with that single key it would be possible to open or close such a chest, which hides mysteries. Here's an example (xxxxxxxxxx is a example key):
$[string] name = "John Doe">;
$[string] encryptedName = <cryptography.Encrypt xxxxxxxxxx :: ${name}!>>;
$[string] decryptedEncryptedName = <cryptography.Decrypt xxxxxxxxxx :: ${name}!>>;
println(${decryptedEncryptedName})
The logger is an evolution of println. It provides more information, useful for more robust systems, such as the exact date, time, second, and millisecond when the information was issued, with different colors for different information, such as warnings, errors or normal information.
<logger.Send Info :: "My name is Yan"!>
<logger.Send Warn :: "Maybe your name isn't Yan"!>
<logger.Send Error :: "Surely your name isn't Yan"!>
You may need to generate integers or floats, or even strings, randomly, i.e. procedurally. To do this, you need 2 arguments, first the type of the sequence to be generated, and then the maximum size.
$[float32] randomFloat = <rand.Num float :: 20!>>;
$[int32] randomInt = <rand.Num int:: 12!>>;
$[string] randomString = <rand.Num string :: 30!>>;