<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hello,<br>
      <br>
      Le 29/03/2010 11:40, Bruno JOFRET a écrit :<br>
    </div>
    <blockquote cite="mid:4BB0758D.9090208@scilab.org" type="cite">Hi,
      <br>
      <br>
      Please find attached SEP #40 talking about Cell Arrays.
      <br>
      This SEP is targeting Scilab 6.0 as we will introduce a new syntax
      for cells.
      <br>
      <br>
      Any feedbacks are welcome.
      <br>
    </blockquote>
    <br>
    6 years after, it is very (very) late to comment or make any
    suggestion. <br>
    Yet, Scilab 6.0 is not yet released, so i hope that this won't be
    too late for the essential: <br>
    Indexation (extraction and insertion) with {} should really not be
    introduced.<br>
    <br>
    This message comes after first comments and rational recently posted
    there:<br>
<a class="moz-txt-link-freetext" href="http://mailinglists.scilab.org/Scilab-users-a-i-j-specific-extraction-syntax-with-should-not-be-introduced-tp4033484.html">http://mailinglists.scilab.org/Scilab-users-a-i-j-specific-extraction-syntax-with-should-not-be-introduced-tp4033484.html</a><br>
    <br>
    As another way to explain why {} extractors and inserters must not
    be introduced, <br>
    we may follow the pages of the current version of the SEP available
    here:<br>
    <a class="moz-txt-link-freetext" href="http://gitweb.scilab.org/?p=scilab.git;a=blob;f=SEP/SEP_040_cell_arrays.odt">http://gitweb.scilab.org/?p=scilab.git;a=blob;f=SEP/SEP_040_cell_arrays.odt</a>
    <br>
    <ul>
      <li>After a cell array <b>c = { %pi %i %t ; %z "abc" list(1,%s)}</b>
        has been (very friendly) built with the new {} heterogeneous
        concatenator:<br>
        <br>
      </li>
      <ul>
        <li>the <b>extraction of the content of any single cell
            component</b> should be direct:</li>
        <ul>
          <li>with Scilab < 6 : c(5).entries  or c(1,3).entries</li>
          <li>with Scilab >=6: c(5) or c(1,3)<br>
            <br>
          </li>
          <li>with Scilab < 6 : c(5)  or c(1,3)</li>
          <li>with Scilab >=6: {c(5)} or {c(1,3)}<br>
            Whenever any wrapped-in-cell answer would be needed, it
            still can be obtain by packaging the answer, instead of
            implementing a "dereferencing" way to address a content
            through a very specific {} extractors and inserters when
            unwrapped values are required.<br>
            <br>
          </li>
        </ul>
        <li>As well, <b>the insertion into a single component must be
            direct, and any type of data should be accepted</b>:</li>
        <ul>
          <li>Scilab < 6: c(5).entries = ["Hi" "Hello"]  or
            c(1,3).entries = ["Hi" "Hello"]  </li>
          <li>Scilab >=6: c(5) = ["Hi" "Hello"]  or c(1,3) = ["Hi"
            "Hello"]  <br>
            So, page 4: <br>
          </li>
          <ul>
            <li>c = cell([4,3,2]); for i = 1:24, c<b>{i}</b> = i, end  <br>
              becomes <br>
            </li>
            <li>c = cell([4,3,2]); for i = 1:24, c<b>(i)</b> = i, end  <br>
              <br>
            </li>
          </ul>
        </ul>
        <li>Is there any reason to not address cells components simply
          as we do for matrix components, directly with (i,j,..)? I do
          not find any.<br>
          The .entries addressing was needed due to the encoding of
          cells as mlists. But what could motivate keeping any
          intermediate level to access to the values of data, for
          extraction as well as for insertion? I do not see a single
          reason.<br>
          As noted here-above, from the fact that the LHS object is a
          cell array, any data type can be accepted and inserted,
          without any prior packaging of the RHS as a cell array. The
          wrapping in cell must be done internally by the insertion
          process.</li>
        <li>Then, Scilab 6: c(5) = {"abcd"}  will insert a true
          elementary cell as the c(1,3) c's component, not the string
          "abcd". This is a straightforward and very clear syntax. What
          is in RHS parameter is just values that are inserted in the
          array, <b>as is</b>.<br>
          <br>
        </li>
      </ul>
      <li><b>The SEP does not present </b><b><u>insertion and
            extraction of multiple components</u> in a once</b>. <br>
        After still <b>c = { %pi %i %t ; %z "abc" list(1,%s)}, </b>the
        current implementation is the following:<br>
        <br>
      </li>
      <ul>
        <li><b>multiple insertion</b>: <font color="#993399"><b>a) of
              corresponding multiple components</b>:</font><br>
        </li>
        <ul>
          <li><tt>c(:,1) = { %e "zz" } <br>
            </tt>assigns %e to c(1,1) and "zz" to c(2,1) <i>in a
              distributive way</i>! <br>
          </li>
          <ol>
            <li>This kind of distributive assignment is a very great new
              feature!!</li>
            <li>The assignment is transparently done using <i>linearized
                indices</i>. unmatching sizes/formats of the recipient
              and of the source is smoothly handled. Here, a row of
              cells feeds a column of cells. This is nice as is! This
              behavior could also be implemented with other types of RHS
              containers, at least for a list. So<br>
              <br>
            </li>
          </ol>
          <li>  <tt>c(:,1) = list(%e, "zz")<br>
            </tt>should do the same. But it does not:<tt><br>
              --> c(:,1) = list(%e, "zz")<br>
              Wrong insertion: A Cell expected: use {...} instead of
              (...).<br>
            </tt>This feature might be implemented later. This is not so
            urgent as removing the {} addressing.<br>
            <br>
            If this feature is implemented, how will it be possible to
            insert a list in a single component?</li>
          <ul>
            <li><tt>c(3) = list(list(%t))</tt> // will do it. Or if the
              size of the list is not 1, even</li>
            <li><tt>c(3) = list(%t, %z)</tt>    // mismatch could be
              handled softly in a comprehensive way<br>
              <br>
            </li>
          </ul>
          <li><tt><tt>c([1 2]) = { %e "zz" } </tt></tt> does the same
            using a vector of linearized indices<tt>. Great!<br>
              <br>
            </tt></li>
        </ul>
        <li><b>multiple insertion</b>: <font color="#993399"><b>b) of a
              single component to be replicated</b>:</font><br>
        </li>
        <ul>
          <li><tt><tt>c([1 4]) = {"abc"}  </tt></tt>inserts the same
            "abc" string at the 1st and 4th positions in c. This is
            great! The only thing is that the syntax should become
            simply<br>
            <tt><tt>c([1 4]) = "abc"<br>
              </tt></tt>In the final implementation that we suggest and
            hope, c([1 4]) = {"abc"} will be as well possible but will
            insert the cell {"abc"} instead of the string "abc" at the
            desired positions.<tt><tt><br>
                <br>
              </tt></tt></li>
        </ul>
        <li><b>multiple extraction:</b></li>
        <ul>
          <li><tt>c(1,:)</tt>   returns<tt> {%pi %i %t}</tt>: this is
            great! By default, this can't be anything else than a cell
            array. <br>
            No <tt>c{1,:} </tt>syntax is required<br>
          </li>
          <li><tt>c(:,3)</tt>   returns <tt>{%t ; list(1,%s)}</tt>:
            still great and expected! <br>
            No <tt>c{3,:}</tt> syntax is required</li>
          <li><tt>c(1:2,[1 3])</tt> returns <tt>{%pi %t ; %z
              list(1,%s)}</tt> as expected. <br>
            No <tt>c{1:2,[1 3]}</tt> syntax is required</li>
          <li>with a linearized index: <tt>c([2 5 3]) </tt>returns  <tt>{%z
              ; %t ; %i}</tt> column cell, as with matrices addressed
            with a linearized index a column is returned: Great! <br>
            No <tt>c{[2 5 3]}</tt> syntax is required<br>
            <br>
          </li>
        </ul>
      </ul>
      <li>Finally, <b>what about conversions between a cell array and a
          list? </b>We think that this kind of conversion between these
        2 types of containers should be available in Scilab.<br>
      </li>
      <ul>
        <li><b>list => cell</b> : <br>
        </li>
        <ul>
          <li>If it becomes possible to feed a cell array (or subarray)
            with a list as discussed above, then this kind of conversion
            won't need anything else. We will just have to do:<br>
            <tt>c = cell(2,3); c(:) = list(%pi, %z, %i, "abc", %t,
              list(1,%s)</tt><tt>) <br>
              <br>
            </tt></li>
          <li>Otherwise: <b>makecell() </b>should be kept and renamed
            <b>list2cell()</b>, instead of being removed. It already
            works as expected : <br>
            L = <tt>list(%pi, %z, %i, "abc", %t, list(1,%s)</tt><tt>);<br>
              --> makecell([2 3], L(:))<br>
               ans  =<br>
                [1x1 constant]  [1x1 polynomial]  [1x1 constant]<br>
                [1x1 string  ]  [1x1 boolean   ]  [    list    ]<br>
              <br>
            </tt></li>
        </ul>
        <li><b>cell => list:</b> <br>
        </li>
        <ul>
          <li>The present special extraction with {:} does it, but this
            syntax must be removed. Keeping it only for that is
            meaningless:<br>
            <tt>--> typeof(c{:})</tt><tt><br>
            </tt><tt> ans  =</tt><tt><br>
            </tt><tt> list</tt><br>
          </li>
          <li>A new <b>cell2list()</b> converter should rather be
            implemented.<br>
          </li>
        </ul>
      </ul>
    </ul>
    <p>Hoping that this will convince you to remove the {} complicated
      addressing and the related data wrapping,<br>
    </p>
    <p>Best regards<br>
      Samuel Gougeon<br>
      <br>
    </p>
  </body>
</html>