Thierry wrote:
> I would like to run a class method on a class where the class name is known at
> runtime.
> 
> I want in fact export the schema of a class giving his name in argument.
> Something like that :
> 
> Class utility
> {
>    Classmethod Export (cl as %String)
>   {
>    write "header"
>    Do ##class(???cl???).XmlSchema
>    write "footer"
>    }
> }
> 
> And I call it with that :
> Set cl =Do ##class("Myclass").XmlSchema

This last line is a bit of a surprise...
This suggests that the class name is known at compile time.
I expected to see Do ##class(utility).Export(Myclass).

> I don't want to create that function for all classes I want to print (or
> inherit)

I think inheritance is a good solution.
Each class that can be exported needs to inherit utility.
What is wrong with inheriting utility?

Asking class X to operate on class Y violates a primary principle of objects - which 
is that classes have to contain their own methods.

Is XmlSchema privileged to give out private properties of any class?
I imagine that you can do what it is that you want to do.
But I think a class should export itself.

Reply via email to