Browse thread
Smells like duck-typing
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Smells like duck-typing |
On Wed, 2007-10-17 at 16:13 +0100, Dario Teixeira wrote: > > I would use something weaker, and I wouldn't use objects > > either. To me, this is essentially a dynamic scenario, > > so the data type should be dynamic. For example: > > > > type field_t = [ > > | `Title of string > > | `Intro of string > > | `Body of string > > | `Field of string * string > > ] > > > > type story_t = field_t list > > > > Hi, > > Interesting idea, but how would you access the fields in a convenient > manner? let rec get_title ls = match ls with | `Title s :: _ -> s | _ ::t -> get_title t | [] -> raise Not_found (* sucks.. *) -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net