[Scilab-users] a{i, j} specific extraction syntax with {} should not be introduced

Samuel Gougeon sgougeon at free.fr
Wed Feb 17 18:22:11 CET 2016


Hello,

Scilab 6.0 is being to introduce a very specific extraction syntax for 
cells.
Is it really worthwhile to do so, when everywhere else Scilab 6.0 tries 
to remove features that are too specific, and works to improve consistency?

When we use a list -- that is the simplest heterogeneous container -- 
and address a component of it,
we do it with (). We do not need specific extractors like [] or {}.
Moreover, this does not return a list with a single component, but the 
component itself, unwrapped from its container:
L = list(%pi, %i, %t, "abcd")
L(2)  // => returns %i, not list(%i)
-->L(2)
  ans  =
     i
-->typeof(L(2))
  ans  =
  constant

But the syntax that is being introduced for cells with 6.0.0 is not 
consistent with that:
C = {%pi %i ; %t "abcd"}
C(3) // returns a cell instead of directly the component %t
typeof(C(3))

// A specific addressing is introduced /just to strip off the cell 
container //OR convert it to a list/():
C{3}    // returns %i  (...not list(%i))
C{1,:}  // returns list(%pi, %i)

--> C = {%pi %i ; %t "abcd"}
  C  =
   [1x1 constant]  [1x1 constant]
   [1x1 boolean ]  [1x1 string  ]

--> C(3)
  ans  =
   [1x1 constant]

--> typeof(C(3))
  ans  =
  ce

--> C{3}
  ans  =
   i

*After C(3), who will need a cell with a single component, instead of 
the component itself?*
As, again, who after L = list(%pi, %i, %t, "abcd"), L(2) would expect 
list(%i) instead of %i ? This has never been reported as a wish.

When several components are extracted, {} returns a list and therefore 
looses the sizes of the extraction. This is a poor result.
Do we really need to introduce just {} to get it?
To get the same when needed, why not "simply" implementing a similar 
behavior of the ":" linearized selector as for lists with *C(:)*?
Or more simply, a cell2list() function could be applied to C(i:j,m:n)

**Conclusion: {} specific extract**ors* *degenerate index addressing, 
are unhandy and inconsistent with extraction from a list when only one 
component is extracted, and have a poor result when several components 
are extracted. As extractors, they should be removed from Scilab 6.0 and 
kept only as cells constructors**.

**Hoping to read your own thoughts about that,

Best regards
Samuel Gougeon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160217/bacc6438/attachment.htm>


More information about the users mailing list