[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Modules vs. dynamic binding
Date: Mon, 11 Dec 89 12:34:47 -0800
From: Andy Freeman <email@example.com>
Scott said that dynamics were often used to pass arguments indirectly;
the simple case is that A calls B and B calls C, but A wants to
provide input to C that it doesn't want to pass through B. I agree.
Scott's proposed solution was for A to construct (using the module
facility), a custom version of C that has the arguments that A wants
to provide and have B call that procedure. The problem with that
is telling B which C to call.
If A and A' construct their own versions (using the module system) of
C, then they have to tell B to call the right one. One way is for
them to pass it. This "works", but misses the point and is awkward
for more complex examples. The alternative is for them to redefine
C's (global to B) definition. Maintaining that redefinition
correctly, when B is not defined within A, requires simulating
I think you're still missing the point, Andy. The possibility you
overlook is that A can have one instance of B which calls C, and A' can
have another instance, B', which calls C'. Or, as you point out, B can
accept an instance of C as an argument. My claim is that these two
choices are all one needs to elegantly structure any program.