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

Should if (condition) { ... } allow if condition { ... } syntax? #351

Open
mhagmajer opened this issue Jul 7, 2020 · 5 comments
Open

Should if (condition) { ... } allow if condition { ... } syntax? #351

mhagmajer opened this issue Jul 7, 2020 · 5 comments
Labels
AskScript ./src/askscript/** discussion A discussion is taking place, please don't work on it yet enhancement New feature or request question Further information is requested type:syntax related to syntax or syntax sugar

Comments

@mhagmajer
Copy link
Contributor

No description provided.

@mhagmajer mhagmajer added question Further information is requested AskScript ./src/askscript/** labels Jul 7, 2020
@mhagmajer
Copy link
Contributor Author

At the second lesson with Marta I saw that she intuitively wanted to write:

if n <= 0 {
  return n
}

instead of

if (n <= 0) {
  return n
}

Should we support the syntax without brackets for if?

@czerwinskilukasz1 czerwinskilukasz1 added the discussion A discussion is taking place, please don't work on it yet label Jul 7, 2020
@czerwinskilukasz1
Copy link
Collaborator

Not sure about that, might degrade readability.

@czerwinskilukasz1 czerwinskilukasz1 added type:syntax related to syntax or syntax sugar enhancement New feature or request labels Jul 15, 2020
@mhagmajer
Copy link
Contributor Author

Not sure about that, might degrade readability.

Can you show an example where this degrades readability? If we allow both syntaxes, which one should the formatter use?

@czerwinskilukasz1
Copy link
Collaborator

Not sure about that, might degrade readability.

Can you show an example where this degrades readability? If we allow both syntaxes, which one should the formatter use?

I'd say in every case, I am simply a proponent of braces.

As for a concrete example, I think it's easier to spot quickly if's condition if there are braces, compare:
image

and:
image

@mhagmajer
Copy link
Contributor Author

Ok, let's leave it open to gather more opinions. For one, I remember that Douglas Crockford advocated for no braces in if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AskScript ./src/askscript/** discussion A discussion is taking place, please don't work on it yet enhancement New feature or request question Further information is requested type:syntax related to syntax or syntax sugar
Projects
None yet
Development

No branches or pull requests

2 participants