bugGNU Octave - Bugs: bug #51709, evaluating function handle to...

 
 

bug #51709: evaluating function handle to class static methods

Submitter:  Piotr Held <jsoh425>
Submitted:  Wed 09 Aug 2017 08:41:09 PM UTC
   
 
Category:  Interpreter Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Piotr Held Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 25 Mar 2019 06:39:32 PM UTC, comment #10: 

Works great.  Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Sun 24 Mar 2019 11:48:55 PM UTC, comment #9: 

I pushed the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/b033cf021048

Using


fh = @obj.meth


for both static and ordinary methods appears to work for me now.

John W. Eaton <jwe>
Group administrator
Fri 22 Mar 2019 07:45:00 PM UTC, comment #8: 

Rik:  thanks, I'll take a look at fixing and adding a test if there isn't one.

John W. Eaton <jwe>
Group administrator
Fri 22 Mar 2019 06:57:28 PM UTC, comment #7: 

Repeating the tests from the original reporter and from comment #5 shows that one form of creating function handles to static methods now works.  Specifically, deriving the function handle from the class.method.  For example


fn = @myclass.foo;
fn()


The second method, creating an instance of the class and then asking the instance for the static class method, still fails.


obj = myclass;
fn = @obj.foo;
fn()
error: obj.foo: invalid function handle



Rik <rik5>
Group administrator
Thu 21 Mar 2019 07:16:49 PM UTC, comment #6: 

I pushed the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/51414d51a973

Using function handles to refer to classdef static methods appears to work for me now.

However, I noticed a problem with shadowed functions in package directories.  It affects calling functios (classdef static or otherwise) defined in package directories, with or without using handles.  That problem is reported in bug #55975.

John W. Eaton <jwe>
Group administrator
Thu 07 Mar 2019 11:22:37 PM UTC, comment #5: 

On the Octave 6 development branch, lazy function handles can now be created, but the error occurs for this bug when trying to evaluate the function handle now:


>> myclass.foo()
>> myclass.foo
>> fn = @myclass.foo;
>> fn()
error: myclass.foo: no longer valid function handle
>> obj = myclass;
>> fn = @obj.foo;
>> fn()
error: obj.foo: no longer valid function handle


Mike Miller <mtmiller>
Group Member
Mon 31 Dec 2018 04:56:52 PM UTC, comment #4: 

Adding jwe to the CC list.  jwe has some massive changes pending on the development branch for how functions and handles to functions are stored in Octave.  This won't be fixed for version 5.0, but should become possible for 6.0.

Marking this bug as won't fix for 5.0 at https://wiki.octave.org/Bug_Fix_List_-_5.0_Release#Bugs_with_severity_.3E.3D_4.

Rik <rik5>
Group administrator
Thu 22 Nov 2018 06:16:38 PM UTC, comment #3: 

Another ping: any news about a fix for this problem?

Avinoam Kalma <avinoam>
Group Member
Thu 15 Mar 2018 02:37:25 PM UTC, comment #2: 

ping:  any news about a fix for this problem?

Anonymous
Wed 09 Aug 2017 09:56:48 PM UTC, comment #1: 

I know it's similar to my other bugs. I just posted it, because I want to post a fix for this problem in particular in the days to come.

Piotr Held <jsoh425>
Wed 09 Aug 2017 08:41:09 PM UTC, original submission:  

Let's have a class:


classdef myclass
  methods (Static)
    function foo()
      1;
    end
  end
end


Matlab allows for the creation of a handle to foo in two ways:


fcn_handle = @myclass.foo;
obj = myclass;
fcn_handle = @obj.foo;




Piotr Held <jsoh425>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by avinoam (Updated the item)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by amro_octave
  • -email is unavailable- added by jsoh425 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-25 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-03-24 jwe StatusConfirmed Ready For Test
    2019-03-07 mtmiller Severity4 - Important 1 - Wish
        Item GroupMatlab Compatibility Feature Request
        SummaryCreating function handle to static methods evaluating function handle to class static methods
    2018-12-31 rik5 StatusNone Confirmed
        Carbon-Copy- Added jwe
    2018-04-08 avinoam Severity3 - Normal 4 - Important
    2018-03-16 avinoam Carbon-Copy- Added avinoam
    2017-12-07 amro_octave Carbon-Copy- Added amro_octave
    2017-08-14 mtmiller Dependencies- bugs #51746 is dependent

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code