Inheritance and Expanded [WAS: Re: message d'erreur cryptique]

Mildred Ki'Lya ml.mildred593 at gmail.com
Fri Feb 5 20:06:34 UTC 2010


On 02/05/2010 08:42 PM, Pierre-Alexandre Voye wrote:
> But you can use a section Insert


Sure, the point of the Section Insert is to have inheritance WITHOUT
inheritance, which is one of the key principles of object orientation.
Just look at BOOLEAN to see how useful it can be :)

That's no fault to Lisaac. To implement polymorphism you need to add an
extra information (a tag, a VFT ...) that simply add to the data
structure. The fact that inherited types can have a different size
doesn't help either.



That being said, in Ada there is something quite interesting.
When you write Some_Type'Class, it represents objects of type Some_Type
and all of its children. That is not possible in Ada, but we can imagine
that a variable of type Some_Type'Class would be the size of the biggest
object in the type hierarchy. As we are in a closed world assumption, it
is possible.

That way, we could have inheritance for Expanded types. It would
translate in C as:

struct "Some_Type'Class" {
    int    tag;
    union {
        Some_Type      some_type;
        Child_Type1    child_type1;
        Child_Type2    child_type2;
    }
};


And if we want to make sure of the data structure for a type, just make
sure that you fill in `type' in Section Header or use a Section Mapping.
But, there would be no polymorphism.




That doesn't solve the original problem. What is likely to solve this
original problem would be to have algorithms that need REAL variables to
actually have a parametric type (that must bahave as a REAL).

Mildred

-- 
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk: <mildred at jabber.fr>
│ Website: <http://ki.lya.online.fr>           GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/lisaac-devel/attachments/20100205/d86a4d86/attachment.pgp>


More information about the Lisaac-devel mailing list