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 RAA26983; Thu, 26 Jul 2001 17:35:36 +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 RAA26979 for ; Thu, 26 Jul 2001 17:35:35 +0200 (MET DST) Received: from www.invert.com (invert.com [209.164.21.15]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f6QFZY500394 for ; Thu, 26 Jul 2001 17:35:34 +0200 (MET DST) Received: (from miles@localhost) by www.invert.com (8.10.1/8.10.1AA) id f6QFZOa65723; Thu, 26 Jul 2001 08:35:24 -0700 (PDT) (envelope-from miles) Date: Thu, 26 Jul 2001 08:35:24 -0700 From: Miles Egan To: Dave Berry Cc: caml-list@inria.fr Subject: Re: [Caml-list] a reckless proposal Message-ID: <20010726083524.B65526@caddr.com> References: <8E31D6933A2FE64F8AE3CC1381EEDCE70B2AEA@NT.kal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <8E31D6933A2FE64F8AE3CC1381EEDCE70B2AEA@NT.kal.com>; from Dave@kal.com on Wed, Jul 25, 2001 at 10:30:09AM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Jul 25, 2001 at 10:30:09AM +0100, Dave Berry wrote: > So perhaps Ocaml should adopt the approach used in Dylan and Moby, > where field names in class definitions have module scope. Then > records and objects would have similar scoping rules, instead of > the current clash, and the distinction between modules and objects > would be clearer. I suppose this is also similar to CLOS generics, right? I suppose this would be more consistent but perhaps even more confusing to people who've been writing ClassA.field and ClassB.field since the first day of their first Java class. > But if you then replace the field with an accessor method, you > have to edit all uses of that field. It's a common recommendation > that OO languages should only access field by accessor methods (or > at least use the same syntax as accessor methods). As you point > out, Ruby does it this way. Dylan and Eiffel are other examples. Ocaml could observe this protocol as well. This is valid code: class a = object val x = 1 method x = x end let _ = new a in a#x So a "macro" like attr_r could transform: class a = object attr_r x = 1 end into the above class definition. Of course, you won't be able to assign to x in the way you'd expect: let _ = new a in a#x = 2 Won't work. -- miles "We in the past evade X, where X is something which we believe to be a lion, through the act of running." - swiftrain@geocities.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr