mani-language / Mani

Máni ... an awesome, super simple programming language!
https://mani-language.github.io/
Mozilla Public License 2.0
28 stars 7 forks source link

Setup internal functions (private and public) #10

Closed crazywolf132 closed 6 years ago

crazywolf132 commented 6 years ago

Each class should be allowed to have functions that can't be reached from outside the class.

Much like java, and swift... we could do something similar. eg.

class A {
    A(str) {
        this.str = str;
    }

    canUse() {
        say "Able to use this function";
    }

    internal cantUse() {
        say "Only internal functions can use me.";
        say this.str;
    }

    useBoth() {
        this.canUse();
        this.cantUse();
    }
}

>> let a = A("wow"); 
>> a.canUse();                  // Can use... as its public
Able to use this function
>> a.cantUse();                 // Wont be able to use... as its internal
Sorry, this is a private class!
>> a.useBoth();                 // Can use... as its a public function, accessing a private function in the same class
Able to use this function
Only internal functions can use me.
wow
>>
crazywolf132 commented 6 years ago

maybe @nitros12 or @brokenprogrammer could help?

crazywolf132 commented 6 years ago

Should add this to the docs. #15

crazywolf132 commented 6 years ago

Will close this issue once added to docs, so we know it's done.