From: Dean Foster (foster_at_[hidden])
Date: 2001-10-04 15:18:16
> > | But, user defined quantities like "apples", "oranges", "fruits", etc
> > | are important from the programming perspective.
> > (5) I think that "apples" qualifies
> > neither as a quantity nor as a unit, but I'm willing to be convinced
> > to the contrary.
> I would agree that calling these things "qualifiers", "modifiers", or
> "unit tags" is a probably a good terminology to use.
I like the idea of using the name "tag" for a user defined quantity.
I also like Kevin's idea of phrase "isa" questions by asking how they
could be used in a calculation. Basically Kevin is reminding us that
we should be using the LSP (Liskov Substitutability Principle,
http://ootips.org/lsp.html) to make our programming decisions NOT
philosophy! The LSP says that if you can substitute one type A for
type B then A should inherit from B. So a "Kg of apples" is a
reasonable thing to pass into any function that wants a "kg of fruit".
Thus, we want to think of it as inheriting from a "kg of fruit." This
answers all the nice questions proposed by Kevin Lynch the exact same
way he answered them.
So we not only need to have use defined tags, but we also need to
allow users to define inheritance structure for these tags. This will
allow us to really challenge compilers since we will need to use
templates that multiple inherit from other templates! Following
previous threads we would want something like:
// weight and distance are predefined quantities
typedef tag<weight> weight_of_fruit;
typedef inherited_tag<weight_of_fruit> weight_of_apples;
typedef tag<distance> shipping_distance;
typedef product_tag<weight_of_apples,shipping_distance> asd;
where has an inheritance structure like:
product_tag<inherited_tag<A>, inherited_tag<B> >:
public product_tag<A,inherited_tag<B> >,
Dean Foster dean_at_[hidden]
Statistics, Wharton, U. Penn 215 898 8233
Philadelphia PA 19104-6302 http://diskworld.wharton.upenn.edu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk