[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: |
Thu, 2 Mar 2017 10:56:10 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0 |
Follow-up Comment #2, bug #50367 (project octave):
This is definitely not a wish but a real bug.
Matlab documentation clearly says,
that the constructor with no arguments is invoked
to initialize a(1),...a(6),
whereas to initialize a(7) the constructor given explicitly is invoked.
In contrast to this,
octave creates a kind of raw objects
without attributes
but with the correct class assigned.
This is not done via invocation of constructor,
but hardcoded.
The result for me, implementing an arithmetics
with class pn (polymorphic number) is,
that in Matlab I would create the 0 value with pn().
That way, a(1),...,a(6) are initialized implicitly with
the 0 value in pn.
This is to make it compatible with double,
where a(7)=4.3
makes a(1),...,a(6) be initialized with the double value 0.
Currently, octave initializes a(1),...a(6)
with some half finished objects
which carry no value at all, while being of the correct class.
As regards the question, whethe the constructor pn()
shall be invoked for a(1),...,a(n) separately,
or just once and then copied,
this is almost immaterial,
because if pn() has no side effects,
the result is the same.
Note that not the reference is copied, but the object.
It is just a matter of optimization,
that the constructor is invoked once only,
and the rest is just memory copy.
So, if I could vote, I would vote urgently,
to recover severity: it is a bug.
The result for me is,
that I very frequently have to check for the object
with all attributes uninitialized,
which is anoying. !!!!
Thank you for considering. !!!!
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?50367>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Mike Miller, 2017/03/01
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array,
Ernst Reissner <=
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Ernst Reissner, 2017/03/02
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Kai Torben Ohlhus, 2017/03/03
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Mike Miller, 2017/03/03
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Ernst Reissner, 2017/03/07
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Ernst Reissner, 2017/03/08
- [Octave-bug-tracker] [bug #50367] Default constructor for objects in array, Ernst Reissner, 2017/03/29