On Wednesday, 2 December 2015 11:38:50 UTC+10, Tim Holy wrote:
>
> Conversely, there are many people who seem to want Julia to treat scalars 
> and 
> 1-vectors indistinguishably (ala Matlab). 
>
Sure, but it should be one way or the other, not half way between. In 
Matlab, scalars are literally 1-vectors, so everything that works with 
1-vectors works with scalars. In Julia, some things work, and others don't. 
That just results in confusion.

As an example, reshape(1,1) throws an error, and squeeze(1,(1,)) gets stuck 
in an infinite loop. vec(1) throws an error, as does cumsum(1). And of 
course there's the issue with getindex involving colon, arrays or ranges 
for indexing (you'd think that, just as a[[1,1]] gives the value of a[1] 
twice for an array, that it would do the same for a scalar, but it doesn't).

I can understand the desire not to have them be identical (since there are 
cases where a function should do a different thing for a number than it 
does for an array), yet allow partial compatibility... it's just a little 
arbitrary which cases work and which don't. 

Reply via email to