From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3EE53BC48 for ; Wed, 23 Mar 2005 21:01:14 +0100 (CET) Received: from biscayne-one-station.mit.edu (BISCAYNE-ONE-STATION.MIT.EDU [18.7.7.80]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j2NK1Chp027197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Mar 2005 21:01:13 +0100 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.12.4/8.9.2) with ESMTP id j2NK1Bq9012632 for ; Wed, 23 Mar 2005 15:01:11 -0500 (EST) Received: from [18.33.6.1] (MCNAIR-TWO-FIFTY-SIX.MIT.EDU [18.33.6.1]) (authenticated bits=0) (User authenticated as farr@ATHENA.MIT.EDU) by outgoing.mit.edu (8.12.4/8.12.4) with ESMTP id j2NK140Z018905 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 23 Mar 2005 15:01:05 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v619.2) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: caml-list@yquem.inria.fr From: "Will M. Farr" Subject: Object Attribute Accessor Syntax Extension Date: Wed, 23 Mar 2005 15:00:55 -0500 X-Pgp-Agent: GPGMail 1.0.2 X-Mailer: Apple Mail (2.619.2) X-Scanned-By: MIMEDefang 2.42 X-Miltered: at concorde with ID 4241CB09.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; accessor:01 syntax:01 hash:01 accessor:01 val:01 mutable:01 val:01 mutable:01 datatypes:01 clos:01 sytax:01 syntax:01 extensible:01 defining:01 functions:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I would like to learn more about camlp4, so I thought I would undertake a simple project, but I would like some comment on my ideas first (in the hope that my project would be useful to others, too). It has always irked me that when defining a class which is essentially an extensible data-container, one has to specify the data accessor functions in addition to the data values: class body (m : float) (qq : float array) (pp : float array) = object val mutable m = m val q = qq val p = pp val mutable f = Array.make (Array.length pp) 0.0 method q = q method p = p method m = m method set_m mm = m <- mm method set_f ff = f <- ff (* etc *) end I think it would be nice to have accessor functions defined automatically for simple datatypes (sort of a simplified version of the :accessor q properties of a data member in CLOS -- Ruby does something like this with its :attr_accessor a,b,c notes in the class definiton, too, and Python probably has something similar). The sytax I was thinking of using was: class body (m : float) (qq : float array) (pp : float array) = object val mutable accessor m = m val reader q = qq val reader p = pp val writer f = Array.make (Array.length pp) 0.0 (* etc *) end If anyone would like to comment on this idea (because you hate the syntax, or love the syntax, or think it's been done before, or think it's a bad idea, etc) before I go ahead and write it, let me know. Will -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) iD8DBQFCQcr+jFCrhUweU3MRArHIAJoC68xlm5Plr6brtXhnmwkDZ5D6tgCaAy5d BcHYs6KXDrBhbssPxGDoPmM= =iy74 -----END PGP SIGNATURE-----