[Scilab-Dev] type of structs and cells
Samuel Gougeon
sgougeon at free.fr
Wed Sep 12 21:48:51 CEST 2018
Hello Stéphane,
Le 12/09/2018 à 17:02, Stéphane Mottelet a écrit :
> Hi all,
>
> I hope some of you are still reading this list, which has a very low
> traffic these days... I just discovered, while working on
>
> https://codereview.scilab.org/#/c/20491/
>
> https://codereview.scilab.org/#/c/19114/
>
> that cells have the same type number, although a different type
> string. Hence, when you want to differentiate between structs, cells,
> lists, mlists, tlists, you cannot rely on typeof(),
I guess you meant that we must use the typeof() instead of type().
Anyway,...
> since for mlists and tlists they return the usertype, neither on
> type(), since it does not make the difference between cells and
> structs. I know there exist isstruct() and iscell(), but why do we
> have the same type number ??
I had the same question in mind for 2 years. So thanks for asking it
here explicitly!
Since in Scilab 6 cells and structs are now native types, it could have
been the opportunity and the right moment to ascribe a dedicated type()
number to each of them, out of their historical mlist type number 17.
We may imagine that this conservatism is to avoid back-compatibility issues.
However, when we look for the "*17*" pattern in the whole native *.sci
Scilab files, we get only *85 possibly relevant hits in 58 files* (*.sci
*.sce *.tst *.dia.ref *.c *.cpp *.java *.xml), over thousands of files.
The full list is attached.
This is much fewer than for some other features removed from 5.5 for
6.0. By the way, contrarily to a syntactic change like []+n that can't
be tracked in the code, parsing any external user code for
"*[^.0-9a-zA-Z%_:"'*/+-;]17[^.0-9a-zA-Z%_:"'*/+-;<]*" is very simple, to
get on the spots and update relevant occurrences.
So, to me, ascribing dedicated and separate type() numbers to cells and
structures is still a relevant question, for Scilab 6.1.
Scilab 6 aims to be more consistent. Ascribing new type codes to now
native cells and structures looks possible at low cost.
Best regards
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/dev/attachments/20180912/7a2896b9/attachment.htm>
-------------- next part --------------
Search "[^.0-9a-zA-Z%_:"'*/+-;]17[^.0-9a-zA-Z%_:"'*/+-;<]" (85 hits in 58 files)
\scilab\modules\atoms\macros\atoms_internals\atomsCatTree.sci (2 hits)
Line 35: if type(tree_in_1) <> 17 then
Line 39: if type(tree_in_2) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDepTreeExt.sci (2 hits)
Line 160: if type(tree) == 17 then
Line 175: if type(tree_out)==17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDepTreeFlat.sci (3 hits)
Line 69: if (rhs==3) & (type(tree_in) <> 17) then
Line 169: if type(tree) == 17 then
Line 185: if type(tree_out)==17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONadd.sci (2 hits)
Line 52: if type(tree_in) <> 17 then
Line 64: if type(description) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONaddField.sci (1 hit)
Line 53: if type(tree_in) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONcat.sci (7 hits)
Line 61: if type(tree_in_1) <> 17 then
Line 65: if type(tree_in_2) <> 17 then
Line 156: if type(tree_in_1) <> 17 then
Line 160: if type(tree_in_2) <> 17 then
Line 218: if type(tree_in_1) <> 17 then
Line 222: if type(tree_in_2) <> 17 then
Line 244: if type(package_versions_struct) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONread.sci (1 hit)
Line 79: if type(additional) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONrm.sci (1 hit)
Line 52: if type(tree_in) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsDESCRIPTIONwrite.sci (2 hits)
Line 51: if type(description_in) <> 17 then
Line 81: if type(package_versions_struct) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsReadDesc.sci (1 hit)
Line 38: if rhs==2 & type(description_in)<>17 then
\scilab\modules\atoms\macros\atoms_internals\atomsRmfields.sci (1 hit)
Line 30: if type(struct_in) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsSaveInstalled.sci (1 hit)
Line 29: if type(installed_struct) <> 17 then
\scilab\modules\atoms\macros\atoms_internals\atomsSaveInstalleddeps.sci (1 hit)
Line 48: if type(child_deps) <> 17 then
\scilab\modules\compatibility_functions\macros\mstr2sci.sci (1 hit)
Line 20: if type(x)==17 then
\scilab\modules\core\macros\whos.sci (1 hit)
Line 42: elseif _type == 17 | _type == 16 then
\scilab\modules\core\tests\unit_tests\type.dia.ref (6 hits)
Line 47: // struct <-> 17
Line 48: if type(struct()) <> 17 then bugmes();quit;end
Line 49: // cell <-> 17
Line 50: if type(cell(1,1)) <> 17 then bugmes();quit;end
\scilab\modules\core\tests\unit_tests\type.tst (6 hits)
Line 65: // struct <-> 17
Line 66: if type(struct()) <> 17 then pause,end
Line 68: // cell <-> 17
Line 69: if type(cell(1,1)) <> 17 then pause,end
\scilab\modules\data_structures\macros\lstsize.sci (1 hit)
Line 27: if type(var) <> 15 & type(var) <> 16 & type(var) <> 17 then
\scilab\modules\development_tools\macros\assert\assert_checkequal.sci (2 hits)
Line 73: if ( or(type(computed)==[16 17]) ) then
Line 78: if ( or(type(expected)==[16 17]) ) then
\scilab\modules\development_tools\macros\testexamples.sce (1 hit)
Line 261: case 17 then //mlist
\scilab\modules\elementary_functions\macros\isempty.sci (1 hit)
Line 61: case 17
\scilab\modules\elementary_functions\macros\resize_matrix.sci (1 hit)
Line 92: if ~(or(type(mat)~=[15 16 17]) ..
\scilab\modules\external_objects_java\src\java\org\scilab\modules\external_objects_java\ScilabJavaObject.java (2 hits)
Line 105: unwrappableType.put(short.class, 17);
Line 141: unwrappableType.put(Short.class, 17);
\scilab\modules\graphics\macros\%h_p.sci (1 hit)
Line 1107: elseif or(td==17) then
\scilab\modules\gui\macros\tree_show.sci (3 hits)
Line 28: if type(x)<>16 & type(x)<>17 & type(x)<>15 & type(x)<>128 then
Line 79: if type(x)==17 & v(1)=="st" then
Line 89: if type(o)==16 | type(o)==17 | type(o)==128 then
\scilab\modules\helptools\macros\xmltoformat.sci (8 hits)
Line 1308: if type(desc_in_1) <> 17 then
Line 1312: if type(desc_in_2) <> 17 then
Line 1353: if type(tree) <> 17 then
Line 1498: if type(tree) <> 17 then
Line 1616: if type(tree_in_1) <> 17 then
Line 1620: if type(tree_in_2) <> 17 then
Line 1703: if type(tree) <> 17 then
Line 1839: if type(tree) <> 17 then
\scilab\modules\io\macros\%_sodload.sci (1 hit)
Line 33: if or(type(var) == [15, 16, 17]) then
\scilab\modules\linear_algebra\tests\nonreg_tests\bug_5017.dia.ref (1 hit)
Line 158: if type(A)==16|type(A)==17 then
\scilab\modules\linear_algebra\tests\nonreg_tests\bug_5017.tst (1 hit)
Line 167: if type(A)==16|type(A)==17 then
\scilab\modules\m2sci\help\en_US\m2scideclare.xml (1 hit)
Line 96: <td>Matlab cell (17)</td>
\scilab\modules\m2sci\help\fr_FR\m2scideclare.xml (1 hit)
Line 101: <td>Cell Matlab (17)</td>
\scilab\modules\m2sci\macros\kernel\infer2txt.sci (1 hit)
Line 41: elseif tp==17 then
\scilab\modules\m2sci\macros\kernel\sci_m2scideclare.sci (1 hit)
Line 321: elseif tp==17 then
\scilab\modules\m2sci\macros\sci_files\sci_char.sci (1 hit)
Line 24: elseif A.vtype==16 | A.vtype==17 then
\scilab\modules\overloading\macros\generic_i_h.sci (1 hit)
Line 51: if type(index)==15 & and(type(property)<>[15 16 17]) then
\scilab\modules\overloading\tests\nonreg_tests\bug_7244.dia.ref (1 hit)
Line 21: assert_checkequal(type(foo), 17);
\scilab\modules\overloading\tests\nonreg_tests\bug_7244.tst (1 hit)
Line 22: assert_checkequal(type(foo), 17);
\scilab\modules\scicos\macros\scicos_scicos\setvalue.sci (1 hit)
Line 224: if type(%vv)<>15& type(%vv)<>16& type(%vv)<>17 then %noooo=-%kk,break,end
\scilab\modules\scicos\macros\scicos_utils\find_scicos_version.sci (1 hit)
Line 36: if type(scs_m)==17 || type(scs_m)==128 then
\scilab\modules\scicos\macros\scicos_utils\scicos_getvalue.sci (1 hit)
Line 269: if type(%vv)<>15& type(%vv)<>16& type(%vv)<>17 then %nok=-%kk,break,end
\scilab\modules\scicos\tests\unit_tests\model\Clone_SuperBlock_in_Diagram.dia.ref (32 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\Deep_cloning.dia.ref (63 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\Delete_objects.dia.ref (15 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\Diagram.dia.ref (114 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\Diagram_cloning.dia.ref (16 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\from_mlist.dia.ref (42 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\Insert_in_SuperBlock.dia.ref (16 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\link_preservation.dia.ref (7 hits)
../..
\scilab\modules\scicos\tests\unit_tests\model\SuperBlock.dia.ref (143 hits)
../..
\scilab\modules\scicos_blocks\macros\Sinks\TOWS_c.sci (2 hits)
Line 56: // If varnam already exists, then it must be of type struct (17) with fields "values" and "names".
Line 58: execstr("if type("+varnam+") <> 17 | or(fieldnames("+varnam+") <> [""values""; ""time""]) then" + ...
\scilab\modules\string\macros\prettyprint.sci (1 hit)
Line 195: case 17 then
\scilab\modules\string\macros\sci2exp.sci (3 hits)
Line 103: case 17 then // cells, struct, mlists
Line 737: elseif type(a.userdata) == 17 then
Line 820: elseif type(a.userdata) == 17 then
\scilab\modules\types\src\java\org\scilab\modules\types\ScilabTypeEnum.java (1 hit)
Line 26: sci_mlist(17),
\scilab\modules\xcos\tests\unit_tests\scicos_diagram.dia.ref (1 hit)
Line 11: assert_checktrue(or(type(scs_m) == [17 128]));
\scilab\modules\xcos\tests\unit_tests\scicos_diagram.tst (1 hit)
Line 15: assert_checktrue(or(type(scs_m) == [17 128]));
\scilab\modules\xcos\tests\unit_tests\xcos_simulate.tst (2 hits)
Line 15: assert_checkequal(type(scs_m), 17);
Line 26: assert_checkequal(type(scs_m), 17);
More information about the dev
mailing list