Just wondering again.....
BlitzMax Forums/BlitzMax Programming/Just wondering again.....
| ||
Is there a way to concatenate a code to make easier to program or not? Like say glColor3f(blah,blah,blah) and glVertex3f(blah,blah,blah) into one line? What to you suggest? |
| ||
Use semi-colons top separate multiple commands:glColor3f(blah,blah,blah) ; glVertex3f(blah,blah,blah) |
| ||
I'm not sure how putting multiple statements onto one physical line can makes things clearer/easier to program. To me, it's just clutter. |
| ||
Think about it, you only have to write half as many lines of code! |
| ||
Heh ;-) |
| ||
Actually, the semicolon is optionalSuperStrict For Local i:Int = 0 To 10 Print i Next |
| ||
Indeed, that makes the code *much* clearer! |
| ||
It is most of the time, but not always.Print Printwill work and print two empty lines, Print Printwill give you an error. Also note that If-statements are really weird and work differently than anything else in the language. If the "Then" keyword (or the condition, in case you omit the "Then") is followed by a statement on the same line, even with a semicolon inbetween, then it is interpreted as a single-line If. And a single-line If can not be terminated by anything other than a line break - anything that follows on the same line is considered part of the Then-"block". Same goes for the Else-"block". In other words, you cannot do this If True Then; Print "yes"; End Ifand if you do this If c Then Print "yes" Else Print "no"; Print "!"then you'll only get the exclamation mark if c was false. Possible errors aside, putting multiple statements on the same will not usually make your code more clear or readable. Sometimes it does, but these cases (no pun intended) are exceptions; most of the time it'll rather do the opposite. |
| ||
Yeah, I think semicolons should've been mandatory as it can create ambiguities without them. Notice how the single line version of the code below behaves differently than the three lines. |
| ||
That ambiguity is what my logical mind likes most about BlitzMax but I am surprised Strict allows unsemicoloned rambling. |
| ||
Thanks for the quick replies folks! I will remember that always. |