octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53524] Java: cannot call method requiring arr


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #53524] Java: cannot call method requiring array argument with single-element-array
Date: Wed, 18 Jul 2018 19:42:44 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Follow-up Comment #2, bug #53524 (project octave):

> I have no idea how Matlab behaves in this regard. 

In Matlab, scalar primitives may be implicitly converted to Java arrays.

For example:


>> java.util.Arrays.toString(42)
ans =
[42.0]


I believe that integer-valued scalar Matlab doubles may also be implicitly
converted to Java int[], short[], byte[], and so on. Here's an example that I
think demonstrates this.


>> java.util.UUID.nameUUIDFromBytes(42)
ans =
3389dae3-61af-39b0-8c9c-8e7057f60cc6
>> java.util.UUID.nameUUIDFromBytes(int8(42))
ans =
3389dae3-61af-39b0-8c9c-8e7057f60cc6


I agree with you that this is unexpected behavior, and the N=1 case should not
differ from the N>1 case.

There is one other concern: if you have an object that defines both
`foo(double x)` and `foo(double x[])` methods, you may need some mechanism to
disambiguate them if scalar doubles can auto-box to Java double[]s.

There's a discontinuity at the N=0 case: in Matlab, [] is implicitly converted
to null, and not a 0-long array. IMHO, this is unfortunate, but Octave will
probably need to do the same if it wants Matlab compatibility.


>> java.util.Arrays.toString([])
ans =
null



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53524>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]