concept-change-class.tex 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. % -*- Mode: TeX -*-
  2. \Thefunction{change-class} can be used to change the \term{class}
  3. of an \term{instance} from its current class, $C\sub {\hbox{{\prmseven from}}}$,
  4. to a different class, $C\sub {\hbox{{\prmseven to}}}$; it changes the
  5. structure of the \term{instance} to conform to the definition of the class
  6. $C\sub {\hbox{{\prmseven to}}}$.
  7. Note that changing the \term{class} of an \term{instance} may cause
  8. \term{slots} to be added or deleted. Changing the \term{class} of an
  9. \term{instance} does not change its identity as defined by the
  10. \funref{eq} function.
  11. When \funref{change-class} is invoked on an \term{instance}, a two-step
  12. updating process takes place. The first step modifies the structure of
  13. the \term{instance} by adding new \term{local slots} and discarding
  14. \term{local slots} that are not specified in the new version of the \term{instance}.
  15. The second step initializes the newly added \term{local slots} and performs
  16. any other user-defined actions. These two steps are further described in the
  17. two following sections.
  18. \beginsubsection{Modifying the Structure of the Instance}
  19. In order to make the \term{instance} conform to the class $C\sub
  20. {\hbox{{\prmseven to}}}$, \term{local slots} specified by the class $C\sub
  21. {\hbox{{\prmseven to}}}$ that are not specified by the class $C\sub
  22. {\hbox{{\prmseven from}}}$ are added, and \term{local slots} not specified by
  23. the class $C\sub {\hbox{{\prmseven to}}}$ that are specified by the
  24. class $C\sub {\hbox{{\prmseven from}}}$ are discarded.
  25. The values of \term{local slots} specified by both the class $C\sub
  26. {\hbox{{\prmseven to}}}$ and the class $C\sub {\hbox{{\prmseven
  27. from}}}$ are retained. If such a \term{local slot} was unbound, it remains
  28. unbound.
  29. The values of \term{slots} specified as shared in the class $C\sub
  30. {\hbox{{\prmseven from}}}$ and as local in the class $C\sub
  31. {\hbox{{\prmseven to}}}$ are retained.
  32. This first step of the update does not affect the values of any
  33. \term{shared slots}.
  34. \endsubsection%{Modifying the Structure of the Instance}
  35. \beginsubsection{Initializing Newly Added Local Slots}
  36. \DefineSection{InitNewLocalSlots}
  37. The second step of the update initializes the newly added \term{slots} and
  38. performs any other user-defined actions. This step is implemented by
  39. the generic function \funref{update-instance-for-different-class}. The
  40. generic function \funref{update-instance-for-different-class} is invoked
  41. by \funref{change-class} after the first step of the update has been
  42. completed.
  43. \issue{CHANGE-CLASS-INITARGS:PERMIT}
  44. The generic function \funref{update-instance-for-different-class} is
  45. invoked on arguments computed by \funref{change-class}.
  46. The first argument passed is a copy of the \term{instance} being updated
  47. and is an \term{instance} of the class $C\sub {\hbox{{\prmseven from}}}$;
  48. this copy has \term{dynamic extent} within the generic function \funref{change-class}.
  49. The second argument is the \term{instance} as updated so far by \funref{change-class}
  50. and is an \term{instance} of the class $C\sub {\hbox{{\prmseven to}}}$.
  51. The remaining arguments are an \term{initialization argument list}.
  52. % The generic function \funref{update-instance-for-different-class} also
  53. % takes any number of initialization arguments. When it is called by
  54. % \funref{change-class}, no initialization arguments are provided.
  55. \endissue{CHANGE-CLASS-INITARGS:PERMIT}
  56. There is a system-supplied primary \term{method} for
  57. \funref{update-instance-for-different-class} that has two parameter
  58. specializers, each of which is \theclass{standard-object}. First
  59. this \term{method} checks the validity of initialization arguments and
  60. signals an error if an initialization argument is supplied that is not
  61. declared as valid. (For more information, \seesection\DeclaringInitargValidity.)
  62. Then it calls the
  63. generic function \funref{shared-initialize} with the following arguments:
  64. the
  65. %Barmar suggested we insert the word "new" here.
  66. new
  67. \term{instance}, a list of \term{names} of the newly added
  68. \term{slots}, and the
  69. initialization arguments it received.
  70. \endsubsection%{Initializing Newly added Local Slots}
  71. \beginsubsection{Customizing the Change of Class of an Instance}
  72. \term{Methods} for \funref{update-instance-for-different-class} may be defined
  73. to specify actions to be taken when an \term{instance} is updated. If only
  74. \term{after methods} for \funref{update-instance-for-different-class} are
  75. defined, they will be run after the system-supplied primary \term{method} for
  76. initialization and will not interfere with the default behavior of
  77. \funref{update-instance-for-different-class}.
  78. %% Removed per X3J13. -kmp 05-Oct-93
  79. % Because no initialization
  80. % arguments are passed to \funref{update-instance-for-different-class} when
  81. % it is called by \funref{change-class},
  82. % the \kwd{initform} forms for \term{slots}
  83. % that are filled by \term{before methods} for
  84. % \funref{update-instance-for-different-class} will not be evaluated by
  85. % \funref{shared-initialize}.
  86. \term{Methods}
  87. for \funref{shared-initialize} may be defined to customize \term{class}
  88. redefinition. For more information, \seesection\SharedInitialize.
  89. \endsubsection%{Customizing the Change of Class of an Instance}