Topic: APLX Help : Help on APL language : System Methods : ⎕DS Display summary of object
[ Previous | Next | Contents | Index | APL Home ]

⎕DS Display summary of object

Implemented for Internal, External and System classes.


    string ← objref.⎕DS
    string ← classref.⎕DS
    string ← ⎕DS            (Within user-defined method, same as ⎕THIS.⎕DS)

⎕DS returns a character vector containing a summary of an object in human-readable form.

For Internal classes, ⎕DS returns a summary of properties of the object, abbreviated if they are longer than around 50 characters. For example, if the class Contact has properties Name, Address, Email, and Recnum, the summary display might be as follows:

      A←⎕NEW Contact
      A.Name←'Alphonse T. Randall'
      A.Address←'The Manor House,Main Square,Moreton-under-Stockwood,Tenby'
Name='Alphonse T. Randall', Address='The Manor House,Main Square,Moreton-under-S
      tockwoo...', EMail='', Recnum=34973

For System classes, ⎕DS returns the class name.

For External classes, ⎕DS is mapped to whichever method in the target architecture is used for the default string form of an object. This is ToString for .Net. to_s for Ruby, toString for Java, and format for R.

In this example, we create (in each of three architectures) an object representing the same date/time, and use ⎕DS to display the date/time in human-readable form:

      'ruby' ⎕SETUP 'require' 'Date'
      RubyDate←'ruby' ⎕NEW 'DateTime' 2004 12 13 8 34 03
      NetDate←'.net' ⎕NEW 'DateTime' 2004 12 13 8 34 03
13/12/2004 08:34:03
      JavaDate←'java' ⎕NEW 'java.util.Date' 2004 12 13 8 34 03
Fri Jan 13 08:34:03 GMT 3905
[ruby:DateTime] [.net:DateTime] [java:Date]
 2004-12-13T08:34:03+00:00 13/12/2004 08:34:03 Fri Jan 13 08:34:03 GMT 3905
      ⎕DISPLAY MixedObjects.⎕DS
│ ┌→────────────────────────┐ ┌→──────────────────┐ ┌→───────────────────────────┐ │
│ │2004-12-13T08:34:03+00:00│ │13/12/2004 08:34:03│ │Fri Jan 13 08:34:03 GMT 3905│ │
│ └─────────────────────────┘ └───────────────────┘ └────────────────────────────┘ │

The actual string which is displayed depends on the individual class. The style of the display may not always be consistent for a given architecture. For example, in the .Net framework, the ToString method sometimes displays the data associated with the class (as in the DateTime example above), sometimes just the object's class name, and sometimes a verbose summary of an object's properties:

      PT←'.net' ⎕NEW 'System.Drawing.Point'

      FD←'.net' ⎕NEW 'System.Windows.Forms.FontDialog'
System.Windows.Forms.FontDialog,  Font: [Font: Name=Microsoft Sans Serif, Size=8
      .25, Units=3, GdiCharSet=0, GdiVerticalFont=False]
      HT←'.net' ⎕NEW 'System.Collections.Hashtable'

In this example, in R, we create an array of complex numbers and use ⎕DS to format it:

      m←'r' ⎕new 'complex' (3 2⍴(1 2) (3 4) (5 6) (7 8) (9 10) (11 12))
 1+ 2i  3+ 4i
 5+ 6i  7+ 8i
 9+10i 11+12i

Topic: APLX Help : Help on APL language : System Methods : ⎕DS Display summary of object
[ Previous | Next | Contents | Index | APL Home ]