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
equality between functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1994-08-15 (10:04)
From: Martin Mueller <mmueller@d...>
Subject: equality between functions
I am just wondering, why CAML light decided to allow for 

#let g x = x in g=g;;

to succeed with 

-: bool = true

but fail on (eg) 

#(function x -> x) = (function x -> x);;
Uncaught exception: Invalid_argument "equal: functional value"

I understand that there are reasons to avoid 
equality between functions, but then should not equality and
inequality be handled symmetrically?
For instance, SML/NJ does so and fails on 

- let fun g x= x in g=g end;

std_in:0.0-0.0 Error: operator and operand don't agree (equality type required)
  operator domain: ''Z * ''Z
  operand:         ('Y -> 'Y) * ('X -> 'X)
  in expression:
    = (g,g)

Could someone shed some light onto that issue? I would also 
be interested in pointers to the literature on that topic.
Is there a basic reference on equality types? 

-- Martin M"uller

Martin M"uller,   DFKI,  Stuhlsatzenhausweg 3,  D-66123 Saarbruecken,   Germany
Tel: +49 681 302-5329;   Fax: +49 681 302-5341;    Net: mmueller@dfki.uni-sb.de