Chapter 8. Unit tom

Table of Contents
8.1. File tom/All
8.2. File tom/Array
8.3. File tom/Bag
8.4. File tom/Block
8.5. File tom/BucketDictElement
8.6. File tom/BucketElement
8.7. File tom/BucketIntDictElement
8.8. File tom/BucketPDictElement
8.9. File tom/BucketSetElement
8.10. File tom/Bundle
8.11. File tom/ByteArray
8.12. File tom/ByteStream
8.13. File tom/ByteString
8.14. File tom/ByteSubstring
8.15. File tom/C
8.16. File tom/CharArray
8.17. File tom/CharEncoding
8.18. File tom/CharString
8.19. File tom/Condition
8.20. File tom/ConditionClass
8.21. File tom/Conditions
8.22. File tom/Cons
8.23. File tom/Constants
8.24. File tom/DCons
8.25. File tom/Date
8.26. File tom/Descriptor
8.27. File tom/Dictionary
8.28. File tom/DoubleArray
8.29. File tom/EqDictionary
8.30. File tom/EqHashTable
8.31. File tom/EqSet
8.32. File tom/Extension
8.33. File tom/File
8.34. File tom/FloatArray
8.35. File tom/HashTable
8.36. File tom/Heap
8.37. File tom/HeapElement
8.38. File tom/IntArray
8.39. File tom/IntDictionary
8.40. File tom/IntegerRangeSet
8.41. File tom/Invocation
8.42. File tom/InvocationResult
8.43. File tom/Limits
8.44. File tom/Lock
8.45. File tom/MutableArray
8.46. File tom/MutableByteArray
8.47. File tom/MutableByteString
8.48. File tom/MutableCharArray
8.49. File tom/MutableCharString
8.50. File tom/MutableDoubleArray
8.51. File tom/MutableFloatArray
8.52. File tom/MutableIntArray
8.53. File tom/MutableObjectArray
8.54. File tom/MutablePointerArray
8.55. File tom/MutableString
8.56. File tom/Number
8.57. File tom/ObjectArray
8.58. File tom/Pointer
8.59. File tom/PointerArray
8.60. File tom/PointerDictionary
8.61. File tom/Queue
8.62. File tom/Random
8.63. File tom/RandomDouble
8.64. File tom/Runtime
8.65. File tom/Selector
8.66. File tom/Set
8.67. File tom/Sorted
8.68. File tom/State
8.69. File tom/StreamBuffer
8.70. File tom/String
8.71. File tom/StringStream
8.72. File tom/Thread
8.73. File tom/Trie
8.74. File tom/TypeDescription
8.75. File tom/Unicoding
8.76. File tom/Unit
8.77. File tom/XL
8.78. File tom/archiving
8.79. File tom/behaviours
8.80. File tom/coding
8.81. File tom/collections
8.82. File tom/config
8.83. File tom/holes
8.84. File tom/numbers
8.85. File tom/streams
8.86. File tom/unique-strings

The tom unit is that standard TOM library.

8.1. File tom/All

class tom.All

The All class does not serve a purpose. It is the stateless All instance which is inherited by both the State class and instance, and, supposedly, by all objects not inheriting from State.

instance tom.All

inherits

State supers: Conditions, Constants

variables

const TRUE = !0;

The boolean truth.

const FALSE = !TRUE;

The boolean non-truth.

const YES = TRUE;

An alternative name for TRUE.

const NO = FALSE;

An alternative name for FALSE.

methods


String
  description;

Return a string informally describing this object.

This returns the result of having the receiver write itself into a new String which is subsequently returned.


boolean (result)
  eq All other
post
  self == other == result;

The selector equivalent of `==', i.e. the returned result is TRUE iff the receiving object and the other object are the same object.

The postcondition states that this method is not overridable.


boolean (result)
  equal id other
post
  self == other -> result;

Return TRUE when the receiving object considers itself equal to the other object. For instance, two Number objects holding the same value will return TRUE.

The receiving object should be able to assume the other object is of the same kind, or at least shares with it a common superclass, as in the case of, for instance, CharString and ByteString which are both subclasses of String and can compare with each other.

As stated by the postcondition, an object must be equal to itself. This knowledge may be used by a caller to prevent a method invocation.


int
  hash;

Return a hash value for the receiving object. The default implementation returns some bit pattern deduced from self.

Two distinct objects considering themselves equal should also return the same hash value.


int
  hashq;

Hash the address of the receiving object. For classes not redefining hash, this performs the same function.


id (self)
  self;

Return the receiving object.


deferred OutputStream
  write OutputStream s;

All objects, even classes, know how to (descriptively) write themselves to a stream.

A default implementation of this method is provided by the State class and instance.


deferred boolean
  classp;

Return TRUE iff the receiving object is a class object. An implementation for this method is provided by the State class and instance.


boolean
  isKindOf class (State) a_class;

Return TRUE iff the class of the receiving object is a subclass of the class.


deferred class (id)
  kind;

Return the class of the receiving object.


boolean
  respondsTo selector sel;

Return YES iff the selector sel can be safely sent to the receiver. The default implementation only checks whether the receiving object provides a direct implementation of the sel; any checking through an alternative forwardDelegate should be performed by the object itself.


All
  forwardDelegate selector sel;

Return an object of which the method indicated by the selector sel should be invoked. This method is invoked if the receiving object does not directly respond to sel. The default implementation returns self. The object returned could be a delegate which is to act upon behalf of the receiving object for the intended call of the selector sel.


InvocationResult
  forwardInvocation Invocation invocation;

Return the result of forwarding the invocation, for example by firing it at an appropriate object. The default implementation raises a program-condition SelectorCondition.


dynamic
  perform selector sel
        : Array arguments = nil;

Send the receiving object a message with the selector sel and the, possibly unboxed, arguments. The number of elements of arguments must match the number of arguments dictated by the selector.

Unboxing the arguments means that if an int argument is needed, the int at int method will be used to retrieve the argument from the arguments, possibly resulting in the object retrieved being asked for its intValue.


dynamic
  perform selector sel
     with dynamic arguments;

Send the receiving object a message with the selector sel and the arguments. The number of arguments must match the number of arguments dictated by the selector.

If the selector sel accepts more than one argument, arguments should be a tuple. The tuple-ization of the actual arguments to the selector sel and the elements of the arguments tuple is ignored.


Thread
  performInThread selector sel
             with dynamic arguments;

Like perform with but create a new thread for the performance. Return the newly created thread or nil upon failure.


boolean
  invocationp;

Return YES iff the receiving object is an Invocation. Only Invocation objects are supposed to return YES.


dynamic
  valueOfVariableNamed ByteString name;

Retrieve the value of the variable with the indicated name. If there is more than one variable with the same name and expected return type, the first is returned.


void
         setValue dynamic value
  ofVariableNamed ByteString name;

Set the value of the variable named name in the receiving object to the value. It is an error if the type of the value does not exactly match the actual type of the variable: no conversion is performed.


int
  typeOfVariableNamed String name
                 from Extension ext
pre
  [[self stateExtensions] memq ext] != nil;

Return the type of the variable named name as introduced by the extension ext. This returns one of the TYPEDESC_* Constants.


Any
  valueOfVariableNamed String name
                  from Extension ext
pre
  [[self stateExtensions] memq ext] != nil;

Return the boxed value of the variable named name as introduced by the extension ext.


Extension
  extensionNamed String name
      inherited: boolean check_supers = NO;

Return the Extension object of this object for the extension named name. If name == nil, the main extension is returned.


Indexed
  extensions;

Return an array of the extensions of the receiving object, not including the extensions introduced by superclasses.


Indexed
  allExtensions;

Return an array of all extensions of the receiving object. This includes the extensions introduced by superclasses.


Indexed
  stateExtensions;

Return an array of state introducing extensions of the receiving object. This includes the extensions introduced by superclasses.


void
  throw dynamic value;

Throw execution to the catch specified for the receiving object, returning the value. If the value is void, the default value for the type to be returned by the catch is returned.


void
  preconditionFailed selector sel;

This method is invoked for a failed precondition of a method invocation of the receiving object. The method is identified by the selector sel. The default implementation raises a condition-condition SelectorCondition.

Method precondition checking is enabled is the option :cc-pre is provided on the program's command line. The code for precondition checking is normally compiled in by the compiler. This code is omitted by passing the -fno-checks or -fno-pre-checks option to the compiler.


void
  postconditionFailed selector sel;

This method is invoked for a failed postcondition of a method invocation of the receiving object. The method is identified by the selector sel. The default implementation raises a condition-condition SelectorCondition.

Similar to precondition checking, postcondition checking is enabled by the :cc-post option on the command line of this program and not providing -fno-checks or -fno-post-checks to the compiler.


protected void
  unimplemented selector sel
       message: String message = nil;

Moan about the selector sel not yet having been implemented by the receiving object. This raises an unimplemented SelectorCondition.


protected void
  shouldNotImplement selector sel;

Contrary to what the inheritance tells you about the selector sel being invokable for the receiving object, that object thinks otherwise.


protected void
  subclassResponsibility selector sel;

Moan about the receiving object defining a method for the selector sel, but actually the implementation of the method by the object thinks it should be implemented by a subclass.


boolean
  consp;

Return TRUE iff the receiving object is a Cons cell. The default implementation returns NO.


OutputStream
  writeListElement OutputStream s;

Finish outputing the list, of which the receiving object is the tail, to the stream s. The default implementation writes itself as a dotted cdr at the end of the list.


deferred boolean
  persistent-coding-p;

Return YES iff the receiving object is a persistent object. This is significant for distributed objects, where class objects and Selector instances must be persistent across different invocations.


pointer
  address;

Return the address of the receiving object as a pointer. This is here solely to be able to print the address of objects, for debugging purposes.


boolean
  coding-permanent-object-p;

Return YES if the receiving object should be maintained in the permanent object store when coding. This does not matter for archiving; it makes a difference for DO. Class objects and Selectors return TRUE for this; the default implementation returns FALSE.


void
   dump (boolean, boolean) (allow_self, allow_simple)
  level int level;

Dump the graph of which the receiving object is the root to stderr.


void
  dump;

Like void dump (boolean, boolean), allowing self/simple printing and doing infinite recursion.


boolean
  dump_simple_p;

Return TRUE iff the receiving object can be dumped simply. This will be true for class objects, strings, numbers, etc. This method is overridden by dump_self_p. The default implementation returns FALSE.


boolean
  dump_self_p;

Return TRUE iff the receiving object wants to dump itself instead of having its variables scrutinized. This is used by collection objects and others which employ pointer typed variables. The default implementation returns FALSE.


OutputStream
  dump_simple OutputStream s;

Dump the receiving object to the stream s, simply. This is only ever invoked if the object returns YES for dump_simple_p. The default implementation simply prints self to the stream.


protected void
  dumpSelf MutableKeyed done
    indent MutableByteString prefix
    simple boolean allow_simple
     level int level
        to OutputStream s;

Have the receiving object dump itself. Only ever invoked if it returns TRUE for dump_self_p. The default implementation invokes shouldNotImplement.


deferred protected void
    dump MutableKeyed done
  indent MutableByteString prefix
  simple boolean allow_simple
   level int level
      to OutputStream s;

Hard worker for dump.


boolean
  gc_dead_p;

Return YES iff the receiving object has not yet been marked alive during the current run of the garbage collector. Class objects are never dead.


void
  gc_mark;

Mark the receiving object as being alive. This method is only needed by the container garbage collection scheme.

This method is invoked during Garbage Collection. During GC, the Runtime library is running in panic mode. If anything goes wrong, for instance a condition is signaled or raised, the program will abort. Moral: be careful during garbage collection.