This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Isn't a Float* just an Array[Float]?

6 replies
Kenneth McDonald
Joined: 2009-01-11,
User offline. Last seen 42 years 45 weeks ago.

I'm getting the following error message:

/Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
error: type mismatch;
found : Float*
required: Array[Float]
def cash_(numbers:Float*) = NS("cash_", numbers)

This confuses me, because I had thought that a Float* was just an
Array[Float]. Could some kind soul tell me what I've missed?

Thanks,
Newbie Ken

hrj
Joined: 2008-09-23,
User offline. Last seen 4 years 3 weeks ago.
Re: Isn't a Float* just an Array[Float]?

Kenneth McDonald wrote:

> I'm getting the following error message:
>
> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
> error: type mismatch;
> found : Float*
> required: Array[Float]
> def cash_(numbers:Float*) = NS("cash_", numbers)
>
> This confuses me, because I had thought that a Float* was just an
> Array[Float]. Could some kind soul tell me what I've missed?

Float* is a Seq[Float]

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Re: Isn't a Float* just an Array[Float]?

On Mon, Jan 19, 2009 at 10:27 AM, Harshad wrote:
> Kenneth McDonald wrote:
>
>> I'm getting the following error message:
>>
>> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
>> error: type mismatch;
>> found : Float*
>> required: Array[Float]
>> def cash_(numbers:Float*) = NS("cash_", numbers)
>>
>> This confuses me, because I had thought that a Float* was just an
>> Array[Float]. Could some kind soul tell me what I've missed?
>
> Float* is a Seq[Float]
>
Correct. As this causes problems with Java interoperability, we'll
change it to Array[Float] in 2.8.

Cheers

Stepan Koltsov
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Isn't a Float* just an Array[Float]?

On Mon, Jan 19, 2009 at 12:34, martin odersky wrote:
> On Mon, Jan 19, 2009 at 10:27 AM, Harshad wrote:
>>> I'm getting the following error message:
>>>
>>> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
>>> error: type mismatch;
>>> found : Float*
>>> required: Array[Float]
>>> def cash_(numbers:Float*) = NS("cash_", numbers)
>>>
>>> This confuses me, because I had thought that a Float* was just an
>>> Array[Float]. Could some kind soul tell me what I've missed?
>>
>> Float* is a Seq[Float]
>>
> Correct. As this causes problems with Java interoperability, we'll
> change it to Array[Float] in 2.8.

Not sure it is proper, because

val l = List(1)
f(l: _*)

now works much faster, than it will work as you plan in 2.8.

What are the problems with Java interoperability?

BTW, please, send a link to some page will all changes, planned in 2.8?

S.

DRMacIver
Joined: 2008-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Isn't a Float* just an Array[Float]?
On Mon, Jan 19, 2009 at 9:34 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Mon, Jan 19, 2009 at 10:27 AM, Harshad <harshad [dot] rj [at] gmail [dot] com> wrote:
> Kenneth McDonald wrote:
>
>> I'm getting the following error message:
>>
>> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
>> error: type mismatch;
>>   found   : Float*
>>   required: Array[Float]
>>      def cash_(numbers:Float*) = NS("cash_", numbers)
>>
>> This confuses me, because I had thought that a Float* was just an
>> Array[Float]. Could some kind soul tell me what I've missed?
>
> Float* is a Seq[Float]
>
Correct. As this causes problems with Java interoperability, we'll
change it to Array[Float] in 2.8.

That seems highly non-optimal. It changes the runtime characteristics of a lot of code in very undesirable ways (the problem isn't just that it changes them, it's that it makes them worse in many cases where it would be nice to make them worse). Wouldn't it make more sense to add some extra special casing to convert it to an Array[Float] at the boundary?
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Re: Isn't a Float* just an Array[Float]?

On Mon, Jan 19, 2009 at 11:41 AM, Stepan Koltsov
wrote:
> On Mon, Jan 19, 2009 at 12:34, martin odersky wrote:
>> On Mon, Jan 19, 2009 at 10:27 AM, Harshad wrote:
>>>> I'm getting the following error message:
>>>>
>>>> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
>>>> error: type mismatch;
>>>> found : Float*
>>>> required: Array[Float]
>>>> def cash_(numbers:Float*) = NS("cash_", numbers)
>>>>
>>>> This confuses me, because I had thought that a Float* was just an
>>>> Array[Float]. Could some kind soul tell me what I've missed?
>>>
>>> Float* is a Seq[Float]
>>>
>> Correct. As this causes problems with Java interoperability, we'll
>> change it to Array[Float] in 2.8.
>
> Not sure it is proper, because
>
> val l = List(1)
> f(l: _*)
>
> now works much faster, than it will work as you plan in 2.8.
>
> What are the problems with Java interoperability?

If you override or implement a Java varargs method, you must use an
array, because that's what Java uses. We could special case or bridge
it, but I'd have preferred to keep things simpler. But your and
David's arguments are quite valid, so it seems we need to do somethign
specisal for Java.

Cheers

DRMacIver
Joined: 2008-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Isn't a Float* just an Array[Float]?
On Mon, Jan 19, 2009 at 5:22 PM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Mon, Jan 19, 2009 at 11:41 AM, Stepan Koltsov
<stepan [dot] koltsov [at] gmail [dot] com> wrote:
> On Mon, Jan 19, 2009 at 12:34, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
>> On Mon, Jan 19, 2009 at 10:27 AM, Harshad <harshad [dot] rj [at] gmail [dot] com> wrote:
>>>> I'm getting the following error message:
>>>>
>>>> /Users/Ken/NetBeansProjects/ScalaGraph/src/scalagraph/Main.scala:4:
..scala:4:
>>>> error: type mismatch;
>>>>   found   : Float*
>>>>   required: Array[Float]
>>>>      def cash_(numbers:Float*) = NS("cash_", numbers)
>>>>
>>>> This confuses me, because I had thought that a Float* was just an
>>>> Array[Float]. Could some kind soul tell me what I've missed?
>>>
>>> Float* is a Seq[Float]
>>>
>> Correct. As this causes problems with Java interoperability, we'll
>> change it to Array[Float] in 2.8.
>
> Not sure it is proper, because
>
> val l = List(1)
> f(l: _*)
>
> now works much faster, than it will work as you plan in 2.8.
>
> What are the problems with Java interoperability?

If you override or implement a Java varargs method, you must use an
array, because that's what Java uses. We could special case or bridge
it, but I'd have preferred to keep things simpler. But your and
David's arguments are quite valid, so it seems we need to do somethign
specisal for Java.

Thanks Martin. It's appreciated.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland