Scala tuples and method call ! help :(

27 views
Skip to first unread message

Edmondo Porcu

unread,
Oct 4, 2011, 5:00:22 AM10/4/11
to scala-user
Dear all,
I am encountering a tedious problem in Scala.

I am calling a third party library which receives as a parameter a java object.

This object however has to have certain characteristics in order for the method to succeed, as you do for example in Hibernate, where you can call session.persist() on every java.lang.Object but that will fail unless the object is annotated for example with @Entity.

My use case is the same, and I need to call a third party java library like that.

gigaSpace.write(curve, Lease.FOREVER,UpdateModifiers.UPDATE_OR_WRITE |UpdateModifiers.NO_RETURN_VALUE);

However, here i want to call gigaSpace.write(object, long, int) , while scala convert automatically that to a tuple, and calls

gigaspaces.write (Tuple3(object,long,int)) and this fails.

How can I avoid my parameters to be converted into a tuple ?

Thank you for your precious help

Best Regards


Edmondo


Edmondo Porcu

unread,
Oct 4, 2011, 5:10:53 AM10/4/11
to scala-user
It appears to be a known problem, any suggested workaround?

http://scala-programming-language.1934581.n4.nabble.com/scalac-mind-your-own-tuple-business-td2285496.html

Best regards

Daniel Sobral

unread,
Oct 4, 2011, 9:55:40 AM10/4/11
to Edmondo Porcu, scala-user
Is Lease.FOREVER of type Long? If it isn't, you can write Lease.FOREVER : Long.

Scala is going for a tuple3 because the types you passed do not match
the types expected by write, _and_ there's a write(Object obj)
overload.

--
Daniel C. Sobral

I travel to the future all the time.

Edmondo Porcu

unread,
Oct 4, 2011, 10:23:48 AM10/4/11
to Daniel Sobral, scala-user
That's right, there was a long-int misunderstanding which mislead the compiler . my fault
Thanks

2011/10/4 Daniel Sobral <dcso...@gmail.com>

Daniel Sobral

unread,
Oct 4, 2011, 10:30:04 AM10/4/11
to Edmondo Porcu, scala-user
On Tue, Oct 4, 2011 at 11:23, Edmondo Porcu <edmond...@gmail.com> wrote:
> That's right, there was a long-int misunderstanding which mislead the
> compiler . my fault

Don't take all blame upon you. The compiler definitely did something
very unexpected instead of producing a compilation error (or just type
widening). With so many places where I'd like auto-tupling or
auto-detupling, it seems the only place it works is the one I don't
like it in.

Ismael Juma

unread,
Oct 4, 2011, 1:33:18 PM10/4/11
to Daniel Sobral, Edmondo Porcu, scala-user
On Tue, Oct 4, 2011 at 3:30 PM, Daniel Sobral <dcso...@gmail.com> wrote:
> Don't take all blame upon you. The compiler definitely did something
> very unexpected instead of producing a compilation error (or just type
> widening). With so many places where I'd like auto-tupling or
> auto-detupling, it seems the only place it works is the one I don't
> like it in.

Yes, I wish it wasn't there at all, personally.

Best,
Ismael

Reply all
Reply to author
Forward
0 new messages