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

Alternative arguments syntax #33

Open
vadzim opened this issue Jan 24, 2018 · 1 comment
Open

Alternative arguments syntax #33

vadzim opened this issue Jan 24, 2018 · 1 comment

Comments

@vadzim
Copy link

vadzim commented Jan 24, 2018

Could it make sense to make arguments syntax for-like?
Instead of writing

// ... this is what you write ...
a(1) do (foo) {
  // ...
}

// ... this is what you get ...
a(1, (foo) => {
  ...
})

we could write

a(let foo of 1) {
  // ...
}
// means
a(1, (foo) => {
  ...
})


a(let [foo, bar] of 1, 2) {
  // ...
}
// means
a(1, 2, ([foo, bar]) => {
  ...
})

a(let foo, bar of 1, 2) {
  // ...
}
// means
a(1, 2, (foo, bar) => {
  ...
})

a(const foo, bar of 1, 2) {
  // ...
}
// means
a(1, 2, (__foo__, __bar__) => {
  const foo = __foo__, bar = __bar__
  ...
})

Or we can use other separator between arguments lists. E.g. ;:

a(let foo; 1) {
  // ...
}
// means
a(1, (foo) => {
  ...
})


a(let [foo, bar]; 1, 2) {
  // ...
}
// means
a(1, 2, ([foo, bar]) => {
  ...
})

a(let foo, bar; 1, 2) {
  // ...
}
// means
a(1, 2, (foo, bar) => {
  ...
})

a(const foo, bar; 1, 2) {
  // ...
}
// means
a(1, 2, (__foo__, __bar__) => {
  const foo = __foo__, bar = __bar__
  ...
})
@vadzim
Copy link
Author

vadzim commented Mar 15, 2018

Hmmm.. may be the for keyword could be better for that:

a(let foo for 1) {
  // ...
}
// means
a(1, (foo) => {
  ...
})


a(let [foo, bar] for 1, 2) {
  // ...
}
// means
a(1, 2, ([foo, bar]) => {
  ...
})

a(let foo, bar for 1, 2) {
  // ...
}
// means
a(1, 2, (foo, bar) => {
  ...
})

a(const foo, bar for 1, 2) {
  // ...
}
// means
a(1, 2, (__foo__, __bar__) => {
  const foo = __foo__, bar = __bar__
  ...
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant