On Fri, Jan 16, 2009 at 12:34 AM, Reinier Zwitserloot <[email protected]>wrote:

> The use case is writing your own language features.

Well. A rather limited set of language feature, involving continue, break
and return.



> Then 'foreach' is utterly unneccessary. You could just write it as a
> library. Same story for ARM-like proposals (File.doForEachLine),
> functional style collections operations, such as filter, flatten, and
> map, map foreach, a synchronized-like block construct for semaphores
> and locks, and whatever else you can think up.

You don't need long returns for that.

foreach don't need it, becase as the name implies it is for _each_ ...

If you want to exit after a particular condition you can do it like this:
public T findFirst(#(boolean(T)) pred)
{
  if(pred(first))
    return first;
  else
    return rest.findFirst(pred);
}


Anytime you use a
> closure to represent the body of such a 'statement', obviously the
> return, continue, and break statements have to be transparent or it's
> a very leaky abstraction.

That argument might have worked if it was allready true for the existing
java, but it isn't. What does "break" mean  here?

final int myVar;
{
  int blah = 0;
  if(blah == 0)
   break;
  else
   blah = 1;
myVar = blah;
}

Besides, even if we would take a kind of iterative kind of thing like "map"
what could break and continue possibly mean in that context?


> It has nothing to do with tail recursion.

Like my example above, I can only thing of example involving typical
do-something-while-not-hitting-an-exit-condition. Which is a very typical
recursion idiom. Given tail call optimization recursion is just as usefull,
if not more so, than typical java iteration idioms.

I just feel like long returns adds complexity and risks to solve a problem
that possibly is solved better in other ways.

BR,
John

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to