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?

I agree. There is no benefit. This way is just comfortable for me. I hide the internals as private methods and expose the ordinary methods as features, so that I can use syntax similar to what I use when working with the Dictionary module, without creating a module.

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.

This code was not meant for the stdlib! I just wanted to share the code that I use. Another (surely better) way of sharing would be creating a functor and uploading it to mogul. I just did not have the time to do this.

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).

Maybe I was too modest to put something in Mogul! ;-)

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 ;-)

As I said, this is just for syntactic purposes.

Cheers,
Filip

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to