From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA08690; Sun, 23 Feb 2003 23:08:50 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA08343 for ; Sun, 23 Feb 2003 23:08:49 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (host13-4.pool62211.interbusiness.it [62.211.4.13] (may be forged)) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1NM8mT11764 for ; Sun, 23 Feb 2003 23:08:48 +0100 (MET) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7E1072739B; Sun, 23 Feb 2003 23:12:59 +0100 (CET) Message-ID: <3E59476B.90006@baretta.com> Date: Sun, 23 Feb 2003 23:12:59 +0100 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Ford Lissett Cc: caml-list@inria.fr Subject: Re: [Caml-list] object single linked list - newbie References: <20030223215439.35663.qmail@web13103.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ford Lissett wrote: > I'm missing something really obvious here, please > explain - > > line 13, characters 17-22: > This expression has type node node_type > It has no method get_link > > > type 't node_type = Class of 't | Nil;; > Type node node_type is not an object type, hence it cannot have methods. Type node is an object type and has method get_link. You must match against the Class constructor to get the object on which you want to invoke get_link. > peek := !next#get_link; (* line 13 *) class node link_ = object (self) val mutable link: node node_type = link_ method add node_ = let next = ref link in let peek = ref link in while (!peek != Nil) do next := !peek; peek := match !next with | Class(obj) -> obj#get_link | Nil -> raise Not_found; (* line 13 *) done; link <- node_ method get_link = link end;; Alex ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners