(Ok, I *promise* I'll go away for a while after this!)

I've added the following three methods to the Class class:
----------------------------------------------------------
    # Invoke a class method by name.
    #
    #   First argument is the name of the method.
    #   Remaining arguments are arguments for that method.
    #
    # Fails if no method exists with that name
    #
    method invoke(mName, args[])
        if hasMethod(mName) then {
            suspend (self.__m[mName]) ! ([self] ||| args)
            }
    end

    # What methods are available in this class (and superclasses)
    #
    method genMethods()
       suspend fieldnames(self.__m)
    end

    # Does this class have a specific method?
    #
    # mName -- method name to check for.
    #
    method hasMethod(mName)
       return mName == genMethods()
    end
----------------------------------------------------------------

The first is the main one - it allows you to invoke any class method
by string form of the method name - akin to string invocation of
procedures.  And yes, the following works:
----------------------------------------------------------------
link "Class"

class D : Class()
end

procedure main()
   every write(D().invoke("invoke","invoke","invoke","genMethods"))
end
----------------------------------------------------------------

-- 
Steve Wampler <[EMAIL PROTECTED]>
National Solar Observatory


-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to