Browse thread
Void type?
[
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: | Arnaud Spiwack <arnaud.spiwack@g...> |
| Subject: | Re: [Caml-list] Re: Void type? |
Jon Harrop a écrit :
> On Sunday 29 July 2007 12:05:47 Arnaud Spiwack wrote:
>
>> It is the good solution if you work with the original syntax (and it's
>> absolutely equivalent to the dual definition in term of empty variant
>> which you can write in the revised syntax).
>>
>
> I don't quite understand this "empty variant from the revised syntax thing".
> How is:
>
> type void
>
> not an empty variant?
>
>
Well, not technically I believe. It's a type with no definition. I
wouldn't be adamant about that but I reckon it's not considered as a sum
type by OCaml type system.
Plus you cannot write the empty matching :
match x with []
in the original syntax, preventing you from writing a function of type
void -> 'a without using exceptions or Obj.magic or an obviously
looping function or such.
Thus it does not really have the logical behavior of an empty variant.
Arnaud Spiwack