Hi, first on point 2)
A) [1 2 3] + 1 (as a scalar) makes mathematically no sense but can be seen as some syntax sugar to avoid having users constantly writing things like: "A+scalar*ones(size(A))" B) [1 2 3] + [4 5] makes no sense and there is no clear way of understanding what the user wanted to do and actually in most cases this means that something went wrong earlier and that the matrices being added do not have the dimension that the user thought that would have at that stage. An error is certainly the right thing to do to prevent the code from throwing an error much later and forcing the user to search backwards. C) [] + 1 = [] makes sense to me as an extension of rule A) D) [2 1 -3] + [] is to my mind as wrong than B) and should not be allowed then on point 3) I agree with Serge: the sooner you get a feedback about an error the better. This even brings me to ask why not throwing a real error instead of falling back to %nan? I think the first thing to consider is that the sign of the step always need to match the sign of the difference end-start. If not that is clearly an error. %inf and %nan are also errors when talking about such ranges. Bringing answer like %nan or [] is such cases usually only make the program blow up some time later and that is not helpful. If someone really wants to make something very special, then he should be forced to specify it in his code, but the default behavior should (to my mind) be as safe, straightforward, and self-explaining as possible. I would however expect [1:0:1] to be [1] since this makes sense and could easily happen when computing bounds like this: "start:stepSize:start+NBsteps*stepSize" when NBsteps is set to 0 (I agree that this is not very elegant but it is very readable for a human being) If we would decide that [1:0:1] = [1] is OK, that would open the question of making a similar exception for %inf:0:%inf and for -%inf:0:-%inf . My opinion is however that with %inf or -%inf that would still be an error. Regards Nicolas On Fri, Oct 2, 2015 at 12:36 AM, Samuel Gougeon <[email protected]> wrote: > Le 01/10/2015 18:37, François Granade a écrit : >> >> .../... >> >> 2. Make operations with the empty matrix more consistent >> ----------- >> >> In particular, change: >> >> 1 + [] >> >> to return [] in 6.0, instead of 1 in 5.5.2; and same for 1 - []. This >> would be more consistent with other operations ( 1*[], 1.^[] ...). >> >> More generally: >> >> A + [] >> >> would return [] for A of any Scilab basic type; same for other binary >> numerical operators. > > . > Here is a debatable question: Are you considering this rule only whether A > is scalar: 1 + [] == [] > or as well whether A is a vector or matrix: [2 1 -3] + [] == [] > ? This discussion started @ http://bugzilla.scilab.org/12661 > It looks to be a hard one. > > > > _______________________________________________ > dev mailing list > [email protected] > http://lists.scilab.org/mailman/listinfo/dev _______________________________________________ dev mailing list [email protected] http://lists.scilab.org/mailman/listinfo/dev
