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
Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-28 (03:21)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods

Le 28 févr. 07 ŕ 02:57, skaller a écrit :

> After all a nominal type is just a structural type with
> a unique tag representing its unique name.

What you miss here is the _process_ behind nominal types.

(paraphrasing Jacques) Types are not precise enough to define the  
semantic of a function, multiplication and addition have the same  
type but in many cases you cannot exchange one for the other. With  
that respect structural typing is a fallacy, it is not because types  
match that you can replace a function by another.

With a nominal type the programmer signals explicitely its intent to  
support a semantic. Notably you cannot use a function in a given  
context if it was not designed for that purpose which sounds  
fascistic but makes sense from a software development point of view.

Structural typing would make sense if it involved the weakest  
invariants a function. But for now, because of the poor information  
types give about semantics, structural typing is just bureaucratic  
compliance whereas nominal typing is a semantic contract --- whether  
actually fulfilled or not is another (undecidable) question.