TEACH SLOT_DEFAULTS Steve Knight, April 92 [See REF * OBJECTCLASS/Field Specifications for more detail] Associated with each slot there is a default-value and a default-procedure. The ordinary "=" syntax syntax specifies a default-procedure which is executed at run-time. e.g. define :class timestamp; slot stamp = sysdaytime(); enddefine; When the timestamp objects are built, the default is calculated at the moment of creation. newtimestamp() => ** ;;; A few moments later newtimestamp() => ** Unfortunately, there is inevitably a small efficiency penalty associated with running procedures at creation-time. Almost always this penalty is too small to worry about. But for applications in which speed matters another way of specifying defaults is avaiable. This uses the "==" keyword. define :class sillystamp; slot stamp == sysdaytime(); ;;; this expression is calculated enddefine; ;;; at compile-time! newsillystamp() => ** ;;; It doesn't matter when this is run. newsillystamp() => ** The "==" specifies that the expression is to be used to calculate a value at the point of compilation. This is then used as the default value. Since the computation only ever happens once, the construction of objects can avoid running a procedure to initialise that slot. --- C.all/lib/objectclass/teach/slot_defaults --- Copyright University of Sussex 1993. All rights reserved.