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 OAA20642; Wed, 6 Aug 2003 14:35:20 +0200 (MET DST) 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 OAA22555 for ; Wed, 6 Aug 2003 14:35:17 +0200 (MET DST) Received: from aibo.runbox.com (cujo.runbox.com [193.71.199.138]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76CZHf00809 for ; Wed, 6 Aug 2003 14:35:17 +0200 (MET DST) Received: from [10.9.9.9] (helo=fetch-bak.runbox.com) by lufsen.runbox.com with esmtp (Exim 4.20) id 19kNVc-00079O-Cs for caml-list@inria.fr; Wed, 06 Aug 2003 14:35:16 +0200 Received: from [213.58.40.48] (helo=James) (Authenticated Sender=j.scott@runbox.com) by fetch-bak.runbox.com with asmtp (Exim 4.20) id 19kNVb-0000ry-9b for caml-list@inria.fr; Wed, 06 Aug 2003 14:35:15 +0200 From: "James Scott" To: Subject: [Caml-list] Unix.kill on Win32 Date: Wed, 6 Aug 2003 13:35:08 +0100 Message-ID: <000201c35c17$2cefc4a0$0300a8c0@James> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0003_01C35C1F.8EB42CA0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Sender: 160313 X-Loop: caml-list@inria.fr X-Spam: no; 0.12; runbox:99 32,:01 unix:02 arial:95 kill:09 message:89 U4:88 sensible:12 multi-part:83 win:18 possible:18 mime:77 some:23 scott:25 com:73 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0003_01C35C1F.8EB42CA0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi All, Would it be possible/sensible to have some limited implementation of Unix.kill for Win32, so that 'kill pid 9' or 'kill pid 15' worked for example? James ------=_NextPart_000_0003_01C35C1F.8EB42CA0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

 

Hi All, =

 

Would it be possible/sensible to have some limited = implementation of Unix.kill for Win32, so that ‘kill pid 9’ or ‘kill pid 15’ worked for example?

 

James =

------=_NextPart_000_0003_01C35C1F.8EB42CA0-- ------------------- 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 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 OAA26797; Wed, 6 Aug 2003 14:56:55 +0200 (MET DST) 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 OAA23833 for ; Wed, 6 Aug 2003 14:56:54 +0200 (MET DST) Received: from thsun1.jinr.ru (thsun1.jinr.ru [159.93.130.2]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76Curf02553 for ; Wed, 6 Aug 2003 14:56:54 +0200 (MET DST) Received: from 159.93.130.65 (pc7004 [159.93.130.65]) by thsun1.jinr.ru (Postfix) with ESMTP id 92ADB2062E for ; Wed, 6 Aug 2003 16:56:53 +0400 (MSD) From: Vovka Organization: =?utf-8?b?0YHQsNC8INC/0L4=?= =?utf-8?b?INGB0LXQsdC1?= To: caml-list@inria.fr Subject: [Caml-list] static class member.... Date: Wed, 6 Aug 2003 16:57:26 +0400 User-Agent: KMail/1.5.3 References: <000201c35c17$2cefc4a0$0300a8c0@James> In-Reply-To: <000201c35c17$2cefc4a0$0300a8c0@James> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200308061657.26300.jove@newmail.ru> X-Loop: caml-list@inria.fr X-Spam: no; 0.00; newmail:99 newbie:01 ocaml:01 objects:02 static:06 programming:07 i'm:07 faced:09 i've:09 write:14 handle:14 common:16 lot:18 please:79 could:20 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi!!!! Could you help me please. I'm newbie in ocaml programming, i used to write programmes in C++ , so I've faced difficulties in introducing static class member(==a common member for all objects of the same class). Can i handle it in ocaml? Thanks a lot. ------------------- 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 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 QAA21899; Wed, 6 Aug 2003 16:45:27 +0200 (MET DST) 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 QAA24959 for ; Wed, 6 Aug 2003 16:45:25 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76EjPf09593 for ; Wed, 6 Aug 2003 16:45:25 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19kPXX-0007iw-00; Wed, 06 Aug 2003 15:45:23 +0100 Date: Wed, 6 Aug 2003 15:45:23 +0100 To: Vovka Cc: caml-list@inria.fr Subject: Re: [Caml-list] static class member.... Message-ID: <20030806144523.GA29653@redhat.com> References: <000201c35c17$2cefc4a0$0300a8c0@James> <200308061657.26300.jove@newmail.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200308061657.26300.jove@newmail.ru> User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 0400,:01 newbie:01 foo:01 incr:01 printf:01 freshmeat:01 ltd:98 ocaml:01 06,:02 objects:02 business:96 wrote:03 obj:03 object:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 04:57:26PM +0400, Vovka wrote: > Hi!!!! > > Could you help me please. I'm newbie in ocaml programming, i used to write > programmes in C++ , so I've faced difficulties in introducing static > class member(==a common member for all objects of the same class). Can i > handle it in ocaml? Thanks a lot. This is one way to do it, there might be other easier ways: class foo = let counter = ref 0 in object (self) method incr = counter := !counter + 1 method show = Printf.printf "counter = %d\n" !counter end let () = let obj1 = new foo in let obj2 = new foo in obj1#incr; obj2#incr; obj1#show; obj2#show There is an ocaml-beginners list for these sorts of questions, and I've written a tutorial here: http://merjis.com/richj/computers/ocaml/tutorial/ Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. "My karma ran over your dogma" ------------------- 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 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 QAA02315; Wed, 6 Aug 2003 16:51:56 +0200 (MET DST) 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 QAA20737 for ; Wed, 6 Aug 2003 16:51:54 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76Eprf10144 for ; Wed, 6 Aug 2003 16:51:53 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19kPdk-0007c6-00; Wed, 06 Aug 2003 07:51:48 -0700 Date: Wed, 6 Aug 2003 07:51:48 -0700 From: David Brown To: Richard Jones Cc: Vovka , caml-list@inria.fr Subject: Re: [Caml-list] static class member.... Message-ID: <20030806145148.GA29231@davidb.org> References: <000201c35c17$2cefc4a0$0300a8c0@James> <200308061657.26300.jove@newmail.ru> <20030806144523.GA29653@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806144523.GA29653@redhat.com> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 0400,:01 newbie:01 foo:01 separates:01 ocaml:01 06,:02 modules:02 objects:02 module:03 dave:03 wrote:03 let:04 namespace:04 aug:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 03:45:23PM +0100, Richard Jones wrote: > On Wed, Aug 06, 2003 at 04:57:26PM +0400, Vovka wrote: > > Hi!!!! > > > > Could you help me please. I'm newbie in ocaml programming, i used to write > > programmes in C++ , so I've faced difficulties in introducing static > > class member(==a common member for all objects of the same class). Can i > > handle it in ocaml? Thanks a lot. > > This is one way to do it, there might be other easier ways: > > class foo = > let counter = ref 0 in But this counter will be unique for each new instance of the class. What they are really asking for is something like let counter = ref 0 class foo = ... counter ... There is only one counter, globally. Remember, Ocaml separates the namespace management (modules) from the class system. It is easy to hide "counter" with the module spec. Dave ------------------- 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 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 RAA30937; Wed, 6 Aug 2003 17:11:36 +0200 (MET DST) 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 RAA30664 for ; Wed, 6 Aug 2003 17:11:35 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76FBYf11252 for ; Wed, 6 Aug 2003 17:11:34 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19kPwC-0007mS-00; Wed, 06 Aug 2003 16:10:52 +0100 Date: Wed, 6 Aug 2003 16:10:51 +0100 To: David Brown Cc: Vovka , caml-list@inria.fr Subject: Re: [Caml-list] static class member.... Message-ID: <20030806151051.GB29704@redhat.com> References: <000201c35c17$2cefc4a0$0300a8c0@James> <200308061657.26300.jove@newmail.ru> <20030806144523.GA29653@redhat.com> <20030806145148.GA29231@davidb.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806145148.GA29231@davidb.org> User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 0400,:01 newbie:01 foo:01 freshmeat:01 autoconf:01 automake:01 compiles:01 rpms:01 ltd:98 ocaml:01 0700,:01 06,:02 objects:02 business:96 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 07:51:48AM -0700, David Brown wrote: > On Wed, Aug 06, 2003 at 03:45:23PM +0100, Richard Jones wrote: > > On Wed, Aug 06, 2003 at 04:57:26PM +0400, Vovka wrote: > > > Hi!!!! > > > > > > Could you help me please. I'm newbie in ocaml programming, i used to write > > > programmes in C++ , so I've faced difficulties in introducing static > > > class member(==a common member for all objects of the same class). Can i > > > handle it in ocaml? Thanks a lot. > > > > This is one way to do it, there might be other easier ways: > > > > class foo = > > let counter = ref 0 in > > But this counter will be unique for each new instance of the class. Not so. Run my code & you'll see it works. Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ ------------------- 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 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 SAA25736; Wed, 6 Aug 2003 18:12:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA24242 for ; Wed, 6 Aug 2003 18:12:28 +0200 (MET DST) Received: from mail.speakeasy.net (mail13.speakeasy.net [216.254.0.213]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h76GCQT12717 for ; Wed, 6 Aug 2003 18:12:27 +0200 (MET DST) Received: (qmail 11256 invoked from network); 6 Aug 2003 16:12:24 -0000 Received: from unknown (HELO grace.speakeasy.org) ([216.254.0.2]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 6 Aug 2003 16:12:24 -0000 Date: Wed, 6 Aug 2003 09:12:24 -0700 (PDT) From: brogoff@speakeasy.net To: Richard Jones cc: David Brown , Vovka , "caml-list@inria.fr" Subject: Re: [Caml-list] static class member.... In-Reply-To: <20030806151051.GB29704@redhat.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 caml-list:01 foo:01 struct:01 incr:01 0400,:01 newbie:01 freshmeat:01 autoconf:01 automake:01 compiles:01 rpms:01 bug:01 faq:01 beginner's:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Yes, it says in the language introduction (the part on objects) Let-bindings within class definitions are evaluated before the object is constructed so using a class local let bound ref works if you want the member to be unique on a per class basis. If you'd like the counter to apply to a class and everything that inherits from it, then you use module level let's like so module Foo = struct let counter = ref 0 class c = object method get () = !counter method bump () = incr counter end end;; A non-orthogonality of the let within a class is that let module isn't permitted. Is there any reason it isn't? As a side advice to the OP, it would be worthwhile to avoid the OOP and just get used to the ML part of Caml first. -- Brian On Wed, 6 Aug 2003, Richard Jones wrote: > On Wed, Aug 06, 2003 at 07:51:48AM -0700, David Brown wrote: > > On Wed, Aug 06, 2003 at 03:45:23PM +0100, Richard Jones wrote: > > > On Wed, Aug 06, 2003 at 04:57:26PM +0400, Vovka wrote: > > > > Hi!!!! > > > > > > > > Could you help me please. I'm newbie in ocaml programming, i used to write > > > > programmes in C++ , so I've faced difficulties in introducing static > > > > class member(==a common member for all objects of the same class). Can i > > > > handle it in ocaml? Thanks a lot. > > > > > > This is one way to do it, there might be other easier ways: > > > > > > class foo = > > > let counter = ref 0 in > > > > But this counter will be unique for each new instance of the class. > > Not so. Run my code & you'll see it works. > > Rich. > > -- > Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj > Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. > MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, > RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ > > ------------------- > 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 > ------------------- 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 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 SAA12248; Wed, 6 Aug 2003 18:27:53 +0200 (MET DST) 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 SAA24712 for ; Wed, 6 Aug 2003 18:27:52 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76GRpf15677 for ; Wed, 6 Aug 2003 18:27:51 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19kR5a-0007kj-00; Wed, 06 Aug 2003 09:24:38 -0700 Date: Wed, 6 Aug 2003 09:24:38 -0700 From: David Brown To: Richard Jones Cc: David Brown , Vovka , caml-list@inria.fr Subject: Re: [Caml-list] static class member.... Message-ID: <20030806162438.GB29738@davidb.org> References: <000201c35c17$2cefc4a0$0300a8c0@James> <200308061657.26300.jove@newmail.ru> <20030806144523.GA29653@redhat.com> <20030806145148.GA29231@davidb.org> <20030806151051.GB29704@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806151051.GB29704@redhat.com> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 foo:01 invocation:01 06,:02 dave:03 wrote:03 let:04 aug:05 arg:06 static:06 0100,:08 davidb:08 function:09 david:09 wed:12 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 04:10:51PM +0100, Richard Jones wrote: > > > class foo = > > > let counter = ref 0 in Now I remember why I thought that wouldn't work. class foo arg = let counter = ref 0 in ... would get a new counter instance each time the class is invoked. This acts as a function wrapped around the class invocation. Dave ------------------- 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 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 TAA02373; Wed, 6 Aug 2003 19:44:07 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA04746 for ; Wed, 6 Aug 2003 19:44:05 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h76Hi5T15516 for ; Wed, 6 Aug 2003 19:44:05 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19kSJu-000815-00; Wed, 06 Aug 2003 18:43:30 +0100 Date: Wed, 6 Aug 2003 18:43:30 +0100 To: brogoff@speakeasy.net Cc: David Brown , Vovka , "caml-list@inria.fr" Subject: Re: [Caml-list] static class member.... Message-ID: <20030806174330.GA30804@redhat.com> References: <20030806151051.GB29704@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 brogoff:01 bug:01 freshmeat:01 ltd:98 compiler:01 irrelevant:01 0700,:01 speakeasy:01 06,:02 objects:02 business:96 wrote:03 object:03 data:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 09:12:24AM -0700, brogoff@speakeasy.net wrote: > Yes, it says in the language introduction (the part on objects) > > Let-bindings within class definitions are evaluated before the object > is constructed Well I take it back. And I must admit that I always have used let-bindings as if they are local to the instance. The question though is why does my example work? Is this a bug in the compiler? Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. All new technology is irrelevant until it is taken up by the public. ------------------- 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 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 UAA32220; Wed, 6 Aug 2003 20:12:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA30299 for ; Wed, 6 Aug 2003 20:11:57 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h76IBsT16539 for ; Wed, 6 Aug 2003 20:11:55 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19kSlI-00081N-00; Wed, 06 Aug 2003 11:11:48 -0700 Date: Wed, 6 Aug 2003 11:11:48 -0700 From: David Brown To: Richard Jones Cc: brogoff@speakeasy.net, David Brown , Vovka , "caml-list@inria.fr" Subject: Re: [Caml-list] static class member.... Message-ID: <20030806181148.GA30782@davidb.org> References: <20030806151051.GB29704@redhat.com> <20030806174330.GA30804@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806174330.GA30804@redhat.com> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 brogoff:01 bug:01 compiler:01 ocaml:01 0700,:01 speakeasy:01 06,:02 objects:02 module:03 behaves:03 dave:03 classes:03 wrote:03 argument:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 06:43:30PM +0100, Richard Jones wrote: > On Wed, Aug 06, 2003 at 09:12:24AM -0700, brogoff@speakeasy.net wrote: > > Yes, it says in the language introduction (the part on objects) > > > > Let-bindings within class definitions are evaluated before the object > > is constructed > > Well I take it back. And I must admit that I always have used > let-bindings as if they are local to the instance. > > The question though is why does my example work? Is this a bug > in the compiler? It works because there are no arguments to the class. In that case, the class is evaluated once, when that part of the module is evaluated. If there is an argument to the class, it behaves as if the entire class definition were wrapped in a function definition. Therefore it can't evaluate things inside until the function is fully evaluated. Creating objects of classes is an unusual thing in ocaml, since it is like a function application of zero arguments. What's scary is that I've been bitten by this several times, and still manage to forget it. Dave ------------------- 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 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 UAA31670; Wed, 6 Aug 2003 20:14:43 +0200 (MET DST) 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 UAA31004 for ; Wed, 6 Aug 2003 20:14:41 +0200 (MET DST) Received: from mwinf0601.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.25]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76IEff23196 for ; Wed, 6 Aug 2003 20:14:41 +0200 (MET DST) Received: from warp (ABordeaux-103-1-26-151.w193-252.abo.wanadoo.fr [193.252.175.151]) by mwinf0601.wanadoo.fr (SMTP Server) with SMTP id 5CE2A340011A; Wed, 6 Aug 2003 20:14:40 +0200 (CEST) Message-ID: <005b01c35c46$a466ea20$2b00a8c0@warp> From: "Nicolas Cannasse" To: , "Richard Jones" Cc: "David Brown" , "Vovka" , References: <20030806151051.GB29704@redhat.com> <20030806174330.GA30804@redhat.com> Subject: Re: [Caml-list] static class member.... Date: Wed, 6 Aug 2003 20:14:47 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 bug:01 foo:01 accessors:01 incr:01 printf:01 compiler:01 ocaml:01 nicolas:01 objects:02 variable:03 object:03 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Yes, it says in the language introduction (the part on objects) > > > > Let-bindings within class definitions are evaluated before the object > > is constructed > > Well I take it back. And I must admit that I always have used > let-bindings as if they are local to the instance. > > The question though is why does my example work? Is this a bug > in the compiler? It's not a bug. You can see your class as function to get a better idea of what's happenning : let foo = let x = ref 0 in (fun () -> !x) against : let foo () = let x = ref 0 in !x To answer to the original post about class static, there is no concept of static class variables in Ocaml , but you can still write accessors to a variable declared outside the class scope : let counter = ref 0 class foo = object method incr = incr counter method print = Printf.printf "counter = %d\n" !counter end Nicolas Cannasse ------------------- 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 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 UAA05282; Wed, 6 Aug 2003 20:30:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA01961 for ; Wed, 6 Aug 2003 20:30:57 +0200 (MET DST) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h76IUuT16994 for ; Wed, 6 Aug 2003 20:30:56 +0200 (MET DST) Received: from force.stwing.upenn.edu (root@force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (8.12.9/8.12.9) with ESMTP id h76IUsgZ022742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Aug 2003 14:30:55 -0400 (EDT) Received: from force.stwing.upenn.edu (wlovas@[127.0.0.1]) by force.stwing.upenn.edu (8.12.9/8.12.9) with ESMTP id h76IUr4Q024037 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Aug 2003 14:30:54 -0400 (EDT) Received: (from wlovas@localhost) by force.stwing.upenn.edu (8.12.9/8.12.9/Submit) id h76IUrun024036 for caml-list@inria.fr; Wed, 6 Aug 2003 14:30:53 -0400 (EDT) Date: Wed, 6 Aug 2003 14:30:53 -0400 From: William Lovas To: "caml-list@inria.fr" Subject: Re: [Caml-list] static class member.... Message-ID: <20030806183052.GA23352@force.stwing.upenn.edu> Mail-Followup-To: "caml-list@inria.fr" References: <20030806151051.GB29704@redhat.com> <20030806174330.GA30804@redhat.com> <20030806181148.GA30782@davidb.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806181148.GA30782@davidb.org> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lovas:01 wlovas:01 stwing:01 caml-list:01 bug:01 instructive:01 new':99 foo:01 incr:01 val:01 closures:01 compiler:01 ocaml:01 0700,:01 closure:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 11:11:48AM -0700, David Brown wrote: > On Wed, Aug 06, 2003 at 06:43:30PM +0100, Richard Jones wrote: > > The question though is why does my example work? Is this a bug > > in the compiler? > [...] > > Creating objects of classes is an unusual thing in ocaml, since it is > like a function application of zero arguments. Yes, i've just been playing around with it. It's somewhat instructive to limit yourself to the core language, and consider instantiation via `new' to be something like applying a function whose first argument is (). For a class with no arguments, e.g. something like, class foo = let counter = ref 0 in object method next () = incr counter; !counter end the equivalent in the core language might be something like the following interaction: # let new_counter = let counter = ref 0 in fun () -> fun () -> (incr counter; !counter);; val new_counter : unit -> unit -> int = # let count1 = new_counter ();; val count1 : unit -> int = # let count2 = new_counter ();; val count2 : unit -> int = # count1 ();; - : int = 1 # count2 ();; - : int = 2 # count1 ();; - : int = 3 where new_counter's first unit parameter is something like `new'. But for classes that take arguments, as in class foo x = let counter = ref 0 in object method next () = incr counter; !counter end the special initial unit parameter gets lifted up to the top, with the other argument: # let new_counter () x = let counter = ref 0 in fun () -> (incr counter; !counter);; val new_counter : unit -> 'a -> unit -> int = # let count1 = new_counter () "(unused)";; val count1 : unit -> int = # let count2 = new_counter () "(unused)";; val count2 : unit -> int = # count1 ();; - : int = 1 # count2 ();; - : int = 1 # count1 ();; - : int = 2 (Note that the "class parameter" `x' is unused in both examples.) When translated into this core language representation, it's syntactically apparent why the counter is local to each "object" in one case and global to all "objects" in the other -- in the first case, `counter's scope is the closure that creates new "objects" (which are also closures), while in the second, it is local to each "object" (each new closure gets its own copy). Using this knowledge, it's possible to create a class with a parameter that keeps the counter global to all instances: class foo = let counter = ref 0 in fun x -> object method next () = incr counter; !counter end Maybe there's a better explanation, but viewed this way, the syntax for class definitions -- or at least the syntactic sugar -- is somewhat idiosyncratic. cheers, William ------------------- 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 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 CAA11779; Thu, 7 Aug 2003 02:13:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA01060 for ; Thu, 7 Aug 2003 02:13:01 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h770CxT25529 for ; Thu, 7 Aug 2003 02:13:00 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id JAA10641; Thu, 7 Aug 2003 09:12:53 +0900 (JST) To: brogoff@speakeasy.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] static class member.... In-Reply-To: References: <20030806151051.GB29704@redhat.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030807091253T.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 07 Aug 2003 09:12:53 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; jacques:01 caml-list:01 brogoff:01 speakeasy:01 garrigue:01 module:03 typing:03 classes:03 let:04 implement:05 static:06 kurims:06 indeed:06 unfortunate:06 usual:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: brogoff@speakeasy.net > A non-orthogonality of the let within a class is that let module isn't > permitted. Is there any reason it isn't? This is indeed unfortunate, and I've wished for its presence several times. I don't think there is a theoretical reason. However the typing of classes being done in several passes, this would be much more difficult to implement correctly than the let module inside usual expressions. Jacques Garrigue ------------------- 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 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 CAA13161; Thu, 7 Aug 2003 02:21:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA12194 for ; Thu, 7 Aug 2003 02:21:43 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h770LgT25752 for ; Thu, 7 Aug 2003 02:21:42 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id JAA10767; Thu, 7 Aug 2003 09:21:37 +0900 (JST) To: j.scott@runbox.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Unix.kill on Win32 In-Reply-To: <000201c35c17$2cefc4a0$0300a8c0@James> References: <000201c35c17$2cefc4a0$0300a8c0@James> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030807092137N.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 07 Aug 2003 09:21:37 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; jacques:01 caml-list:01 runbox:99 32,:01 api:01 ocamlrun:01 dynamically:01 dlls:01 ctrl-c:01 garrigue:01 unix:02 thread:02 module:03 suppose:03 receiving:96 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: "James Scott" > Would it be possible/sensible to have some limited implementation of > Unix.kill for Win32, so that 'kill pid 9' or 'kill pid 15' worked for > example? I may be wrong, but when I looked at the problem about 5 years ago, I couldn't find any way to act on a windows process from outside it. The process manager must be using some internal API. The only solution I found for ocamlbrowser is to have ocamlrun create a special thread waiting on a pipe, and break when receiving C on this pipe, and commit suicide when receiving T! This only works if you can modify the source of the process you want to kill, so this cannot be in the Unix module. Now, as it seems that you can dynamically change the dlls a running process is accessing, I suppose you could also do it without the source code, if you're a guru. By the way, the comment in the microsoft documentation about Ctrl-C handlers being activated in another thread in console applications let me think that this is more or less the standard way to do it on windows :-( I hope I am wrong. Jacques Garrigue ------------------- 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 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 CAA15578; Thu, 7 Aug 2003 02:41:25 +0200 (MET DST) 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 CAA07208 for ; Thu, 7 Aug 2003 02:41:24 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h770fMf12880 for ; Thu, 7 Aug 2003 02:41:22 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id JAA11091; Thu, 7 Aug 2003 09:41:17 +0900 (JST) To: j.scott@runbox.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Unix.kill on Win32 In-Reply-To: <20030807092137N.garrigue@kurims.kyoto-u.ac.jp> References: <000201c35c17$2cefc4a0$0300a8c0@James> <20030807092137N.garrigue@kurims.kyoto-u.ac.jp> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030807094116O.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 07 Aug 2003 09:41:16 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; jacques:01 caml-list:01 32,:01 api:01 followup:01 garrigue:01 unix:02 functions:05 seems:05 kurims:06 problem:07 signals:08 kill:09 iirc:09 kyoto-u:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Jacques Garrigue > > Would it be possible/sensible to have some limited implementation of > > Unix.kill for Win32, so that 'kill pid 9' or 'kill pid 15' worked for > > example? > > I may be wrong, but when I looked at the problem about 5 years ago, I > couldn't find any way to act on a windows process from outside it. > The process manager must be using some internal API. Just a small followup to myself: after a quick search on the web, there seems to be two functions, TerminateProcess and GenerateConsoleControlEvent, but making them work like signals is far from easy. IIRC TerminateProcess on Windows95--ME may sometimes break the OS. Jacques Garrigue ------------------- 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 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 HAA06932; Thu, 7 Aug 2003 07:20:50 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA17603 for ; Thu, 7 Aug 2003 07:20:48 +0200 (MET DST) Received: from wetware.com (wetware.wetware.com [199.108.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h775KlT02681 for ; Thu, 7 Aug 2003 07:20:47 +0200 (MET DST) Received: from 208.177.152.18.ptr.us.xo.net ([208.177.152.18] helo=wetware.com) by wetware.com with esmtp (Exim 4.20) id 19kdCf-0003Fn-LL; Wed, 06 Aug 2003 22:20:45 -0700 Date: Wed, 6 Aug 2003 22:20:44 -0700 Subject: Re: [Caml-list] static class member.... Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: Ocaml Beginners To: The Trade From: james woodyatt In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; woodyatt:01 jhw:01 wetware:01 caml-list:01 beginners:01 brogoff:01 functors:01 avoiding:01 variance:01 annotations:01 newbie:01 village:99 ocaml:01 caml:01 speakeasy:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk [please reply to ocaml_beginners@yahoogroups.com] On Wednesday, Aug 6, 2003, at 09:12 US/Pacific, on the main Ocaml mailing list, brogoff@speakeasy.net wrote: > > As a side advice to the OP, it would be worthwhile to avoid the OOP > and just > get used to the ML part of Caml first. I would strongly second this advice. When I came to Ocaml from C++, I did not heed this advice-- and I wasted a lot of time learning why that was a mistake. In fact, the first piece of advice I would pass along to Java/C++ programmers who are new to Ocaml is this: + Don't use classes unless functors and module inclusion fail to satisfy your requirements. There are many fine ways to obtain the kinds of relationships in the Ocaml type system that C++ and Java both only use classes to offer. In Ocaml, the object class and class type semantic is only one of the ways to skin a particular kind of cat. It's not, in fact, the most straightforward one either. Until you understand the tradeoffs for choosing it, I recommend avoiding it. You can do *almost* everything with 'functor' and 'include' and/or phantom polymorphic variant type parameters on abstract types with parameter variance annotations. That said, the class and class type semantic is an indispensable aspect of the language, from my point of view. It's just not very easy explaining why I say that to a newbie. -- j h woodyatt that's my village calling... no doubt, they want their idiot back. ------------------- 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 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 TAA30402; Thu, 7 Aug 2003 19:02:26 +0200 (MET DST) 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 TAA27298 for ; Thu, 7 Aug 2003 19:02:24 +0200 (MET DST) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h77H2Mf15775 for ; Thu, 7 Aug 2003 19:02:23 +0200 (MET DST) Received: (qmail 18265 invoked from network); 7 Aug 2003 17:02:19 -0000 Received: from unknown (HELO grace.speakeasy.org) ([216.254.0.2]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 7 Aug 2003 17:02:19 -0000 Date: Thu, 7 Aug 2003 10:02:19 -0700 (PDT) From: brogoff@speakeasy.net To: james woodyatt cc: The Trade , Ocaml Beginners Subject: Re: [Caml-list] static class member.... In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 caml-list:01 g'caml:01 modula-:01 woodyatt:01 beginners:01 functors:01 avoiding:01 variance:01 annotations:01 newbie:01 jhw:01 wetware:01 village:99 bug:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I think that my issue with the class system is that IMO it doesn't quite fit well with the rest of the language, as a class shares some properties with modules, and some with records, and has a few of it's own, but doesn't permit pattern matching syntax. With a few extensions to records (a new kind of records, dual to polymorphic variants as sum types are to records), modules (first class modules?, mixin modules?), and core ML (yes, I'm still rooting for G'Caml extensions :) that even OOP fans would find it classy sans class. Even without those extensions, I find the core language + modules sufficient to do almost everything nicely, but my pre "ML epiphany" tastes ran towards Modula-2/3 and Ada 95 rather than C++ so I may just be warped... -- Brian On Wed, 6 Aug 2003, james woodyatt wrote: > [please reply to ocaml_beginners@yahoogroups.com] > > On Wednesday, Aug 6, 2003, at 09:12 US/Pacific, on the main Ocaml > mailing list, brogoff@speakeasy.net wrote: > > > > As a side advice to the OP, it would be worthwhile to avoid the OOP > > and just > > get used to the ML part of Caml first. > > I would strongly second this advice. When I came to Ocaml from C++, I > did not heed this advice-- and I wasted a lot of time learning why that > was a mistake. > > In fact, the first piece of advice I would pass along to Java/C++ > programmers who are new to Ocaml is this: > > + Don't use classes unless functors and module inclusion fail to > satisfy your requirements. > > There are many fine ways to obtain the kinds of relationships in the > Ocaml type system that C++ and Java both only use classes to offer. In > Ocaml, the object class and class type semantic is only one of the ways > to skin a particular kind of cat. It's not, in fact, the most > straightforward one either. Until you understand the tradeoffs for > choosing it, I recommend avoiding it. You can do *almost* everything > with 'functor' and 'include' and/or phantom polymorphic variant type > parameters on abstract types with parameter variance annotations. > > That said, the class and class type semantic is an indispensable aspect > of the language, from my point of view. It's just not very easy > explaining why I say that to a newbie. > > > -- > j h woodyatt > that's my village calling... no doubt, they want their idiot back. > > ------------------- > 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 > ------------------- 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 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 XAA08620; Thu, 7 Aug 2003 23:53:32 +0200 (MET DST) 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 XAA01274 for ; Thu, 7 Aug 2003 23:53:30 +0200 (MET DST) Received: from mail1.tpgi.com.au (mail.tpgi.com.au [203.12.160.57]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h77LrSf01502 for ; Thu, 7 Aug 2003 23:53:29 +0200 (MET DST) Received: from ozemail.com.au (203-213-127-88-syd-ts20-2600.tpgi.com.au [203.213.127.88]) (authenticated (0 bits)) by mail1.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h77LrOo03235; Fri, 8 Aug 2003 07:53:24 +1000 Message-ID: <3F32CA53.4090505@ozemail.com.au> Date: Fri, 08 Aug 2003 07:53:23 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: caml-list@inria.fr CC: ocaml_beginners@yahoogroups.com Subject: Re: [Caml-list] static class member.... References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ozemail:01 caml-list:01 woodyatt:01 stupid:01 abstracted:01 abstraction:01 ocamldoc:01 sensibly:01 non-trivial:01 encapsulate:01 abstractions:01 toxteth:01 glebe:01 2037,:01 9660:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk james woodyatt wrote: > I would strongly second this advice. When I came to Ocaml from C++, I > did not heed this advice-- and I wasted a lot of time learning why that > was a mistake. Actaully, my advice to C++ programmers is the same :-) Don't use classes. Plain old data structures are generally better -- precisely because they *don't* provide encapsulation. This saves a whole lot of time writing methods, when you could just manipulate the data structure directly. Just kill off stupid Visitor patterns and things and write the code you need without encumbering yourself with attempts to abstract things that usually aren't abstract in the first place. In most business code, even the kinds which are in principle abstractable are often best not abstracted simply because there aren't enough instances of the abstraction to bother, and the client is sure to change the rules and break your polymorphism anyhow :-) An example where abstraction is useful: the back end of a code generator (such as Ocaml itself, or Ocamldoc), can sensibly be abstracted. However getting the abstraction just right is a non-trivial exercise and it's often better to do case by case encoding until the actual abstraction emerges in the code itself (and then you can encapsulate it). To put this another way -- don't use abstractions unless you have a strong theory that tells you what they actually are, and even then, be circumspect ... -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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