bugGNU Octave - Bugs: bug #53911, default implementation of 'eq' for...

 
 

bug #53911: default implementation of 'eq' for handle classes

Submitted by:  Richard <crobar>
Submitted on:  Tue 15 May 2018 02:13:18 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Need Info Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  Open
Release:  4.4.0 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 15 May 2018 06:18:47 PM UTC, comment #2:

True, but I also need some way of uniquely identifying the instance, like adding a random number property or something like this. I can probably come up with something, but if there's some other method of uniquely identifying objects that would be useful.

The default behaviour of isequal and == for handle classes is mentioned briefly in this doc:

https://uk.mathworks.com/help/matlab/ref/handle.relationaloperators.html

A more comprehensive discussion is here:

https://uk.mathworks.com/help/matlab/matlab_oop/comparing-handle-and-value-classes.html

basically handle class has a default eq operator. == returns true if the instances are the same, isequal returns true if the property values are the same.

For value classes there is not a default eq operator, but isequal will return true if the objects are of the same class and have the same property values.

There does seem to be a default ne operator for handle classes too:

Richard <crobar>
Tue 15 May 2018 05:18:44 PM UTC, comment #1:

Well you can add your own 'eq' overload method to your class to do a value comparison between two instances.

So Matlab has a default 'eq' operation for classdef instances? I'm guessing also a 'ne' operation? What about value classes? What are the default equality semantics for handle or value classes? Are these default operations documented anywhere?

Mike Miller <mtmiller>
Project Administrator
Tue 15 May 2018 02:13:18 PM UTC, original submission:

In matlab you can compare two handle class object to determine if the are actually the same instance, e.g. in Matlab:

In Octave this is not possible:

Is there any workaround to determine if two handle objects are actually the same?

Richard <crobar>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #44161:  compare1.m added by crobar (98B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can 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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Tue 15 May 2018 05:18:44 PM UTC mtmiller CategoryNone => Interpreter
        StatusNone => Need Info
        SummaryComparing handle classes using == fails => default implementation of 'eq' for handle classes
    Tue 15 May 2018 02:13:18 PM UTC crobar Attached File- => Added compare1.m, #44161

    Back to the top


    Powered by Savane 3.3