Here, "data-oriented programming mode", which is suitable for processing a certain amount of data (herein) has a number of expressions, and the problems brought. The previous 2.4.2 is based on type-based display assignment, which uses an episode as a interface between multiple counts and two representations, which has two weaknesses: 1, each process must know All expressions of the plural; 2, naming difficulties. The root cause of the two weaknesses is that this type-based display assignment does not have "addability".
Data-oriented programming, put all the operations for multiplexes, enter the table, to form a two-dimensional table (if the plural is more than two expressions, "more than two-dimensional table). The data-oriented programming is to make the program directly using this form of programming.
The two-dimensional table of the calculated plural in this section is the following figure, and its first dimension is Operation, the second dimension is the data type. Follow the (Get 'Operation' Polar).
I want (Define-from-Real-Imag 1 2), the program is not run, showing Expected Procedure, Given: #F Check reason: 1, the form is operating normally 2, the reason is that there is no package, install: (Install-Rectangular-package) (Install-Polar-Package) OK
Key process:; apply-generic --------------- KEY (APPLY-GENERIC OP. ARGS) ((Type-Type-tag Args)); Args IS A Complex, Z (LET (Get Op Type-tags)); Proc Is The Needed Process (Apply Proc (Map Contents Args); The Second Param of Apply Must Be a List (Error "No Method for Types - Apply-generic")))))))))))))))))))))))))))))
In the data-oriented programming, the most critical ideas are various universal operations in the hypervisor (such as Real-Part, IMAG-Part) by displaying the processing-type table (such as the figure). In Section 2.4.2, an organizational method based on type (Polar, Rectangular), and assignment based on the type of assignment is to manage each operation (ie universal procedure such as Real-Part, IMAG-Part ...). Your own dispatch. (Real-part z) (Real-Part-Rectangular (ContentS Z))) (Real-Part-Polar (Contents Z))) (Else "Unknown Type - Real-Part" z)))))) From the effect, this method is to divide the above table into a row, each universal process represents a line in the table.
Another implementation strategy is to decompose this form, not using a group of "intelligent operations" (ie, the above general-purpose process) to assign the data type, but use "smart data object" to make them based on The operand completes the assigned work required. The so-called "intelligent data object" is also implemented by the process, that is, the dispatch method. (Define (Dispatch OP) (((EQ? OP 'Real-Part) ((Eq? OP' IMAG-Part) Y) ((EQ? OP 'Magnitude) (SQRT ( (Square Y))))))))) ((EQ? OP' Angle) (Else (Erse (Error "Unknown Op - Make-from-Real-IMAG" OP ))))) Here, make-from-real-imag returns a process - the interior DISPATCH process. This style is called messaging, the name comes from, enjudes the data object into one entity, and it receives the name of the required operation in a message. Note that the use of a table is not a message oriented programming when using a table in this section, but a data-oriented programming.