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

Argument/Property name can be omitted if variable passed has same name #204

Closed
giann opened this issue Oct 9, 2023 · 1 comment · Fixed by #213
Closed

Argument/Property name can be omitted if variable passed has same name #204

giann opened this issue Oct 9, 2023 · 1 comment · Fixed by #213
Labels
language Issue related to the language proposal Something we consider doing
Milestone

Comments

@giann
Copy link
Collaborator

giann commented Oct 9, 2023

buzz only allows the first argument of a function to be unnamed. I stand by that choice but sometimes, named argument can be a little repetitive if the value passed has the same name.

With this, we would go from:

fun hello(str firstname, str lastname, int age) > void {
    | ...
}

hello(firstname, lastname: lastname, age: calculatedAge);

to:

fun hello(str firstname, str lastname, int age) > void {
    | ...
}

hello(firstname, lastname, age: calculatedAge);

We can do the same for object initialization (like rust):

object Person {
    str firstname,
    str lastname,
    int age,
}

var person = Person{
    firstname,
    lastname,
    age = calculatedAge
}
@giann giann added language Issue related to the language proposal Something we consider doing labels Oct 9, 2023
@giann giann added this to the 0.4.0 milestone Oct 9, 2023
@matdexir
Copy link
Contributor

matdexir commented Oct 9, 2023

That's a good one! It really makes the language feel more natural.

giann added a commit that referenced this issue Oct 15, 2023
giann added a commit that referenced this issue Oct 16, 2023
giann added a commit that referenced this issue Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Issue related to the language proposal Something we consider doing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants