MAINSAIL Language Manual, Section 32.22

previous   next   top   contents   index   framed top   this page unframed


32.22. $className

Figure 32–18. $className
STRING
PROCEDURE   $className  (POINTER p);

p is a POINTER to a dynamic record, CLASS descriptor, or data section. The name of the associated CLASS is returned. If there is no associated CLASS (e.g., p is NULLPOINTER), the null STRING is returned. The effect if p points to a data section is described in Section 32.22.1.

CLASS descriptor POINTERs may be obtained with $createClassDscr, $classInfo, or $dscrPtr.

Since CLASS names need not be unique within a MAINSAIL program, the correct way to determine whether two dynamic records are of the same CLASS is to compare their CLASS descriptor POINTERs (as returned by $dscrPtr).

32.22.1. $className of a Data Section

Temporary feature: subject to change

The behavior of $className(p) if p points to a data section is complicated and subject to change.

Let p point to a data section for some MODULE M:

See Example 32–19.

Example 32–19. Behavior of $className with Data Section Arguments
Given the declarations:

        MODULE m (PROCEDURE foo);
        
MODULE n (INTEGER i; ...);
        
CLASS c (INTEGER j; ...);
        
MODULE(co (PROCEDURE foo);
        
MODULE(cp (INTEGER i; ...);
        
CLASS d (PROCEDURE bar);
        
MODULE(dq (PROCEDURE foo);

then:

If p points to a data section for: then $className(p) returns:
M ""
N "N"
O "C"
P "P"
Q ""

It is not obvious that $className should behave this way, so the behavior is subject to change. The reasoning behind this approach is that $className returns the name of the CLASS that describes the interface data fields of the data section. If there are no interface data fields, then it returns null STRING; otherwise, it returns the name of the actual CLASS if all the data fields came from a CLASS; otherwise, it returns the name of the dummy CLASS created by the compiler to describe the fields declared for the MODULE, and the compiler happens to give this CLASS the name of the MODULE.


previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Language Manual, Section 32.22