Browse thread
How to do this properly with OCaml?
-
Thomas Fischbacher
- Christophe Dehlinger
- Berke Durak
- Michel Quercia
- Eric Cooper
-
Michael Alexander Hamburg
-
Xavier Leroy
- Berke Durak
- Michael Alexander Hamburg
- Thomas Fischbacher
- Alex Baretta
- skaller
- Thomas Fischbacher
-
Xavier Leroy
[
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: | Berke Durak <obdurak@f...> |
| Subject: | Re: [Caml-list] How to do this properly with OCaml? |
On Sat, Jul 23, 2005 at 09:36:47AM -0700, Stephane Glondu wrote:
> On Saturday 23 July 2005 06:16, Berke Durak wrote:
> > However I was wondering how feasible it would be to have a "any : 'a"
> > value, that would return an (unspecified) value of any given type...
>
> That seems to be dirty and would surely beak type safety.
>
> > This is clearly feasible for base types.
> > possible for tuples, records and functions of base types.
>
> What do you mean?
I mean that there could be a built-in, type-safe Ocaml function that would
yield a valid, yet arbitrary value of any type.
> > Recursive values could prove problematic :
> >
> > type stuff1 = { mutable a : stuff2 }
> > and stuff2 = { mutable b : stuff1 }
>
> What's the problem here? You can always define a dummy value of a given
> type:
>
> let rec dummy1 = { a = dummy2 } and dummy2 = { b = dummy1 }
Yes of course, but you may need to compute a path in a type dependency
graph.
> > Would it be worth the fuss ?
>
> I think that a better design (which doesn't need such hacks) would be
> worth.
That was my point. You could cleanly initialize your heap with that "any"
value.
--
Berke Durak