
20 Nov
2005
20 Nov
'05
10:21 a.m.
Am Samstag, 19. November 2005 17:35 schrieb Bulat Ziganshin:
[...]
7. OOP-like fields inheritance:
data Coord = { x,y :: Double } data Point : Coord = { c :: Color }
of course this is just another sort of syntax sugar once we start using classes to define getter/setter functions
I thought that even many OO people say that inheritance of fields is not good practice. So why should we want to support it? A point is not a special coordinate pair. Instead it has a coordinate paar as one of its properties. So the above-mentioned problem would be better handled this way: data Coord { x, y :: Double } data Point = Point {coord :: Coord, c :: Color }
[...]
Best wishes, Wolfgang