bugGNU Octave - Bugs: bug #51801, OO: constructor without arguments

 
 

bug #51801: OO: constructor without arguments

Submitted by:  None
Submitted on:  Sun 20 Aug 2017 12:03:43 PM UTC  
 
Category: DocumentationSeverity: 2 - Minor
Priority: 5 - NormalItem Group: Documentation
Status: Need InfoAssigned to: None
Originator Name: Originator Email: -unavailable-
Open/Closed: OpenRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 22 Aug 2017 02:30:33 PM UTC, comment #5:

There is another bug: in the new release, the default constructor
without is no longer invoked.
instead it seems as if a void default constructor
merely applying class(...) is invoked.

Ernst Reissner <ernstreissner>
Tue 22 Aug 2017 02:24:41 PM UTC, comment #4:

@mike
you ask what i suggest:
We read in the manual:

We should say why:

Ideally, even when the constructor is called with no arguments
it should return a valid object
because octave invokes the constructor with no arguments
to determine the default value.

https://www.mathworks.com/help/matlab/matlab_oop/class-constructor-methods.html

The default value is used for padding values into an array.
If you write a(5)=1 where a is undefined,
a(1),...,a(4) are padded with the default value which is 0.

Accordingly, if you have a class say pn which allows argument 1
and if you write a(5)=1 where a is undefined,
a(1),...,a(4) are padded with the default value
which is determined invoking pn().

What is strange: in the newest release, octave does no longer invoke pn() 4 times as it used to do.
So i ask myself how it determines the default value.

Is there another bug here???

Ernst Reissner <ernstreissner>
Mon 21 Aug 2017 08:05:53 PM UTC, comment #3:

For example

Mike Miller <mtmiller>
Project Administrator
Mon 21 Aug 2017 08:05:16 PM UTC, comment #2:

Even for a classdef class, a user may choose to not allow construction of an object without any arguments if they want to, there is nothing wrong with that.

For example

Mike Miller <mtmiller>
Project Administrator
Mon 21 Aug 2017 07:59:32 PM UTC, comment #1:

Are you suggesting that the wording should be changed from "it should return a valid object" to "it must return a valid object"?

I disagree with that, however this is only describing the situation for legacy style classes. What we need is a rewrite of the OO section of the manual to cover classdef classes, which do always return a valid object, because it's not even left up to the user to assign a return value.

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 12:03:43 PM UTC, original submission:

In the manual, Section 34.1 we read:

That is too weak.
Say, the class has name pn, then pn() defines the default value.
Default values are known (yet not mentioned in the documentation)
for primitive types:
As a consequence, writing a(3,3)=1 fills up a with zeros:
a =
0 0 0
0 0 0
0 0 1
Along the same lines, pn() is the default value
and so a(3,3)=pn(1)
yields
a =
0 0 0
0 0 0
0 0 1
also, where the 1 is created by pn(1)
and the 0 by pn() (not pn(0))!

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ernstreissner (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 21 Aug 2017 08:05:16 PM UTCmtmillerSeverity3 - Normal=>2 - Minor
      Item GroupNone=>Documentation
      StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1