Mo'Minis

About Mo'Minis Studio Download Get2Mobile Tutorials Sample Games Graphics Library Distribution
Welcome, Guest. Please login or register. September 09, 2010, 08:18:35 pm *

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: exit event command  (Read 496 times)
bojan
Newbie
*
Posts: 38


View Profile WWW
« on: April 20, 2010, 11:14:07 am »

I think it would be a good idea to add the exit event (= java's return) command in the next version of the studio.
Logged
tzachh
Administrator
Full Member
*****
Posts: 134



View Profile
« Reply #1 on: April 20, 2010, 06:30:41 pm »

Hi Bojan,

Can you give a bit more details?
I'm not really sure I understand what is the exact feature you would like to see
Logged

Tzach Hadar
Mo'Minis
bojan
Newbie
*
Posts: 38


View Profile WWW
« Reply #2 on: April 20, 2010, 08:05:54 pm »

Hi Tzach,

I'm talking about a command to immediately exit the event. Sometimes when an event has a lot of commands it would be convenient to be able to exit it after some condition.

You know, like the "return" can be used to quickly exit the function in C. This way the code can become clearer with fewer if-else structures and less indentations.

For example, try to write the following without using quick exits. It soon becomes complex (and repetitive!) structure quite hard to grasp.

Code:
void foo() {
  if( condition_1 ) {
    do_something_1 ;
    if( condition_2 ) {
      do_something_2 ;
      return ;
    }
  }
  if( condition_3 ) {
    do_something_3 ;
    if( condition_4 ) {
      do_something_4 ;
      return ;
    }
  }
  do_something_5 ;
}

Ok, it can be rewritten relatively straight forward with an additional variable and couple of more ifs. I do it that way at the moment, but it is slightly slower and not so elegant.


« Last Edit: April 21, 2010, 09:24:59 am by bojan » Logged
tzachh
Administrator
Full Member
*****
Posts: 134



View Profile
« Reply #3 on: April 21, 2010, 01:36:48 pm »

Ah, I understand

This is a great idea and I will make sure it will make it into our next release.

Thanks for the feedback
Logged

Tzach Hadar
Mo'Minis
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!