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

About: "if","else","for","while","switch" etc... #60

Open
X64E opened this issue Nov 29, 2021 · 4 comments
Open

About: "if","else","for","while","switch" etc... #60

X64E opened this issue Nov 29, 2021 · 4 comments
Labels
bug good first issue Good issue for first-time contributors.

Comments

@X64E
Copy link
Contributor

X64E commented Nov 29, 2021

Why operators:
if, else, for, while, switch
calls as structure?

"<code><a cbot|if>if</a> </code>Choice structure\n"
"<code><a cbot|if>else</a> </code>Alternative choice structure\n"
"<code><a cbot|switch>switch</a> </code>Multiple choice structure\n"
"<code><a cbot|switch>case</a> </code>One choice\n"
"<code><a cbot|switch>default</a> </code>Default choice\n"
"<code><a cbot|for>for</a> </code>Loop structure\n"
"<code><a cbot|while>while</a> </code>Control structure\n"
"<code><a cbot|do>do</a> </code>Control structure\n"

And i thing "if" is compare operator. Choiсe operator is "switch"

@MrSimbax MrSimbax added the bug label Nov 29, 2021
@X64E X64E changed the title About if else for while switch etc... About: "if","else","for","while","switch" etc... Nov 30, 2021
@MrSimbax MrSimbax added the good first issue Good issue for first-time contributors. label Dec 4, 2021
@MrSimbax
Copy link
Contributor

MrSimbax commented Dec 4, 2021

Yeah, "structure" seems like a weird word to use here.

  • if is a conditional statement
  • else is a part of the if statement, maybe merge them in one line? if-else
  • switch is a switch statement (duh!), which doesn't tell much. Maybe "multiway branch"?
  • case merge with switch: switch-case
  • default I guess it also needs to be merged with switch: switch-case-default. They all link to the same page anyway.
  • for, while and do are all loop statements. Do not merge them together, just repeat the "loop statement" description.

And i thing "if" is compare operator. Choiсe operator is "switch"

These are not operators (like +, *, ++, or ?:), they are statements. In some languages, they may also be expressions (they return a value, f.e. Java switch expression), but in CBOT they are just statements.

@X64E
Copy link
Contributor Author

X64E commented Dec 4, 2021

I dont know why, but in any Russian sources "statement" is translated as "оператор" = "operator". May be this is translation error. https://docs.microsoft.com/ru-ru/cpp/cpp/if-else-statement-cpp?view=msvc-170 However, it does not matter.

About combining keywords into one line, I think it's not worth to doing this. For students, better if they should be visible all in one list.

What if we use "keyword" word?

For example:

  Main constructions in the CBOT language: (header)

  if         Keyword for conditional statement
  else       Keyword for else conditional statement
  switch     Keyword for multiple choice statement
  ...
  for        Keyword for loop statement
  ...
  break      Keyword for exit from loop or switch case
  continue   Keyword for run new iteration of loop
  return     Keyword for exit from a function
  sizeof     Keyword for get size of an array

"Main constructions" i.e. - branching (if,switch) and cycles(for,while,do-while,repeat).

@MrSimbax
Copy link
Contributor

MrSimbax commented Dec 4, 2021

I would also like to keep them in separate lines.

"Keyword" seems ok to use here, albeit it is a bit generic. On the other hand, beginning every description with "Keyword for" seems a little silly to me as it doesn't convey any new or useful information. This repetition indicates to me that it could be dropped completely and we should leave only the part after "for".

if         conditional statement
else       alternative conditional statement
switch     multiple choice statement
...
for        loop statement
...
break      exit from a loop or a switch case
continue   run next iteration of a loop unconditionally
return     exit from a function
sizeof     get size of an array

This looks much better IMHO. The goal is to have better one-line descriptions for each keyword and remove the misleading "structure" word.

@X64E
Copy link
Contributor Author

X64E commented Dec 4, 2021

I will clarify. "sizeof" and "new" is really unary operators http://candcplusplus.com/c-operator-precedence-and-associativity as "+","&&",">" etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good issue for first-time contributors.
Projects
None yet
Development

No branches or pull requests

2 participants