Skip to content

Instantly share code, notes, and snippets.

@ilfey
Last active February 22, 2024 12:50
Show Gist options
  • Select an option

  • Save ilfey/98ee7478a817f717a13dee316a836fcf to your computer and use it in GitHub Desktop.

Select an option

Save ilfey/98ee7478a817f717a13dee316a836fcf to your computer and use it in GitHub Desktop.
My programming language concept

Primitives

  • Iterable (aka List) [1, 2, 3]
  • Number 1 1.0
  • String “string {statement}” ‘string’
  • Boolean true false
  • Object
  • Function
  • Null null

Variables

global variable_name = true
local other_variable = false

global - глобальная переменная. Глобальные переменные могут быть объявлены только в глобальной области видимости

local - локальная переменная. Локальные переменные доступны только в том файле, в котором они объявлены

Operators

  • + сложение
  • - вычитание
  • / деление
  • % остаток от деления
  • * умножение
  • ** возведение в степень
  • < меньше чем
  • > больше чем
  • <= меньше или равно
  • >= больше
  • is проверка на принадлежность типа
  • in итератор

Conditions

if condition { 
    // block
}

Loops

for true {} // infinity loop
for condition {} // while loop
for initial; condition; increment/decrement {} // for loop

Golang reference

Functions

global callback = () => {}

Objects

class MyClass {
    local property = 'property'
   
    global constructor = () => {
        print(this.property)
    }

    global __string__ = () => {
        return "[MyClass] {this.property}"
    }
}

local cls = new MyClass()

global - модификатор доступа public

local - модификатор доступа private

__string__ - магический метод приведения объекта к строке

Magic methods

  • Logically
    • __and__ logical and
    • __or__ logical or
  • Comparsion
    • __eq__ equal
    • __ne__ not equal
    • __lt__ less than
    • __gt__ greater than
    • __le__ less than or equals
    • __ge__ greater than
  • Mathematical
    • __pos__ unary plus
    • __neg__ unary minus
    • __add__ addition
    • __sub__ subtraction
    • __mul__ multiple
    • __div__ division
    • __mod__ modulo
    • __pow__ power

Global functions

  • string()
  • array()
  • list()
@bot08
Copy link

bot08 commented Feb 22, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment