Question

Community home and general chat.
Post Reply
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Question

Post 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?
User avatar
esa94
Guru
Posts: 1855
Joined: Tue Sep 04, 2007 5:35 pm

Re: Question

Post 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.
koodaaja
Moderator
Moderator
Posts: 1583
Joined: Mon Aug 27, 2007 11:24 pm
Location: Otaniemi - Mikkeli -pendelöinti

Re: Question

Post 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.
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Re: Question

Post 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 !
User avatar
Zero
Lead Developer
Lead Developer
Posts: 727
Joined: Sun Aug 26, 2007 2:30 pm
Location: Helsinki, Finland
Contact:

Re: Question

Post 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.
CoolBasic henkilökuntaa
Johtava Suunnittelija
CoolBasic V3, CoolBasic Classic

http://www.coolbasic.com/blog
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Re: Question

Post 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
Post Reply