Thanks for answering!
Interesting comment, I never thought it looks IO specific. I believe it has many interesting usages (please see the example below answering to princec)
Btw. I chose the character :' to reuse the for (Object : Iterable it) syntax and '#' because I' not aware of conflicts and it looks like a macro, which is similar in functionality. However these are details, syntax may change.
I may refer to an example from Neal Gafter's Blog
. It's about closures, but benefit is the same: Early exits
from loops or recursive functions (in my case recursive inline
-methods or those containing loops) without
encoding it into return types or whatever.
thanks for listening
I can see where you got from and it makes sense. Thinking about it though I feel that in a method your working at a more micro level and a keyword wouldn't hurt. but as you said thats quite missing the point to going on about it at this stage.
hmm I relatively new to the closure discussion, I saw some ppl lock horn's and decided not to get involved till the dust settled. (well ok thats only part I simply didn't have time
) So excuse my naiveness, but if you want to shortcircuit the search you basicly have meta data about the return value.... conditions that yo don't want to tie into your method. 'There isn't any' is rewritten as 'after checking all there is no positive match' -> 'searching yields no positive match' The implementation of search should not be altered for reuse, preferably else make it receptable to reuse. (aparandly though a hook)
..I doubt you can see where I'm going so i'll edit it when I'm at work, gotta run to catch the bus now though.
so ok I'm at work.
an early stop can only be applied to actions that have as a result a collection of things or can 'run' (numbers) If you can 'hint' that your only interested in a restrained result then the jvm can probebly be made smart enough to interpret and optimize it. Specifying the constraint is probably even less verbose then describing the logic to enforce it.
does that make any sense at all?
about the other point; it doesn't look too IO specific but all the examples you gave are only applied to IO, yes Gafter's Blog uses it in another context but also applies a different approach. It's dangerous to refer to other sources or leave it to the reader, because it allows for different views, with subtle differences while everyone has the idea that everyone else has the same idea about it. By the time you have to actually specify it on paper(the specification) all hell breaks lose.