#1208 Problem with super~init statement

None
invalid
nobody
None
none
5
2013-11-19
2013-11-19
David Ashley
No

To show the problem we need tp define two classes.

::class orxvirtDomain public
::METHOD init EXTERNAL "LIBRARY orxvirt orxvirtDomainNew"

::CLASS bldmachine subclass orxvirtDomain
::METHOD init
use strict arg myarg
super~init(myarg)
return

Now the problem. When the statement super~init(myarg) is called a runtime error is generated any time an argument is passed to the super method. The error message claims that the super class init method only supports zero arguments.

This is a completely bad assumption on the part of the interpreter. The only way for it to tell what is supported is to actually call the external method.

You can work around this problem by creating a duplicate super class method with a different name and calling it instead. So we know this is a special problem that applies to an init method only.

Discussion

  • Rick McGuire
    Rick McGuire
    2013-11-19

    This is working correctly. Because your superclass method did not override the init method, the one getting called is the init method for the Object class, which does not take any arguments. For forwarding init methods, it is the responsibility of the overriding class to meet the requirements of the superclass init method. Since your superclass did not have any requirements other than that of the object class, passing an argument is an error.

     
  • David Ashley
    David Ashley
    2013-11-19

    Maybe I am dense. How is the definition of the init method in the orxvirtDomain class not an override for the default init method? If I do an domain-.orxvirtDomain~new(myarg) it works perfectly. So obviously the new definition is overriding the default definition of init for that class.

    Why can the the bldmachine init method not call the init method I have defined for the super class?

     
  • Rick McGuire
    Rick McGuire
    2013-11-19

    Ah, I see the problem now. You are not invoking the super class INIT method correctly. You need to use "self~init:super(myarg)", not "super~init(myarg)". Your version is invoking the init method of the superclass object, not the instance method for the object.

     
  • Rick McGuire
    Rick McGuire
    2013-11-19

    Ah, sorry, I missed that you overrode init with a native method. What is
    the method definition for the native code?

    On Tue, Nov 19, 2013 at 11:18 AM, David Ashley wdashley@users.sf.netwrote:

    Maybe I am dense. How is the definition of the init method in the
    orxvirtDomain class not an override for the default init method? If I do an
    domain-.orxvirtDomain~new(myarg) it works perfectly. So obviously the new
    definition is overriding the default definition of init for that class.

    Why can the the bldmachine init method not call the init method I have
    defined for the super class?


    [bugs:#1208] Problem with super~init statement

    Status: invalid
    Created: Tue Nov 19, 2013 03:50 PM UTC by David Ashley
    Last Updated: Tue Nov 19, 2013 03:59 PM UTC
    Owner: nobody

    To show the problem we need tp define two classes.

    ::class orxvirtDomain public
    ::METHOD init EXTERNAL "LIBRARY orxvirt orxvirtDomainNew"

    ::CLASS bldmachine subclass orxvirtDomain
    ::METHOD init
    use strict arg myarg
    super~init(myarg)
    return

    Now the problem. When the statement super~init(myarg) is called a runtime
    error is generated any time an argument is passed to the super method. The
    error message claims that the super class init method only supports zero
    arguments.

    This is a completely bad assumption on the part of the interpreter. The
    only way for it to tell what is supported is to actually call the external
    method.

    You can work around this problem by creating a duplicate super class
    method with a different name and calling it instead. So we know this is a
    special problem that applies to an init method only.


    Sent from sourceforge.net because you indicated interest in <
    https://sourceforge.net/p/oorexx/bugs/1208/>

    To unsubscribe from further messages, please visit <
    https://sourceforge.net/auth/subscriptions/>

     


Anonymous


Cancel   Add attachments