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-08-01 (11:37)
From: Tom <tom.primozic@g...>
Subject: Re: [Caml-list] Re: Void type?
On 31/07/07, Brian Hurt <bhurt@spnz.org> wrote:
> So how do I use that module and say, in the type system, "I will never
> pass in a b"?  This is where the void type comes in.  I can declare:
> module Myreq = struct
>         type a = whatever;;
>         type b = void;;
> end;;
> module Myexample = Example(Myreq);;
> Note that I can still call function Myexample.foo- I can call it with an
> empty list, or with a list of as many A's as I want.  But it's impossible
> for me to create a B element.

I am still not convinced about the usability of the void type... Why simply
not declare type b as abstract?

module Myreq = struct
        type a = whatever
        type b

Essentially, it means the same, just less typing.

 - Tom