
namespace MuPAD {
    // All those objects own the MTcell pointer

    SomethingOwningACell (takes care of the memory management)

    /// Any MuPAD cell
    Object              (former SimpleCell)

    /// MuPAD library objects (DOM_INT / DOM_STRING / ..., as well as plain domain elements)

    LibraryObject?

    Container : Cell    (does some type checking; implements container operations)
    Arithmetical : Cell (implements arithmetical operations)

    Integer/DOM_INT : Arithmetical
    Rational/DOM_RAT
	a MuPAD object of type DOM_RAT

    LibraryObject: Object (former Cell)
        Represents the union of all of the above. To be put at the top of that sub hierarchy?

    /// C++ objects stored in a MuPAD cell

    Wrapper<T> : Cell      (former ObjectInCell)
	C++ object of type T stored in the data part of a MuPAD domain element)
    ArrayWrapper : Cell (former ArrayInCell)
    ReferenceEffectWrapper:
	C++ object of type T stored in the data part of a MuPAD domain
        (or similar cell), achieving reference effect


    /// Helper classes/Views:
    - Reference<T>  contains an Object, an index, and must know the operation
      to be used (subsop, set_index, slot, ...)
      could e.g. be
        ReferenceImpl<T> { ... }// abstract
        ReferenceImplOp<T, C=Container> : ReferenceImpl<T> { ... }
        ReferenceImplIndex<T, C=Container> : ReferenceImpl<T> { ... }
        Reference<T> {
               ...
               ~Reference { delete impl; }
            private:
               ReferenceImpl<T> *impl;
        }
    - Iterator/ConstIterator : Reference
}


- Define error properly to make it practical to create error messages
  while limiting memory leaks

------------------------------------------------------------------------------
Standard operators

- Default constructor (null pointer for cell)
- Copy constructor (logical copy)
- Destructor (MFfree)
- Assignment (see below; be safe with self assignment)
- Specialization of std::swap(Object / Object)
- Make sure it is possible to extend the conversions to from MuPAD::Object

- At the C++ level, should lists be indexed from 1..n or 0..n-1?
- Overload assign so that Cell c = 1 does the conversion automatically.
  Even better: make c.at(i) = 1 work.

- MuPAD::List should probably be intialized, either with null pointers
  or with pointers to some fixed MuPAD object like NIL.

- Should at and [] call sign() each time? No. See email discussion.

MuPAD::List l

l[4] = 1;
l[5] = 1;
l.sign()   // Do you have to sign explicitly when done?
           // We could think of taking care of signing l the
           // next time we make a copy of it (probably)

x[4] = l; // Copy semantic (logical copy of l + unique of x)
y    = l; // Copy semantic


- Does "reference" operator[] really work?
- Define operators +, -, ... on Cell's
  Define operator [](Cell) on Cell's
  Make [] work with tables, sets, ..., mimicking MuPAD indexed access.

  Methods:
   op    : equivalent to op at the library level	(not exactly MFop ...)
   extop : equivalent to extop at the library level     ...
   []    : equivalent to [] at the library level

  That will require the implementation of close variants on Reference
  which do setIndex / subsop / extsubsop appropriately
  Iterators should follow the op order, as does for i in ... do
  Should conversion to vector<...> and such use the output iterator (yes)
- Check that all the Container functionalities are available in MuPAD::Object

------------------------------------------------------------------------------
Wrapper

- Add a shift constant in ArrayInCell, so that one can inherit
  simultaneously from ObjectInCell<T> and ArrayInCell<S>
  Add an example of use.
- Define a container interface for the data part of a SimpleCell c:
  Interface: c.data<T>->begin(), c.data<T>->end(), c.data<T>->size(), resize
             c.data->begin()  (default to void * pointer)
  Implementation:
  class DataCell<T> {
      cell &
      T begin(), ...
  }
  Use this in *InCell, and possibly move the "shift" up in SimpleCell
- Give an example of how to store pointers to external C++ objects
  in a cell using ObjectInCell

- Make LongInCell into a complete example

- Get rid of the string template arg in *Wrapper
  Find another way to provide the domain to the dynamic module functions
  via some kind of prog::bless (see email from CCR)
  Find a way to deal with inheritance with dynamic modules functions
  Or maybe those types of data will always be "inherited from" via
  facade domains.
- Provide a domain/category Dom::MAPITLClass(dynamicModule) that aleviates
  the implementation of *InCell domains


domain A()
    _mult := mymodule::prefix__mult; // what's achieved by insertMethod below

    _divide := if field then mymodule::prefix__divide end;
end:

DomainConstructor::insertMethodsFromModule(A, mymodule, "prefix_");

------------------------------------------------------------------------------
Memory management

- Define a proper copy/reference semantic for *Cell's
  Get a review from MuPAD's experts
  Check TODO comments in the code for assignments
- Add compatibility tests of MuPAD cells with STL algorithms
- Check with MuPAD's experts if there is a way to have a destructor
  called, at least when the ref count goes to zero
  In general, find a way to reference/embed properly C++ classes
  with dynamic allocation in MuPAD cell's

------------------------------------------------------------------------------
- Split the files:
  MAPITL/Cell.h
  MAPITL/Cell_tmpl.h
  MAPITLCell.mcc		// Demonstrates how to use Cell's
  MAPITLCell.tst
  Idem for ObjectInCell, ArrayInCell, Old0_4
  The entries CXXFLAGS, LDFLAGS, SCRIPTS, LTLIBRARIES, BUILT_SOURCES,
  CLEAN_FILES can be shared between all the modules

- Update GLIP and the other dynamic modules to use the new interface
- Use doxygen to build reasonnable html/... documentation

- Use an ArrayInCell<int> to implement a faster generator in
  MachineIntegerListsLex (or a variation of ArrayInCell<int>
  with average constant time resize)
- Use it in generation algorithm to really achieve CAT complexity
