On 16.02.2006, at 10:47, Filip Konvička wrote:
To be constructive, I attach an implementation of sorted associative
container that uses a red-black tree and a double-linked list (it is
not as generic as could be, but could be enhanced easily).
I am a bit surprised by the way you use object features, because you
use them as class features. (Some people even consider those
features as a design mistake.) Why don't you use standard methods?
This way I expose similar interface as the Dictionary module, and the
syntax is exactly the same (well, except the syntactic sugar available
for dictionaries). I guess that I should provide a module rather than
a class.
I understood that in Mozart a class instance is represented as a data
structure which contains all its methods as data. You do this even
explicitly with your methods bound to features. This increases the
memory footprint of an instance.
For your proposal I don't see much benefits doing it the OOP way: do
you expect most users of your data structure would create some
subclasses which inherit from RBTree?
Alternatively, a data structure which separates the actual data and the
procedures on this data would need less memory for an instance of the
data. E.g., this is the case for most data structures in Mozart such as
List, Record etc. An abstract data representation could hide its
internals in a first-class procedure. Everything would then be
integrated in a functor (as you propose yourself).
This might be a better approach for something proposed to be integrated
in the standard library.
BTW: Why not first putting something in Mogul from where it can be use
almost as if it is part of the standard library (you only need to
install it yourself).
But I use this also regularly when I want to have a procedure (i.e. a
"static method") inside a class, either because it uses some private
identifiers (names) of the class, or just to logically group the code.
Coming from an OOP background myself, I do much stuff in Oz the OOP
way. Nevertheless, this is not necessarily the better way ;-)
Best,
Torsten
--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users