On 22 March 2010 12:01, <[email protected]> wrote: >> 1. How important is inheritance in the eyes of people here? > > For me, it's a very important property of a programming language. OO, > if done right, seems to naturally fit the way I think. And a good > programming language is one that bridges the gap between telling the > computer what to do and concisely telling the human reader what's going > on. > > Take, for example, the task of making fruit salad. I have a little > recipe in my head that involves cutting fruit into pieces, adding > raisins, lime juice and rum, mixing it all and letting it rest for an > hour in the fridge. Obviously, that's a generic algorithm written using > abstract fruits. To actually execute it, we need concrete fruits, that > is, objects with fruit-like properties in taste and texture and support > for a polymorphic "cut" method (bananas need peeling, apples don't). > > Ok, so far that's an argument for polymorphism in the language. Now why > inheritance? When talking about things, it really makes your life > easier to give them names. I want to be able to specify an algorithm in > terms of fruits, and later be able to refine it by saying "hey, a banana > is a fruit, and by the way, you need to peel it before cutting it to > pieces". That's a named abstract concept here, and an IS-A > relationship, and polymorphism. OO, if you want. I'd feel very > uncomfortable having to talk about "objects with fruit-like properties > in taste and texture and support for a polymorphic cut method" all of > the time, it's much better to be able to talk "fruits". This closely > corresponds with my frustration when using C++ templates or > Haskell/ML-style languages with algebraic data types: compile time type > errors spanning multiple screen pages make my poor brain hurt. "Cheese > is not a fruit" is much easier to parse. > As I understand the current state of BitC it takes a slightly different approach.
To make a salad you need something to cut into pieces so you devise an object (or you may think of it as an interface) Cuttable and the function make_salad can operates, say on list of Cuttatbles. Thus you can make cheese salad and fruit salad in the same way but to ensure you end up with a fruit salad you have to devise a make_fruit_salad which operates on Cuttables and checks that they do look like fruits because there is no provision for assertions in a BitC object, you just have to check them in the code. The fact that fruits and nuts and cheese are Cuttables has nothing to do with the fact that cheese and most fruits are also Squishables. You do not need that to make a salad so you aren't concerned with that at the moment. If, on the other hand, you wanted to make food for your grandma who forgot her denthal prothesis at home you could devise a make_soft_food which operates on a list of Squishables and while many fruits and cheeses would fit the requirement nuts most likely would not unless you have some special equipment for that case. Thanks Michal _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
