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

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

[Octave-bug-tracker] [bug #50367] Default constructor for objects in arr


From: Ernst Reissner
Subject: [Octave-bug-tracker] [bug #50367] Default constructor for objects in array
Date: Tue, 21 Feb 2017 07:59:40 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0

URL:
  <http://savannah.gnu.org/bugs/?50367>

                 Summary: Default constructor for objects in array 
                 Project: GNU Octave
            Submitted by: ernstreissner
            Submitted on: Tue 21 Feb 2017 12:59:39 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: Ernst Reissner
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.0
        Operating System: Any

    _______________________________________________________

Details:

According to 

https://de.mathworks.com/help/matlab/matlab_oop/initialize-object-arrays.html

if matlab is called with 
a(7) = SimpleValue(7),
SimpleValue a class constructor, 
then for initializing a(1), ...a(6), 
the default constructor is invoked as SimpleValue(). 

I tried this with a very simple class 
defined in folder @xxx 
with the following constructor: 


function obj = xxx(in)
  if nargin == 0 
    printf("xxx: empty arguments");
    obj.str = "no init";
  else
    printf("xxx: argument %d ", in);
    obj.str = in;
  end
  class(obj, "xxx");
end % function


When assigning 
a(3)=xxx(3), 
then this constructor is invoked only once. 
If I try a(3), then str is initialized, 
whereas if I try a(2), it is not initialized. 


This seems a bug. 
In my case, I implement an arithmetics in java 
which shall behave here as double, 
i.e. the default constructor without arguments 
shall return an object with 0 value, 
but it returns an uninitialized object. 
        





    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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