Page 1 of 1

Question

Posted: Mon Jan 31, 2011 7:34 pm
by peter
Hi,

recently I have read the last blog entry and I ask me, why they use 'THEN'
for a whole block !
I think, a 'then' should be for a single line only and a block is without 'THEN'.

example:

if a =b THEN b =a :single line'

if a =b :block
a =10
b =20
end if

additionally, some C expressions would be good:
a += 1
b -= 2
c *= 4
d /= 8

What do you think?

Re: Question

Posted: Mon Jan 31, 2011 7:42 pm
by esa94
peter wrote:Hi,

recently I have read the last blog entry and I ask me, why they use 'THEN'
for a whole block !
I think, a 'then' should be for a single line only and a block is without 'THEN'.

example:

if a =b THEN b =a :single line'

if a =b :block
a =10
b =20
end if

additionally, some C expressions would be good:
a += 1
b -= 2
c *= 4
d /= 8

What do you think?
Then is the token that separates the condition and the block. It's a feature seen in many languages that don't require parentheses around the conditional expression.

And I believe those C expressions were already planned for future versions of CoolBasic.

Re: Question

Posted: Mon Jan 31, 2011 7:53 pm
by koodaaja
I don't know if it's a bug or a planned feature, but in CoolBasic Beta #10 it works with and without - having a 'then' is optional with multiline ifs. Having (undocumented) optional features like that might be confusing to the programmers, though.

Re: Question

Posted: Mon Jan 31, 2011 8:05 pm
by peter
thanks esa94,

I know this behaviour of some Baisc dialects.
But I programs in some other Basic dialects, which need not
round brackets and 'THEN' for an 'IF block !

Re: Question

Posted: Wed Feb 02, 2011 9:12 am
by Zero
Usage of the "Then" keyword greatly varies between different BASIC dialects; some compilers consider it optional for an If-block, but require it for a single line statement. Since there are dozens of BASIC languages out there, we have decided to follow the same design as the "most used" BASIC which is Visual Basic. Also, this particular behavior is the same in both VB6 and modern VB.NET.

Re: Question

Posted: Wed Feb 02, 2011 11:59 am
by peter
Thanks Zero for this clarification.
I think that I must say some Basic dialects ,go home!

It's really too much to write in so many program languages.
I love VB, but less VB NET!

Peter