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 OAA27870; Wed, 2 Jun 2004 14:57:09 +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 OAA28332 for ; Wed, 2 Jun 2004 14:57:08 +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.12.10/8.12.10) with ESMTP id i52Cv5SH009562 for ; Wed, 2 Jun 2004 14:57:07 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id VAA07789; Wed, 2 Jun 2004 21:56:55 +0900 (JST) Date: Wed, 02 Jun 2004 21:56:55 +0900 (JST) Message-Id: <20040602.215655.68536952.garrigue@kurims.kyoto-u.ac.jp> To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] Default values for structures (feature request) From: Jacques GARRIGUE In-Reply-To: <20040602121210.GA4385@redhat.com> References: <20040602121210.GA4385@redhat.com> X-Mailer: Mew version 4.0.64 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40BDCEA1.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 supposes:01 jacques:01 int:01 garrigue:01 garrigue:01 interfaces:01 syntax:02 module:03 string:03 dependent:03 interface:03 arguments:03 arguments:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Richard Jones > Could have a syntax for default values for structures? Something > like: > > type t = { field1 : int = 0; > field2 : string; (* no default *) > } The difficulty should be apparent in your example: this supposes writing values in interfaces, which would be a major (huge) change in language design... Note that labeled arguments let you do that. let new_t ?(field1 = 0) ~field2 () = {field1=field1; field2=field2} > The reason for having default fields is so that I can export struct- > ures from my module interface, but be able to add fields with default > values later without breaking dependent code. (But in some circum- > stances I would deliberately add fields without default values in > order to break code). This is the point with optional/labeled arguments. 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