Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multivariable assignment and destructuring #33

Open
kaiserthe13th opened this issue Apr 11, 2022 · 0 comments
Open

Multivariable assignment and destructuring #33

kaiserthe13th opened this issue Apr 11, 2022 · 0 comments
Labels
enhancement | yükseltme New feature or request | Yeni özellik veya istek todo | yapılacaklar something we are to do | yapacağımız bir şey

Comments

@kaiserthe13th
Copy link
Owner

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

@kaiserthe13th kaiserthe13th added enhancement | yükseltme New feature or request | Yeni özellik veya istek todo | yapılacaklar something we are to do | yapacağımız bir şey labels Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement | yükseltme New feature or request | Yeni özellik veya istek todo | yapılacaklar something we are to do | yapacağımız bir şey
Projects
None yet
Development

No branches or pull requests

1 participant