If Type – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search

The article states that the so-called if type is a "helper type". I need a stricter definition of both the "if type" and the concept of "helper type" in general. To help you understand what I'm asking, look at the following:

if ( expression )

As you can see, that is an incomplete if statement. Is the term "if type" meant to refer to the part of an if statement consisting of the reserved word if followed by a boolean expression enclosed in parentheses, as exemplified above? If not, clarify in good, unambiguous english. Killswitch 02:01, 24 March 2007 (CET)


In the BI comref that I have the If Type is defined exactly the same way as the Wiki defines it.
If Type to my way of seeing it is perfectly understandable:
if exitWith code
The if in the syntax definition represents the fact that a conditional is the first parameter.
if is the condition, which can be the condition you write that determines when to exit, in this example.
if: If Type ... in the parameter section says what sort of conditional statement it is.
I agree that the If Type could probably do with a better definition, but the present definition does point to :the if and then commands to aid in determining what type of condition to use.
Planck 12:55, 24 March 2007 (CET)

The if type is quite understandable by both you and I since we're used to programming and scripting. Getting back to the actual question, the term is indeed in need of a better definition. The reason for that is how it's used on the reference pages where it occurs (then,exitWith). It is potentially confusing to newcomers to use the reserved word "if" to represent an "if type condition". The reserved word if and an if type condition are different things. A similar confusing use of reserved words is seen on the then page, where the reserved word else is used to represent the Code or Array that ends an if..then construct.
A better way of describing the syntax can be seen on the for_do page, where the part that comes before the word do is forCommand, referring to a For_Type. In the end, I'm looking for two things:
  • A clear definition of the term if type.
  • Doing away with the misuse of reserved words in presenting the syntax of else and exitWith.
Perhaps we can solve the first one right here? The terms if type and if type condition might be equivalent and refer to a language construct of the following form:
IfTypeCondition:
if ( expression )
If that can serve as a definition of the term if type, the article can be improved. On the other hand, on the Talk:Control_Structures page, Suma states that 'there are actually no "Control Structures" in this scripting language, only expressions.' Would that suggest that if type is a term used to describe the result of the evaulation of an "if-expression", not the syntactic form of the "if type condition" as above?
Killswitch 16:28, 24 March 2007 (CET)
For a scripting beginner it couldn't matter less what name or description is given to a command like "if".
What they want and need are reproducible examples to play and tinker with.
Some Computer Science student may find one or the other definition suspect, but if he can't figure out by himself how those commands work, then he may have picked the wrong field... --Kronzky 16:39, 24 March 2007 (CET)


I suppose it is possible that we could copy the forCommand term and use ifCommand in the exitWith scripting command.
This would remove the use of the reserved command word from the syntax definition.
Other reserved words could also be 'edited' so as not to lose the meaning as well.
I edited exitWith again, we can see how it goes, it can always be altered again if needed
Planck 16:51, 24 March 2007 (CET)
Exactly. if command returns a value of "if type", which is usable only as an argument for the left operand of then command. This "value" holds the condition for the is as well. If you want, you can create a constructs like this: ifHelper = if (condition) ifHelper then someCode. I doubt there is a lot of practical use to this, but some may be interested to know it. --Suma 12:49, 22 June 2007 (CEST)