[Suggestion] Returning stops function

  • In all programming languages to my knowledge, a return statement stops the function and returns the value to the caller.

    In Construct 2, setting a return value does not stop the function. If this was intended behavior, arguing that it makes more sense to beginners, then offer an option in an action like "Stop Function" or something.

    I feel like I have to vouch for all programming languages trying to explain why this is beneficial. For brevity, it allows for [at times far] more optimized code and it prevents tricky logic situations that would otherwise muddle code with needless variables and events.

  • I agree with this.

    @Ashley

  • Just for reference, there are actually quite a few programming languages which allow multiple return points.

    Different languages have different idioms, and it really depends on the language and programmers involved whether or not multiple return points are considered a good idea.

  • jbadams I've never encountered a language that continued executing statements beyond a return statement. Can you provide an example?

  • Trevor10 jbadams

    I think jbadams is just misunderstanding the OP.

    Yes, every programming language (to my knowledge) allows multiple "return points", heck there wouldn't be much of a reason for one to execute "early" if that weren't the case.

    However, no programming language continues executing statements within a function past the return statement (but Construct 2 does, *ahem...).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Pascal has no return. It becomes an issue of design if you don't have a return statement. Though a return would be handy.

  • CannedEssence:

    Ah yes, I see what you mean now! Hadn't actually tried to use multiple returns in Construct 2 (I consider it a bit messy in the majority of cases) and realised that execution continues after a return.

    Plenty of programming languages allow you to have multiple return points from functions, but you're correct that it would be extremely unusual -- i.e. I can't think of any examples -- where this doesn't also jump back out of the function.

    Apologies for the misunderstanding! <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)