Steve, There's actually a long-standing issue about allowing for better use/declaration of pre-allocated return variables, particularly for arrays. A group of us were discussing this last week and the consensus seemed to be that an "output" keyword should be allowed to many functions where the pre-allocated arrays can be passed. Feel free to check out this issue for more details: https://github.com/JuliaLang/julia/issues/1115
-Jacob On Thu, Jun 12, 2014 at 4:36 PM, <[email protected]> wrote: > And let me actually make a further point in concerning this matter. In > addition to annotation const (inargs), Julia should also have notation for > outargs. See, for example, the variable called 'ret' in Section 1.26.9 of > the documentation, which covers the topic of 'preallocating return > variables.' Since preallocating return variables is important for > performance, and since scientific computing people care about performance, > they will probably use this technique often. By declaring an argument to > be an outarg, a subroutine is promising not to use any of the values that > might be stored in it at the time the routine is invoked. > > > -- Steve Vavasis > > > > > > > On Thursday, June 12, 2014 8:28:18 PM UTC+3, [email protected] wrote: > >> Both C++ and Fortran 90 allow the programmer to annotate >> call-by-reference arguments to a function as to whether the function is >> allowed to change them (this is denoted const & in C++). The compiler >> then enforces the const-ness of the argument. I don't see how to do this >> in Julia. Is it available? If not, is there a reason why it was not >> included? This is a fairly basic tool for self-documenting code and for >> ensuring program correctness. >> >> And a related question: the documentation makes a big deal about "stable >> types" for function return arguments. An obvious question is why the >> language doesn't allow the programmer to declare in the function heading >> what will be the return types of the function, and then have the compiler >> enforce this stability. Is this possible in Julia? If not, is there a >> technical reason for omitting it? >> >> Thanks, >> Steve Vavasis >> >> P.S. I have a few more questions but I'll pause now to wait for answers >> to these questions. I hope they are easy to answer! >> >
