Old 01-06-2005, 11:54 PM   #1
johanatan
Human being with feelings
 
Join Date: Jan 2005
Posts: 14
Default Return statement to exit code block early?

Is there a 'return' statement to exit a code block early? I don't see any mention of it in the documentation and I haven't seen it used in any of the examples (though I haven't looked at each one).

Thanks.
johanatan is offline   Reply With Quote
Old 01-07-2005, 10:12 AM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,197
Default

Quote:
Originally Posted by johanatan
Is there a 'return' statement to exit a code block early? I don't see any mention of it in the documentation and I haven't seen it used in any of the examples (though I haven't looked at each one).

Thanks.
Nope, no real plans for one either, but one might be pursuaded...
Justin is online now   Reply With Quote
Old 01-07-2005, 10:53 AM   #3
johanatan
Human being with feelings
 
Join Date: Jan 2005
Posts: 14
Default

Quote:
Originally Posted by Justin
Nope, no real plans for one either, but one might be pursuaded...
Well, I think it would be nice because it would allow for saving a few clock ticks. For example, in my slicer code, you could say in the @block section to exit right away if the size of the block size is greater than the number of samples to drop per slice. This probably won't save too many ticks, but every little bit helps (and there may definitely be other situations where alot of ticks can be saved).

-Jonathan
johanatan is offline   Reply With Quote
Old 01-07-2005, 11:36 AM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,197
Default

Quote:
Originally Posted by johanatan
Well, I think it would be nice because it would allow for saving a few clock ticks. For example, in my slicer code, you could say in the @block section to exit right away if the size of the block size is greater than the number of samples to drop per slice. This probably won't save too many ticks, but every little bit helps (and there may definitely be other situations where alot of ticks can be saved).

-Jonathan
of course doing

x < y ? (


);

would be approximately as fast. and the @block section only runs a few hundred times a second, typically...
Justin is online now   Reply With Quote
Old 01-07-2005, 12:25 PM   #5
johanatan
Human being with feelings
 
Join Date: Jan 2005
Posts: 14
Default

Quote:
Originally Posted by Justin
of course doing

x < y ? (


);

would be approximately as fast. and the @block section only runs a few hundred times a second, typically...

Good point. Except it makes for an extra level of nesting. No biggie though I suppose.

I would like to do:

Code:
x < y ? return;

// other stuff
It would just keep the parenthesis matching a little easier for programmers/maintainers. Even a goto-label system would work, but then you could end up facilitating really intermingled code.
johanatan is offline   Reply With Quote
Old 01-08-2005, 12:22 PM   #6
cryptomail
Human being with feelings
 
cryptomail's Avatar
 
Join Date: Jan 2005
Location: SF BA
Posts: 163
Default goto may or maynot be harmful

Another construct that could help with your early out (and also heavily debated within the annals of computing time ) , is the goto statement

Personally, I don't want to see it in there....but just bringing it up

IE:

loop:
variable ?
goto earlyout;

earlyout:
/* see ya */


Quote:
Originally Posted by johanatan
Good point. Except it makes for an extra level of nesting. No biggie though I suppose.

I would like to do:

Code:
x < y ? return;

// other stuff
It would just keep the parenthesis matching a little easier for programmers/maintainers. Even a goto-label system would work, but then you could end up facilitating really intermingled code.
cryptomail is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.