Cω - Reference

Direct Member Access

Direct member access (using .) in Cω is similar to direct member in other object-oriented languages. It selects the statically accessible, direct members of an object (for instance members) or type (for static members).

Since Cω supports structural types and unlabelled members, selection distributes over unlabelled nested structural types (structs, choices, streams), as is expected from an XPath point of view.

For example the type FourXs below has four nested members x of type int:

  class FourXs {
    struct {
      int x;
      struct {
        int x;
        struct {
          int x;
          int x;
        }
      }
    }
  }
  fourxs = <FourXs><x>0</x><x>1</x><x>2</x><x>3</x></FourXs>;

Direct member selection fourxs.x will return a stream of integers containing all four of these nested members:

  int* xxxx = fourxs.x; // xxxx = [0,1,2,3]

Selection does not distributes over labelled nested sequences (which from an XSD perspective correspond to anonymous complex types).

Consider the following class Book that has a Title and an Author member, where the Author is an anonymous struct (tuple) that has a Name and a (job) Title:

   class Book {
      struct {
        string Title;
        struct { string Name; string Title; } Author;
      } 
   }
   ...
   Book b = <Book>
             <Title>.NET IL Assembler</Title>
             <Author>
               <Name>Serge Lidin</Name>
               <Title>Dr.</Title>
             </Author>
            </Book>;

When we directly select the Title member via b.Title, the result is the single string ".NET IL Assembler". In order to select all Title members we need to use descendant selection b...Title, which returns the stream containing both strings [".NET IL Assembler", "Dr."].