On functional, procedural and OO

Hum… I’m not sure I’m following you. You don’t need Objects for what you’re talking about, unless I misunderstood you. You just need some static type checker and a way to define user level types.

In Haskell for example:

data Car = Car {percent-full-of-tank :: Int
               , door-count :: Int
               , left-window-state :: WindowState
               , right-window-state :: WindowState}

closeLeftWindow :: Car -> Car
closeLeftWindow car = car { left-window-state = Closed }

So we defined a Car datatype, and there’s a function called closeLeftWindow that takes an argument of type Car and returns a new Car with the left-window-state field set to Closed.

But there’s no Objects involved, and the function closeLeftWindow is not contained together with the Car structure, this is only compiler information.

So all we have here is a function and some compiler type declarations and we can statically type check. No need for OO.

1 Like