bugGNU Octave - Bugs: bug #51659, Calling 'methods' on self causes...

 
 

bug #51659: Calling 'methods' on self causes syntax error

Submitted by:  Piotr Held <jsoh425>
Submitted on:  Fri 04 Aug 2017 05:57:30 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: NoneAssigned to: None
Originator Name: Piotr HeldOpen/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Mon 07 Aug 2017 05:41:01 PM UTC, comment #5:

And also 'methods', 'properties' or 'events' are illegal names for properties or events.

However they are not illegal names for methods (which I guess is so that you could overload what methods() or properties() or events() does?). So you can have:

and you will not get a syntax error. It will only spit out an error when calling the method itself. If the method does actually make sense, calling methods(obj_classname) actually executes the method 'methods' instead of listing all the methods of obj_classname.

Piotr Held <jsoh425>
Mon 07 Aug 2017 05:26:14 PM UTC, comment #4:

I did some investigation into this matter and here are my results:

Using properties(), methods (), events() inside 'properties' tag is illegal:

Using properties(), methods(), events() from 'methods' tag is legal:

Would you like me test more things out?

Piotr Held <jsoh425>
Sat 05 Aug 2017 09:09:27 PM UTC, comment #3:

I just wanted to understand whether these classdef section tags (methods, events, properties, etc.) are all only keywords inside classdef blocks, and only outside of one of the sections. If that's the way things work, then I think the problem would be relatively easy to fix.

John W. Eaton <jwe>
Project Administrator
Sat 05 Aug 2017 01:23:23 AM UTC, comment #2:

If you want to close the bug, that's fine. I do see your point. If you want the answer to what methods(self) returns, it's what you'd expect: 'foo' and 'm1'.

The way someone was using it was to try to randomly call class methods for test cases. So they had a method (within the test class):

Obviously the code does a little more (it actually shuffles) but that's the just of it.

Do you have some suggestions of how to get around that?

Piotr Held <jsoh425>
Fri 04 Aug 2017 10:50:40 PM UTC, comment #1:

OK, so "methods" should not be considered a keyword inside a methods block. That makes sense. Also, I'm assuming that if there were a functions called properties, events, or enumerations, that they should also not be considered keywords inside functions defined in the classdef methods block? What should happen for something like this:

for example? Or what about something like this:

? Does that make an enumeration with those names, or is it supposed to be an error?

John W. Eaton <jwe>
Project Administrator
Fri 04 Aug 2017 05:57:30 PM UTC, original submission:

When calling methods on self the interpreter calls a syntax error. Which kind of makes sense since it hasn't yet interpreted the whole class yet, however Matlab lets you do this. Let me give an example.

Consider the following code:

When calling 'test test_methods' the interpreter responds with:

I will upload this as a file as well.

Piotr Held <jsoh425>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #41413:  test_methods.m added by jsoh425 (162B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by jsoh425 (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):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 04 Aug 2017 05:57:30 PM UTCjsoh425Attached File-=>Added test_methods.m, #41413

    Back to the top


    Powered by Savane 3.1-cleanup1