Dependency solving

"Piotr Wyderski" <>
29 Apr 2004 11:59:25 -0400

          From comp.compilers

Related articles
Dependency solving (Piotr Wyderski) (2004-04-29)
Re: Dependency solving (SM Ryan) (2004-05-02)
| List of all articles for this month |

From: "Piotr Wyderski" <>
Newsgroups: comp.compilers
Date: 29 Apr 2004 11:59:25 -0400
Organization: Faculty of Computer Science, University of Wroclaw
Keywords: OOP, analysis, question
Posted-Date: 29 Apr 2004 11:59:25 EDT

How are cyclic dependencies solved in object-oriented languages?
Say, we have a class (in a C++-like language):

        class T {


                        T clone() {

                                T p();
                                return p;

To solve dependencied of the class T, which depends on
the method clone(), the type checking mechanism must
solve dependencies of clone(), which depends on T.
A simple, recursive solver, like this pseudocode:

        if (t == class)

        for all m in methods


will loop forever. Node marking (to detect a cycle)
doesn't help much, it only allows us to break the
cycle and report an error. However most programming
languages do not have problems with cycles and they
gently solve such dependencies. So, how does the
algorithm work?

        Best regards
        Piotr Wyderski

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.