www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can I rely on format returned by fullyQualifiedName?

reply Jack <jckj33 gmail.com> writes:
Can I rely on this format from fullyQualifiedName? for example, 
let's say I do:

```d
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?


```d
class A
{
   void f() { }

    void baa()
    {
       enum s = fullyQualifiedName!f.split;
    }
}
```
Apr 23
parent reply Mike Parker <aldacron gmail.com> writes:
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:

 ```d
 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
Apr 23
parent Jack <jckj33 gmail.com> writes:
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:

 ```d
 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
Apr 24