is it possible to see what classes are defined in the project before you instantiate them?

I know Introspection can tell me about classes that I’ve already instantiated, but is there a way to see what classes are actually in the program? I suspect the answer is no for many reasons :wink:

What I was thinking of was being able to create a list of available subclasses that I didn’t have to update every time I added one. Something that could get a list of all the subclasses of something and make a menu of them so I could choose to create instances of them via a UI.

I could do this with a pre-compile script I think, something that looked at the code or at the actual files and figured it out and wrote me a resource file, but then I’m not sure how I would instantiate them as my code would have to access them by name after the fact somehow.

I’m really thinking it’s not going to work or not going to be worth the effort of making scripts that alter code, but since it’s an interesting idea I thought I’d ask to see if anyone else has done anything similar.

You’re right
You can’t

well :slight_smile: I COULD if I saved the project as a VCP file an wrote a pre-compilation script that scanned for files of a specific type and then re-generated a source file that created my accessors for them :wink: But not sure if the compiler at that point would know that module had been changed… and it’s totally not worth the effort. just thinking there should be some kind of extrospection for things not yet actually instantiated :wink:

if you never use the class in code it will be stripped
so it may exist in source code but wont exist in the compiled app

at best a module that just does

   dim obj as Object
   if obj isa <name of class here> then
   end if

over and over one for every class
and you could alter that in a precompile script

now the code will exist but introspection has no way to get at it anywayuntil / unless you create an instance

may be something to ask Thomas Tempelmann’s to implement in Arbed ?

adding a module with everything in your source code that you may / may not actually use in your code would just make your app fatter than it might need to be

I don’t write code I’m not going to use :slight_smile:

Compat flags make it entirely possible to do so :stuck_out_tongue:
And there might be good reason - have a method that for desktop does one thing
Same module dropped into a console app there might be a method with the same sig does something else

Right no thats trickier to do with classes but certainly possible
Not really radically different than what I outlined in a prerelease post you can read
https://forum.xojo.com/conversation/post/449253