FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

this minid script code do not work?

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
smjk



Joined: 12 Oct 2007
Posts: 5

PostPosted: Sat Oct 20, 2007 7:59 am    Post subject: this minid script code do not work? Reply with quote

Code:

module test;
local ss=0;
local sum=0;
while(ss++<1000000)
   sum+=ss;
   
   



run result:

minid.types.MDCompileException: test.md(3:9): ')' expected; found '++' instead


the code is like c , [while] statement can't continal any expression such as '++' '--' ??
Back to top
View user's profile Send private message MSN Messenger
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Sat Oct 20, 2007 8:44 am    Post subject: Reply with quote

Assignments in MiniD do not have a value like in C or D. ++ and -- are assignments, as they are rewritten as += 1 and -= 1. So no, this code is not legal. You can use a for loop instead:

Code:

module test;
local ss = 0;
local sum = 0;

// Use <= because in "ss++ < 100000" comparison happens after the ++
for(; ss <= 1000000; ss++)
    sum += ss;
Back to top
View user's profile Send private message
the_darkside_986



Joined: 04 Apr 2008
Posts: 10

PostPosted: Tue Apr 22, 2008 7:00 pm    Post subject: Reply with quote

Would it be possible to add to the language a return value for assignment for single assignments only that are nested in parentheses? I guess that would add a bit of complexity to the compiler. Or what about a different operator for assignments that should return a value and assignments that do not (and can be multiple) such as ':=' vs. '=' (the latter returning a value)? I guess that would be adding non-C-ish weirdness to the language but it would be neat to have assignments returning values IMO.
Back to top
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Wed Apr 23, 2008 7:33 am    Post subject: Reply with quote

Assignments returning a value are a possibility, but like you say it'd be restricted to *single* assignments. Personally I think they're awful form and lead to unreadable code (like what the OP posted..) which is why I've disallowed them in the first place. But enough people have moaned about it Rolling Eyes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group