Skip to content

Rust-like structs(without types) with implementations in tr-lang and Basic Enums #31

@kaiserthe13th

Description

@kaiserthe13th

A proposal to add Rust-like structs(without types) to the language. As in Turkish struct means yapı, which also means building. It may be a confusing name. Thus after some consideration I renamed them to şekil (shape). Enums have been directly translated into sayım. And here is the syntax proposal. methods are metot or yöntem and new is yeni

# A struct
şekil Human
  name
  age
  gender
son
# An enumeration
sayım Gender
  male female # at runtime assigned to 0 and 1
  # or instead of at runtime we turn it into this
  # blok Gender
  #   0 -> male
  #   1 -> female
  # son
  # thus enums can also be compared with numbers
son
# With this syntax you can only implement things in scope
metot is-male >> Human # methods have self thrown into them as a value when executed
  :gender = Gender:male ver
son
# Creating a member function that doesn't take self
bağlı işlev new-human >> Human -> gender -> age -> name
  yeni Human # initializer keyword: yeni
    name age gender
  son ver
son

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions