Yes, this is absolutely the right approach that Julia takes here. I just had not kept in mind that the dimension is a type parameter when considering a reshape! function.
Am Donnerstag, 24. April 2014 14:44:44 UTC+2 schrieb Stefan Karpinski: > > Not being able to change the type of an object is one of the constraints > on totally dynamic behavior that Julia makes to keep everyone – including > but not limited to the compiler – sane. If the type of an object could > change, this would happen all over: > > A = zeros(m,n) > f(A) > # now we have no idea what the type of A is > > > When you don't know the type of something, you can't generate efficient > code to manipulate it, so you're back to running at interpreted > Python/Matlab/R speeds. In systems with lots of built-in functions > (implemented in a low-level language), you could just know which built-in > functions do this sort of thing, but in Julia almost everything is > implemented in Julia, so you don't know this. It's possible to analyze the > definitions of things to try to know from definitions which functions might > change the type of an argument, but in a language with as much open-ended > polymorphism as Julia, that can be surprisingly difficult. >