Section 2.4.3 of SICP provides an example of data-directed programing in the context of dispatching on type, but I didn't find a general definition of what it is. Wikipedia article says that it is a programming technique mentioned in SICP and seems to claim that it is the same as polymorphism. I am not convinced however that "data-directed programing" could be a reasonable way to call polymorphism.

The following looks to me intuitively like a reasonable definition of data-directed programming:

extensive use of data structures to direct the control flow of the program.

For example, in Python there is no case or switch statement, and one suggested work-around is to use dictionaries. This looks to me like an example of data-directed programming.

Is my understanding correct? If not, what would be the correct general definition? I would like to see any references.

  • $\begingroup$ If I recall correctly, data-directed programming entails manually programming a lookup table in function of the arguments' types. Polymorphism and method overloading are the "automated" (i.e., as language builtins) way of doing this in "classic" OOP languages (e.g, Java). Python only supports polymorphism, hence you need dictionaries. $\endgroup$
    – dkaeae
    Mar 3, 2019 at 16:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.