Version française
Home     About     Download     Resources     Contact us    
Browse thread
Smells like duck-typing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Stefano Zacchiroli <zack@b...>
Subject: Re: [Caml-list] Smells like duck-typing
On Wed, Oct 17, 2007 at 09:24:05PM +0100, Dario Teixeira wrote:
> ideas.  For the time being, I am going for the no-inheritance object solution:

Uhm sorry, why aren't you going for the object *with* inheritance
solution? The one you're proposing here is more lightweight than the
initial one due to the lack of option types, not due to the lack of
inheritance.

Can't you just go for:

  class blurb (id, title, intro) =
  object
          method id: int = id
          method title: string = title
          method intro: string = intro
  end

  class full (id, title, intro, body) =
  object
          inherit blurb (id, title, intro)
          method body: string = body
  end

that way you would also gain code reuse and can maybe define printing
functions on top of each other.

Cheers.

-- 
Stefano Zacchiroli -*- PhD in Computer Science ............... now what?
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
(15:56:48)  Zack: e la demo dema ?    /\    All one has to do is hit the
(15:57:15)  Bac: no, la demo scema    \/    right keys at the right time