octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #50359] clearer documentation for difference b


From: Kai Torben Ohlhus
Subject: [Octave-bug-tracker] [bug #50359] clearer documentation for difference between isnull and isempty
Date: Thu, 14 Sep 2017 10:51:30 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36

Follow-up Comment #19, bug #50359 (project octave):

Here is a simple Matlab R2017a demo class:


classdef aclass
  properties
    a
  end
  
  methods
    function obj = subsasgn(obj,s,val)
      disp('----')
      disp(nargin)
      disp(s)
      disp(val)
      disp(isempty(val))
      disp('----')
    end
  end
end


nargin seems to be no Matlab compatible way to figure out if a delete
assignment happened:


clear CLASSES; clear all; clc;

obj = aclass();
obj(:) = 3;
obj(:) = [];
obj(:) = zeros (0,0);
----
     3

    type: '()'
    subs: {':'}

     3

   0

----
----
     3

    type: '()'
    subs: {':'}

   1

----
----
     3

    type: '()'
    subs: {':'}

   1

----


I think Octave's `isnull` provides much more (in the negative sense) than
there is possible with Matlab and can be made an internal function.

When I have an object of a class with array data, a call like


my_class(1:2) = [];


usually forwards the assigned whatsoever (null or zeros(0,0)) to my underlying
data where the delete operation gets detected and applied, as answer to
comment #13 maybe.  Why should I write code like:


function obj = subsasgn(obj,s,val)
  if (isnull (val)) ## User wants to delete
    mydata = [];    ## Forward delete
  endif
endfunction


That is why I asked in comment #14 for a practical example, at least Octave
itself does not have any and I have not seen any code where this might be
important to know?

Coming back to the roots of this report.  isnull is a pure Octave   solution
for user defined classes, not applicable for Java's null.  As long as no
expert tells us, how this can be done in Matlab, we cannot make any progress
here.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50359>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]