[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Changeset] Re: namelengthmax?
From: |
David Bateman |
Subject: |
[Changeset] Re: namelengthmax? |
Date: |
Sun, 23 Mar 2008 23:35:54 +0100 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080306) |
Bill Denney wrote:
> David Bateman wrote:
>> Since we're picking off the easy functions to implement that are matlab
>> core functions and not implemented in Octave, I looked at namelengthmax.
>> In matlab this is 63 which is basically limited by the string name
>> reserved for the variable name in matlab's "save" file format. However,
>> the same limits don't apply in Octave and the variable name length limit
>> is essentially "2^31-1". However when Octave writes to a mat-file it
>> truncates the variable names to 63 character (or 31 characters for v5
>> files).
>>
>> So if we implement namelengthmax should we return 63, or 2^31-1? Is this
>> function of any use in any case?
>>
> My personal thoughts are that since we go for Matlab compatibility in
> almost all things and since it is not really useful for octave, we
> should have the function and it should have a warning similar to what
> you discuss above and then it should return 63.
Yeah that's what I thought.. See the attached patch..
> Have a good day,
>
> Bill
>
> P.S. You're welcome to implement the hard ones, I was just going for
> the easy ones. :)
Hey the easy ones are faster to implement, and you can't get much easier
than
function n = namelengthmax ()
n = 63;
endfunction
There are still over 400 missing functions, so I'm sure we can't find
some other easy ones :-)
D.
# HG changeset patch
# User David Bateman <address@hidden>
# Date 1206311517 -3600
# Node ID ac4e70a647d1329fe9dadab32a5bc6c6ac8d761d
# Parent 35e6d57df330e64c57c044e6fe22d6c316344751
Add the namelengthmax function
diff --git a/scripts/miscellaneous/Makefile.in
b/scripts/miscellaneous/Makefile.in
--- a/scripts/miscellaneous/Makefile.in
+++ b/scripts/miscellaneous/Makefile.in
@@ -39,7 +39,7 @@ SOURCES = ans.m bincoeff.m bug_report.m
fileattrib.m fileparts.m flops.m fullfile.m getfield.m gunzip.m \
gzip.m inputname.m ismac.m ispc.m isunix.m license.m list_primes.m ls.m \
ls_command.m menu.m mex.m mexext.m mkoctfile.m movefile.m \
- news.m orderfields.m pack.m paren.m parseparams.m \
+ namelengthmax.m news.m orderfields.m pack.m paren.m parseparams.m \
run.m semicolon.m setfield.m single.m substruct.m swapbytes.m tar.m \
tempdir.m tempname.m texas_lotto.m unix.m unpack.m untar.m \
unzip.m ver.m version.m warning_ids.m what.m xor.m zip.m
diff --git a/scripts/miscellaneous/namelengthmax.m
b/scripts/miscellaneous/namelengthmax.m
new file mode 100644
--- /dev/null
+++ b/scripts/miscellaneous/namelengthmax.m
@@ -0,0 +1,39 @@
+## Copyright (C) 2008 David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING. If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} namelengthmax ()
+## Returns the matlab compatible maximum variable name length. Octave is
+## capable of storing strings up to
+## @iftex
+## @tex
+## $2^{31} - 1$
+## @end tex
+## @end iftext
+## @ifnottex
+## @code{2 ^ 31 - 1}
+## @end ifnottex
+## in length. However for matlab compatibility all variable, function
+## and structure field names should be shorter than the length supplied by
+## @code{namelengthmax}. In particular variables stored to a matlab file
+## format will have their names truncated to this length.
+## @end deftypefn
+
+function n = namelengthmax ()
+ n = 63;
+endfunction