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 LAA09290; Thu, 3 Jun 2004 11:20:12 +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 LAA09279 for ; Thu, 3 Jun 2004 11:20:11 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from mwinf0402.wanadoo.fr (smtp4.wanadoo.fr [193.252.22.27]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i539KASH028979 for ; Thu, 3 Jun 2004 11:20:10 +0200 Received: from pegasos (AStrasbourg-251-1-32-96.w82-126.abo.wanadoo.fr [82.126.150.96]) by mwinf0402.wanadoo.fr (SMTP Server) with ESMTP id 1F0798000AC; Thu, 3 Jun 2004 11:20:08 +0200 (CEST) Received: from luther by pegasos with local (Exim 4.34) id 1BVoYD-0000ee-O5; Thu, 03 Jun 2004 11:30:17 +0200 Date: Thu, 3 Jun 2004 11:30:13 +0200 To: Jacques GARRIGUE Cc: rich@annexia.org, caml-list@inria.fr Subject: Re: [Caml-list] Default values for structures (feature request) Message-ID: <20040603093013.GA2462@pegasos> References: <20040602121210.GA4385@redhat.com> <20040602.215655.68536952.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20040602.215655.68536952.garrigue@kurims.kyoto-u.ac.jp> User-Agent: Mutt/1.5.6i From: Sven Luther X-Miltered: at concorde with ID 40BEED4A.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 sven:01 luther:01 sven:01 luther:01 2004:99 0900,:01 jacques:01 supposes:01 jacques:01 int:01 garrigue:01 garrigue:01 interfaces:01 syntax:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Jun 02, 2004 at 09:56:55PM +0900, Jacques GARRIGUE wrote: > 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 Well, what about adding a syntaxic wrapper over those to let you automatically do it using a syntax similar to what Richard Jones proposed ? Friendly, Sven luther ------------------- 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