DID This did work at one time? I THINK SO

I’ve got a deep hierarchy of modules (namespaces) … At the bottom I have a class which has an enum defined on it…

IIRC In the past (and it might have been a long while ago) I believe I was able write code like this:

theClassInstance.EnumProperty = theClassInstance.EnumType.EnumValue

and it compiled…

Autocomplete worked (and still works!!) for writing the code … But the compiler complains the instance does not have such a member…

Did this work at one time? I am pretty sure it did.(Though back then I was not using much name spacing) Should it still be working now?

Without a Using clause (which makes no sense for one line in a method), I now have to write:

theClassInstance.EnumProperty = ModuleA.ModuleB.ModuleC.Classname.EnumType.EnumValue

Which makes reading code a lot harder as the first form above is perfectly clear and unambiguous (as long as EnumTypes, Consts, etc can not have the same name) …

If for some reason that ability was changed (or never was?), is making it work that way something Xojo would consider? The example above shows why it would be a good thing, and particularly so if one uses hierarchical namespaces!

This in one case where Autocomplete IMO gets it right… but in general It has issues with namespaces that makes using nested namespaces a real pain!

-karen

Cou can attach the enum definitions to the first (upper) module. That would allow you to do:

Module1.MyEnumtypes.enumval
You can even then make them global.

I think that this has changes as i’ve noticed this too once before but i’m not sure too long ago.

I am using hierarchical namespaces to:

  1. help organize the navigator so I get lost less

  2. help keep the autocomplete menus short and relevant only to the code at hand- THIS IS A BIGGIE!!! … it helps speed my coding a lot (when autocomplete works (grumble … grumble…)

  3. help encourage me to use encapsulation

I though of doing what you suggest, but it defeats all of those objectives.

-Karen

Then keep using the full namespace path? Outside if your module(s) namespaces you need to use the the full namespacing.

Yes, I think you are right.
I found myself changing such references to class enumerations quite often because the compiler blamed me of trying nasty things.

When Xojo starts to “behave in new and creative ways” then I clear out the cache, quit Xojo, and restart my Mac - and everything is usually back to normal.

System updates and Xojo are the only reasons for restarting my Mac …

1 Like

Unfortunately yes, when it does not make sense to use Using.

-Karen