English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Void type?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-07-28 (18:53)
From: Basile STARYNKEVITCH <basile@s...>
Subject: Re: [Caml-list] Void type?
Stefan Monnier wrote:
>>> Is there a void type in OCaml (i.e. a type which has no values), or a way to
>>> simulate it?
>> If you're looking for a "true" void (as opposed to the unit type,
>> which has exactly one value), just declaring it as an abstract type:
>> type void
>> should do the trick.  You will be unable to instantiate any values of
>> that type using pure O'Caml (i.e. no Obj.magic or C code).
> But can I pass [] to a function that expects a "void list"?

Yes. It is the only list of type void list.

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net | mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***