One reason I was thinking of the array style return, is that means we're not
actually replacing javas "single return type" idiom, we're just changing the
type system slightly to allow us syntactic sugar around that single return
value (I'm thinking this would easier than the alternatives, maybe).
What we really want is something like .NETs new anonymous type, which make
LINQ possible:
var productsAnonymous =
from p in products2
select new { p.Name, p.LaunchDate, p.Price };
productsAnonymous contains instances of an anonymous type, with 3 fields
based off the names of the parameters passed into the constructor (my
understanding anyway).
You can read more about them at
http://www.developer.com/net/csharp/article.php/3589916
...and then Buffy staked Edward. The End.
On Mon, Feb 9, 2009 at 3:52 PM, Jason Waring <[email protected]>wrote:
>
> Hi Mark,
>
> Smells similar to how Matlab passes multiple return arguments. The []
> give the feeling that it is an array, which I like, but I'm not too
> keen on accessing the elements by index. Following is an alternate
> suggestion for how to use the return arguments:
>
> [Integer foo, String bar] = doSomething();
>
> Better yet, if we could infer types then:
>
> var [foo, bar] = doSomething();
>
> also, one could ignore return arguments if not required. For example:
>
> [null, String bar] = doSomething();
> or [, String bar] = doSomething();
>
> I think it's important to package the return arguments, for clarity
> sake. As such, I would be uncomfortable with:
>
> Integer foo, String bar = doSomething();
>
> Cheers,
> Jason
>
> On Feb 9, 3:55 am, Mark Derricutt <[email protected]> wrote:
> > We have Tuple2, Tuple3, Tuple4 in our utils package, rather handy. Wish
> > this was avaialable directly in the language, probably as form of
> > generic/typed "array", maybe something like:
> >
> > public [Integer,String] doSomething() {
> > return new [Integer,String] {5, "Hello"};
> >
> > }
> >
> > ...
> > Integer foo = doSomething()[0];
> >
> > This reuses the style of an array, but specifying a type signature for
> each
> > element. Anyone know if this would be a viable suggestion?
> >
> > ...and then Buffy staked Edward. The End.
> >
> > On Mon, Feb 9, 2009 at 2:12 AM, [email protected] <
> >
> > [email protected]> wrote:
> >
> > > This is the first time I've felt the need to change the language. I
> > > guess everybody else here wants other changes. I've got this class in
> > > every project I've worked on for the last 2 years. Anybody has a
> > > better one?
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---