From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 2EF15BC69 for ; Sat, 4 Aug 2007 02:39:01 +0200 (CEST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l740cxQR001839 for ; Sat, 4 Aug 2007 02:39:00 +0200 Received: from localhost (rabbit-172 [172.16.254.254]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id l740cgLX010925; Sat, 4 Aug 2007 09:38:42 +0900 (JST) Date: Sat, 04 Aug 2007 09:38:42 +0900 (JST) Message-Id: <20070804.093842.2004166723.garrigue@math.nagoya-u.ac.jp> To: oliver@first.in-berlin.de Cc: caml-list@inria.fr Subject: Re: [Caml-list] Type notation in OO-layer From: Jacques GARRIGUE In-Reply-To: <1186176540.46b39e1c6f460@webmail.in-berlin.de> References: <1186175921.46b39bb1508b1@webmail.in-berlin.de> <1186176540.46b39e1c6f460@webmail.in-berlin.de> X-Mailer: Mew version 4.2 on Emacs 21.4 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46B3CAA3.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; notation:01 bandel:01 in-berlin:01 bandel:01 in-berlin:01 -function:01 meth:01 meth:01 lablgtk:01 accessors:01 mutable:01 syntax:01 mutable:01 oliver:01 oliver:01 From: Oliver Bandel > Zitat von Oliver Bandel : > > [...] > > As it is not a true "unit"-function, we at least should give it a > > unit-like type like "message -> string" so that the type-system > > make a complete annotation of type?! > > > OK, I had misleading thoughts here: not the method get's the message, > the object gets the message. > > So, the type of the function is OK. > But shouldn't the message be somewhere else notated? > > Or is this thrown out in general, when using OO? > > I sthere no contradiction, when using such a type annotation, > when comparing it to the non-OO stuff? The object-oriented view that objects "understand" messages is somewhat confusing, because it makes unclear where the code is. More directly, a method call is decoded as: obj#meth == obj.meth obj So, as you have correctly noted, since any method is getting the object itself as argument, any method call contains a function application, and the value it returns need not be always the same. However, this may also be confusing and/or not practical at times. For instance, what is the meaning of a method of type only "unit" ? The approach used in lablgtk for instance is to have all side-effecting methods take at least one argument. Taking unit as an argument is useful at times, for instance if you want to use it as a callback (i.e. if you want to make a closure of a method call). On the other hand, accessors to mutable values do not take unit as argument. This reflects the fact we use the same syntax for both mutable and immutable fields in records. While I think this distinction between side-effecting and non side-effecting methods is useful, there is no way to have the language verify it (you would have to know it for functions too...), and some people might not like the extra argument, so this is difficult to make it a hard rule. Jacques Garrigue