Skip to content

Instantly share code, notes, and snippets.

@kittech0
Last active June 18, 2023 08:54
Show Gist options
  • Select an option

  • Save kittech0/4e615e4e5df1cf355cb55a8c10297957 to your computer and use it in GitHub Desktop.

Select an option

Save kittech0/4e615e4e5df1cf355cb55a8c10297957 to your computer and use it in GitHub Desktop.

Revisions

  1. kittech0 revised this gist Jun 18, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion The Prismatica Programming language 2.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ Accessing a tuple:
    val tuple: (fsize,u16,bool) = (1.0, 24, true)

    val float: fsize = tuple[0] //1.0
    val positiveNumber = tuple[1] //24
    val positiveNumber: u16 = tuple[1] //24
    val boolean: bool = tuple[3] //true
    ```
    Supports also deconstructing syntax into multiple variables.
  2. kittech0 revised this gist Jun 18, 2023. 1 changed file with 302 additions and 1 deletion.
    303 changes: 302 additions & 1 deletion The Prismatica Programming language 2.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,302 @@
    .
    Welcome to the idea of language v2 based around Kotlin and Rust!

    ## Comments
    Comments in this language use C-like syntax.
    ```c
    // One-liner
    function(/* Insides */) // Description of it!
    /*
    Multiple lines!
    */
    ```
    ## Variables and mutability
    Language uses rust-like declaring variables that means every variable is immutable by default. Also instead of `let` it is `val` like in kotlin.
    Declaring variable:
    ```c
    val variable: i32 = 2
    ```
    Declaring mutable variable:
    ```c
    val mut variable: i32 = 2
    ```
    Declaring constant (only primitive values can be in constant):
    ```c
    const CONSTANT: i32 = 2
    ```
    ## Types
    Uses rust-like types
    1. Signed integers: `i8`,`i16`,`i32`,`i64`,`i128` and `isize`
    2. Unsigned integer: `u8`,`u16`,`u32`,`u64`,`u128` and `usize`
    3. Floating-point numbers: `f8`,`f16`,`f32`,`f64`,`f128` and `fsize`
    4. Characters: `char` (to create character use `''` example: `'a'`)
    5. Boolean: `bool` (`true` or `false`)
    6. ### Tuples
    Tuples have a Rust-like syntax. They are groups with multiple types of values inside and have a fixed size.
    Declaring a tuple:
    ```c
    val tuple: (fsize,u16,bool) = (1.0, 24, true)
    ```
    To access a tuple use array-like syntax.
    Accessing a tuple:
    ```c
    val tuple: (fsize,u16,bool) = (1.0, 24, true)

    val float: fsize = tuple[0] //1.0
    val positiveNumber = tuple[1] //24
    val boolean: bool = tuple[3] //true
    ```
    Supports also deconstructing syntax into multiple variables.
    Deconstracting tuple:
    ```c
    val tuple: (fsize,u16,bool) = (1.0, 24, true)

    val (float: fsize, positiveNumber: u16, boolean: bool) = tuple
    ```
    ### Arrays
    Arrays also use kotlin-like syntax. `type[size]`, type can be anything, size has usize type.
    Declaring array:
    ```c
    val array: char[5] = ['0','1','a','c','n'] //declares array
    ```
    Getting value from array:
    ```c
    val array: char[5] = ['0','1','a','c','n']

    val letter: char = array[2] // 'a'
    ```
    ### Set
    Sets in this language have a math-like syntax. They are collection of elements of the same type and have dynamic size. They work like hashset in other languages.
    Delcaring set:
    ```c
    val set: char{} = {'a','b','c','d','e','f','g','h'}
    ```
    Adding new value to set:
    ```c
    val mut set: char{} = {'a','b','c','d','e','f','g','h'}
    set.push('i')
    ```
    Removing value:
    ```c
    val mut set: char{} = {'a','b','c','d','e','f','g','h','i'}
    set.remove('i')
    ```
    ### Map
    Maps in this language has js-like syntax. They work like HashMaps, having key-value pairs, keys are unique.
    Declaring is done between `{type:type}`, first type is of key, second type is of value.
    Declaring map:
    ```c
    val map: {char:i32} = {
    'a': 2,
    'b': 3,
    'g': 3,
    'o': 0
    }
    ```
    Modifying/getting value from map has array-like syntax but instead of usize, you pass the key type.
    Modifying map:
    ```c
    val mut map: {char:i32} = {
    'a': 2,
    'b': 3,
    'g': 3,
    'o': 0
    }

    map['o'] = 10
    ```
    Getting value:
    ```c
    val map: {char:i32} = {
    'a': 2,
    'b': 3,
    'g': 3,
    'o': 0
    }

    val value: i32 = map['a'] //2
    ```
    ### Table
    Tables are similiar to maps but allows multiple values per key. The syntax for creating a table is the same as for maps, but with additional types specified inside the curly braces. Type `{key:value,value}`
    Declaring table:
    ```c
    val table: {char:i32,bool} {
    'a': 64, true
    'b': 128, true
    }
    ```
    Getting value from table:
    ```c
    val table: {char:i32,bool} {
    'a': 64, false
    'b': 128, true
    }

    val value: (i32,bool) = table['b'] // (128,true)
    ```
    ### List
    List is similiar to array, but it can be resized.
    Declaring a list:
    ```
    val list: [[char]] = [['a','a','g','f']]
    ```
    ### Functions
    Function syntax is similiar to kotlin functions, difference is replacement of `fun` with `fn`
    Declaring a function:
    ```
    fn function(x: i32): i32 = x^2 //short syntax
    fn function(x: i32): i32 {
    <- x^2 //instead of return there is <-
    } //long syntax
    ```
    Functions also support default values in arguments.
    Example default value:
    ```
    fn function(x: i32 = 2): i32 = x^2 //4 by default :p
    ```
    ### Lambdas
    Language also supports lambdas, the lambda syntax is kotlin-like.
    ```
    val lambda: () -> () = {}
    val lambda: (i32) -> i32 = { x -> x^2 }
    ```
    ## Modules and Packages
    Supports kotlin-like package syntax. Instead of `public` there is `pub`, all declared stuff are private (file specific), also supports `inter` which means `internal`, it makes declared stuff only accessible inside the application/library.
    Package example:
    ```
    package MyPackage
    pub fun publicated(x: i32): i32 = x^2
    fun private(x: u32): u32 = x^2
    inter fun internal(x: i32, y: i32): i32 = x^y
    ```
    Importing a package:
    MyPackage file:
    ```
    package MyPackage
    pub fun publicated(x: i32): i32 = x^2
    fun private(x: u32): u32 = x^2
    inter fun internal(x: i32, y: i32): i32 = x^y
    ```
    OtherFile:
    ```
    import MyPackage //imports a package that you can use MyPackage@
    import MyPackage.publicated //imports specific thing from package
    import MyPackage.* //imports everything from package
    ```
    ## Structures
    Structures are used to create more complex data types from existing types. The language combines Rust's structure syntax with Kotlin's implementation of function syntax. (`pub` inside structures means that the value can be used outside the structure). Structure values also support default values.
    Declaring structure:
    ```
    import std
    struct Person {
    pub name: str@string = "Jane" //you dont need std@, you can just import `string` manually.
    }
    ```
    Implementing a function:
    ```
    import std
    struct Person {
    pub name: str@string = "Jane"
    }
    Person.getName(): std@string = $.name
    ```
    You can also implement a static value by putting `*` before `Person`
    Implementing a static function:
    ```
    import std
    struct Person {
    pub name: str@string = "Jane"
    }
    fn *Person.new(name: std@string): It = It(name) //It returns itself
    ```
    ## References
    This language has references with rust-like syntax, modifying mutable references is done using `:=`.
    Use of references:
    ```
    import std
    fun referenceMutate(x: &mut i32) = x := x ^ 2
    fun function() {
    val mut x: i32 = 100
    referenceMutate(&mut x)
    std@println("{x}") //prints 10000
    }
    ```
    ## DSL
    DSL is builder syntax that can be found in kotlin. Uses kotlin-like syntax. Type is `Struct.(additional)->(return)`
    Declaring DSL function:
    ```
    import std
    struct Builder {
    pub mut str: std@string,
    pub mut integer: i32
    }
    fn builder(str: std@string, integer: i32, build: Builder.()->()) {
    Builder(str,integer).apply(build)
    }
    ```
    Using a DSL function:
    ```
    import std
    struct Builder {
    pub mut str: std@string,
    pub mut integer: i32
    }
    fn Builder.callMe() = std@println("{$.str}: {$.integer}")
    fn builder(str: std@string, integer: i32, build: Builder.()->()) {
    Builder(str,integer).apply(build) //apply applies all modification and stuff done in builder
    }
    //...
    builder("aaa", 100) {
    $.str = "bbb"
    $.integer = -100
    $.callMe() //prints "bbb: -100"
    } //this is lambda shorting that can be found in kotlin too.
    ```
    ## Initializer
    Uses a DSL builder called `init` which is replacement for `main` function in kotlin/rust. This is done to give users way more stuff :p
    A hello world example:
    ```
    init {
    println("Hello world!")
    }
    ```
    Using arguments:
    ```
    init {
    println("{$.args}") // prints list of arguments
    }
    ```
    ## Operators
    1. Addition: `+`
    2. Subtraction: `-`
    3. Multiplication: `*`
    4. Power: `^`
    5. Modulo: `%`
    6. Root: `^^`
    7. Approximate: `~`
    8. Equal: `==`
    9. Not equal: `!=`
    10. Greater than: `>`
    11. Lesser than: `<`
    12. Greater or equal than: `>=`
    13. Lesser or equal than: `<=`
    14. Division: `\`
    15. Bitwise logic: `~`, `&`, `|`, `**`
    16. Bitwise shifts: `<<`, `>>`,
    17. Or: `||`
    18. And: `&&`

    ## Loops, If and When
  3. kittech0 revised this gist Jun 18, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions The Prismatica Programming language 2.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    .
  4. kittech0 revised this gist Jun 17, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -238,7 +238,7 @@ Person.sayHello: || = std@out.println("{$.name}: Hello!") // Implements a functi

    mut Person.setName: |name: std@String| = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable

    |Person.new: |name: std@String, age: u16| -> it = it(name, age)
    *Person.new: |name: std@String, age: u16| -> it = it(name, age)
    // This is a static variable on Person. You create it by putting `Person` between `||`.
    // `it` is used for returning itself and only stores the constructor and static variables.
    // Static variables are immutable and cannot be changed.
  5. kittech0 revised this gist Jun 17, 2023. 1 changed file with 148 additions and 6 deletions.
    154 changes: 148 additions & 6 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -37,32 +37,127 @@ Uses rust-like types
    Tuples have a Rust-like syntax. They are groups with multiple types of values inside and have a fixed size. Tuples can be destructured.
    Example way of creating:
    ```c
    tuple: (fsize, u16, bool) = (1.0, 24, true)
    tuple: (fsize:u16:bool) = (1.0, 24, true)
    ```
    Accessing values is different from Rust. Instead of `tuple.i` (where `i` is the index/place of the value in the tuple), it uses array-like syntax for accessing elements.
    Example way of accessing value:
    ```c
    //tuple: (fsize, u16, bool) = (1.0, 24, true)
    value: fsize = tuple[0] //returns 1.0 of type fsize
    // remember `tuple` variable is (1.0, 24, true)
    ```
    You can also destructure tuples using a different variable syntax, which destructures the tuple into multiple variables.
    Example of destruction:
    ```c
    //tuple: (fsize, u16, bool) = (1.0, 24, true)
    (float: fsize, number: u16, answer: bool) = tuple
    float //returns 1.0 with type fsize
    number //returns 24 with type u16
    answer //returns true with type bool
    ```
    ### Array
    Arrays have a Kotlin-like syntax. They are groups of the same type and have a fixed size.
    Arrays in this language have a Kotlin-like syntax. They are collections of elements of the same type and have a fixed size.
    Example way of creating:
    ```c
    array: char[5] = ['h','e','l','l','o']
    ```
    The number inside `char[5]` defines the fixed size of the array, and `char` defines the type of values in the array. You can access values inside an array in the same way you would in a tuple.
    In the above example, `char[5]` specifies the type of the array (`char`) and its fixed size (`5`).

    You can access values inside an array using the indexing syntax, similar to tuples.
    Example of accessing value:
    ```c
    letter: char = array[3] //returns `l` with type char
    array: char[5] = ['h','e','l','l','o']
    letter: &char = array[3] //returns `l` with reference of char
    ```
    You can also modify values in array.
    ```c
    mut array: char[5] = ['h','e','l','l','o']
    array[2] := 'w'
    ```
    ### Set
    Sets in this language have a math-like syntax. They are collections of elements of the same type and have a dynamic size. Sets only allow unique values.
    Example use:
    ```c
    set: char{} = {'a','b','c','d','e','f','g','h'}
    ```
    Example of adding new values:
    ```c
    mut set: char{} = {'a','b','c','d','e','f','g','h'}
    set.add('i') // adds one value on the end of set
    set.push('j') //adds one value on the start of set
    set[1] := 'l' //replaces value in this index
    ```
    Example of removing values:
    ```c
    mut set: char{} = {'j','a','b','c','d','e','f','g','h','i'}
    set.removeFirst() //removes first value in set
    set.removeLast() //removes last value in set
    set.remove(2) //removes value with index 2 which is 'a'
    ```
    Getting values from a set is done in the same way as accessing values in an array
    Example of getting value:
    ```c
    set: char{} = {'a','b','c','d','e','f','g','h'}
    letter: &char = set[0] //'a'
    ```
    ## Map
    Maps in this language have a JavaScript-like syntax. They have key-value pairs, where the keys are unique and the values can be of any type. Maps are created by specifying the key and value types inside curly braces.
    Example use:
    ```c
    map: {char:i32} = { //char is key type, i32 is value type
    'a' : 1
    'b' : 2
    'c' : 3
    'g' : 1
    }
    ```
    You can also modify values in map.
    ```c
    mut map: {char:i32} = {
    'a' : 1
    'b' : 2
    'c' : 3
    'g' : 1
    }

    map['g'] := 2 //modifying value based on key!
    map.remove('a') //removes value from map by key
    ```
    ## Table
    Tables in this language are similar to maps but allow multiple values per key. The syntax for creating a table is the same as for maps, but with additional types specified inside the curly braces.
    Example use:
    ```c
    table: {char:i32:bool} = {
    'a' : 64 : true
    'b' : 32 : false
    'c' : 16 : true
    }
    ```
    When getting a value from a table, you receive a reference to a tuple containing the values associated with the key.
    Example of getting value:
    ```c
    table: {char:i32:bool} = {
    'a' : 64 : true
    'b' : 32 : false
    'c' : 16 : true
    }
    value: &(&i32,&bool) = table['a'] //returns (64,true)
    ```
    Example of modifying value:
    ```c
    table: {char: i32: bool} = {
    'a' : 64 : true,
    'b' : 32 : false,
    'c' : 16 : true
    }
    table['a'] := (18, false) // modifies the entire tuple associated with the key 'a'
    table['a'][0] := 24 // modifies a specific value in the tuple associated with the key 'a'
    ```
    ## List
    List is similiar to set, but instead it doesn't require values to be unique. Getting value is exactly the same.
    Example use:
    ```c
    list: [[char]] = [['a','a','g','f']]
    ```
    ### Lambda
    Lambdas are a replacement for functions in this language. They use a different syntax from other languages. To create a lambda, you use `||`. By default, they return nothing. Lambdas are executed like C functions. They also support compact one-line execution, similar to Kotlin.
    @@ -171,10 +266,57 @@ builder(100) || = {
    ```
    Every struct has an `.apply` function that can be called by passing the builder DSL lambda as an argument.
    ## Initializer
    Like other languages that have `main` function this language also has something similiar, but instead you use `init` which is dsl!
    Example hello world!
    In this language, the entry point of a program is defined using the `init` keyword which is DSL builder This is similar to the `main` function in other languages.
    Example of an initializer:
    ```c
    init || = {
    std@println("Hello world!")
    }
    ```
    The code inside the initializer block will be executed when the program starts.
    ## Operators
    1. Addition: `+`
    2. Subtraction: `-`
    3. Multiplication: `*`
    4. Power: `^`
    5. Modulo: `%`
    6. Root: `^^`
    7. Approximate: `~`
    8. Equal: `==`
    9. Not equal: `!=`
    10. Greater than: `>`
    11. Lesser than: `<`
    12. Greater or equal than: `>=`
    13. Lesser or equal than: `<=`
    14. Division: `\`
    15. Bitwise logic: `~`, `&`, `|`, `**`
    16. Bitwise shifts: `<<`, `>>`
    ## References
    This language supports references that can be found in Rust programming language. They have exactly the same syntax like you would found in rust. To modify reference, use `:=`.
    Example use:
    ```c
    foo: |x: &mut i128| = x := x^2
    bar: |x: &i128| = std@println("{x}")
    init || = {
    mut fooBar: i128 = 1234567890
    std@println("{fooBar}") //prints 1234567890
    bar(&fooBar) //prints 1234567890
    foo(&mut foodBar) //modifes the reference
    bar(&fooBar) //prints 1524157875019052100
    std@println("{fooBar}") //prints 1524157875019052100
    }
    ```
    ## Nullability
    This language by default is not nullable, but it has nullability syntax exact the same for kotlin `?`.
    Example use:
    ```c
    foo: |x: i32| -> i32? = null
    bar: |x: i32?| -> i32 = x!! //will panic if x is null
    init || = {
    num: i32 = 10
    nullableNum: i32? = foo(num)
    notNullableNum: i32 = bar(nullableNum) //panics.
    }
    ```
    ## Loops, If and When
  6. kittech0 revised this gist Jun 17, 2023. 1 changed file with 18 additions and 9 deletions.
    27 changes: 18 additions & 9 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -108,41 +108,42 @@ Example use:
    ```c
    lambda: |lam: || | = lam()
    //without shorting syntax
    lambda(|| = std\println("Hello world!"))
    lambda(|| = std@println("Hello world!"))
    //with shorting syntax
    lambda || = std\println("hello world!")
    lambda || = std@println("hello world!")
    ```
    When multiple arguments are used, the shorthand syntax can be applied to each argument.
    Example of a lambda with multiple arguments and shorthand syntax:
    ```c
    lambda: |x: i32, lam: |y: i32|| = lam(x)
    lambda(32) |x| = std\println("Hello {x}") //you do exactly same thing but instead you add the value in `()`
    lambda(32) |x| = std@println("Hello {x}") //you do exactly same thing but instead you add the value in `()`
    ```
    ## Modules and Packages
    This language supports creating modules and importing them. The standard library is included by default and can be used. Modules use a syntax similar to Rust, and the namespace specifier is `\`.
    This language supports creating modules and importing them. The standard library is included by default and can be used. Modules use a syntax similar to Rust, and the namespace specifier is `@`.
    Example module:
    ```c
    mod MyModule

    pub powerMe: |x: i128| -> i128 = x^2 // Use `pub` keyword to make something public!
    //to use it you would write MyModule\powerMe(2) (returns 4)
    //to use it you would write MyModule@powerMe(2) (returns 4)
    //Also before using module, you need to import it using `import MyModule`
    ```
    ## Structure
    Structures are used to create more complex data types from existing types. The language combines Rust's structure syntax with Kotlin's implementation of function syntax.
    Example usage:
    ```c
    struct Person {
    mut name: std\String = "Jane" // To make a mutable variable in a structure, use `mut`
    mut name: std@String = "Jane" // To make a mutable variable in a structure, use `mut`
    pub age: u16 // By default, values in a structure are only available for implemented functions. Using `pub` makes them accessible internally and externally.
    } // You can initialize it using `Person("Kittech", 20)` or `Person(age = 16)`

    Person.sayHello: || = std\out.println("{$.name}: Hello!") // Implements a function for the structure
    Person.sayHello: || = std@out.println("{$.name}: Hello!") // Implements a function for the structure
    // To access values from inside the structure, use `$` (similar to `self` in Rust or `this` in Kotlin)

    mut Person.setName: |name: std\String| = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable
    mut Person.setName: |name: std@String| = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable

    |Person.new: |name: std\String, age: u16| -> it = it(name, age)
    |Person.new: |name: std@String, age: u16| -> it = it(name, age)
    // This is a static variable on Person. You create it by putting `Person` between `||`.
    // `it` is used for returning itself and only stores the constructor and static variables.
    // Static variables are immutable and cannot be changed.
    @@ -169,3 +170,11 @@ builder(100) || = {
    } // Returns ExampleBuild with `number` equal to 201
    ```
    Every struct has an `.apply` function that can be called by passing the builder DSL lambda as an argument.
    ## Initializer
    Like other languages that have `main` function this language also has something similiar, but instead you use `init` which is dsl!
    Example hello world!
    ```c
    init || = {
    std@println("Hello world!")
    }
    ```
  7. kittech0 revised this gist Jun 17, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Welcome to the idea of language based around Kotlin and Rust!

    ## Comments
    Comments in this language use C-like syntax.
    ```
    ```c
    // One-liner
    function(/* Insides */) // Description of it!
    /*
    @@ -13,17 +13,17 @@ function(/* Insides */) // Description of it!
    ## Variables and mutability
    There are multiple ways of declaring variables in this language. By default, every variable is immutable, and you need to specify mutability. The syntax for declaring variables is Rust-like, with an optional `let` keyword.
    Example of an immutable variable:
    ```
    ```c
    variable: i32 = 2
    let variable: i32 = 2 // `let` is optional and not required; it will work the same in the example above
    ```
    Example of mutable variable:
    ```
    ```c
    mut variable: i32 = 2 //you just put `mut` before name!
    let mut variable: i32 = 2 // same here but after `let`
    ```
    There are also constant values, which are strictly immutable and only allow primitive values. They require the `const` keyword before the name. They are automatically inlined by the compiler.
    ```
    ```c
    const CONSTANT_VARIABLE: i32 = 2
    ```
    ## Types
  8. kittech0 revised this gist Jun 17, 2023. 1 changed file with 60 additions and 38 deletions.
    98 changes: 60 additions & 38 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -36,18 +36,18 @@ Uses rust-like types
    ### Tuples
    Tuples have a Rust-like syntax. They are groups with multiple types of values inside and have a fixed size. Tuples can be destructured.
    Example way of creating:
    ```
    ```c
    tuple: (fsize, u16, bool) = (1.0, 24, true)
    ```
    Accessing values is different from Rust. Instead of `tuple.i` (where `i` is the index/place of the value in the tuple), it uses array-like syntax for accessing elements.
    Example way of accessing value:
    ```
    ```c
    value: fsize = tuple[0] //returns 1.0 of type fsize
    // remember `tuple` variable is (1.0, 24, true)
    ```
    You can also destructure tuples using a different variable syntax, which destructures the tuple into multiple variables.
    Example of destruction:
    ```
    ```c
    (float: fsize, number: u16, answer: bool) = tuple
    float //returns 1.0 with type fsize
    number //returns 24 with type u16
    @@ -56,94 +56,116 @@ answer //returns true with type bool
    ### Array
    Arrays have a Kotlin-like syntax. They are groups of the same type and have a fixed size.
    Example way of creating:
    ```
    ```c
    array: char[5] = ['h','e','l','l','o']
    ```
    The number inside `char[5]` defines the fixed size of the array, and `char` defines the type of values in the array. You can access values inside an array in the same way you would in a tuple.
    Example of accessing value:
    ```
    ```c
    letter: char = array[3] //returns `l` with type char
    ```
    ### Lambda
    Lambdas are a replacement for functions in this language. They use a different syntax from other languages. To create a lambda, you use `f()` (where `f` is used to differentiate from tuples). By default, they return nothing. Lambdas are executed like C functions. They also support compact one-line execution, similar to Kotlin.
    Lambdas are a replacement for functions in this language. They use a different syntax from other languages. To create a lambda, you use `||`. By default, they return nothing. Lambdas are executed like C functions. They also support compact one-line execution, similar to Kotlin.
    Example use of lambda in variable
    ```
    lambda: f() = something()
    ```c
    lambda: || = something()
    ```
    Lambdas can span multiple lines by using `{}`.
    Example use:
    ```
    lambda: f() = {
    ```c
    lambda: || = {
    something()
    something()
    }
    ```
    Lambdas can also have a return type, which is specified after `f()`, like `f(): i32`.
    Lambdas can also have a return type, which is specified after `||`, like `|| -> i32`.
    Example use:
    ```
    lambda: f(): i32 = 2 //will return `2`
    ```c
    lambda: || -> i32 = 2 //will return `2`
    ```
    You can also specify when the lambda should return, if required; otherwise, it will return the last statement in the block. Instead of using `return` as in other languages, you use `<-` to indicate a return.
    Example use:
    ```
    lambda: f(): i32 = {
    ```c
    lambda: || -> i32 = {
    2+2 //won't be returned
    <- 4+4 //will return 8 and stop lambda here
    5-5 //won't be reached
    }
    ```
    Lambdas also support arguments. Arguments are specified inside `()` parentheses, similar to other languages' function syntax.
    Lambdas also support arguments. Arguments are specified inside `||`, similar to other languages' function syntax.
    Example use:
    ```
    lambda: f(x: i32): i32 = x^2 //if executed `lambda(2)` will return `4`
    ```c
    lambda: |x: i32| -> i32 = x^2 //if executed `lambda(2)` will return `4`
    //You can also specify which argument you pass value by using `lambda(x=2)`
    ```
    Arguments also support default values, as you would see in Kotlin.
    Example use:
    ```c
    lambda: |x: i32 = 2| -> i32 = x^2 //If not passed anything by doing `lambda()` it will return 4, if did for example `lambda(6)` it will return 36.
    ```
    lambda: f(x: i32 = 2): i32 = x^2 //If not passed anything by doing `lambda()` it will return 4, if did for example `lambda(6)` it will return 36.
    Lambdas can be used as arguments, and there is a shorthand syntax for it.
    Example use:
    ```c
    lambda: |lam: || | = lam()
    //without shorting syntax
    lambda(|| = std\println("Hello world!"))
    //with shorting syntax
    lambda || = std\println("hello world!")
    ```
    When multiple arguments are used, the shorthand syntax can be applied to each argument.
    Example of a lambda with multiple arguments and shorthand syntax:
    ```c
    lambda: |x: i32, lam: |y: i32|| = lam(x)
    lambda(32) |x| = std\println("Hello {x}") //you do exactly same thing but instead you add the value in `()`
    ```
    ## Modules and Packages
    This language supports creating modules and importing them. By default, the language contains a standard library that you can use. It uses a Rust-like syntax for modules, and the namespace specifier is `\`.
    This language supports creating modules and importing them. The standard library is included by default and can be used. Modules use a syntax similar to Rust, and the namespace specifier is `\`.
    Example module:
    ```
    ```c
    mod MyModule

    pub powerMe: f(x: i128): i128 = x^2 // Use `pub` keyword to make something public!
    pub powerMe: |x: i128| -> i128 = x^2 // Use `pub` keyword to make something public!
    //to use it you would write MyModule\powerMe(2) (returns 4)
    ```
    ## Structure
    Structures are used to create more complex data from existing types. The language combines Rust's structure syntax with Kotlin's implementation of function syntax.
    Structures are used to create more complex data types from existing types. The language combines Rust's structure syntax with Kotlin's implementation of function syntax.
    Example usage:
    ```
    ```c
    struct Person {
    mut name: std\String = "Jane" // To make a mutable variable in a structure, use `mut` as well!
    pub age: u16 // By default, values in a structure are only available for implemented functions. Using `pub` makes them available internally and externally.
    } // Can be initialized by writing `Person("Kittech", 20)` or `Person(age = 16)`
    mut name: std\String = "Jane" // To make a mutable variable in a structure, use `mut`
    pub age: u16 // By default, values in a structure are only available for implemented functions. Using `pub` makes them accessible internally and externally.
    } // You can initialize it using `Person("Kittech", 20)` or `Person(age = 16)`

    Person.sayHello: || = std\out.println("{$.name}: Hello!") // Implements a function for the structure
    // To access values from inside the structure, use `$` (similar to `self` in Rust or `this` in Kotlin)

    Person.sayHello: f() = std\out.println("{$.name}: Hello!") // Implements a function for the structure
    // To access values from inside the structure, use `$` (in Rust, you would use `self`, and in Kotlin, `this`).
    mut Person.setName: |name: std\String| = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable

    mut Person.setName: f(name: std\String) = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable
    |Person.new: |name: std\String, age: u16| -> it = it(name, age)
    // This is a static variable on Person. You create it by putting `Person` between `||`.
    // `it` is used for returning itself and only stores the constructor and static variables.
    // Static variables are immutable and cannot be changed.
    ```
    ## DSL
    A DSL is a building pattern that can be found in Groovy or Kotlin. It makes it easy for developers to create builder functions, and for users to use them without problems. In this language, we can implement a builder using lambda-like syntax with some differences.
    A DSL is a building pattern commonly found in Groovy or Kotlin. It makes it easy for developers to create builder functions, and for users to use them without problems. In this language, we can implement a builder using lambda-like syntax with some differences.
    Example implementation:
    ```
    ```c
    // Example structure
    struct ExampleBuild {
    mut number: isize
    }

    mut ExampleBuild.addNumber: f(num: isize) = $.number += num
    mut ExampleBuild.addNumber: |num: isize| = $.number += num

    // DSL builder implementation
    |ExampleBuild|.builder f(num: isize) = ExampleBuild(num).apply($)
    builder: |num: isize, example: ExampleBuild.|| | = ExampleBuild(num).apply(example)
    // `ExampleBuild.||` is similar to a lambda but provides DSL abilities

    // Example usage
    ExampleBuild.builder(100) = {
    builder(100) || = {
    $.addNumber(1)
    $.addNumber(100)
    } // Returns ExampleBuild with `number` 201
    } // Returns ExampleBuild with `number` equal to 201
    ```
    Every struct has a default `apply` function, which allows them to apply builders to themselves. It works by gathering all the functions from the builder and executing them on the object. `|ExampleBuild|` can be a bit confusing, but it basically means that we are creating a DSL builder on the structure we want to work on. The builder function might also seem confusing, but it simply sets all the functions to execute when applying them to the object.
    Every struct has an `.apply` function that can be called by passing the builder DSL lambda as an argument.
  9. kittech0 revised this gist Jun 16, 2023. 1 changed file with 43 additions and 0 deletions.
    43 changes: 43 additions & 0 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -103,4 +103,47 @@ Example use:
    ```
    lambda: f(x: i32 = 2): i32 = x^2 //If not passed anything by doing `lambda()` it will return 4, if did for example `lambda(6)` it will return 36.
    ```
    ## Modules and Packages
    This language supports creating modules and importing them. By default, the language contains a standard library that you can use. It uses a Rust-like syntax for modules, and the namespace specifier is `\`.
    Example module:
    ```
    mod MyModule
    pub powerMe: f(x: i128): i128 = x^2 // Use `pub` keyword to make something public!
    ```
    ## Structure
    Structures are used to create more complex data from existing types. The language combines Rust's structure syntax with Kotlin's implementation of function syntax.
    Example usage:
    ```
    struct Person {
    mut name: std\String = "Jane" // To make a mutable variable in a structure, use `mut` as well!
    pub age: u16 // By default, values in a structure are only available for implemented functions. Using `pub` makes them available internally and externally.
    } // Can be initialized by writing `Person("Kittech", 20)` or `Person(age = 16)`
    Person.sayHello: f() = std\out.println("{$.name}: Hello!") // Implements a function for the structure
    // To access values from inside the structure, use `$` (in Rust, you would use `self`, and in Kotlin, `this`).
    mut Person.setName: f(name: std\String) = $.name = name // To mutate any value in the structure, the implemented lambda also needs to be mutable
    ```
    ## DSL
    A DSL is a building pattern that can be found in Groovy or Kotlin. It makes it easy for developers to create builder functions, and for users to use them without problems. In this language, we can implement a builder using lambda-like syntax with some differences.
    Example implementation:
    ```
    // Example structure
    struct ExampleBuild {
    mut number: isize
    }
    mut ExampleBuild.addNumber: f(num: isize) = $.number += num
    // DSL builder implementation
    |ExampleBuild|.builder f(num: isize) = ExampleBuild(num).apply($)
    // Example usage
    ExampleBuild.builder(100) = {
    $.addNumber(1)
    $.addNumber(100)
    } // Returns ExampleBuild with `number` 201
    ```
    Every struct has a default `apply` function, which allows them to apply builders to themselves. It works by gathering all the functions from the builder and executing them on the object. `|ExampleBuild|` can be a bit confusing, but it basically means that we are creating a DSL builder on the structure we want to work on. The builder function might also seem confusing, but it simply sets all the functions to execute when applying them to the object.
  10. kittech0 revised this gist Jun 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ function(/* Insides */) // Description of it!
    */
    ```

    ## Varibles and mutability
    ## Variables and mutability
    There are multiple ways of declaring variables in this language. By default, every variable is immutable, and you need to specify mutability. The syntax for declaring variables is Rust-like, with an optional `let` keyword.
    Example of an immutable variable:
    ```
  11. kittech0 revised this gist Jun 16, 2023. 1 changed file with 24 additions and 26 deletions.
    50 changes: 24 additions & 26 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -1,52 +1,51 @@
    Welcome to the idea of language based around Kotlin and Rust!

    ## Comments
    Uses C-like comments
    Comments in this language use C-like syntax.
    ```
    // One liner
    function(/* Insides */) // description of it!
    // One-liner
    function(/* Insides */) // Description of it!
    /*
    multiple liner!
    Multiple lines!
    */
    ```

    ## Varibles and mutability
    There are many ways of writting variables in here. Every variable is by default immutable, requires you to specify mutability. Syntax of declaring variable is rust-like with optional `let`.
    Example of immutable variable:
    There are multiple ways of declaring variables in this language. By default, every variable is immutable, and you need to specify mutability. The syntax for declaring variables is Rust-like, with an optional `let` keyword.
    Example of an immutable variable:
    ```
    variable: i32 = 2
    let variable: i32 = 2 //let is completely optional and not required, it will work exactly the same in example above
    let variable: i32 = 2 // `let` is optional and not required; it will work the same in the example above
    ```
    Example of mutable variable:
    ```
    mut variable: i32 = 2 //you just put `mut` before name!
    let mut variable: i32 = 2 // same here but after `let`
    ```
    There also exists constant values which are strictly immutable, and only allow primitive values. They require to have `const` before name. It gets automatically inlined by compiler.
    Example use:
    There are also constant values, which are strictly immutable and only allow primitive values. They require the `const` keyword before the name. They are automatically inlined by the compiler.
    ```
    const CONSTANT_VARIABLE: i32 = 2
    ```
    ## Types
    Uses rust-like types
    1. `i8`,`i16`,`i32`,`i64`,`i128` and `isize` signed intiger
    2. `u8`,`u16`,`u32`,`u64`,`u128` and `usize` unsigned integer
    3. `f8`,`f16`,`f32`,`f64`,`f128` and `fsize` float
    4. `char` character (to create character use `''` example: `'a'`)
    5. `bool` boolean (`true` or `false`)
    1. Signed integers: `i8`,`i16`,`i32`,`i64`,`i128` and `isize`
    2. Unsigned integer: `u8`,`u16`,`u32`,`u64`,`u128` and `usize`
    3. Floating-point numbers: `f8`,`f16`,`f32`,`f64`,`f128` and `fsize`
    4. Characters: `char` (to create character use `''` example: `'a'`)
    5. Boolean: `bool` (`true` or `false`)
    ### Tuples
    Tuple syntax is also rust-like. They are groups with multiple types of values inside with fixed size and can be destructed.
    Tuples have a Rust-like syntax. They are groups with multiple types of values inside and have a fixed size. Tuples can be destructured.
    Example way of creating:
    ```
    tuple: (fsize, u16, bool) = (1.0, 24, true)
    ```
    Accessing value is different than in rust, instead of `tuple.i` (i is index/place of value in tuple) it uses array like syntax accessing.
    Accessing values is different from Rust. Instead of `tuple.i` (where `i` is the index/place of the value in the tuple), it uses array-like syntax for accessing elements.
    Example way of accessing value:
    ```
    value: fsize = tuple[0] //returns 1.0 of type fsize
    // remember `tuple` variable is (1.0, 24, true)
    ```
    You can also destruct the tuples by using different variable syntax which simply destructs the tuple into multiple variables.
    You can also destructure tuples using a different variable syntax, which destructures the tuple into multiple variables.
    Example of destruction:
    ```
    (float: fsize, number: u16, answer: bool) = tuple
    @@ -55,37 +54,36 @@ number //returns 24 with type u16
    answer //returns true with type bool
    ```
    ### Array
    Array syntax is instead kotlin-like. They are groups of same type and with fixed size.
    Arrays have a Kotlin-like syntax. They are groups of the same type and have a fixed size.
    Example way of creating:
    ```
    array: char[5] = ['h','e','l','l','o']
    ```
    number inside `char[5]` defines fixed size of array, and `char` defines type of values in array.
    You can access value inside array exactly the same way like you did in tuple!
    The number inside `char[5]` defines the fixed size of the array, and `char` defines the type of values in the array. You can access values inside an array in the same way you would in a tuple.
    Example of accessing value:
    ```
    letter: char = array[3] //returns `l` with type char
    ```
    ### Lambda
    Lambda are replacement for functions in this language, they use different syntax from other languages. To create lambda you use `f()`, f is used to different from tuples. By default they return nothing. They are executed like a function in C. They also use compacting for one line executions like in kotlin.
    Lambdas are a replacement for functions in this language. They use a different syntax from other languages. To create a lambda, you use `f()` (where `f` is used to differentiate from tuples). By default, they return nothing. Lambdas are executed like C functions. They also support compact one-line execution, similar to Kotlin.
    Example use of lambda in variable
    ```
    lambda: f() = something()
    ```
    They can be used in multiple line by using `{}`.
    Lambdas can span multiple lines by using `{}`.
    Example use:
    ```
    lambda: f() = {
    something()
    something()
    }
    ```
    Lambda also can have return type which is said after `f()` like `f(): i32`.
    Lambdas can also have a return type, which is specified after `f()`, like `f(): i32`.
    Example use:
    ```
    lambda: f(): i32 = 2 //will return `2`
    ```
    You can also specify when the lambda will return if required, otherwise it will return last statement in block. Use `<-` for returning something instead of `return` in other languages.
    You can also specify when the lambda should return, if required; otherwise, it will return the last statement in the block. Instead of using `return` as in other languages, you use `<-` to indicate a return.
    Example use:
    ```
    lambda: f(): i32 = {
    @@ -94,13 +92,13 @@ lambda: f(): i32 = {
    5-5 //won't be reached
    }
    ```
    Lambdas also support arguments, arguments can be stated inside `()` like in other languages you would with functions.
    Lambdas also support arguments. Arguments are specified inside `()` parentheses, similar to other languages' function syntax.
    Example use:
    ```
    lambda: f(x: i32): i32 = x^2 //if executed `lambda(2)` will return `4`
    //You can also specify which argument you pass value by using `lambda(x=2)`
    ```
    Arguments also support default arguments, like you would see in kotlin.
    Arguments also support default values, as you would see in Kotlin.
    Example use:
    ```
    lambda: f(x: i32 = 2): i32 = x^2 //If not passed anything by doing `lambda()` it will return 4, if did for example `lambda(6)` it will return 36.
  12. kittech0 revised this gist Jun 16, 2023. 1 changed file with 60 additions and 2 deletions.
    62 changes: 60 additions & 2 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,32 @@
    Welcome to the idea of language based around Kotlin and Rust!

    ## Comments
    Uses C-like comments. `//` comments entire lines, `/* ... */` gives you ability to comment inside of something or comment multiple lines
    Uses C-like comments
    ```
    // One liner
    function(/* Insides */) // description of it!
    /*
    multiple liner!
    */
    ```

    ## Varibles and mutability
    There are many ways of writting variables in here. Every variable is by default immutable, requires you to specify mutability. Syntax of declaring variable is rust-like with optional `let`.
    Example of immutable variable:
    ```
    variable: i32 = 2
    let variable: i32 = 2 //let is completely optional and not required, it will work exactly the same in example above
    ```
    Example of mutable variable:
    ```
    mut variable: i32 = 2 //you just put `mut` before name!
    let mut variable: i32 = 2 // same here but after `let`
    ```
    There also exists constant values which are strictly immutable, and only allow primitive values. They require to have `const` before name. It gets automatically inlined by compiler.
    Example use:
    ```
    const CONSTANT_VARIABLE: i32 = 2
    ```
    ## Types
    Uses rust-like types
    1. `i8`,`i16`,`i32`,`i64`,`i128` and `isize` signed intiger
    @@ -47,4 +65,44 @@ You can access value inside array exactly the same way like you did in tuple!
    Example of accessing value:
    ```
    letter: char = array[3] //returns `l` with type char
    ```
    ```
    ### Lambda
    Lambda are replacement for functions in this language, they use different syntax from other languages. To create lambda you use `f()`, f is used to different from tuples. By default they return nothing. They are executed like a function in C. They also use compacting for one line executions like in kotlin.
    Example use of lambda in variable
    ```
    lambda: f() = something()
    ```
    They can be used in multiple line by using `{}`.
    Example use:
    ```
    lambda: f() = {
    something()
    something()
    }
    ```
    Lambda also can have return type which is said after `f()` like `f(): i32`.
    Example use:
    ```
    lambda: f(): i32 = 2 //will return `2`
    ```
    You can also specify when the lambda will return if required, otherwise it will return last statement in block. Use `<-` for returning something instead of `return` in other languages.
    Example use:
    ```
    lambda: f(): i32 = {
    2+2 //won't be returned
    <- 4+4 //will return 8 and stop lambda here
    5-5 //won't be reached
    }
    ```
    Lambdas also support arguments, arguments can be stated inside `()` like in other languages you would with functions.
    Example use:
    ```
    lambda: f(x: i32): i32 = x^2 //if executed `lambda(2)` will return `4`
    //You can also specify which argument you pass value by using `lambda(x=2)`
    ```
    Arguments also support default arguments, like you would see in kotlin.
    Example use:
    ```
    lambda: f(x: i32 = 2): i32 = x^2 //If not passed anything by doing `lambda()` it will return 4, if did for example `lambda(6)` it will return 36.
    ```

  13. kittech0 revised this gist Jun 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Welcome to the idea of language based around Kotlin and Rust!

    ## Comments
    Uses C-like comments
    Uses C-like comments. `//` comments entire lines, `/* ... */` gives you ability to comment inside of something or comment multiple lines
    ```
    // One liner
    function(/* Insides */) // description of it!
  14. kittech0 revised this gist Jun 16, 2023. 1 changed file with 38 additions and 94 deletions.
    132 changes: 38 additions & 94 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -1,106 +1,50 @@
    ## Example hello world!
    ```
    import std
    main: f() = std#out.println("Hello world!")
    ```
    Welcome to the idea of language based around Kotlin and Rust!

    ## Comments
    Uses C-like comments
    ```
    main: f() = doingSomething(;; something can be here ;;) ; doing something!
    ;;
    or can be nowhere!
    ;;
    ```
    ## Variables, constants, lambdas and mutable!
    ```
    fool: i8 = 2
    ; or
    let fool: i8 = 2
    const anotherFool: bool = true
    l: f(x: i128): i128 = x^2
    mut nonFool: i32 = 1234567890
    ; or
    let mut nonFool: i32 = 1234567890
    ```
    ## More of lambda
    ```
    main: f() = {
    fstop ; will stop lambda and return here
    }
    example: f(): i32 = {
    fstop 1 ; return value is required when fstop
    }
    // One liner
    function(/* Insides */) // description of it!
    /*
    multiple liner!
    */
    ```
    ## Scalar types
    1. `i8` to `i128` and `isize` integers
    2. `u8` to `u128` and `usize` unsigned integers
    3. `f8` to `f128` float
    4. `bool` boolean
    5. `char` character
    ## Tuple type
    Tuple groups multiple types into one type. Example use:
    ## Types
    Uses rust-like types
    1. `i8`,`i16`,`i32`,`i64`,`i128` and `isize` signed intiger
    2. `u8`,`u16`,`u32`,`u64`,`u128` and `usize` unsigned integer
    3. `f8`,`f16`,`f32`,`f64`,`f128` and `fsize` float
    4. `char` character (to create character use `''` example: `'a'`)
    5. `bool` boolean (`true` or `false`)
    ### Tuples
    Tuple syntax is also rust-like. They are groups with multiple types of values inside with fixed size and can be destructed.
    Example way of creating:
    ```
    example: f(x: i8): (i8,i8) = (x-2,x+2)
    tuple: (fsize, u16, bool) = (1.0, 24, true)
    ```
    ## Arrays
    Way of grouping multiple values into one collection. Example use:
    Accessing value is different than in rust, instead of `tuple.i` (i is index/place of value in tuple) it uses array like syntax accessing.
    Example way of accessing value:
    ```
    example: f(x: char, y: char): [char:2] = [x,y]
    value: fsize = tuple[0] //returns 1.0 of type fsize
    // remember `tuple` variable is (1.0, 24, true)
    ```
    ## References
    Due to our language being null safe there are no pointers that you can see in C/C++ which are nullable. Example use:
    You can also destruct the tuples by using different variable syntax which simply destructs the tuple into multiple variables.
    Example of destruction:
    ```
    main: f() = {
    mut x: i32 = 1
    example($mut x)
    std#out.println("It is now: $x!") ; It is now 2!
    }
    example: f(x: $mut i32) = x := 2
    (float: fsize, number: u16, answer: bool) = tuple
    float //returns 1.0 with type fsize
    number //returns 24 with type u16
    answer //returns true with type bool
    ```
    ## Loops
    1. `each` loops through stuff
    2. `while` loops as long as it is true
    3. `loop` infinite loop
    ### Example use for `each`
    ### Array
    Array syntax is instead kotlin-like. They are groups of same type and with fixed size.
    Example way of creating:
    ```
    main: f() = {
    elements: [char:5] = ['a','b','c','d','f']
    each element : elements std#out.println(element)
    ; now range operator
    each int : 1..100 std#out.println(int)
    }
    ```
    ### Example use for `while`
    ```
    main: f() = {
    elements: [char:5] = ['a','b','c','d','f']
    mut found: bool = false
    mut i: i8 = 0
    while !found {
    if elements[i] == 'd' = found = true
    i++
    }
    std#out.println("Found 'd' on $i place")
    }
    ```
    ### Example use for `loop`
    ```
    main: f() = {
    mut i: i32 = 0
    loop {
    std#out.println("Now number is $i")
    if i == 100 = stop ; stops loops and blocks of code and returns
    i++
    }
    }
    ```

    ## Structure
    Ability to construct own data. Example use:
    array: char[5] = ['h','e','l','l','o']
    ```
    stuct Example {
    pub x: i32 =2 ; supports default too!
    y: $mut char
    }
    Example.getY: f(): $char = &.y
    mut Example.mutateY: f(y: char) = &.y := y
    number inside `char[5]` defines fixed size of array, and `char` defines type of values in array.
    You can access value inside array exactly the same way like you did in tuple!
    Example of accessing value:
    ```
    letter: char = array[3] //returns `l` with type char
    ```
  15. kittech0 revised this gist Jun 16, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,9 @@ main: f() = std#out.println("Hello world!")
    ## Comments
    ```
    main: f() = doingSomething(;; something can be here ;;) ; doing something!
    ;:
    ;;
    or can be nowhere!
    :;
    ;;
    ```
    ## Variables, constants, lambdas and mutable!
    ```
  16. kittech0 revised this gist Jun 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -98,7 +98,7 @@ main: f() = {
    Ability to construct own data. Example use:
    ```
    stuct Example {
    pub x: i32
    pub x: i32 =2 ; supports default too!
    y: $mut char
    }
    Example.getY: f(): $char = &.y
  17. kittech0 created this gist Jun 16, 2023.
    106 changes: 106 additions & 0 deletions The Prismatica Programming language.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,106 @@
    ## Example hello world!
    ```
    import std
    main: f() = std#out.println("Hello world!")
    ```
    ## Comments
    ```
    main: f() = doingSomething(;; something can be here ;;) ; doing something!
    ;:
    or can be nowhere!
    :;
    ```
    ## Variables, constants, lambdas and mutable!
    ```
    fool: i8 = 2
    ; or
    let fool: i8 = 2
    const anotherFool: bool = true
    l: f(x: i128): i128 = x^2
    mut nonFool: i32 = 1234567890
    ; or
    let mut nonFool: i32 = 1234567890
    ```
    ## More of lambda
    ```
    main: f() = {
    fstop ; will stop lambda and return here
    }
    example: f(): i32 = {
    fstop 1 ; return value is required when fstop
    }
    ```
    ## Scalar types
    1. `i8` to `i128` and `isize` integers
    2. `u8` to `u128` and `usize` unsigned integers
    3. `f8` to `f128` float
    4. `bool` boolean
    5. `char` character
    ## Tuple type
    Tuple groups multiple types into one type. Example use:
    ```
    example: f(x: i8): (i8,i8) = (x-2,x+2)
    ```
    ## Arrays
    Way of grouping multiple values into one collection. Example use:
    ```
    example: f(x: char, y: char): [char:2] = [x,y]
    ```
    ## References
    Due to our language being null safe there are no pointers that you can see in C/C++ which are nullable. Example use:
    ```
    main: f() = {
    mut x: i32 = 1
    example($mut x)
    std#out.println("It is now: $x!") ; It is now 2!
    }
    example: f(x: $mut i32) = x := 2
    ```
    ## Loops
    1. `each` loops through stuff
    2. `while` loops as long as it is true
    3. `loop` infinite loop
    ### Example use for `each`
    ```
    main: f() = {
    elements: [char:5] = ['a','b','c','d','f']
    each element : elements std#out.println(element)
    ; now range operator
    each int : 1..100 std#out.println(int)
    }
    ```
    ### Example use for `while`
    ```
    main: f() = {
    elements: [char:5] = ['a','b','c','d','f']
    mut found: bool = false
    mut i: i8 = 0
    while !found {
    if elements[i] == 'd' = found = true
    i++
    }
    std#out.println("Found 'd' on $i place")
    }
    ```
    ### Example use for `loop`
    ```
    main: f() = {
    mut i: i32 = 0
    loop {
    std#out.println("Now number is $i")
    if i == 100 = stop ; stops loops and blocks of code and returns
    i++
    }
    }
    ```

    ## Structure
    Ability to construct own data. Example use:
    ```
    stuct Example {
    pub x: i32
    y: $mut char
    }
    Example.getY: f(): $char = &.y
    mut Example.mutateY: f(y: char) = &.y := y
    ```