Skip to content

Multivariable assignment and destructuring #33

@kaiserthe13th

Description

@kaiserthe13th

so another syntax proposal I have is this simple syntax that is very effective
and much more user friendly than x, y -> a -> b (which will result in a = y, b = x)

# sets a = 1, b = 2
1, 2 |a, b| ile

# can be used as a way of expecting function arguments
işlev name |a, b| ile
  ...
son

# we can implement for .. in loops easily
[1, 2, 3, 4, 5] için |i| ile
  ...
son

# Destructuring

# Get first element of list
[1, 2, 3, 4] |[a, ..]| ile

# Get a and b from a block
blok c
  1 -> a
  2 -> b
son

c |{a, b}| ile

it can also be used as a way of bringing multiple things into scope

yükle ".." -> a
a |b, c, d| ile

In the background it would probably function as taking elements from the stack in reverse order
for pattern destructuring it would probably be destructure objects with curly braces
for list destructuring it would again reverse order and take
meanwhile .. means reverse order again and can only be used once

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement | yükseltmeNew feature or request | Yeni özellik veya istektodo | yapılacaklarsomething we are to do | yapacağımız bir şey

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions