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 OAA25559; Wed, 2 Jun 2004 14:12:14 +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 OAA19434 for ; Wed, 2 Jun 2004 14:12:13 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i52CCBEV009784 for ; Wed, 2 Jun 2004 14:12:12 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BVUbK-0001Bk-00 for ; Wed, 02 Jun 2004 13:12:10 +0100 Date: Wed, 2 Jun 2004 13:12:10 +0100 To: caml-list@inria.fr Subject: [Caml-list] Default values for structures (feature request) Message-ID: <20040602121210.GA4385@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce with ID 40BDC41B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; non-mutable:01 ltd:98 int:01 syntax:02 arch:02 module:03 module:03 string:03 string:03 dependent:03 interface:03 perl:03 let:04 investment:94 structures:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Could have a syntax for default values for structures? Something like: type t = { field1 : int = 0; field2 : string; (* no default *) } It's sort of possible to do this currently for non-mutable structures by having a default_value declared, and writing: let new_value = { default_value with field2 = "new string" } but this doesn't allow the module to force the user to declare certain fields in a new value. 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). Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment MONOLITH is an advanced framework for writing web applications in C, easier than using Perl & Java, much faster and smaller, reusable widget-based arch, database-backed, discussion, chat, calendaring: http://www.annexia.org/freeware/monolith/ ------------------- 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