Browse thread
[Caml-list] Sumtypes of records
[
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: | Marcin 'Qrczak' Kowalczyk <qrczak@k...> |
| Subject: | Re: [Caml-list] Sumtypes of records |
Dnia sob 17. maja 2003 03:35, Chris Hecker napisa³:
> It has type { age : int; }, just like int * int has type int * int and
> doesn't need a name. Does the record need a name for some other reason?
let foo x = x.bar
What is the type of foo if there is no named record in scope having field bar?
I don't say that I like it but it's a consequence of the OCaml's type system.
Haskell has that too (but theoretically type classes could be made to help).
SML is what you would like; it has sort of overloading of certain builtin
operations and in this case requires the type of x to be statically known
somehow. There is no problem with dynamically typed languages, and
"non-functional" statically typed ones require to explicitly write the type
of bound variables anyway. Having the same field name in various record
types just doesn't mix well with type inference.
--
__("< Marcin Kowalczyk
\__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners