They're actually unifying Function arguments and Tuples so you can use
them interchangeably (I believe in 2.8).  In java this looks
ridiculuous, as you don't have scala's style of type-inference.  My
guess would be that if tuple support isn't native to the language
currently, it will be in the future.

Scala sometimes gets the syntactic-sugar wrong where you have to do
things like someFunction((x,y)), but in general it "just works".
It also supports extracting tuples using pattern matching like so:
val (x,y) = someFunction()

which may look a lot uglier in java:

(String x, int y) = someFunction();

but is still rather nice for a "pair" class.

Also, as a Side note, Tony Morris's project "Functional Java" has a
Tuple class hidden in its bowels of Monads and Theory.  It's actually
called a "Product" (the classes are named PN where N is a number from
1-8)
Here's the docs
http://functionaljava.googlecode.com/svn/artifacts/2.17/javadoc/index.html




On Feb 9, 8:48 pm, Michael Neale <[email protected]> wrote:
> Thanks David !
>
> 22... interesting...
> How did they do the syntactic support for ( and ) to mean Tuple? Is it
> special or like anything else, just defs?
>
> On Feb 10, 11:51 am, David Chuhay <[email protected]> wrote:
>
> > Scala has tuple classes up to size 22 included in the base langauge
> > package. The (var1, var2, ...) syntax gets compiled into an
> > instantiation of the properly sized Tuple class.
>
> > Michael Neale wrote:
> > > So how would you do it in scala ;) ?
>
> > > (sorry I always find it crushing how easy everything is in scala, when
> > > I have to look at java).
>
> > > Of course you can just do:
>
> > > def foo() : (String, Int) = ("Hello", 42)
>
> > > never looking into what scala *actually* does with tuples, if its
> > > something nasty or not... (someone else I am sure knows if it is a
> > > good or bad thing).

--~--~---------~--~----~------------~-------~--~----~
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