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 SAA25219; Fri, 9 May 2003 18:08:15 +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 SAA25519 for ; Fri, 9 May 2003 18:08:14 +0200 (MET DST) Received: from eos.telenet-ops.be (eos.telenet-ops.be [195.130.132.40]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h49G8DH29600 for ; Fri, 9 May 2003 18:08:13 +0200 (MET DST) Received: from localhost (localhost.localdomain [127.0.0.1]) by eos.telenet-ops.be (Postfix) with SMTP id 8E3A31FF43 for ; Fri, 9 May 2003 18:08:13 +0200 (CEST) Received: from j (D5760EE5.kabel.telenet.be [213.118.14.229]) by eos.telenet-ops.be (Postfix) with SMTP id 6AF6A1FF33 for ; Fri, 9 May 2003 18:08:13 +0200 (CEST) Message-ID: <003e01c31645$2bfa3c00$e50e76d5@j> From: "Christophe Poucet" To: Subject: [Caml-list] Sumtypes of records Date: Fri, 9 May 2003 18:08:04 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_003B_01C31655.EF6AA200" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam: no; 0.00; stupid:01 plop:01 foo:01 W28:99 christophe:01 int:01 constructors:01 age:96 arial:95 type:07 message:89 U4:88 doesn't:12 can't:15 bar:15 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_003B_01C31655.EF6AA200 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Why can't constructors of sumtypes take nameless records? (Warning = stupid example follows) type plop =3D Foo | Bar {age : int};; doesn't work, but =20 type person =3D {age : int};; type plop =3D Foo | Bar of person;; does. Anyone know why? Thanking you in advance, ------=_NextPart_000_003B_01C31655.EF6AA200 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Why can't constructors of sumtypes take = nameless=20 records? (Warning stupid example follows)
 
type plop =3D Foo | Bar {age :=20 int};;
 
doesn't work, but          &= nbsp;           &n= bsp;     

type person =3D {age : int};;
type plop =3D Foo | Bar of person;;
 
does.
 
Anyone know why?
 
Thanking you in advance,
 
------=_NextPart_000_003B_01C31655.EF6AA200-- ------------------- 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 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 TAA26869; Fri, 9 May 2003 19:12:21 +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 TAA26864 for ; Fri, 9 May 2003 19:12:20 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h49HCJT24422 for ; Fri, 9 May 2003 19:12:19 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id 8AE285EB7; Fri, 9 May 2003 20:12:18 +0300 (EEST) Date: Fri, 9 May 2003 20:12:17 +0300 Subject: Re: [Caml-list] Sumtypes of records Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: To: "Christophe Poucet" From: Ville-Pertti Keinonen In-Reply-To: <003e01c31645$2bfa3c00$e50e76d5@j> Message-Id: <62B8AA7D-8241-11D7-A0A9-000393863F70@exomi.com> Content-Transfer-Encoding: quoted-printable X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 stupid:01 plop:01 foo:01 int:01 constructors:01 age:96 probably:05 pattern:06 type:07 tuple:07 matching:08 printable:10 sense:12 record:15 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Why can't constructors of sumtypes take nameless records? (Warning=20 > stupid example follows) > =A0 > type plop =3D Foo |=A0Bar {age : int};; ... Probably because it wouldn't make much sense. Either the only way you=20= could access age in the above is by matching Bar { age =3D x }, which is=20= not very useful (you might as well have Bar of int, or a tuple for=20 multiple fields), or the record type needs to have a name so that x in=20= the pattern Bar x has some printable type. ------------------- 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 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 DAA00303; Sat, 17 May 2003 03:36:27 +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 DAA00638 for ; Sat, 17 May 2003 03:36:25 +0200 (MET DST) Received: from relay.pair.com (relay.pair.com [209.68.1.20]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h4H1aNT24022 for ; Sat, 17 May 2003 03:36:24 +0200 (MET DST) Received: (qmail 99445 invoked from network); 17 May 2003 01:36:22 -0000 Received: from arda.pair.com (HELO compaqreview.d6.com) (209.68.1.133) by relay.pair.com with SMTP; 17 May 2003 01:36:22 -0000 X-pair-Authenticated: 209.68.1.133 Message-Id: <4.3.2.7.2.20030516182821.042f6dd0@localhost> X-Sender: checker@localhost X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Fri, 16 May 2003 18:35:42 -0700 To: Ville-Pertti Keinonen , "Christophe Poucet" From: Chris Hecker Subject: Re: [Caml-list] Sumtypes of records Cc: In-Reply-To: <62B8AA7D-8241-11D7-A0A9-000393863F70@exomi.com> References: <003e01c31645$2bfa3c00$e50e76d5@j> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Spam: no; 0.00; hecker:01 checker:01 caml-list:01 stupid:01 plop:01 foo:01 record-like:01 chris:01 int:01 constructors:01 match:02 age:96 probably:05 pattern:06 feature:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>Why can't constructors of sumtypes take nameless records? (Warning stupid >>example follows) >>type plop = Foo | Bar {age : int};; >Probably because it wouldn't make much sense. Either the only way you >could access age in the above is by matching Bar { age = x }, which is not >very useful (you might as well have Bar of int, or a tuple for multiple >fields), I disagree, it would be useful, it's far more self-documenting than a tuple (which usually need a record-like comment right next to their declaration to tell what's what), and you could match the record like Bar x -> x.age and it wouldn't need a type name. I've wanted this feature myself a number of times. >or the record type needs to have a name so that x in the pattern Bar x has >some printable type. It has type { age : int; }, just like int * int has type int * int and doesn't need a name. Does the record need a name for some other reason? Chris ------------------- 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 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 KAA18362; Sat, 17 May 2003 10:13:34 +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 KAA05340 for ; Sat, 17 May 2003 10:13:33 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4H8DWT04603 for ; Sat, 17 May 2003 10:13:33 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id C61355DE2; Sat, 17 May 2003 11:13:31 +0300 (EEST) Date: Sat, 17 May 2003 11:13:30 +0300 Subject: Re: [Caml-list] Sumtypes of records Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: To: Chris Hecker From: Ville-Pertti Keinonen In-Reply-To: <4.3.2.7.2.20030516182821.042f6dd0@localhost> Message-Id: <71A9CFA4-883F-11D7-BDA3-000393863F70@exomi.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 record-like:01 int:01 match:02 age:96 obj:03 arguments:03 types:03 probably:05 definition:06 feature:07 type:07 tuple:07 defines:08 comment:08 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I disagree, it would be useful, it's far more self-documenting than a > tuple (which usually need a record-like comment right next to their > declaration to tell what's what), and you could match the record like > > Bar x -> x.age > > and it wouldn't need a type name. I've wanted this feature myself a > number of times. If you can say Bar x -> x.age, you can say Bar x -> x, which implies that the type of x should be a type in its own right, independent of Bar. I think this is consistent. > It has type { age : int; }, just like int * int has type int * int and > doesn't need a name. Does the record need a name for some other > reason? int * int denotes a type, { age : int } defines a type. One { age : int } is not compatible with a different { age : int }. It would probably be possible for { age : int } to be made a valid type expression, but it would change the language significantly and provide you with fairly little gain (it would save you one type definition when using it as part of a sum type). Also note that sum types of records are less storage-efficient than sum types with multiple arguments (the record is indirect, because you must be able to write Bar x -> x). Incidentally, if the record weren't indirect, Bar x could be Obj.magic-compatible with x, but that's just a detail of the implementation... ------------------- 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 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 KAA06278; Sat, 17 May 2003 10:24:50 +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 KAA06435 for ; Sat, 17 May 2003 10:24:49 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4H8OmT04957 for ; Sat, 17 May 2003 10:24:48 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id D7CD25DE2 for ; Sat, 17 May 2003 11:24:47 +0300 (EEST) Date: Sat, 17 May 2003 11:24:46 +0300 Subject: Re: [Caml-list] Sumtypes of records Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Ville-Pertti Keinonen To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <71A9CFA4-883F-11D7-BDA3-000393863F70@exomi.com> Message-Id: <0495144C-8841-11D7-BDA3-000393863F70@exomi.com> X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 obj:03 type:07 incidentally:10 weren't:12 write:14 record:15 bar:15 but:16 detail:82 could:20 inevitably:20 myself:22 because:25 com:73 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > x). Incidentally, if the record weren't indirect, Bar x could be > Obj.magic-compatible with x, but that's just a detail of the > implementation... Correcting myself - that wouldn't work because you also have to be able to write Bar x -> Bar x... So a sum type of a record is inevitably indirect. ------------------- 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 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 PAA13074; Sat, 17 May 2003 15:26:47 +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 PAA12970 for ; Sat, 17 May 2003 15:26:46 +0200 (MET DST) Received: from qrnik.knm.org.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4HDQhT12298 for ; Sat, 17 May 2003 15:26:45 +0200 (MET DST) Received: from localhost ([127.0.0.1] ident=qrczak) by qrnik.knm.org.pl with esmtp (Exim 3.36 #1) id 19H1hw-0003b2-00 for caml-list@inria.fr; Sat, 17 May 2003 15:26:40 +0200 From: "Marcin 'Qrczak' Kowalczyk" To: caml-list@inria.fr Subject: Re: [Caml-list] Sumtypes of records Date: Sat, 17 May 2003 15:26:39 +0200 User-Agent: KMail/1.5.1 References: <003e01c31645$2bfa3c00$e50e76d5@j> <4.3.2.7.2.20030516182821.042f6dd0@localhost> In-Reply-To: <4.3.2.7.2.20030516182821.042f6dd0@localhost> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8bit Message-Id: <200305171526.39769.qrczak@knm.org.pl> X-Spam: no; 0.00; marcin:01 'qrczak':01 kowalczyk:01 qrczak:01 caml-list:01 hecker:01 foo:01 ocaml's:01 haskell:01 statically:01 dynamically:01 inference:01 chris:01 overloading:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Dnia sob 17. maja 2003 03:35, Chris Hecker napisał: > It has type { age : int; }, just like int * int has type int * int and > doesn't need a name. Does the record need a name for some other reason? let foo x = x.bar What is the type of foo if there is no named record in scope having field bar? I don't say that I like it but it's a consequence of the OCaml's type system. Haskell has that too (but theoretically type classes could be made to help). SML is what you would like; it has sort of overloading of certain builtin operations and in this case requires the type of x to be statically known somehow. There is no problem with dynamically typed languages, and "non-functional" statically typed ones require to explicitly write the type of bound variables anyway. Having the same field name in various record types just doesn't mix well with type inference. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ ------------------- 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 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 IAA31256; Sun, 18 May 2003 08:33:59 +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 IAA29139 for ; Sun, 18 May 2003 08:33:58 +0200 (MET DST) Received: from relay.pair.com (relay.pair.com [209.68.1.20]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h4I6XvT07922 for ; Sun, 18 May 2003 08:33:57 +0200 (MET DST) Received: (qmail 14938 invoked from network); 18 May 2003 06:33:55 -0000 Received: from arda.pair.com (HELO compaqreview.d6.com) (209.68.1.133) by relay.pair.com with SMTP; 18 May 2003 06:33:55 -0000 X-pair-Authenticated: 209.68.1.133 Message-Id: <4.3.2.7.2.20030517232318.033e19c0@localhost> X-Sender: checker@localhost X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Sat, 17 May 2003 23:33:05 -0700 To: "Marcin 'Qrczak' Kowalczyk" , caml-list@inria.fr From: Chris Hecker Subject: Re: [Caml-list] Sumtypes of records In-Reply-To: <200305171526.39769.qrczak@knm.org.pl> References: <4.3.2.7.2.20030516182821.042f6dd0@localhost> <003e01c31645$2bfa3c00$e50e76d5@j> <4.3.2.7.2.20030516182821.042f6dd0@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Spam: no; 0.00; hecker:01 checker:01 caml-list:01 foo:01 shorthand:01 inference:01 compiler:01 chris:01 int:01 age:96 explicitly:03 let:04 somewhat:06 type:07 defined:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >let foo x = x.bar >What is the type of foo if there is no named record in scope having field bar? It could have a type, it just doesn't have a programmer defined name. This has nothing to do with having the same field names in various records...field names would hide previous ones just like they [annoyingly] currently do. This is just about whether there's some way to do anonymous records. So for "Bar { age : int; }" the compiler would generate some internal name to use for the record type. It would be shorthand for: type bar_anonymous_record_type_name_123 = { age : int; } type foo = Bar bar_anonymous_record_type_name_123 The only difference is you wouldn't be able to use "bar_anon...123" explicitly, only via inference since it's generated. This isn't a big deal or a high priority to add, but I don't see why it wouldn't just work and be somewhat useful. Chris ------------------- 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 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 JAA32673; Sun, 18 May 2003 09:46: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 JAA32559 for ; Sun, 18 May 2003 09:46:13 +0200 (MET DST) Received: from qrnik.knm.org.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4I7kDT09215 for ; Sun, 18 May 2003 09:46:13 +0200 (MET DST) Received: from localhost ([127.0.0.1] ident=qrczak) by qrnik.knm.org.pl with esmtp (Exim 3.36 #1) id 19HIs0-00012R-00 for caml-list@inria.fr; Sun, 18 May 2003 09:46:12 +0200 From: "Marcin 'Qrczak' Kowalczyk" To: caml-list@inria.fr Subject: Re: [Caml-list] Sumtypes of records Date: Sun, 18 May 2003 09:46:11 +0200 User-Agent: KMail/1.5.1 References: <4.3.2.7.2.20030516182821.042f6dd0@localhost> <4.3.2.7.2.20030517232318.033e19c0@localhost> In-Reply-To: <4.3.2.7.2.20030517232318.033e19c0@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200305180946.12006.qrczak@knm.org.pl> X-Spam: no; 0.00; marcin:01 'qrczak':01 kowalczyk:01 qrczak:01 caml-list:01 nie:99 hecker:01 shorthand:01 foo:01 pointers:01 structs:01 unions:01 arrays:01 compiler:01 chris:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Dnia nie 18. maja 2003 08:33, Chris Hecker napisał: > This is just about whether there's some way to do anonymous > records. So for "Bar { age : int; }" the compiler would generate some > internal name to use for the record type. It would be shorthand for: > > type bar_anonymous_record_type_name_123 = { age : int; } > type foo = Bar bar_anonymous_record_type_name_123 Ah, I see. Like in Turbo Pascal (I don't know about Pascal in theory) where it applies to arrays and pointers too. And like structs and unions in C and C++. I don't like it because it's confusing. The syntax suggests that record types are built on the fly like tuples (like in SML) but the semantics is that they are explicitly defined somewhere like algebraic types. And this would be the only such case. When you would write: type foo = Foo of {x : int} type bar = Bar of {x : int} then this is a type error: let f (Foo y) = Bar y -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ ------------------- 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 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 XAA28702; Mon, 2 Jun 2003 23:30:01 +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 XAA28593 for ; Mon, 2 Jun 2003 23:30:00 +0200 (MET DST) Received: from mail1.tpgi.com.au (mail.tpgi.com.au [203.12.160.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h52LTwT07253 for ; Mon, 2 Jun 2003 23:29:58 +0200 (MET DST) Received: from ozemail.com.au (203-219-234-174-syd-ts25-2600.tpgi.com.au [203.219.234.174]) (authenticated (0 bits)) by mail1.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h52LTUT31149; Tue, 3 Jun 2003 07:29:39 +1000 Message-ID: <3EDBC1BA.3060707@ozemail.com.au> Date: Tue, 03 Jun 2003 07:29:30 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: "Marcin 'Qrczak' Kowalczyk" CC: caml-list@inria.fr Subject: Re: [Caml-list] Sumtypes of records References: <4.3.2.7.2.20030516182821.042f6dd0@localhost> <4.3.2.7.2.20030517232318.033e19c0@localhost> <200305180946.12006.qrczak@knm.org.pl> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ozemail:01 caml-list:01 marcin:01 'qrczak':01 kowalczyk:01 foo:01 pointers:01 structs:01 unions:01 extensively:01 toxteth:01 glebe:01 2037,:01 9660:01 0850:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Marcin 'Qrczak' Kowalczyk wrote: >>type bar_anonymous_record_type_name_123 = { age : int; } >>type foo = Bar bar_anonymous_record_type_name_123 >> > > Ah, I see. Like in Turbo Pascal (I don't know about Pascal in theory) where it > applies to arrays and pointers too. And like structs and unions in C and C++. > > I don't like it because it's confusing. The syntax suggests that record types > are built on the fly like tuples (like in SML) but the semantics is that they > are explicitly defined somewhere like algebraic types. And this would be the > only such case. > > When you would write: > type foo = Foo of {x : int} > type bar = Bar of {x : int} > then this is a type error: > let f (Foo y) = Bar y There is no reason for it. The compiler already does sophisticated signature matching. There's no reason it can't identify all anonymous record types with the same structure the same way it does for tuples (and polymorphic variants). So this *could* be consistently supported if it was deemed useful, but I would have to warn that anonymous types invariable lead to difficult to understand error messages (I use polymorphic variants extensively and regularly get 200 line error messages). -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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