[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60643] struct disp and display
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #60643] struct disp and display |
Date: |
Wed, 19 May 2021 19:18:05 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?60643>
Summary: struct disp and display
Project: GNU Octave
Submitted by: nrjank
Submitted on: Wed 19 May 2021 07:18:04 PM EDT
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: Nicholas Jankowski
Originator Email:
Open/Closed: Open
Release: 6.2.0
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
Output from Matlab R2021a:
>> abc = struct("foo","def","bar",1)
abc =
struct with fields:
foo: "def"
bar: 1
>> display(abc)
abc =
struct with fields:
foo: "def"
bar: 1
>> disp(abc)
foo: "def"
bar: 1
with Octave 6.2.1 (hg id: 161daebce243)
>> abc = struct("foo","def","bar",1)
abc =
scalar structure containing the fields:
foo = def
bar = 1
>> display(abc)
abc =
scalar structure containing the fields:
foo = def
bar = 1
>> disp(abc)
scalar structure containing the fields:
foo = def
bar = 1
the difference is disp, which still displays the object type and text for
Octave.
This came up when trying to overload display for a matlab-octave compatible
class. here's a simple old class style example:
@MyClass/myClass.m:
function si = MyClass ()
si = struct("foo","def","bar",1);
si = class (si, 'MyClass');
end
with no display overloading:
Matlab:
>> A = MyClass
A =
MyClass object: 1-by-1
>> A
A =
MyClass object: 1-by-1
>> disp(A)
MyClass object: 1-by-1
>> display(A)
A =
MyClass object: 1-by-1
Octave:
>> A = MyClass
A =
<class MyClass>
>> A
A =
<class MyClass>
>> disp(A)
<class MyClass>
>> display(A)
A =
<class MyClass>
adding the following display overloading:
function display (obj)
disp(sprintf('%s object containing the properties:', class(obj)))
disp(struct(obj))
end
Matlab:
>> A = MyClass
MyClass object containing the properties:
foo: "def"
bar: 1
>> A
MyClass object containing the properties:
foo: "def"
bar: 1
>> disp(A)
MyClass object: 1-by-1
>> display(A)
MyClass object containing the properties:
foo: "def"
bar: 1
Octave:
疘>> A = MyClass
MyClass object containing the properties:
scalar structure containing the fields:
foo = def
bar = 1
>> A
MyClass object containing the properties:
scalar structure containing the fields:
foo = def
bar = 1
>> disp(A)
<class MyClass>
>> display(A)
MyClass object containing the properties:
scalar structure containing the fields:
foo = def
bar = 1
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60643>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #60643] struct disp and display,
Nicholas Jankowski <=