From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id B4FB5BC84 for ; Thu, 24 Mar 2005 09:13:22 +0100 (CET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2O8DKSk031932 for ; Thu, 24 Mar 2005 09:13:22 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j2O8DAAQ024220; Thu, 24 Mar 2005 17:13:10 +0900 (JST) Date: Thu, 24 Mar 2005 17:13:22 +0900 (JST) Message-Id: <20050324.171322.41200116.garrigue@math.nagoya-u.ac.jp> To: farr@mit.edu Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Object Attribute Accessor Syntax Extension From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 424276A0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 accessor:01 syntax:01 accessor:01 datatypes:01 clos:01 sytax:01 val:01 mutable:01 val:01 grammar:01 modular:01 grammar:01 syntax:01 expr: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: > 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 Looks nice. I actually wrote the same extension (with the same names) experimentally in the yacc grammar last year. Having it in camlp4 would be more modular. Note that in a yacc grammar your syntax would require "reader" and "writer" to be keywords, but it may be OK with camlp4. It may also be nice to have another small extension, so that o#f <- expr would be handled as o#set_f <- (expr) Jacques Garrigue