colobot / colobot-data

Data files source for open-source Colobot: Gold Edition project developed by Epsitec and TerranovaTeam

Home Page:http://colobot.info/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

X64E opened this issue · comments

commented

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"

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.

commented

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).

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.

commented

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