> Another observation is, that the Octave language has the nice feature to
> make 2 real implementations and 4 convenience m-file wrappers to get all the
> work done. Instead Octave currently provides 6 "real" (more redundant)
> implementations in file-io.cc. Means, if any serious error is detected, the
> code has to be touched more than once! Needless to say, that the source file
> with important code is bloated up to 3k lines of code, so it's harder for
> newcomers to get into it.
True. That's why I suggested it might make sense to turn some of them
into m-file wrappers, just not labeled as deprepcated. In #octave, jwe
made the point that these functions have hardly had any bugs reported at
all and the code, even though it is in C++ routines, is still very small
and easily maintainable. They are mostly wrappers around octave_stream.
[...]
Personally I think we should keep printf forever, there's no reason to
get rid of it, it's a useful convenient wrapper to have, yes even though
fprintf without a file argument is the same exact thing.
Yes, maybe deprecation is no option at all then. But I think we should use the power of Octave, to make the code base as easy as possible, if the m-file does not result in a total performance penalty.
tic; for i = 1:5, printf_m("%s", "hi everyone"); end, disp(toc)
6.3205e-04
tic; for i = 1:5, printf("%s", "hi everyone"); end, disp(toc)
2.1100e-04
tic; for i = 1:20000, printf_m("%s", "hi everyone"); end, disp(toc)
1.5331
tic; for i = 1:20000, printf("%s", "hi everyone"); end, disp(toc)
1.5113
function numbytes = printf_m (varargin)
if (nargin < 1)
print_usage ();
endif
numbytes = fprintf (varargin{:});
endfunction
> @Mike: you mean varargin{:}?
> http://hg.savannah.gnu.org/hgweb/octave/file/96518f623c91/scripts/deprecated/usage.m
> Can you explain, what this does better? I would like to mention this in
> https://www.gnu.org/software/octave/doc/v4.0.1/Variable_002dlength-Argument-Lists.html
> if it is not documented elsewhere.
Yes, varargin is a cell array while varargin{:} expands to a cs-list,
which is what is necessary for the elements of the cell array to be
interpreted as distinct arguments.
args = {"one", "two", "three"};
func (args)
vs
func (args{:})
The first calls func with a single argument which is a cell array, the
second calls func with 3 arguments.
[...]
Thank you for the explanation Mike, as I had to notice, this is already documented in the example -.-
So if there are no objections, or an unmistakably no, I will come up with a reduced version of the cset, only making puts, fputs, printf and scanf (not deprecate) M-files next week.
Kai