(ref.doc)maxtal 150593

Next bs 190593 Prev: bs 110593 Up: Usenet

Newsgroups: comp.lang.c++
From: [email protected] (John Max Skaller) (Note:
 Skaller)
Subject: Re: Anyone read "Advanced C++ Programming
Nntp-Posting-Host: physics.su.oz.au
Organization: School of Physics, University of Sydney, Australia
Date: Sat, 15 May 1993 12:21:48 GMT

[...]
>Could you cover them here?  I ran across mixins in a Flavors swamp
>called GeoFlavors(mapping package), but never had a formal
>introduction.  What do mixins have to do with before/after/ init
>methods?  What possible implementations are there in C++?

	I dont know enough about them myself to cover them completely.

	There isnt much to do with before/after/init methods, although
there is the connection that comes from using Multiple inheritance.

	The basic idea of mixins is to use abstract classes to define
abstractions, use MI to create new ones, and use MI again to implement
the classes in various way such that you can choose any combination
of implementations you want for a complex class.

	The technique is based on the standard mixin diamond:

		A  f()=0
	      /   \
      f();   I     U  call f();
	      \  /
		M

A is the abstraction. U is the user interface, built on the abstraction.
It might be built on other abstractions too.
I is the implementation subclass. Concrete. Inaccessible.

M is the mixin class. It is used to construct the object,
and is thereafter inaccessible. Generally, its best not to access A
either: only U is accessed by the user.

Ther idea is you can replace I by I2 anytime by defining M2.
but the user of U doesnt know about that...polymorphism
via sibling call hooks the I version of f() via A.

You can sometimes dispense with U and use A instead: I like the
diamond here because the abstraction represents Axioms:
too primitive for the user to call. Private virtual functions
would do instead.

The reason its called 'mixin' is unclear, but it does come from
Lisp/Flavours/CLos.

Typically, I build  a 'mesh' of abstractions with MI. The provide
various implementations. The user chooses which implementation
is useful by binding the abstraction to the implementation
in the mixin class, constructing an object, and then
forgetting the mixin class (which exists only to
enable construction of the object).



--
        JOHN (MAX) SKALLER,         INTERNET:[email protected]
	Maxtal Pty Ltd,		    CSERVE:10236.1703 
        6 MacKay St ASHFIELD,	    Mem: SA IT/9/22,SC22/WG21 
        NSW 2131, AUSTRALIA	    



automatically generated by info2www version 1.2.2.8