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: | Ville-Pertti Keinonen <will@e...> |
| Subject: | Re: [Caml-list] Sumtypes of records |
> Why can't constructors of sumtypes take nameless records? (Warning
> stupid example follows)
>
> type plop = Foo | Bar {age : int};;
...
Probably because it wouldn't make much sense. Either the only way you
could access age in the above is by matching Bar { age = x }, which is
not very useful (you might as well have Bar of int, or a tuple for
multiple fields), or the record type needs to have a name so that x in
the pattern Bar x has some printable type.
-------------------
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