Thread overview
Can I rely on format returned by fullyQualifiedName?
Apr 24, 2021
Jack
Apr 24, 2021
Mike Parker
Apr 25, 2021
Jack
April 24, 2021

Can I rely on this format from fullyQualifiedName? for example, let's say I do:

enum s = fullyQualifiedName!f.split;

where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name and s[2] the functio name? is this standard or can the compile change that? I've tested on dmd, does ldc or gdc do something different?

class A
{
  void f() { }

   void baa()
   {
      enum s = fullyQualifiedName!f.split;
   }
}
April 24, 2021

On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote:

>

Can I rely on this format from fullyQualifiedName? for example, let's say I do:

enum s = fullyQualifiedName!f.split;

where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name and s[2] the functio name? is this standard or can the compile change that? I've tested on dmd, does ldc or gdc do something different?

You can rely on the order, but you cannot expect any of the names to be at a specific index. The FQN includes the symbol's entire hierarchy. So you could have one or more package names in front of the module name. Essentially:

{all.package.names.}moduleName.{struct/class/functionName}.symbolName

April 25, 2021

On Saturday, 24 April 2021 at 04:09:15 UTC, Mike Parker wrote:

>

On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote:

>

Can I rely on this format from fullyQualifiedName? for example, let's say I do:

enum s = fullyQualifiedName!f.split;

where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name and s[2] the functio name? is this standard or can the compile change that? I've tested on dmd, does ldc or gdc do something different?

You can rely on the order, but you cannot expect any of the names to be at a specific index. The FQN includes the symbol's entire hierarchy. So you could have one or more package names in front of the module name. Essentially:

{all.package.names.}moduleName.{struct/class/functionName}.symbolName

thank you Mike, having sure I can rely on the other is enough to me