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
Another polymorphism puzzle
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-04-01 (10:51)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Another polymorphism puzzle
Jacques Garrigue wrote:
> From: Manos Renieris <er@cs.brown.edu>
>># let f x = { () with foo = 3};;                    
>>val f : 'a -> int t = <fun>
>># let f x = { 42 with foo = 3};; 
>>val f : 'a -> int t = <fun>
>>I think this qualifies as a bug. Especially since the documentation
>>says the expr on the left hand side of with has to be a record.
> What do you mean by worse? You just exhibit an immediate consequence
> of the typing of f below.

I think that "worse" here stands for "completely counterintuitive".

> Following the manual, the typing could be more restrictive, but the
> current typing is perfectly sound.
> Jacques Garrigue

I doubt that any one of us has every written buggy code like the 
examples in this thread, yet, it it ever happens out of pure thermal 
agitation in the PS2 cable, I would expect the type checker to track 
down such "unsound" code, even if it would not cause a segfault.


Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)

The FreerP Project