/Poly

Poly is Object-Oriented Static-typed and Strong-structured programming language

Primary LanguageC#MIT LicenseMIT

Poly

Poly is Object-Oriented Static-typed and Strong-structured programming language

Syntax

Basic hello world code:

namespace: 'MyProgram';

class Program
{
    method Main(array<string> args)
    {
        print('hello world !');
    }
}

Basic Object-oriented code:

namespace: 'MyProgram';

class car
{
    string name;
    int price;
    
    ctor(string _name)
    {
        self.name = _name;
    }
    
    method reset_name()
    {
        self.name = '';
    }
}

class Program
{
    method Main(array<string> args)
    {
        car mycar = new car('bmw');
        print(mycar.name);
    }
}

Progress

  • Namespace (namespace 'name';)
  • Import (import 'name';)
  • Variable declaration (type name = value;)
  • Variable assigning (name = value;)
  • Return (return value;)
  • Conditions
    • If (if(cond) {})
    • ElseIf (else if(cond) {})
    • Else (else {})
  • Loops
    • While ... Do, Do ... While
    • For
    • Foreach
    • Repeat
  • Class declaration (class name {})
  • Static classes (static class name {})
  • Class fields (field name;)
  • Class methods (method type name(args){})
  • Method declaration (method type name(args) {})
  • System library
    • print(value)
    • printin(value)
    • read()
    • gettype(value)
    • tostring()
    • toint()
    • toreal()
    • tobool()
    • toarray()
    • time()
    • string.length
    • array.length
    • array.find
    • array.map
    • array.reduce
  • Expressions
    • +, -, *, /, % (Arithemtic)
    • &&, || (Boolean)
    • ==, !=, <, >, <=, >= (Boolean)
    • ? (true ? true : false)
    • ?? (true ?? true)
    • Number type (123)
    • Real type (1.0)
    • Boolean type (true/false)
    • String type ('abc')
      • String formatting ($'hello ${abc}')
    • Array type ([])
    • T of types (array<array>)
    • Object type ({})
    • Lambda type(() => {})
    • Method calls (abc())
    • Array calls (abc[0+1])
    • Dot expressions (abc.cdf.ghj)
    • Instance creation