Re: Separation of API and implementation



On Wed, 15 Aug 2007 08:18:31 -0400, Daniel T. wrote:

In the zoo metaphor above lies the answer to a proper design. However,
since we are talking about programs and not zoos, we have a few extra
resources available to us. Think of the six ways X can acquire a Y to
use:

1) X can create a Y inside 'foo'
2) X can create its Y as a contained object
3) X can be given its Y as a parameter of 'foo'
4) X can be handed a Y though some other method
5) X can use a global Y
6) X can ask a third party for its Y

Objection. Bringing the context in changes little if nothing. In fact, you
replace double-dispatching

foo : X x Y, with

again double-dispatching

foo : X x Context,

here Y is somehow deduced from the context. What changes?

The problem is not in who determines Y, as long it is not X. I.e. the
problem is in which relation are X and Y in foo. If Y is fully independent
or else can be evaluated from X, only then it can be handled by single
dispatch. The former is class-wide Y, the latter is no Y parameter at all.

Animals are used to eat food and each other, food can be an animal and
reverse. It is a role-playing game... (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Lexical contexts; or, Lambda, the Ultimate Module?
    ... (defun foo (...) ... Here the `defcontext' declares, not a lexical environment, but a ... that binds the names declared in the context to the values in the ... certainly slow down incremental compilation a bit. ...
    (comp.lang.lisp)
  • Re: [ANN] test/spec 0.10, a BDD interface for Test::Unit
    ... context "Foo" do ... specify "should bar" do ... When we put a cursor inside a def test_case and claw, ... remap of test_case architecture is the ability to run nested context{} blocks with incrementally nested setupblocks. ...
    (comp.lang.ruby)
  • Re: Selecting directories containing specific fileglobs
    ... glob() ) in a scalar context has weird magical ... Actully the second prints the first two starting foo because the scalar ... context glob function remembers that it's got a list of files starting ... You need to force a list context on glob. ...
    (comp.lang.perl.misc)
  • Re: Perl vs Python vs Ruby
    ... I think it makes perfect sense in the context of Perl. ... > and that being able to use %foo, @foo, ... > Ruby is closely related to Smalltalk and Lisp. ...
    (comp.lang.perl.misc)
  • Re: "instance_eval" (eg, sent to a class object)
    ... I do know what it means to evaluate code in the context of a *class* ... # We're now in the context of the object Foo. ... Intro to Rails, London, UK, December 3-6 ...
    (comp.lang.ruby)