Skip to content

v1.9.0

Latest

Choose a tag to compare

@thewhynow thewhynow released this 30 Jul 04:57
29384b3

Classes, a standard library, improved list syntax, and so much more!
Sorry for holding off on so long, im going to try and cover most of the new features in this post:

  • Libraries:
    You are now able to import libraries into your code using the use keyword. The syntax looks like this: use <fileNameAsStringWithType>
    A Standard library has been defined. Using it will add new methods to the num class, while making no difference on the user end. If the user wants, they can still use primitives.
    Eventually I will write all the other primitves out inside the standard library as well. To include the standard library, simply do use "standard.g"
    P.S. including a library literally pastes all the code from the library. Here is an example of using the new methods for the num type defined in the standard library:
a = 12.345;
out(a.round(2));
out(a.is_integer());
out(a.abs());

these output 12.35, 0, and 12.345 respectively

  • Classes:
    Methods to classes have been implemented along with some other syntax updates.
    By using the set(<identifier>, <value>) function, a variable is able to be kept as a method after the constructor is finished running inside a collec. Here is an example:
collec Person = (name){
     set(name, name);   
     out("Person created!"); 
 }

if we try and access the name property after by doing me = Person("TheWhyNow") and then me.name we would get "TheWhyNow". However, if we did not use the set() function that variable would automatically get deleted. Note that functions defined in a collec bypass this rule and do not need to be marked using the set() function

In addition, changing the properties of a collec is now much easier. instead of previously doing me.name =/ "thewhynow", you can now just do me.name = "thewhynow", which looks much better syntactically.

OVERLOADING METHODS:
you can now overload certain operators with classes in this language. Please check the README for more info, but here is an example number class with the four basic operations overloaded:

collec number = (value){
     set(value, value);
     
     func __add__ = (valueB){} -> value + valueB.value;
     func __sub__ = (valueB){} -> value - valueB.value;
     func __mul__ = (valueB){} -> value * valueB.value;
     func __div__ = (valueB){} -> value / valueB.value;
}
# if i try adding two instances of this class, the __add__() function gets called
  • Improved List Operations:
    instead of indexing with // and changing a value with =/, i have now updated it to use [] and = respectively. Additionally, instead of [] being used to define a list, {} now are used. Here is an example showcasing all of the new improvements:
lst = {1, 2, 3, 4, 5};
lst[0] = 0;
out(lst[0]);

this outputs 0 to the terminal.

There have been many other minor improvements, please check the readme for more info!
Sue me for skipping version numbers >:)